预处理

改进来自低质量扫描和照片的输入。使用我们的预处理滤波器清理、拉直和增强困难图像,以获得最佳OCR准确性。

输入色彩校正过滤器

1

二值化

直接在 IronOCR 中轻松对输入内容进行二值化处理,将图像转化为清晰的黑白版本。该过滤器能有效地将文本从复杂的背景中分离出来,减少噪点,使文本提取更容易、更可靠。

了解如何:在 .NET C# 中修复图像颜色以便阅读

灰度

更改像素颜色

using IronOcr;

// Instantiate IronTesseract
IronTesseract ocrTesseract = new IronTesseract();

// Add image
using var imageInput = new OcrImageInput("sample.jpg");
IronSoftware.Drawing.Color currentColor = new IronSoftware.Drawing.Color("#DB645C");
IronSoftware.Drawing.Color newColor = IronSoftware.Drawing.Color.DarkCyan;

// Replace color
imageInput.ReplaceColor(currentColor, newColor, 80);

// Export the modified image
imageInput.SaveAsImages("replaceColor");

输入形态操作

膨胀

更改像素颜色

using IronOcr;

// Instantiate IronTesseract
IronTesseract ocrTesseract = new IronTesseract();

// Add image
using var imageInput = new OcrImageInput("sample.jpg");
IronSoftware.Drawing.Color currentColor = new IronSoftware.Drawing.Color("#DB645C");
IronSoftware.Drawing.Color newColor = IronSoftware.Drawing.Color.DarkCyan;

// Replace color
imageInput.ReplaceColor(currentColor, newColor, 80);

// Export the modified image
imageInput.SaveAsImages("replaceColor");

输入方向操作

轮换

检测方向

using IronOcr;

using var input = new OcrInput();

// Load PDF document
input.LoadPdf("Clockwise90.pdf");

// Detect page rotation
var results = input.DetectPageOrientation();

// Ouput result
foreach(var result in results)
{
    Console.WriteLine(result.PageNumber);
    Console.WriteLine(result.HighConfidence);
    Console.WriteLine(result.RotationAngle);
}

输入分辨率控制

规模

增强分辨率

过滤器向导

using IronOcr;

var ocrTesseract = new IronTesseract();

// WIZARD - If you are unsure which filters to use,
// use the debug-wizard to test all combinations:
string codeToRun = OcrInputFilterWizard.Run(@"images\image.png", out double confidence, ocrTesseract);
Console.WriteLine($"Confidence: {confidence}");
Console.WriteLine(codeToRun);

OCR 图像的一个区域

using IronOcr;
using IronSoftware.Drawing;

var ocrTesseract = new IronTesseract();
using var ocrInput = new OcrInput();
var ContentArea = new Rectangle(x: 215, y: 1250, width: 1335, height: 280);
ocrInput.LoadImage("img/example.png", ContentArea);
var ocrResult = ocrTesseract.Read(ocrInput);
Console.WriteLine(ocrResult.Text);

准备开始了吗?

Nuget Downloads 6,357,159版本:2026.11刚刚发布