---
title: "Enhance characters in PDFs and images in C# .NET | Nutrient .NET SDK"
canonical_url: "https://www.nutrient.io/guides/dotnet/ocr/preprocess/enhance-characters/"
md_url: "https://www.nutrient.io/guides/dotnet/ocr/preprocess/enhance-characters.md"
last_updated: "2026-05-21T17:12:02.207Z"
description: "Learn how to enhance character clarity in PDFs and images using C# with Nutrient .NET SDK. Improve optical character recognition (OCR) accuracy through character enhancement techniques."
---

# Enhance characters in PDFs and images in C#

This guide explains how to enhance characters in PDFs and images.

## Thick and oversampled characters

Sometimes characters in documents appear thick and their features are unclear — for example, if too much ink was used to print a page, or if a document was scanned and printed many times. A process called erosion can fix this issue by removing pixels on the edges of images.

The images below show what a document looks like before and after erosion.![Before enhancement](@/assets/guides/dotnet/ocr/preprocess/before-erode.png)![After enhancement](@/assets/guides/dotnet/ocr/preprocess/after-erode.png)

Don’t preprocess documents before recognizing text with OCR. Nutrient.NET SDK’s OCR engine preprocesses documents automatically with better results than manual preprocessing.

To fix thick characters, follow the steps below:

1. Create a `GdPictureImaging` object.

2. Select the image by passing its path to the `CreateGdPictureImageFromFile` method of the `GdPictureImaging` object.

3. Fix thick characters by passing the image ID to the `FxBitonalErode8` method of the `GdPictureImaging` object.

4. Save the output in a new image with the `SaveAsPNG` method of the `GdPictureImaging` object.

5. Release the image resource with the `ReleaseGdPictureImage` method of the `GdPictureImaging` object.

The example below fixes thick characters:

### C#

```csharp

using GdPictureImaging gdpictureImaging = new GdPictureImaging();
// Load the image from a file.
int imageId = gdpictureImaging.CreateGdPictureImageFromFile(@"C:/temp/source.png");
// Fix thick characters.
gdpictureImaging.FxBitonalErode8(imageId);
// Save the output in a new image.
gdpictureImaging.SaveAsPNG(imageId, @"C:/temp/output.png");
gdpictureImaging.ReleaseGdPictureImage(imageId);

```

### VB.NET

```vb

Using gdpictureImaging As GdPictureImaging = New GdPictureImaging()
    ' Load the image from a file.
    Dim imageId As Integer = gdpictureImaging.CreateGdPictureImageFromFile("C:/temp/source.png")
    ' Fix thick characters.
    gdpictureImaging.FxBitonalErode8(imageId)
    ' Save the output in a new image.
    gdpictureImaging.SaveAsPNG(imageId, "C:/temp/output.png")
    gdpictureImaging.ReleaseGdPictureImage(imageId)
End Using

```

#### Used methods and properties

- [`CreateGdPictureImageFromFile`](/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPictureImaging~CreateGdPictureImageFromFile.html)

- [`FxBitonalErode8`](/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPictureImaging~FxBitonalErode8.html)

- [`ReleaseGdPictureImage`](/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPictureImaging~ReleaseGdPictureImage.html)

- [`SaveAsPNG`](/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPictureImaging~SaveAsPNG.html)

#### Related topics

- [Load a file](/guides/dotnet/load-a-file.md)

- [Save a file](/guides/dotnet/save-a-file.md)

## Faint and low-sampled characters

Sometimes characters in documents appear faint and low-sampled, and their features are unclear — for example, if the brightness used to scan a page was too high, or a document was converted to binary images with a bad algorithm. A process called black dilation can fix this issue by adding black pixels around objects.

To fix faint characters, follow the steps below:

1. Create a `GdPictureImaging` object.

2. Select the image by passing its path to the `CreateGdPictureImageFromFile` method of the `GdPictureImaging` object.

3. Fix faint characters by passing the image ID to the `FxBitonalDilate8` method of the `GdPictureImaging` object.

4. Save the output in a new image with the `SaveAsPNG` method of the `GdPictureImaging` object.

5. Release the image resource with the `ReleaseGdPictureImage` method of the `GdPictureImaging` object.

The example below fixes faint characters:

### C#

```csharp

using GdPictureImaging gdpictureImaging = new GdPictureImaging();
// Load the image from a file.
int imageId = gdpictureImaging.CreateGdPictureImageFromFile(@"C:/temp/source.png");
// Fix faint characters.
gdpictureImaging.FxBitonalDilate8(imageId);
// Save the output in a new image.
gdpictureImaging.SaveAsPNG(imageId, @"C:/temp/output.png");
gdpictureImaging.ReleaseGdPictureImage(imageId);

```

### VB.NET

```vb

Using gdpictureImaging As GdPictureImaging = New GdPictureImaging()
    ' Load the image from a file.
    Dim imageId As Integer = gdpictureImaging.CreateGdPictureImageFromFile("C:/temp/source.png")
    ' Fix faint characters.
    gdpictureImaging.FxBitonalDilate8(imageId)
    ' Save the output in a new image.
    gdpictureImaging.SaveAsPNG(imageId, "C:/temp/output.png")
    gdpictureImaging.ReleaseGdPictureImage(imageId)
End Using

```

#### Used methods

- [`CreateGdPictureImageFromFile`](/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPictureImaging~CreateGdPictureImageFromFile.html)

- [`FxBitonalDilate8`](/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPictureImaging~FxBitonalDilate8.html)

- [`ReleaseGdPictureImage`](/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPictureImaging~ReleaseGdPictureImage.html)

- [`SaveAsPNG`](/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPictureImaging~SaveAsPNG.html)

#### Related topics

- [Load a file](/guides/dotnet/load-a-file.md)

- [Save a file](/guides/dotnet/save-a-file.md)

---

## Related pages

- [Remove lines from images and PDFs in C#](/guides/dotnet/ocr/preprocess/remove-lines.md)
- [Auto-invert images and PDFs in C#](/guides/dotnet/ocr/preprocess/auto-invert.md)
- [Remove noise from images in C#](/guides/dotnet/ocr/preprocess/remove-noise.md)
- [Image preprocessing and OCR accuracy in C#](/guides/dotnet/ocr/preprocess.md)
- [Deskew PDFs and images in C#](/guides/dotnet/ocr/preprocess/deskew.md)
- [Remove punch holes from images and PDFs in C#](/guides/dotnet/ocr/preprocess/remove-punch-holes.md)

