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 chainUse 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.
-
1Install IronOCR with NuGet Package Manager
-
2Copy and run this code snippet.
string code = OcrInputFilterWizard.Run("image.png", out double confidence, new IronTesseract());C# -
3Deploy to test on your live environment
Start using IronOCR in your project today with a free trial
Minimal Workflow (5 steps)
- Download a C# library to use the filter wizard
- Instantiate the
IronTesseractengine - 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.Despeckle()- 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?
using 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}");
}
}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?
using 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}");
}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 primary function of the IronOCR Filter Wizard?
The IronOCR Filter Wizard automatically tests various image preprocessing filter combinations to find the optimal OCR settings, returning the highest confidence score and exact C# code needed for effective results.
Why is preprocessing necessary for OCR tasks?
Preprocessing is crucial in OCR tasks as it enhances image quality, which can significantly improve text recognition accuracy by reducing noise, correcting distortions, and optimizing the image for the OCR process.
How does the `OcrInputFilterWizard.Run` method work?
The `OcrInputFilterWizard.Run` method evaluates multiple preprocessing filter combinations on an input image using the Tesseract Engine and returns the highest confidence score and the C# code for the best filter configuration.
Can the Filter Wizard handle low-quality images effectively?
Yes, the Filter Wizard is designed to handle challenging scenarios, including low-quality images with noise and distortion, by finding the best filter combinations to maximize OCR accuracy.
What types of image filters are available in IronOCR?
IronOCR includes a variety of filters such as Contrast, Sharpen, Binarize, ToGrayScale, Invert, Deskew, Scale, DeNoise, Despeckle, EnhanceResolution, Dilate, and Erode to improve OCR performance.
How can I apply the recommended filter combination in C#?
After running the Filter Wizard, you can apply the recommended filter combination using the provided C# code snippet, which includes a sequence of image processing methods tailored for optimal OCR results.
What factors should be considered when selecting test images for the Filter Wizard?
When selecting test images, consider factors like image resolution, document type, and source quality, as these can affect the filter evaluation process and OCR performance.
How can I optimize the Filter Wizard for large-scale operations?
For large-scale operations, consider using multithreading to process multiple images simultaneously, and implement performance optimizations like the fast OCR configuration to reduce processing time.
What advanced usage tips are recommended for using the Filter Wizard?
Advanced tips include batch processing, performance optimization, custom language support, API integration, document-specific optimization, memory management, and error recovery strategies.
Is the Filter Wizard suitable for handling different document types?
Yes, the Filter Wizard can optimize OCR processing for various document types by automatically finding the best preprocessing pipeline, applicable to forms, mixed content, multi-page documents, and more.

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.