IRONSOFTWAREHOME
OCR图像优化滤镜
using IronOcr;
using System;

var ocrTesseract = new IronTesseract();
using var ocrInput = new OcrInput();
// First load all image(s)
ocrInput.LoadImage(@"images\image.png");

// Note: You don't need all of them; most users only need Deskew() and occasionally DeNoise()
ocrInput.WithTitle("My Document");
ocrInput.Binarize();
ocrInput.Contrast();
ocrInput.Deskew();
ocrInput.DeNoise();
ocrInput.Despeckle();
ocrInput.Dilate();
ocrInput.EnhanceResolution(300);
ocrInput.Invert();
ocrInput.Rotate(90);
ocrInput.Scale(150);
ocrInput.Sharpen();
ocrInput.ToGrayScale();
ocrInput.Erode();

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

// Optional: Export modified images so you can view them.
foreach (var page in ocrInput.GetPages())
{
    page.SaveAsImage($"filtered_{page.Index}.bmp");
}

var ocrResult = ocrTesseract.Read(ocrInput);
Console.WriteLine(ocrResult.Text);
Imports IronOcr
Imports System

Dim ocrTesseract = New IronTesseract()
Using ocrInput = New OcrInput()
    ' First load all image(s)
    ocrInput.LoadImage("images\image.png")

    ' Note: You don't need all of them; most users only need Deskew() and occasionally DeNoise()
    ocrInput.WithTitle("My Document")
    ocrInput.Binarize()
    ocrInput.Contrast()
    ocrInput.Deskew()
    ocrInput.DeNoise()
    ocrInput.Despeckle()
    ocrInput.Dilate()
    ocrInput.EnhanceResolution(300)
    ocrInput.Invert()
    ocrInput.Rotate(90)
    ocrInput.Scale(150)
    ocrInput.Sharpen()
    ocrInput.ToGrayScale()
    ocrInput.Erode()

    ' WIZARD - If you are unsure use the debug-wizard to test all combinations:
    Dim codeToRun As String = OcrInputFilterWizard.Run("images\image.png", confidence:=Nothing, ocrTesseract)
    Console.WriteLine(codeToRun)

    ' Optional: Export modified images so you can view them.
    For Each page In ocrInput.GetPages()
        page.SaveAsImage($"filtered_{page.Index}.bmp")
    Next

    Dim ocrResult = ocrTesseract.Read(ocrInput)
    Console.WriteLine(ocrResult.Text)
End Using
NuGet Download
PM > Install-Package IronOcr
OCR图像优化滤镜

OCR图像优化滤镜

OcrInput类为C#和.NET开发人员提供精细的控制,以在OCR处理之前对图像输入进行速度和准确性的预处理。 这就否定了使用 Photoshop 批处理脚本或 ImageMagick 来准备用于 OCR 的图像的常见做法。

以下是示例,展示了如何在C#中使用IronOCR的OcrInput类:

使用我们的指南提升 OCR 图像质量
在 GitHub 上查看

准备开始了吗?

Nuget Downloads 6,236,385版本:2026.9刚刚发布

Key in blue circle

立即获取免费的 30 天试用版密钥

Your trial license will be sent to your email address

无任何限制。100% 解锁。无需信用卡。

bullet_checked无需信用卡或创建账户无任何限制。100% 解锁。无需信用卡。
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronPDF
获取您的无义务咨询
填写下面的表格或通过sales@ironsoftware.com
您的资料将始终保密。
深受全球数百万工程师信赖
Iron Software 的客户徽标
立即获取您的免费30 天试用密钥
无需信用卡或创建账户