How to Use the Filter Wizard in C# for Better OCR
The IronOCR Filter Wizard automatically tests all preprocessing filter combinations on your image to find optimal OCR settings, returning both the highest confidence score and exact C# code needed to reproduce results.
Preprocessing images for OCR can be challenging. Multiple filters can improve recognition, but finding the right combination requires extensive trial and error. Each image presents unique challenges, making manual testing time-consuming. This is particularly true when working with low-quality scans or images with varying noise and distortion levels.
IronOCR's OcrInputFilterWizard solves this problem. The Filter Wizard automatically evaluates filter combinations to maximize OCR confidence and accuracy. It performs exhaustive testing for optimal settings and returns the best filter combination as a code snippet, allowing easy reproduction of results. This feature integrates seamlessly with the OcrInput class, simplifying filter application to your images.
This guide demonstrates how the Filter Wizard works and showcases the code snippets and parameters it uses. For additional OCR workflow optimization, explore our guide on image quality correction.
Quickstart: Automatically discover your ideal image filter chain
Use IronOCR's Filter Wizard to test all preprocessing filter combinations and get the best-performing code snippet. One line returns your highest confidence score and the exact C# filter chain for similar images.
Get started making PDFs with NuGet now:
Install IronOCR with NuGet Package Manager
Copy and run this code snippet.
string code = OcrInputFilterWizard.Run("image.png", out double confidence, new IronTesseract());Deploy to test on your live environment
Minimal Workflow (5 steps)
- Download a C# library to use the filter wizard
- Instantiate the IronTesseract engine
- Load the input image into the
OcrInputFilterWizard Runthe filter wizard and review the outputs, such as confidence- Utilize the code given and apply it to the input image, and verify the results
How Does the Filter Wizard Work?
The OcrInputFilterWizard.Run method takes three parameters: the input image, an out parameter for the resulting confidence level, and the Tesseract Engine instance. For advanced engine control, see our guide on Tesseract detailed configuration.
It tests multiple combinations of preprocessing filters to achieve the best confidence score. The highest confidence score determines which filter set to apply to your input image. This approach works effectively with challenging images requiring image orientation correction or other complex preprocessing steps.
The filter wizard has no presets or combination limits. It focuses on achieving the best possible confidence score through comprehensive filter testing. For real-time feedback during processing, implement progress tracking to monitor wizard operations.
Available filters in combination testing:
input.Contrast()- Adjusts contrast for text clarityinput.Sharpen()- Enhances edge definitioninput.Binarize()- Converts to black and whiteinput.ToGrayScale()- Removes color informationinput.Invert()- Inverts colorsinput.Deskew()- Corrects skewed textinput.Scale(...)- Resizes to optimal dimensionsinput.Denoise()- Removes pixel noiseinput.DeepCleanBackgroundNoise()- Advanced noise removalinput.EnhanceResolution()- Improves low-quality resolutioninput.Dilate(),input.Erode()- Text refinement operations
For detailed filter information, see this tutorial on image filters. Additional preprocessing techniques are available in the image correction filters guide.
This exhaustive testing method requires processing time. For large-scale operations, use multithreading support to process multiple images simultaneously.
What Type of Image Should I Use for Testing?
This example uses a screenshot with heavy artificial noise to demonstrate filter wizard functionality. The Filter Wizard handles various image types effectively, from scanned documents to photos with text.

When selecting test images, consider these factors:
- Image Resolution: Higher DPI images typically yield better results. See our guide on DPI settings for optimization tips.
- Document Type: Different document types benefit from specific filter combinations. Identity documents may require different preprocessing than standard text documents.
- Source Quality: The Filter Wizard excels with problematic images but starts with the highest quality source available when possible.
How Do I Run the Filter Wizard in My Code?
:path=/static-assets/ocr/content-code-examples/how-to/filter-wizard-process.csusing IronOcr;
using System;
// Initialize the Tesseract engine
var ocr = new IronTesseract();
// 1. Pass the image path ("noise.png").
// 2. Pass an 'out' variable to store the best confidence score found.
// 3. Pass the tesseract instance to be used for testing.
string codeToRun = OcrInputFilterWizard.Run("noise.png", out double confidence, ocr);
// The 'confidence' variable is now populated with the highest score achieved.
Console.WriteLine($"Best Confidence Score: {confidence}");
// 'codeToRun' holds the exact C# code snippet that achieved this score.
// The returned string is the code you can use to filter similar images.
Console.WriteLine("Recommended Filter Code:");
Console.WriteLine(codeToRun);Imports IronOcr
Imports System
' Initialize the Tesseract engine
Dim ocr As New IronTesseract()
' 1. Pass the image path ("noise.png").
' 2. Pass an 'out' variable to store the best confidence score found.
' 3. Pass the tesseract instance to be used for testing.
Dim confidence As Double
Dim codeToRun As String = OcrInputFilterWizard.Run("noise.png", confidence, ocr)
' The 'confidence' variable is now populated with the highest score achieved.
Console.WriteLine($"Best Confidence Score: {confidence}")
' 'codeToRun' holds the exact C# code snippet that achieved this score.
' The returned string is the code you can use to filter similar images.
Console.WriteLine("Recommended Filter Code:")
Console.WriteLine(codeToRun)The Filter Wizard processes various input formats. For supported formats information, see our guide on input images. You can also process PDF files or work directly with streams for dynamic image sources.
For batch processing scenarios, consider this expanded example:
/* :path=/static-assets/ocr/content-code-examples/how-to/filter-wizard-batch.cs */
using IronOcr;
using System;
using System.IO;
// Process multiple similar images
var ocr = new IronTesseract();
string[] imageFiles = Directory.GetFiles(@"C:\Images", "*.png");
// Run Filter Wizard on first image to discover optimal settings
string optimalCode = OcrInputFilterWizard.Run(imageFiles[0], out double baselineConfidence, ocr);
Console.WriteLine($"Baseline confidence: {baselineConfidence:P2}");
Console.WriteLine($"Optimal filter sequence discovered");
// Apply discovered filters to all images
foreach (string imagePath in imageFiles)
{
using (var input = new OcrImageInput(imagePath))
{
// Apply the filter sequence discovered by the wizard
// The actual filters would be applied here based on the wizard output
var result = ocr.Read(input);
Console.WriteLine($"Processed: {Path.GetFileName(imagePath)} - Confidence: {result.Confidence:P2}");
}
}/* :path=/static-assets/ocr/content-code-examples/how-to/filter-wizard-batch.cs */
using IronOcr;
using System;
using System.IO;
// Process multiple similar images
var ocr = new IronTesseract();
string[] imageFiles = Directory.GetFiles(@"C:\Images", "*.png");
// Run Filter Wizard on first image to discover optimal settings
string optimalCode = OcrInputFilterWizard.Run(imageFiles[0], out double baselineConfidence, ocr);
Console.WriteLine($"Baseline confidence: {baselineConfidence:P2}");
Console.WriteLine($"Optimal filter sequence discovered");
// Apply discovered filters to all images
foreach (string imagePath in imageFiles)
{
using (var input = new OcrImageInput(imagePath))
{
// Apply the filter sequence discovered by the wizard
// The actual filters would be applied here based on the wizard output
var result = ocr.Read(input);
Console.WriteLine($"Processed: {Path.GetFileName(imagePath)} - Confidence: {result.Confidence:P2}");
}
}Imports IronOcr
Imports System
Imports System.IO
' Process multiple similar images
Dim ocr As New IronTesseract()
Dim imageFiles As String() = Directory.GetFiles("C:\Images", "*.png")
' Run Filter Wizard on first image to discover optimal settings
Dim baselineConfidence As Double
Dim optimalCode As String = OcrInputFilterWizard.Run(imageFiles(0), baselineConfidence, ocr)
Console.WriteLine($"Baseline confidence: {baselineConfidence:P2}")
Console.WriteLine("Optimal filter sequence discovered")
' Apply discovered filters to all images
For Each imagePath As String In imageFiles
Using input As New OcrImageInput(imagePath)
' Apply the filter sequence discovered by the wizard
' The actual filters would be applied here based on the wizard output
Dim result = ocr.Read(input)
Console.WriteLine($"Processed: {Path.GetFileName(imagePath)} - Confidence: {result.Confidence:P2}")
End Using
NextWhat Results Will the Filter Wizard Return?

The filter wizard output shows 65% confidence as the best achievable result for this specific image. Confidence scores are crucial metrics for evaluating OCR accuracy. Learn more about result confidence in our dedicated guide.
The input image contains extreme distortion and artificial noise. This demonstrates Filter Wizard capabilities in challenging scenarios. For production use, start with higher quality source images when possible.
The generated code snippet provides:
- Exact filter sequence: The order of operations matters for optimal results
- Method chaining: Clean, readable code that's easy to implement
- No parameters to guess: Each filter is configured for best performance
How Do I Apply the Recommended Filter Combination?
After running the filter wizard, apply the provided code snippet settings to your input image to verify results and confidence. This ensures reproducible results across similar images in your document processing pipeline.
How to implement the recommended code?
:path=/static-assets/ocr/content-code-examples/how-to/filter-wizard-best-combination.csusing IronOcr;
using System;
// Initialize the Tesseract engine
var ocrTesseract = new IronTesseract();
// Load the image into an OcrInput object
using (var input = new OcrImageInput("noise.png"))
{
// Apply the exact filter chain recommended by the Wizard's output
input.Invert();
input.DeNoise();
input.Contrast();
input.AdaptiveThreshold();
// Run OCR on the pre-processed image
OcrResult result = ocrTesseract.Read(input);
// Print the final result and confidence
Console.WriteLine($"Result: {result.Text}");
Console.WriteLine($"Confidence: {result.Confidence}");
}Imports IronOcr
Imports System
' Initialize the Tesseract engine
Dim ocrTesseract As New IronTesseract()
' Load the image into an OcrInput object
Using input As New OcrImageInput("noise.png")
' Apply the exact filter chain recommended by the Wizard's output
input.Invert()
input.DeNoise()
input.Contrast()
input.AdaptiveThreshold()
' Run OCR on the pre-processed image
Dim result As OcrResult = ocrTesseract.Read(input)
' Print the final result and confidence
Console.WriteLine($"Result: {result.Text}")
Console.WriteLine($"Confidence: {result.Confidence}")
End UsingFilter application order matters significantly. The Filter Wizard determines both which filters to use and their optimal sequence. This intelligent sequencing makes the Filter Wizard valuable for complex preprocessing scenarios.
For enhanced control over the OCR process, consider implementing error handling and validation:
/* :path=/static-assets/ocr/content-code-examples/how-to/filter-wizard-validation.cs */
using IronOcr;
using System;
var ocrEngine = new IronTesseract();
try
{
using (var input = new OcrImageInput(@"C:\Images\document.png"))
{
// Apply Filter Wizard recommended sequence
input.Invert();
input.DeNoise();
input.Contrast();
input.AdaptiveThreshold();
// Configure additional OCR settings
ocrEngine.Configuration.ReadBarCodes = false;
ocrEngine.Configuration.RenderSearchablePdf = true;
// Perform OCR with timeout protection
var result = ocrEngine.Read(input);
// Validate results
if (result.Confidence >= 0.6)
{
Console.WriteLine("OCR successful with high confidence");
// Process the extracted text
}
else
{
Console.WriteLine("Low confidence result - consider manual review");
}
}
}
catch (Exception ex)
{
Console.WriteLine($"OCR processing error: {ex.Message}");
}/* :path=/static-assets/ocr/content-code-examples/how-to/filter-wizard-validation.cs */
using IronOcr;
using System;
var ocrEngine = new IronTesseract();
try
{
using (var input = new OcrImageInput(@"C:\Images\document.png"))
{
// Apply Filter Wizard recommended sequence
input.Invert();
input.DeNoise();
input.Contrast();
input.AdaptiveThreshold();
// Configure additional OCR settings
ocrEngine.Configuration.ReadBarCodes = false;
ocrEngine.Configuration.RenderSearchablePdf = true;
// Perform OCR with timeout protection
var result = ocrEngine.Read(input);
// Validate results
if (result.Confidence >= 0.6)
{
Console.WriteLine("OCR successful with high confidence");
// Process the extracted text
}
else
{
Console.WriteLine("Low confidence result - consider manual review");
}
}
}
catch (Exception ex)
{
Console.WriteLine($"OCR processing error: {ex.Message}");
}Imports IronOcr
Imports System
Dim ocrEngine As New IronTesseract()
Try
Using input As New OcrImageInput("C:\Images\document.png")
' Apply Filter Wizard recommended sequence
input.Invert()
input.DeNoise()
input.Contrast()
input.AdaptiveThreshold()
' Configure additional OCR settings
ocrEngine.Configuration.ReadBarCodes = False
ocrEngine.Configuration.RenderSearchablePdf = True
' Perform OCR with timeout protection
Dim result = ocrEngine.Read(input)
' Validate results
If result.Confidence >= 0.6 Then
Console.WriteLine("OCR successful with high confidence")
' Process the extracted text
Else
Console.WriteLine("Low confidence result - consider manual review")
End If
End Using
Catch ex As Exception
Console.WriteLine($"OCR processing error: {ex.Message}")
End TryWhat are the final OCR results after applying filters?

IronOCR extracts most text even under heavily distorted conditions. The confidence level matches the filter wizard's report. For detailed OCR result handling, consult our guide on data output.
What Advanced Usage Tips Should I Consider?
Consider these best practices when using the Filter Wizard in production:
Batch Processing: Test on representative samples, then apply the filter chain to similar images.
Performance Optimization: The Filter Wizard is thorough but time-consuming. For faster OCR, see fast OCR configuration.
Custom Language Support: For non-English text, explore multiple languages to optimize recognition.
API Integration: Visit our API reference for complete documentation.
Document-Specific Optimization: Different document types benefit from specialized approaches:
- For forms, consider reading tables
- For mixed content, enable barcode reading
- For multi-page documents, explore TIFF processing
Memory Management: Properly dispose of
OcrInputobjects using theusingstatement.- Error Recovery: Implement fallback strategies for low-confidence results. Consider manual review for critical documents.
The Filter Wizard provides powerful automated preprocessing discovery for optimal OCR results. By automatically finding the best preprocessing pipeline for your specific images, it eliminates guesswork from image preparation and ensures consistent, high-quality text extraction across your applications.
Frequently Asked Questions
What is the OCR Filter Wizard and how does it help with image preprocessing?
The IronOCR Filter Wizard is an automated tool that tests all possible preprocessing filter combinations on your image to find optimal OCR settings. It eliminates the manual trial-and-error process by automatically evaluating various filter combinations to maximize OCR confidence and accuracy, then returns the best filter combination as a ready-to-use C# code snippet.
How do I use the Filter Wizard in my C# application?
Using IronOCR's Filter Wizard is simple - just call OcrInputFilterWizard.Run() with your image path, an out parameter for confidence score, and an IronTesseract instance. For example: string code = OcrInputFilterWizard.Run("image.png", out double confidence, new IronTesseract());
What parameters does the OcrInputFilterWizard.Run method accept?
The OcrInputFilterWizard.Run method in IronOCR takes three parameters: the input image (as a file path), an out parameter that returns the resulting confidence level, and an instance of the IronTesseract Engine for processing.
Why should I use the Filter Wizard instead of manually testing filters?
Manual preprocessing filter testing is time-consuming and challenging, especially with low-quality scans or images with varying noise levels. IronOCR's Filter Wizard automates this process by exhaustively testing filter combinations and returning the highest confidence score with the exact C# code needed, saving significant development time.
How does the Filter Wizard determine the best filter combination?
IronOCR's Filter Wizard tests multiple combinations of preprocessing filters on your image and measures the OCR confidence score for each combination. It then selects the filter set that achieves the highest confidence score and returns this optimal combination as executable C# code.
Can the Filter Wizard work with low-quality or noisy images?
Yes, IronOCR's Filter Wizard is particularly effective with challenging images including low-quality scans and images with varying noise and distortion levels. It automatically finds the optimal preprocessing combination to maximize OCR accuracy even with difficult source material.






