跳過到頁腳內容

預處理

改進低質量掃描和照片的輸入。使用我們的預處理濾波器來清理、校正並增強困難圖像,以取得最大 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

Deskew

自動偵測並拉直歪斜或傾斜的影像,大幅提升不完美掃描的 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 Image 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 影像的一個區域

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

學習如何:在 C# 中使用 Tesseract OCR 圖像的特定區域 Tesseract 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);
C#
準備好開始了嗎?
Nuget 下載 5,167,857 | Version: 2025.11 剛發表