How to Correct Images Using Filters for Reading

Image correction filters are digital image processing techniques used to improve the quality and characteristics of an image, particularly for the purpose of enhancing text recognition and extraction. Image correction filters available in IronOcr are sharpen, enhance resolution, denoise, dilate, and erode.

These image correction filters play a critical role in preprocessing images before OCR, as they help optimize the image for accurate text extraction by improving the quality and visibility of the text and reducing unwanted noise or artifacts.

Get started with IronOCR

Start using IronOCR in your project today with a free trial.

First Step:
green arrow pointer



Sharpen Filter Example

This filter increases the contrast along the edges in the image, giving them a more defined appearance. It improves the clarity of text and details, making it easier for OCR software to recognize characters.

To apply the sharpen filter, invoke the Sharpen method of the OcrImageInput object.

:path=/static-assets/ocr/content-code-examples/how-to/image-quality-correction-sharpen-filter.cs
using IronOcr;

// Instantiate IronTesseract
IronTesseract ocrTesseract = new IronTesseract();

// Add image
using var imageInput = new OcrImageInput("sample.jpg");
// Apply sharpen filter
imageInput.Sharpen();

// Export filtered image
imageInput.SaveAsImages("sharpen.jpg");
Imports IronOcr

' Instantiate IronTesseract
Private ocrTesseract As New IronTesseract()

' Add image
Private imageInput = New OcrImageInput("sample.jpg")
' Apply sharpen filter
imageInput.Sharpen()

' Export filtered image
imageInput.SaveAsImages("sharpen.jpg")
$vbLabelText   $csharpLabel

For convenience, you can export the filtered image using the SaveAsImages method. Below is a comparison of the image before and after applying the sharpening filter.

Sample image
Sharpen filter applied

Enhance Resolution Filter Example

This filter is designed to increase the pixel density of an image, effectively improving its sharpness and clarity. It can be especially useful for enhancing the legibility of text in low-resolution images.

Invoke the EnhanceResolution method to apply the enhanced resolution filter. This method accepts the target DPI, with 225 DPI as the default value.

:path=/static-assets/ocr/content-code-examples/how-to/image-quality-correction-enhance-resolution-filter.cs
// Apply enhance resolution filter
imageInput.EnhanceResolution();
' Apply enhance resolution filter
imageInput.EnhanceResolution()
$vbLabelText   $csharpLabel
Sample image
Enhance resolution filter applied

Denoise Filter Example

Denoising filters reduce the level of noise or unwanted artifacts in an image. Noise reduction is crucial for OCR as it helps isolate text from background interference, leading to cleaner and more accurate recognition.

To apply the denoise filter, use the DeNoise method. The default morphology is 2x2. To apply a stronger denoise algorithm, pass 'true' to enable a 3x3 morphology.

:path=/static-assets/ocr/content-code-examples/how-to/image-quality-correction-denoise-filter.cs
// Apply denoise filter
imageInput.DeNoise();
' Apply denoise filter
imageInput.DeNoise()
$vbLabelText   $csharpLabel
Sample image
Denoise filter applied

Dilate Filter Example

Dilation expands the brighter regions (foreground) in an image. It helps thicken and enhance the text, making it more prominent and easier for OCR software to interpret.

To apply the dilation filter, use the Dilate method. Default morphology is 2x2, and setting 'true' enables the 3x3 option.

:path=/static-assets/ocr/content-code-examples/how-to/image-quality-correction-dilate-filter.cs
// Apply dilate filter
imageInput.Dilate();
' Apply dilate filter
imageInput.Dilate()
$vbLabelText   $csharpLabel
Sample image
Dilate filter applied

Erode Filter Example

Erosion reduces the size of bright regions in an image, useful for refining characters and lines, especially when they are thick or distorted.

Use the Erode method to apply the erode filter. As with previous methods, default morphology is 2x2, and setting 'true' enables 3x3.

:path=/static-assets/ocr/content-code-examples/how-to/image-quality-correction-erode-filter.cs
// Apply erode filter
imageInput.Erode();
' Apply erode filter
imageInput.Erode()
$vbLabelText   $csharpLabel
Sample image
Erode filter applied

Frequently Asked Questions

How can I enhance image quality for better OCR results?

You can enhance image quality for better OCR results using IronOCR by applying various image correction filters like sharpen, enhance resolution, denoise, dilate, and erode. These filters improve text clarity and reduce noise, facilitating more accurate text extraction.

What are the benefits of using sharpening filters in image preprocessing?

Sharpening filters in IronOCR increase edge contrast, improving text clarity and readability in images. This enhancement is crucial for improving the accuracy of OCR text recognition.

How do I increase the resolution of an image for OCR processing?

To increase the resolution of an image for OCR processing in IronOCR, use the enhance resolution filter, which boosts the pixel density, improving the sharpness and clarity of low-resolution images.

What steps should I follow to reduce noise in images before OCR?

To reduce noise in images before OCR with IronOCR, apply the `DeNoise` method. For stronger noise reduction, you can enable a 3x3 morphology by setting the option to 'true'.

How does dilation filtering affect text visibility in images?

Dilation filtering in IronOCR expands brighter regions in an image, making text more prominent and aiding the OCR process in interpreting characters more effectively.

What is the method to refine text using erosion filters?

To refine text using erosion filters in IronOCR, use the `Erode` method. This filter reduces the size of bright regions, helping to refine thick or distorted characters and lines in the image.

What DPI setting is recommended for enhancing image resolution?

The default DPI setting for the enhance resolution filter in IronOCR is 225 DPI. However, you can specify a different DPI based on your needs to optimize image clarity.

Is it possible to adjust the intensity of the dilation effect in IronOCR?

Yes, you can adjust the intensity of the dilation effect in IronOCR by enabling a stronger 3x3 morphology during the application of the dilate filter, which is done by setting the option to 'true'.

How can I start using image correction filters in .NET C#?

To start using image correction filters in .NET C#, download the IronOCR library via NuGet, import your images, apply the desired filters such as sharpen or denoise, and then export the enhanced images for OCR processing.

Chaknith Bin
Software Engineer
Chaknith works on IronXL and IronBarcode. He has deep expertise in C# and .NET, helping improve the software and support customers. His insights from user interactions contribute to better products, documentation, and overall experience.