How to Get C# OCR Read Confidence with IronOCR
IronOCR's read confidence indicates how certain the OCR system is about recognized text accuracy, with values from 0 to 100 where higher scores mean greater reliability - access it via the Confidence property on any OcrResult object.
Read confidence in OCR (Optical Character Recognition) refers to the level of certainty or reliability that the OCR system assigns to the accuracy of the text it has recognized in an image or document. It is a measure of how confident the OCR system is that the recognized text is correct. This metric becomes particularly important when processing scanned documents, photos, or any images where text quality might vary.
A high confidence score indicates a high degree of certainty that the recognition is accurate, while a low confidence score suggests that the recognition may be less reliable. Understanding these confidence levels helps developers implement appropriate validation logic and error handling in their applications.
Quickstart: Get OCR Read Confidence in One LineUse IronTesseract's Read method with an image file path, then access the Confidence property on the returned OcrResult to see how certain IronOCR is about its text recognition. It's a simple, reliable way to start evaluating OCR output accuracy.
-
1Install IronOCR with NuGet Package Manager
-
2Copy and run this code snippet.
double confidence = new IronOcr.IronTesseract().Read("input.png").Confidence;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 access read confidence
- Prepare the targeted image and PDF document
- Access the
Confidenceproperty of the OCR result - Retrieve the confidence of pages, paragraphs, lines, words, and characters
- Check the
Choicesproperty for alternative word choices
How Do I Get Read Confidence in C#?
After performing OCR on the input image, the confidence level of the text is stored in the Confidence property. Utilize the 'using' statement to automatically dispose of objects after use. Add documents such as images and PDFs with the OcrImageInput and OcrPdfInput classes, respectively. The Read method will return an OcrResult object that allows access to the Confidence property.
using IronOcr;
// Instantiate IronTesseract
IronTesseract ocrTesseract = new IronTesseract();
// Add image
using var imageInput = new OcrImageInput("sample.tiff");
// Perform OCR
OcrResult ocrResult = ocrTesseract.Read(imageInput);
// Get confidence level
double confidence = ocrResult.Confidence;Imports IronOcr
' Instantiate IronTesseract
Private ocrTesseract As New IronTesseract()
' Add image
Private imageInput = New OcrImageInput("sample.tiff")
' Perform OCR
Private ocrResult As OcrResult = ocrTesseract.Read(imageInput)
' Get confidence level
Private confidence As Double = ocrResult.ConfidenceThe confidence value returned ranges from 0 to 100, where:
- 90-100: Excellent confidence - Text is highly reliable
- 80-89: Good confidence - Text is generally accurate with minor uncertainties
- 70-79: Moderate confidence - Text may contain some errors
- Below 70: Low confidence - Text should be reviewed or reprocessed
How Can I Get Confidence at Different Levels?
Not only can you retrieve the confidence level of the entire document, but you can also access the confidence levels of each page, paragraph, line, word, and character. Furthermore, you can obtain the confidence of a block, which represents a collection of one or more paragraphs located closely together.
// Get page confidence level
double pageConfidence = ocrResult.Pages[0].Confidence;
// Get paragraph confidence level
double paragraphConfidence = ocrResult.Paragraphs[0].Confidence;
// Get line confidence level
double lineConfidence = ocrResult.Lines[0].Confidence;
// Get word confidence level
double wordConfidence = ocrResult.Words[0].Confidence;
// Get character confidence level
double characterConfidence = ocrResult.Characters[0].Confidence;
// Get block confidence level
double blockConfidence = ocrResult.Blocks[0].Confidence;' Get page confidence level
Dim pageConfidence As Double = ocrResult.Pages(0).Confidence
' Get paragraph confidence level
Dim paragraphConfidence As Double = ocrResult.Paragraphs(0).Confidence
' Get line confidence level
Dim lineConfidence As Double = ocrResult.Lines(0).Confidence
' Get word confidence level
Dim wordConfidence As Double = ocrResult.Words(0).Confidence
' Get character confidence level
Dim characterConfidence As Double = ocrResult.Characters(0).Confidence
' Get block confidence level
Dim blockConfidence As Double = ocrResult.Blocks(0).ConfidencePractical Example: Filtering by Confidence
When processing documents with varying quality, such as low-quality scans, you can use confidence scores to filter results:
using IronOcr;
using System.Linq;
// Instantiate IronTesseract
IronTesseract ocrTesseract = new IronTesseract();
// Configure for better accuracy
ocrTesseract.Configuration.ReadBarCodes = false;
ocrTesseract.Configuration.PageSegmentationMode = TesseractPageSegmentationMode.AutoOsd;
// Add image
using var imageInput = new OcrImageInput("invoice.png");
// Apply filters to improve quality
imageInput.Deskew();
imageInput.DeNoise();
// Perform OCR
OcrResult ocrResult = ocrTesseract.Read(imageInput);
// Filter words with confidence above 85%
var highConfidenceWords = ocrResult.Words
.Where(word => word.Confidence >= 85)
.Select(word => word.Text)
.ToList();
// Process only high-confidence text
string reliableText = string.Join(" ", highConfidenceWords);
Console.WriteLine($"High confidence text: {reliableText}");
// Flag low-confidence words for manual review
var lowConfidenceWords = ocrResult.Words
.Where(word => word.Confidence < 85)
.Select(word => new { word.Text, word.Confidence })
.ToList();
foreach (var word in lowConfidenceWords)
{
Console.WriteLine($"Review needed: '{word.Text}' (Confidence: {word.Confidence:F2}%)");
}Imports IronOcr
Imports System.Linq
' Instantiate IronTesseract
Dim ocrTesseract As New IronTesseract()
' Configure for better accuracy
ocrTesseract.Configuration.ReadBarCodes = False
ocrTesseract.Configuration.PageSegmentationMode = TesseractPageSegmentationMode.AutoOsd
' Add image
Using imageInput As New OcrImageInput("invoice.png")
' Apply filters to improve quality
imageInput.Deskew()
imageInput.DeNoise()
' Perform OCR
Dim ocrResult As OcrResult = ocrTesseract.Read(imageInput)
' Filter words with confidence above 85%
Dim highConfidenceWords = ocrResult.Words _
.Where(Function(word) word.Confidence >= 85) _
.Select(Function(word) word.Text) _
.ToList()
' Process only high-confidence text
Dim reliableText As String = String.Join(" ", highConfidenceWords)
Console.WriteLine($"High confidence text: {reliableText}")
' Flag low-confidence words for manual review
Dim lowConfidenceWords = ocrResult.Words _
.Where(Function(word) word.Confidence < 85) _
.Select(Function(word) New With {Key .Text = word.Text, Key .Confidence = word.Confidence}) _
.ToList()
For Each word In lowConfidenceWords
Console.WriteLine($"Review needed: '{word.Text}' (Confidence: {word.Confidence:F2}%)")
Next
End UsingWhat Are Character Choices in OCR?
Apart from the confidence level, there is another interesting property called Choices. Choices contain a list of alternative word choices and their statistical relevance. This information allows the user to access other possible characters. This feature is particularly useful when working with multiple languages or specialized fonts.
using IronOcr;
using static IronOcr.OcrResult;
// Instantiate IronTesseract
IronTesseract ocrTesseract = new IronTesseract();
// Add image
using var imageInput = new OcrImageInput("Potter.tiff");
// Perform OCR
OcrResult ocrResult = ocrTesseract.Read(imageInput);
// Get choices
Choice[] choices = ocrResult.Characters[0].Choices;Imports IronOcr
Imports IronOcr.OcrResult
' Instantiate IronTesseract
Private ocrTesseract As New IronTesseract()
' Add image
Private imageInput = New OcrImageInput("Potter.tiff")
' Perform OCR
Private ocrResult As OcrResult = ocrTesseract.Read(imageInput)
' Get choices
Private choices() As Choice = ocrResult.Characters(0).ChoicesHow Do Alternative Character Choices Help?
Alternative character choices provide several benefits:
- Ambiguity Resolution: When characters like 'O' and '0', or 'l' and '1' are confused
- Font Variations: Different interpretations for stylized or decorative fonts
- Quality Issues: Multiple possibilities when dealing with degraded text
- Language Context: Alternative interpretations based on language rules

Working with Character Choices
Here's a comprehensive example demonstrating how to use character choices for improved accuracy:
using IronOcr;
using System;
using System.Linq;
using static IronOcr.OcrResult;
// Configure IronTesseract for detailed results
IronTesseract ocrTesseract = new IronTesseract();
// Process image with potential ambiguities
using var imageInput = new OcrImageInput("ambiguous_text.png");
OcrResult ocrResult = ocrTesseract.Read(imageInput);
// Analyze character choices for each word
foreach (var word in ocrResult.Words)
{
Console.WriteLine($"\nWord: '{word.Text}' (Confidence: {word.Confidence:F2}%)");
// Check each character in the word
foreach (var character in word.Characters)
{
if (character.Choices != null && character.Choices.Length > 1)
{
Console.WriteLine($" Character '{character.Text}' has alternatives:");
// Display all choices sorted by confidence
foreach (var choice in character.Choices.OrderByDescending(c => c.Confidence))
{
Console.WriteLine($" - '{choice.Text}': {choice.Confidence:F2}%");
}
}
}
}Imports IronOcr
Imports System
Imports System.Linq
Imports IronOcr.OcrResult
' Configure IronTesseract for detailed results
Dim ocrTesseract As New IronTesseract()
' Process image with potential ambiguities
Using imageInput As New OcrImageInput("ambiguous_text.png")
Dim ocrResult As OcrResult = ocrTesseract.Read(imageInput)
' Analyze character choices for each word
For Each word In ocrResult.Words
Console.WriteLine(vbCrLf & $"Word: '{word.Text}' (Confidence: {word.Confidence:F2}%)")
' Check each character in the word
For Each character In word.Characters
If character.Choices IsNot Nothing AndAlso character.Choices.Length > 1 Then
Console.WriteLine($" Character '{character.Text}' has alternatives:")
' Display all choices sorted by confidence
For Each choice In character.Choices.OrderByDescending(Function(c) c.Confidence)
Console.WriteLine($" - '{choice.Text}': {choice.Confidence:F2}%")
Next
End If
Next
Next
End UsingAdvanced Confidence Strategies
When working with specialized documents like passports, license plates, or MICR cheques, confidence scores become crucial for validation:
using IronOcr;
public class DocumentValidator
{
private readonly IronTesseract ocr = new IronTesseract();
public bool ValidatePassportNumber(string imagePath, double minConfidence = 95.0)
{
using var input = new OcrImageInput(imagePath);
// Configure for passport reading
ocr.Configuration.ReadBarCodes = true;
ocr.Configuration.PageSegmentationMode = TesseractPageSegmentationMode.SingleLine;
// Apply preprocessing
input.Deskew();
input.Scale(200); // Upscale for better accuracy
var result = ocr.Read(input);
// Find passport number pattern
var passportLine = result.Lines
.Where(line => line.Text.Contains("P<") || IsPassportNumberFormat(line.Text))
.FirstOrDefault();
if (passportLine != null)
{
Console.WriteLine($"Passport line found: {passportLine.Text}");
Console.WriteLine($"Confidence: {passportLine.Confidence:F2}%");
// Only accept if confidence meets threshold
return passportLine.Confidence >= minConfidence;
}
return false;
}
private bool IsPassportNumberFormat(string text)
{
// Simple passport number validation
return System.Text.RegularExpressions.Regex.IsMatch(text, @"^[A-Z]\d{7,9}$");
}
}Imports IronOcr
Public Class DocumentValidator
Private ReadOnly ocr As New IronTesseract()
Public Function ValidatePassportNumber(imagePath As String, Optional minConfidence As Double = 95.0) As Boolean
Using input As New OcrImageInput(imagePath)
' Configure for passport reading
ocr.Configuration.ReadBarCodes = True
ocr.Configuration.PageSegmentationMode = TesseractPageSegmentationMode.SingleLine
' Apply preprocessing
input.Deskew()
input.Scale(200) ' Upscale for better accuracy
Dim result = ocr.Read(input)
' Find passport number pattern
Dim passportLine = result.Lines _
.Where(Function(line) line.Text.Contains("P<") OrElse IsPassportNumberFormat(line.Text)) _
.FirstOrDefault()
If passportLine IsNot Nothing Then
Console.WriteLine($"Passport line found: {passportLine.Text}")
Console.WriteLine($"Confidence: {passportLine.Confidence:F2}%")
' Only accept if confidence meets threshold
Return passportLine.Confidence >= minConfidence
End If
Return False
End Using
End Function
Private Function IsPassportNumberFormat(text As String) As Boolean
' Simple passport number validation
Return System.Text.RegularExpressions.Regex.IsMatch(text, "^[A-Z]\d{7,9}$")
End Function
End ClassOptimizing for Better Confidence
To achieve higher confidence scores, consider using image filters and preprocessing techniques:
using IronOcr;
// Create an optimized OCR workflow
IronTesseract ocr = new IronTesseract();
using var input = new OcrImageInput("low_quality_scan.jpg");
// Apply multiple filters to improve confidence
input.Deskew(); // Correct rotation
input.DeNoise(); // Remove noise
input.Sharpen(); // Enhance edges
input.Dilate(); // Thicken text
input.Scale(150); // Upscale for clarity
// Configure for accuracy over speed
ocr.Configuration.TesseractVersion = TesseractVersion.Tesseract5;
ocr.Configuration.EngineMode = TesseractEngineMode.TesseractOnly;
var result = ocr.Read(input);
Console.WriteLine($"Document confidence: {result.Confidence:F2}%");
// Generate confidence report
var confidenceReport = result.Pages
.Select((page, index) => new
{
PageNumber = index + 1,
Confidence = page.Confidence,
WordCount = page.Words.Length,
LowConfidenceWords = page.Words.Count(w => w.Confidence < 80)
});
foreach (var page in confidenceReport)
{
Console.WriteLine($"Page {page.PageNumber}: {page.Confidence:F2}% confidence");
Console.WriteLine($" Total words: {page.WordCount}");
Console.WriteLine($" Low confidence words: {page.LowConfidenceWords}");
}Imports IronOcr
' Create an optimized OCR workflow
Dim ocr As New IronTesseract()
Using input As New OcrImageInput("low_quality_scan.jpg")
' Apply multiple filters to improve confidence
input.Deskew() ' Correct rotation
input.DeNoise() ' Remove noise
input.Sharpen() ' Enhance edges
input.Dilate() ' Thicken text
input.Scale(150) ' Upscale for clarity
' Configure for accuracy over speed
ocr.Configuration.TesseractVersion = TesseractVersion.Tesseract5
ocr.Configuration.EngineMode = TesseractEngineMode.TesseractOnly
Dim result = ocr.Read(input)
Console.WriteLine($"Document confidence: {result.Confidence:F2}%")
' Generate confidence report
Dim confidenceReport = result.Pages _
.Select(Function(page, index) New With {
.PageNumber = index + 1,
.Confidence = page.Confidence,
.WordCount = page.Words.Length,
.LowConfidenceWords = page.Words.Count(Function(w) w.Confidence < 80)
})
For Each page In confidenceReport
Console.WriteLine($"Page {page.PageNumber}: {page.Confidence:F2}% confidence")
Console.WriteLine($" Total words: {page.WordCount}")
Console.WriteLine($" Low confidence words: {page.LowConfidenceWords}")
Next
End UsingSummary
Understanding and utilizing OCR confidence scores is essential for building robust document processing applications. By leveraging IronOCR's confidence properties and character choices, developers can implement intelligent validation, error handling, and quality assurance mechanisms in their OCR workflows. Whether you're processing screenshots, tables, or specialized documents, confidence scores provide the metrics needed to ensure accurate text extraction.
Frequently Asked Questions
What is OCR Read Confidence in IronOCR?
OCR Read Confidence in IronOCR indicates the certainty level of the text recognition process. It utilizes a confidence score ranging from 0 to 100, where a higher score signifies greater accuracy of recognized text.
How can I access the Confidence score in IronOCR?
You can access the Confidence score in IronOCR by utilizing the `Confidence` property of the `OcrResult` object returned by the `IronTesseract.Read` method.
Why is the Confidence score important in OCR?
The Confidence score is crucial as it helps evaluate the reliability of the recognized text. Understanding these scores allows developers to implement appropriate validation and error handling for improved accuracy in OCR applications.
What does a high OCR Confidence score signify?
A high OCR Confidence score signifies a high degree of certainty in text recognition accuracy, indicating that the extracted text is likely correct and reliable.
Can IronOCR provide Confidence scores for different levels of text?
Yes, IronOCR can provide Confidence scores for multiple levels including entire documents, pages, paragraphs, lines, words, and characters, allowing for detailed accuracy assessment.
How can I improve OCR Confidence scores with IronOCR?
To improve OCR Confidence scores with IronOCR, you can apply preprocessing techniques like deskewing, denoising, and upscaling images before running the OCR process. Additionally, configuring IronTesseract for optimal settings can enhance accuracy.
What are character choices in IronOCR?
Character choices in IronOCR refer to alternative word choices and their relevance metrics provided during OCR. This feature is useful for handling ambiguities and understanding potential character variations in the text.
How can character choices aid in text recognition?
Character choices help resolve ambiguities by offering alternative interpretations for similar-looking characters and words. This is particularly beneficial when dealing with font variations, degraded text, and multiple languages.
What preprocessing techniques improve IronOCR text accuracy?
Preprocessing techniques such as deskewing, denoising, sharpening, and scaling can significantly enhance text accuracy by improving image quality before executing OCR processes with IronOCR.
How does IronOCR handle low confidence recognition results?
IronOCR allows you to filter and flag low-confidence recognition results for review. You can identify words with confidence scores below a certain threshold and address uncertainties by using validation or reprocessing strategies.

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.