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}")
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
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)
过度扩张的常见问题有哪些?
过度扩展可能会导致:
相邻字母合并时的字符出血
内部细节丢失("e "或 "8 "中的漏洞)
降低粗体文字的准确性
监控结果并做出相应调整。 对于具有混合文本权重的文档,请有选择地使用我们的图像质量校正过滤器。
前
后
如何应用 Erode 过滤器?
侵蚀可以减小图像中明亮区域的大小,细化粗大或扭曲的字符并改善字符分离效果。
为什么腐蚀对厚文本有帮助?
侵蚀会使文本笔画变细,并分离接触到的字符。 该过滤器擅长
过墨印刷文件
有字符出血的复印件
出现合并的粗体文字
低质量传真传输
仔细的侵蚀可以恢复字符分隔,提高单个字母的识别能力,防止整个单词被误读。
using Erode 方法应用此筛选器。 默认形态为 2x2; 为 3x3 传递 "true":
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)
IronOCR 可让您保存应用了过滤器的修改过的 PDF 文件或其原始状态。 SaveAsSearchablePdf 方法的第二个参数决定是否保存时应用过滤器。
保留过滤器更改的好处是什么?
保留过滤器的更改具有以下几个优势:
创建更简洁、更易读的文档
保持各批次文件的一致性
提供文本质量改进的可视化确认
实现质量控制比较
创建可搜索的 PDF,嵌入 OCR 文本层,同时保持视觉外观。 了解更多信息,请参阅我们的创建可搜索 PDF 指南。
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")
IronOCR 的最小工作流程包括 5 个步骤:下载库、导入 PDF 或图像、应用所需的过滤器(锐化、增强分辨率、去噪、扩张、侵蚀)、导出校正后的图像以供查看,以及使用读取方法进行 OCR 处理。
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.