# C# Image Correction Filters for Improved OCR Reading
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.
*as-heading:2(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.
```cs
:title=Fix Blurry Text Instantly
new IronOcr.OcrImageInput("sample.png").Sharpen().SaveAsImages("output.png");
```
<div class="hsg-featured-snippet">
<h3>Minimal Workflow (5 steps)</h3>
<ol>
<li><a class="js-modal-open" data-modal-id="trial-license-after-download" href="https://nuget.org/packages/IronOcr/">Download a C# library for image correction using filters</a></li>
<li>Import the PDF document and images for reading</li>
<li>Apply desired filters, such as sharpening, enhancing resolution, denoising, dilation, and erosion</li>
<li>Export the corrected image for viewing</li>
<li>Use the <code>Read</code> method for OCR processing</li>
</ol>
</div>
<br class="clear" />
## 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](https://ironsoftware.com/csharp/ocr/examples/ocr-image-filters-for-net-tesseract/).
To apply the sharpen filter, invoke the `Sharpen` method of the `OcrImageInput` object:
```csharp
:path=/static-assets/ocr/content-code-examples/how-to/image-quality-correction-sharpen-filter.cs
```
### 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](https://ironsoftware.com/csharp/ocr/examples/ocr-low-quality-scans-tesseract/).
Export filtered images using the `SaveAsImages` method. Below is a before-and-after comparison.
<div class="competitors-section__wrapper-even-1">
<div class="competitors__card" style="width: 48%;">
<img src="/static-assets/ocr/how-to/image-quality-correction/sample.jpg" alt="Blurred text sample showing business article content before applying sharpen filter" class="img-responsive add-shadow" />
<p class="competitors__download-link" style="color: #181818; font-style: italic;">Before</p>
</div>
<div class="competitors__card" style="width: 48%;">
<img src="/static-assets/ocr/how-to/image-quality-correction/sharpen_0.webp" alt="Text sample after sharpen filter application showing improved edge definition and character clarity" class="img-responsive add-shadow" />
<p class="competitors__download-link" style="color: #181818; font-style: italic;">After</p>
</div>
</div>
<hr />
## 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](https://ironsoftware.com/csharp/ocr/how-to/dpi-setting/).
Invoke the `EnhanceResolution` method to apply this filter. Default target is 225 DPI:
```csharp
:path=/static-assets/ocr/content-code-examples/how-to/image-quality-correction-3.cs
```
### 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](https://ironsoftware.com/csharp/ocr/examples/ocr-image-dpi-for-tesseract/) provides insights into how DPI affects accuracy across document types.
<div class="competitors-section__wrapper-even-1">
<div class="competitors__card" style="width: 48%;">
<img src="/static-assets/ocr/how-to/image-quality-correction/sample.jpg" alt="Low-resolution text sample showing blurry, pixelated business article requiring OCR enhancement" class="img-responsive add-shadow" />
<p class="competitors__download-link" style="color: #181818; font-style: italic;">Before</p>
</div>
<div class="competitors__card" style="width: 48%;">
<img src="/static-assets/ocr/how-to/image-quality-correction/enhanceResolution_0.webp" alt="Resolution-enhanced text showing clearer characters after DPI improvement for better OCR accuracy" class="img-responsive add-shadow" />
<p class="competitors__download-link" style="color: #181818; font-style: italic;">After</p>
</div>
</div>
<hr />
## 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:
```csharp
:path=/static-assets/ocr/content-code-examples/how-to/image-quality-correction-4.cs
```
### 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](https://ironsoftware.com/csharp/ocr/examples/filter-wizard/).
<div class="competitors-section__wrapper-even-1">
<div class="competitors__card" style="width: 48%;">
<img src="/static-assets/ocr/how-to/image-quality-correction/sample.jpg" alt="Noisy scanned document with speckles and artifacts degrading text about Japanese tech executives" class="img-responsive add-shadow" />
<p class="competitors__download-link" style="color: #181818; font-style: italic;">Before</p>
</div>
<div class="competitors__card" style="width: 48%;">
<img src="/static-assets/ocr/how-to/image-quality-correction/denoise_0.webp" alt="Clean document after denoise filter removes background speckles and improves text clarity" class="img-responsive add-shadow" />
<p class="competitors__download-link" style="color: #181818; font-style: italic;">After</p>
</div>
</div>
<hr />
## 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:
```csharp
:path=/static-assets/ocr/content-code-examples/how-to/image-quality-correction-5.cs
```
### 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.
<div class="competitors-section__wrapper-even-1">
<div class="competitors__card" style="width: 48%;">
<img src="/static-assets/ocr/how-to/image-quality-correction/sample.jpg" alt="Document with thin text strokes that would benefit from dilation filtering for OCR" class="img-responsive add-shadow" />
<p class="competitors__download-link" style="color: #181818; font-style: italic;">Before</p>
</div>
<div class="competitors__card" style="width: 50%;">
<img src="/static-assets/ocr/how-to/image-quality-correction/dilate_0.webp" alt="Text after dilation filter showing thickened character strokes and improved legibility" class="img-responsive add-shadow" />
<p class="competitors__download-link" style="color: #181818; font-style: italic;">After</p>
</div>
</div>
<hr />
## 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:
```csharp
:path=/static-assets/ocr/content-code-examples/how-to/image-quality-correction-6.cs
```
### 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](https://ironsoftware.com/csharp/ocr/examples/csharp-configure-setup-tesseract/).
<div class="competitors-section__wrapper-even-1">
<div class="competitors__card" style="width: 48%;">
<img src="/static-assets/ocr/how-to/image-quality-correction/sample.jpg" alt="Document with merged/thick characters that would benefit from erosion filter processing" class="img-responsive add-shadow" />
<p class="competitors__download-link" style="color: #181818; font-style: italic;">Before</p>
</div>
<div class="competitors__card" style="width: 50%;">
<img src="/static-assets/ocr/how-to/image-quality-correction/erode_0.webp" alt="Text after erosion filter showing separated characters and refined stroke thickness" class="img-responsive add-shadow" />
<p class="competitors__download-link" style="color: #181818; font-style: italic;">After</p>
</div>
</div>
## 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](https://ironsoftware.com/csharp/ocr/how-to/searchable-pdf/).
```csharp
:path=/static-assets/ocr/content-code-examples/how-to/image-quality-correction-7.cs
```
### 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](https://ironsoftware.com/csharp/ocr/examples/csharp-pdf-ocr/). For optimal filter combinations, see the [Filter Wizard tutorial](https://ironsoftware.com/csharp/ocr/how-to/filter-wizard/).
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.
Apply desired filters, such as sharpening, enhancing resolution, denoising, dilation, and erosion
Export the corrected image for viewing
Use the Read method for OCR processing
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 IronTesseractIronTesseract ocrTesseract = new IronTesseract();// Add imageusing var imageInput = new OcrImageInput("sample.jpg");// Apply sharpen filterimageInput.Sharpen();// Export filtered imageimageInput.SaveAsImages("sharpen.jpg");
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");
ImportsIronOcr' Instantiate IronTesseractPrivate ocrTesseract As New IronTesseract()' Add imagePrivate imageInput = New OcrImageInput("sample.jpg")' Apply sharpen filterimageInput.Sharpen()' Export filtered imageimageInput.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")
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.
Before
After
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 inputvar imageInput = new OcrImageInput("low-res-scan.jpg");// Apply enhance resolution filter with default 225 DPIimageInput.EnhanceResolution();// Or specify a custom DPIimageInput.EnhanceResolution(300);// Combine with OCR readingvar ocr = new IronTesseract();var result = ocr.Read(imageInput);Console.WriteLine($"Extracted text: {result.Text}");
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}");
ImportsIronOcr' Create OCR inputDim imageInput As New OcrImageInput("low-res-scan.jpg")' Apply enhance resolution filter with default 225 DPIimageInput.EnhanceResolution()' Or specify a custom DPIimageInput.EnhanceResolution(300)' Combine with OCR readingDim ocr As New IronTesseract()Dim result = ocr.Read(imageInput)Console.WriteLine($"Extracted text: {result.Text}")
Imports IronOcr
' Create OCR input
Dim imageInput As 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
Dim ocr As New IronTesseract()
Dim 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)
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 documentvar imageInput = new OcrImageInput("noisy-scan.pdf");// Apply denoise filter with default 2x2 morphologyimageInput.DeNoise();// Apply stronger denoising with 3x3 morphologyimageInput.DeNoise(true);// Combine with other filters for severely degraded imagesimageInput.DeNoise() .Sharpen() .EnhanceResolution(300);// Process with OCRvar ocr = new IronTesseract();var result = ocr.Read(imageInput);// Check confidence levelsforeach (var page in result.Pages){Console.WriteLine($"Page confidence: {page.Confidence}%");}
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}%");
}
ImportsIronOcr' Load noisy documentDim imageInput As New OcrImageInput("noisy-scan.pdf")' Apply denoise filter with default 2x2 morphologyimageInput.DeNoise()' Apply stronger denoising with 3x3 morphologyimageInput.DeNoise(True)' Combine with other filters for severely degraded imagesimageInput.DeNoise() _ .Sharpen() _ .EnhanceResolution(300)' Process with OCRDim ocr As New IronTesseract()Dim result = ocr.Read(imageInput)' Check confidence levelsFor Each page In result.PagesConsole.WriteLine($"Page confidence: {page.Confidence}%")Next
Imports IronOcr
' Load noisy document
Dim imageInput As 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
Dim ocr As New IronTesseract()
Dim result = ocr.Read(imageInput)
' Check confidence levels
For Each page In result.Pages
Console.WriteLine($"Page confidence: {page.Confidence}%")
Next
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.
Before
After
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 enginevar ocrTesseract = new IronTesseract();// Apply dilate filtervar imageInput = new OcrImageInput("thin-text.jpg");imageInput.Dilate();// For more aggressive dilationimageInput.Dilate(true);// Practical example for faded receipt processingvar receiptInput = new OcrImageInput("faded-receipt.jpg");receiptInput.Dilate() .DeNoise() .EnhanceResolution(300);// Configure for better receipt readingocrTesseract.Configuration.PageSegmentationMode = TesseractPageSegmentationMode.SingleBlock;ocrTesseract.Configuration.ReadBarCodes = true;// Perform OCRvar result = ocrTesseract.Read(receiptInput);
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);
ImportsIronOcr' Create OCR engineDim ocrTesseract As New IronTesseract()' Apply dilate filterDim imageInput As New OcrImageInput("thin-text.jpg")imageInput.Dilate()' For more aggressive dilationimageInput.Dilate(True)' Practical example for faded receipt processingDim receiptInput As New OcrImageInput("faded-receipt.jpg")receiptInput.Dilate() _ .DeNoise() _ .EnhanceResolution(300)' Configure for better receipt readingocrTesseract.Configuration.PageSegmentationMode = TesseractPageSegmentationMode.SingleBlockocrTesseract.Configuration.ReadBarCodes = True' Perform OCRDim result = ocrTesseract.Read(receiptInput)
Imports IronOcr
' Create OCR engine
Dim ocrTesseract As New IronTesseract()
' Apply dilate filter
Dim imageInput As New OcrImageInput("thin-text.jpg")
imageInput.Dilate()
' For more aggressive dilation
imageInput.Dilate(True)
' Practical example for faded receipt processing
Dim receiptInput As 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
Dim 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.
Before
After
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 instancevar ocrTesseract = new IronTesseract();// Load image with thick textvar imageInput = new OcrImageInput("thick-text.jpg");// Apply erode filterimageInput.Erode();// Stronger erosion for heavily bleeding textimageInput.Erode(true);// Example: Processing a poor-quality photocopyvar photocopyInput = new OcrImageInput("thick-text-photocopy.pdf");// Apply erosion followed by sharpening for best resultsphotocopyInput.Erode() .Sharpen() .EnhanceResolution(300);// Configure OCR for better accuracyocrTesseract.Configuration.BlackListCharacters = "~`@#$%^&*()_+-={}[]|\\:\";<>?,./";ocrTesseract.Configuration.WhiteListCharacters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 ";var ocrResult = ocrTesseract.Read(photocopyInput);// Extract with confidence checkvar highConfidenceText = ocrResult.Blocks .Where(b => b.Confidence > 90) .Select(b => b.Text);
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);
ImportsIronOcr' Create OCR instanceDim ocrTesseract As New IronTesseract()' Load image with thick textDim imageInput As New OcrImageInput("thick-text.jpg")' Apply erode filterimageInput.Erode()' Stronger erosion for heavily bleeding textimageInput.Erode(True)' Example: Processing a poor-quality photocopyDim photocopyInput As New OcrImageInput("thick-text-photocopy.pdf")' Apply erosion followed by sharpening for best resultsphotocopyInput.Erode() _ .Sharpen() _ .EnhanceResolution(300)' Configure OCR for better accuracyocrTesseract.Configuration.BlackListCharacters = "~`@#$%^&*()_+-={}[]|\:"";<>?,./"ocrTesseract.Configuration.WhiteListCharacters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 "Dim ocrResult = ocrTesseract.Read(photocopyInput)' Extract with confidence checkDim highConfidenceText = ocrResult.Blocks _ .Where(Function(b) b.Confidence > 90) _ .Select(Function(b) b.Text)
Imports IronOcr
' Create OCR instance
Dim ocrTesseract As New IronTesseract()
' Load image with thick text
Dim imageInput As 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
Dim photocopyInput As 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 "
Dim ocrResult = ocrTesseract.Read(photocopyInput)
' Extract with confidence check
Dim highConfidenceText = ocrResult.Blocks _
.Where(Function(b) b.Confidence > 90) _
.Select(Function(b) b.Text)
How Do I Balance Erosion with Text Readability?
Finding the right erosion level requires careful testing:
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 fileocrInput.LoadPdf("invoice.pdf");// Apply multiple filters for comprehensive improvementocrInput.ToGrayScale() .DeNoise() .Sharpen() .EnhanceResolution(300);// Perform OCROcrResult result = ocr.Read(ocrInput);// Save the result as a searchable PDF with filters appliedresult.SaveAsSearchablePdf("outputFiltered.pdf", true);// Or save without filters to preserve original appearanceresult.SaveAsSearchablePdf("outputOriginal.pdf", false);// Export to other formatsresult.SaveAsTextFile("extracted-text.txt");result.SaveAsHocrFile("output.html");
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");
ImportsIronOcrDim ocr As New IronTesseract()Dim ocrInput As New OcrInput()' Load a PDF fileocrInput.LoadPdf("invoice.pdf")' Apply multiple filters for comprehensive improvementocrInput.ToGrayScale() _ .DeNoise() _ .Sharpen() _ .EnhanceResolution(300)' Perform OCRDim result AsOcrResult = ocr.Read(ocrInput)' Save the result as a searchable PDF with filters appliedresult.SaveAsSearchablePdf("outputFiltered.pdf", True)' Or save without filters to preserve original appearanceresult.SaveAsSearchablePdf("outputOriginal.pdf", False)' Export to other formatsresult.SaveAsTextFile("extracted-text.txt")result.SaveAsHocrFile("output.html")
Imports IronOcr
Dim ocr As New IronTesseract()
Dim ocrInput As New OcrInput()
' Load a PDF file
ocrInput.LoadPdf("invoice.pdf")
' Apply multiple filters for comprehensive improvement
ocrInput.ToGrayScale() _
.DeNoise() _
.Sharpen() _
.EnhanceResolution(300)
' Perform OCR
Dim result As OcrResult = 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
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 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.