跳至頁尾內容

預處理

改善低品質掃描件和照片的輸入品質。使用我們的預處理濾鏡來清理、矯正和增強難以識別的影像,從而最大限度地提高 OCR 識別準確率。

Icon Main related to 預處理
輸入顏色校正濾鏡

1

二值化

在 IronOCR 中即可輕鬆將輸入影像二值化,將其轉換為清晰的黑白版本。此濾鏡可有效將文字從複雜的背景中分離出來,降低雜訊,使文字擷取更加輕鬆可靠。

學習如何:在 .NET C# 中修復圖像顏色以進行閱讀
using IronOcr;

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

// Add image
using var imageInput = new OcrImageInput("sample.jpg");

// Apply binarize affect
imageInput.Binarize();

// Export the modified image
imageInput.SaveAsImages("binarize.jpg");
C#
2

灰階

將彩色影像轉換為灰階影像—這是為更高級的預處理濾鏡準備影像的關鍵步驟。

學習如何:在 .NET C# 中修復圖像顏色以進行閱讀
using IronOcr;

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

// Add image
using var imageInput = new OcrImageInput("sample.jpg");

// Apply grayscale affect
imageInput.ToGrayScale();

// Export the modified image
imageInput.SaveAsImages("grayscale.jpg");
C#
3

變更像素顏色

取代影像中的特定色彩範圍,讓您在 OCR 之前移除浮水印、彩色背景或其他幹擾元素。

學習如何:在 .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");
C#

Icon Main related to 預處理
輸入形態操作

1

擴張

加粗圖像中的字符,有助於連接文字中的斷行,並提高對模糊或細字體的辨識度。

學習如何:使用濾鏡校正影像以進行閱讀
using IronOcr;

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

// Add image
using var imageInput = new OcrImageInput("sample.jpg");

// Apply Dilate filter
imageInput.Dilate();

// Export filtered image
imageInput.SaveAsImages("dilate.jpg");
C#
2

侵蝕

將影像中的字元拉細,可用於分離相互接觸或重疊的字元。

學習如何:使用濾鏡校正影像以進行閱讀
using IronOcr;

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

// Add image
using var imageInput = new OcrImageInput("sample.jpg");

// Apply Erode filter
imageInput.Erode();

// Export filtered image
imageInput.SaveAsImages("erode.jpg");
C#
3

變更像素顏色

取代影像中的特定色彩範圍,讓您在 OCR 之前移除浮水印、彩色背景或其他幹擾元素。

學習如何:在 .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");
C#

Icon Main related to 預處理
輸入方向操控

1

桌子

自動偵測並矯正傾斜或歪斜的影像,顯著提高不完美掃描影像的 OCR 準確率。

學習如何在 .NET C# 中修復圖像方向以進行閱讀
using IronOcr;

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

// Add image
using var imageInput = new OcrImageInput("paragraph_skewed.png");

// Apply Deskew filter
imageInput.Deskew();
C#
2

旋轉

透過程式設計方式將影像旋轉任意角度,以確保文字方向正確,以便 OCR 引擎識別。

學習如何在 .NET C# 中修復圖像方向以進行閱讀
using IronOcr;

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

// Add image
using var imageInput = new OcrImageInput("paragraph_skewed.png");

// Rotate the image 180 degrees clockwise
imageInput.Rotate(180);

// Export the modified image
imageInput.SaveAsImages("rotate");
C#
3

檢測方向

自動偵測頁面方向(0°、90°、180°、270°),方便在OCR辨識前進行方向校正。即使文件上下顛倒掃描,也能確保高精度辨識。

學習如何:檢測頁面旋轉
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);
}
C#

Icon Main related to 預處理
輸入解析度控制

1

規模

將影像調整為 OCR 的最佳分辨率,從而顯著提高低解析度來源檔案的辨識準確率。

學習如何在 .NET C# 中修復圖像方向以進行閱讀
using IronOcr;

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

// Add image
using var imageInput = new OcrImageInput("paragraph_skewed.png");

// Apply scale
imageInput.Scale(70);

// Export the modified image
imageInput.SaveAsImages("rotate");
C#
2

DPI設定

對於低解析度影像或缺少元資料的掃描件,請手動設定每英吋點數 (DPI)。提供 DPI 值可以指導 OCR 引擎,並顯著提高識別品質。

學習如何使用C# Tesseract 實作影像 DPI
using IronOcr;
using System;

var ocrTesseract = new IronTesseract();
using var ocrInput = new OcrInput();
ocrInput.TargetDPI = 300;
ocrInput.LoadImage(@"images\image.png");
var ocrResult = ocrTesseract.Read(ocrInput);
Console.WriteLine(ocrResult.Text);
C#
3

增強解析度

透過演算法提高低解析度影像的清晰度和銳利度,以挽救模糊或像素化的輸入文字。

學習如何:使用濾鏡校正影像以進行閱讀
using IronOcr;

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

// Add image
using var imageInput = new OcrImageInput("sample.jpg");

// Apply enhance resolution filter
imageInput.EnhanceResolution();

// Export filtered image
imageInput.SaveAsImages("sharpen.jpg");
C#
4

篩選嚮導

使用單一智慧方法應用一系列精心設計的預處理濾波器。濾波器精靈會自動分析輸入影像,並套用最佳校正序列,以獲得最佳的 OCR 效果。

了解如何使用:篩選精靈
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);
C#
5

OCR辨識影像區域

透過僅針對影像中包含文字的特定區域進行處理,節省處理時間。只需定義一個矩形區域,即可從表單、表格或雜亂的背景中隔離並提取文字。

學習如何使用Tesseract OCR 在 C# 中辨識影像的特定區域
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);
C#
準備好開始了嗎?
Nuget 下載 5,299,091 | 版本: 2025.12 剛剛發布