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.
How to Correct Images Using Filters for Reading
- Download a C# library for image correction using filters
- Import the PDF document and images for reading
- Apply desired filters, such as sharpening, enhancing resolution, denoising, dilation, and erosion
- Export the corrected image for viewing
- Utilize the
Read
method for OCR processing
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")
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.

Before

After
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()

Before

After
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()

Before

After
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()

Before

After
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()

Before

After
Frequently Asked Questions
What are image correction filters?
Image correction filters in IronOCR are digital image processing techniques used to improve the quality and characteristics of an image, enhancing text recognition and extraction. Filters include sharpen, enhance resolution, denoise, dilate, and erode.
How do image correction filters improve text recognition accuracy?
Image correction filters in IronOCR optimize images by improving text quality and visibility and reducing noise or artifacts, which enhances the accuracy of OCR text extraction.
How can I apply a filter to improve image clarity?
To apply the sharpen filter in IronOCR, use the `Sharpen` method of the OcrImageInput object. It increases contrast along edges, improving text clarity for OCR.
What is the purpose of a resolution enhancement filter?
The enhance resolution filter in IronOCR increases the pixel density of an image, improving sharpness and clarity, particularly beneficial for low-resolution images.
How do I reduce noise in images?
Use the `DeNoise` method in IronOCR to apply the denoise filter, which reduces noise in images. For stronger noise reduction, set the option to 'true' for a 3x3 morphology.
What does a dilation filter do to an image?
The dilate filter in IronOCR expands brighter regions in an image, enhancing the prominence of text, which aids OCR in interpreting characters.
How can I refine text in images?
To apply the erode filter in IronOCR, use the `Erode` method. It reduces the size of bright regions, refining thick or distorted characters and lines.
What is the default DPI for resolution enhancement?
The default DPI for the enhance resolution filter in IronOCR is 225 DPI, but you can specify any desired DPI as needed.
Can I adjust the strength of the dilation effect?
Yes, when applying the dilate filter in IronOCR, you can enable a stronger 3x3 morphology by setting the option to 'true'.