IRONSOFTWAREHOME

C# Image Correction Filters for Improved OCR Reading

Curtis Chau
Curtis Chau
Updated: August 2, 2026

IronOCR provides five essential image correction filters (sharpen, enhance resolution, denoise, dilate, and erode) that preprocess images to significantly improve OCR accuracy by enhancing text clarity and reducing noise before text extraction.

Quickstart: Apply Sharpen Filter for Clear Text

Use IronOCR's OcrImageInput to sharpen a blurry image with a single line of code. This example demonstrates image enhancement for accurate OCR.

  1. 1Install IronOCR with NuGet Package Manager

    PM > Install-Package IronOcr

  2. 2Copy and run this code snippet.

    new IronOcr.OcrImageInput("sample.png").Sharpen().SaveAsImages("output.png");
    C#
  3. 3Deploy to test on your live environment

    Start using IronOCR in your project today with a free trial
    arrow pointer

How Do I Apply the Sharpen Filter?

This filter increases contrast along edges in the image, creating more defined text boundaries. It improves text clarity, making character recognition more accurate.

Why Does Sharpening Improve OCR Accuracy?

The sharpen filter emphasizes boundaries between text and background by enhancing edge contrast. Character recognition algorithms need clear, distinct letter shapes to function properly. Blurry text with soft edges - common in scanned documents or low-quality photos - causes OCR engines to misidentify character boundaries. To learn more about optimal image processing for OCR, check our comprehensive guide on OCR Image Optimization Filters.

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

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");

When Should I Use the Sharpen Filter?

Use sharpening for slightly out-of-focus images, scanned documents with soft text edges, or photographs taken in poor lighting. Avoid over-sharpening clear text, as this introduces artifacts and reduces accuracy. For extremely blurry scans, combine sharpening with other filters or see our guide on Fixing Low Quality Scans & Images.

Export filtered images using the SaveAsImages method. Below is a before-and-after comparison.

Blurred text sample showing business article content before applying sharpen filter
Text sample after sharpen filter application showing improved edge definition and character clarity

How Do I Enhance Resolution for Better OCR?

This filter increases pixel density, improving sharpness and clarity. It helps OCR engines read text in low-resolution images more accurately.

What DPI Should I Target for OCR?

OCR engines perform best at 300 DPI (dots per inch). Lower resolutions cause character misrecognition; higher resolutions slow processing without improving accuracy. IronOCR's enhancement filter intelligently upscales images to optimal DPI levels. For detailed guidance, see our DPI Settings guide.

Invoke the EnhanceResolution method to apply this filter. Default target is 225 DPI:

using IronOcr;

// Create OCR input
var imageInput = new OcrImageInput("low-res-scan.jpg");

// Apply enhance resolution filter with default 225 DPI
imageInput.EnhanceResolution();

// Or specify a custom DPI
imageInput.EnhanceResolution(300);

// Combine with OCR reading
var ocr = new IronTesseract();
var result = ocr.Read(imageInput);
Console.WriteLine($"Extracted text: {result.Text}");

When Does Resolution Enhancement Matter Most?

Resolution enhancement is crucial for:

  • Screenshots captured at screen resolution (72-96 DPI)
  • Web images downloaded from the internet
  • Historical documents scanned at low resolutions
  • Fax transmissions with inherently low resolution

The OCR Tesseract Image DPI example provides insights into how DPI affects accuracy across document types.

Low-resolution text sample showing blurry, pixelated business article requiring OCR enhancement
Resolution-enhanced text showing clearer characters after DPI improvement for better OCR accuracy

How Do I Remove Noise from Images?

Denoising filters reduce unwanted artifacts in images. Noise reduction isolates text from background interference, producing cleaner and more accurate OCR results.

What's the Difference Between 2x2 and 3x3 Morphology?

Morphology size determines denoising strength. A 2x2 morphology applies gentle noise reduction for minimal artifacts while preserving fine text. The 3x3 morphology provides aggressive noise removal for heavily degraded documents but may affect very small text.

To apply the denoise filter, use the DeNoise method. Default morphology is 2x2. Pass 'true' for 3x3 morphology:

using IronOcr;

// Load noisy document
var imageInput = new OcrImageInput("noisy-scan.pdf");

// Apply denoise filter with default 2x2 morphology
imageInput.DeNoise();

// Apply stronger denoising with 3x3 morphology
imageInput.DeNoise(true);

// Combine with other filters for severely degraded images
imageInput.DeNoise()
         .Sharpen()
         .EnhanceResolution(300);

// Process with OCR
var ocr = new IronTesseract();
var result = ocr.Read(imageInput);

// Check confidence levels
foreach (var page in result.Pages)
{
    Console.WriteLine($"Page confidence: {page.Confidence}%");
}

How Do I Know If My Image Needs Denoising?

Look for these noise indicators:

  • Random speckles or dots on the background
  • Salt-and-pepper noise from poor scanning
  • Graininess from high ISO photography
  • Background texture from recycled paper

For automatic noise detection, explore our Filter Wizard.

Noisy scanned document with speckles and artifacts degrading text about Japanese tech executives
Clean document after denoise filter removes background speckles and improves text clarity

How Do I Use the Dilate Filter?

Dilation expands bright regions in images. It thickens text, making it more prominent and easier for OCR software to interpret.

When Should I Apply Dilation to Text?

Dilation works best with thin or broken text characters found in:

  • Old typewriter documents with inconsistent ink
  • Faded receipts and thermal paper printouts
  • Documents with hairline fonts
  • Over-compressed text in image formats

Dilation fills small gaps within characters and strengthens weak stroke connections. This prevents OCR engines from misinterpreting broken characters as multiple symbols.

To apply the dilation filter, use the Dilate method. Default morphology is 2x2; pass 'true' for 3x3:

using IronOcr;

// Create OCR engine
var ocrTesseract = new IronTesseract();

// Apply dilate filter
var imageInput = new OcrImageInput("thin-text.jpg");
imageInput.Dilate();

// For more aggressive dilation
imageInput.Dilate(true);

// Practical example for faded receipt processing
var receiptInput = new OcrImageInput("faded-receipt.jpg");
receiptInput.Dilate()
           .DeNoise()
           .EnhanceResolution(300);

// Configure for better receipt reading
ocrTesseract.Configuration.PageSegmentationMode = TesseractPageSegmentationMode.SingleBlock;
ocrTesseract.Configuration.ReadBarCodes = true;

// Perform OCR
var result = ocrTesseract.Read(receiptInput);

What Are Common Issues with Over-Dilation?

Excessive dilation may cause:

  • Character bleeding where adjacent letters merge
  • Loss of internal details (holes in 'e' or '8')
  • Reduced accuracy for bold text

Monitor results and adjust accordingly. For documents with mixed text weights, use our image quality correction filters selectively.

Document with thin text strokes that would benefit from dilation filtering for OCR
Text after dilation filter showing thickened character strokes and improved legibility

How Do I Apply the Erode Filter?

Erosion reduces bright region sizes in images, refining thick or distorted characters and improving character separation.

Why Does Erosion Help with Thick Text?

Erosion thins text strokes and separates touching characters. This filter excels with:

  • Over-inked printed documents
  • Photocopies with character bleeding
  • Bold text that appears merged
  • Low-quality fax transmissions

Careful erosion restores character separation and improves individual letter recognition, preventing entire words from being misread.

Use the Erode method to apply this filter. Default morphology is 2x2; pass 'true' for 3x3:

using IronOcr;

// Create OCR instance
var ocrTesseract = new IronTesseract();

// Load image with thick text
var imageInput = new OcrImageInput("thick-text.jpg");

// Apply erode filter
imageInput.Erode();

// Stronger erosion for heavily bleeding text
imageInput.Erode(true);

// Example: Processing a poor-quality photocopy
var photocopyInput = new OcrImageInput("thick-text-photocopy.pdf");

// Apply erosion followed by sharpening for best results
photocopyInput.Erode()
              .Sharpen()
              .EnhanceResolution(300);

// Configure OCR for better accuracy
ocrTesseract.Configuration.BlackListCharacters = "~`@#$%^&*()_+-={}[]|\\:\";<>?,./";
ocrTesseract.Configuration.WhiteListCharacters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 ";

var ocrResult = ocrTesseract.Read(photocopyInput);

// Extract with confidence check
var highConfidenceText = ocrResult.Blocks
    .Where(b => b.Confidence > 90)
    .Select(b => b.Text);

How Do I Balance Erosion with Text Readability?

Finding the right erosion level requires careful testing:

  • Start with default 2x2 morphology
  • Test on representative document samples
  • Check that punctuation marks remain visible
  • Ensure thin fonts don't become broken

For documents with mixed text weights, see our advanced configuration options.

Document with merged/thick characters that would benefit from erosion filter processing
Text after erosion filter showing separated characters and refined stroke thickness

How Do I Save Filtered Images as Searchable PDFs?

IronOCR lets you save modified PDFs with filters applied or in their original state. The SaveAsSearchablePdf method's second parameter determines whether to save with filters.

What's the Benefit of Preserving Filter Changes?

Preserving filter changes offers several advantages:

  • Creates cleaner, more readable documents
  • Maintains consistency across document batches
  • Provides visual confirmation of text quality improvements
  • Enables quality control comparisons

Creating searchable PDFs embeds an OCR text layer while maintaining visual appearance. Learn more in our guide on creating searchable PDFs.

using IronOcr;

var ocr = new IronTesseract();
var ocrInput = new OcrInput();

// Load a PDF file
ocrInput.LoadPdf("invoice.pdf");

// Apply multiple filters for comprehensive improvement
ocrInput.ToGrayScale()
        .DeNoise()
        .Sharpen()
        .EnhanceResolution(300);

// Perform OCR
OcrResult result = ocr.Read(ocrInput);

// Save the result as a searchable PDF with filters applied
result.SaveAsSearchablePdf("outputFiltered.pdf", true);

// Or save without filters to preserve original appearance
result.SaveAsSearchablePdf("outputOriginal.pdf", false);

// Export to other formats
result.SaveAsTextFile("extracted-text.txt");
result.SaveAsHocrFile("output.html");

How Do I Choose Between Filtered and Original PDFs?

Save with filters (true) when:

  • Original document quality is poor
  • Consistent appearance across documents is needed
  • Filtered version significantly improves readability
  • Archiving documents for long-term storage

Save without filters (false) when:

  • Preserving original appearance is legally required
  • Color information is important
  • Document authenticity must be maintained
  • Filters are only needed for OCR accuracy

For advanced PDF processing options, explore our PDF OCR Text Extraction guide. For optimal filter combinations, see the Filter Wizard tutorial.

Frequently Asked Questions

What image correction filters does IronOCR provide for OCR improvement?

IronOCR offers five essential image correction filters: sharpen, enhance resolution, denoise, dilate, and erode. These filters improve OCR accuracy by enhancing text clarity and reducing noise in images.

How does the sharpen filter improve OCR accuracy?

The sharpen filter increases contrast along edges in the image, creating more defined text boundaries. This enhancement helps OCR engines recognize characters more accurately by emphasizing the separation between text and background.

When should I use the enhance resolution filter?

Enhance resolution is useful for low-resolution images like screenshots, web images, and scanned historical documents. It increases pixel density, improving sharpness and clarity to facilitate more accurate OCR reading.

What is the benefit of using denoising filters?

Denoising filters remove unwanted artifacts and noise from images, helping to isolate text from background interference. This results in cleaner, more accurate OCR outputs.

How does the dilate filter aid OCR processes?

The dilate filter thickens text, making it more prominent in images. This is especially useful for thin or broken text characters, allowing OCR software to interpret them more effectively.

Why would I use the erode filter on scanned documents?

The erode filter reduces the size of bright regions, refining thick or distorted characters and improving character separation. It is beneficial for over-inked, bold text that appears merged in scanned documents.

How can I save a filtered image as a searchable PDF using IronOCR?

You can save modified images as searchable PDFs by using the `SaveAsSearchablePdf` method in IronOCR. This method allows you to choose whether to save the document with applied filters or in its original state.

What parameters should I consider when choosing between filtered and original PDFs?

Choose filtered PDFs when you need consistent appearance, improved readability, or archiving. Opt for original PDFs when preserving original appearance is legally required, or when maintaining color information and document authenticity is important.

What are common signs that my image needs denoising?

Noise indicators include random speckles, salt-and-pepper noise, graininess from high ISO photography, and background texture that interferes with text clarity.

What typical DPI settings are recommended for optimal OCR results?

OCR engines perform best at 300 DPI. Lower resolutions may lead to character misrecognition, while higher resolutions might slow processing without enhancing accuracy. IronOCR's enhancement filter can upscale images to the optimal DPI level.

Curtis Chau
Technical Writer

Curtis Chau holds a Bachelor’s degree in Computer Science (Carleton University) and specializes in front-end development with expertise in Node.js, TypeScript, JavaScript, and React. Passionate about crafting intuitive and aesthetically pleasing user interfaces, Curtis enjoys working with modern frameworks and creating well-structured, visually appealing manuals.

...
Read More

Ready to Get Started?

Nuget Downloads 6,236,385Version:2026.9just released

Get your FREE

30-day Trial Key instantly.

bullet_checkedNo credit card or account creation required
bullet_testTest in production
without watermarks
bullet_calendar30 days fully
functional product
bullet_support24/5 technical
support during trial
Get your free 30-day Trial Key instantly.
No credit card or account creation required
C# NuGet Library for PDF
Install with NuGet

Version: 2026.9

PM > Install-Package IronOcr
nuget.org/packages/IronOcr/
  1. In Solution Explorer, right-click References, Manage NuGet Packages
  2. Select Browse and search "IronOCR"
  3. Select the package and install
C# PDF DLL
Download DLL

Version: 2026.9

or download Windows Installer here.

  1. Download and unzip IronOCR to a location such as ~/Libs within your Solution directory
  2. In Visual Studio Solution Explorer, right click References. Select Browse, "IronOCR.dll"

Licenses from $999

Key in blue circle

Get your free 30-day Trial Key instantly.

Your trial license will be sent to your email address

No limitations. 100% unlocked. No credit card.

bullet_checkedNo credit card or account creation requiredNo limitations. 100% unlocked. No credit card.
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronPDF
Get Your No-Obligation Consult
Complete the form below or email sales@ironsoftware.com
Your details will always be kept confidential.
Trusted by Millions of Engineers Worldwide
Iron Software's customer logos
Get your free 30-day Trial Key instantly.
No credit card or account creation required