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方法應用此濾鏡。 預設形態為2x2; 傳遞'true'可使用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)
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")
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.