小编Gia*_*ini的帖子

C# 如何校正图像

我目前正在使用 OCR 程序。我正在使用超正方体,我需要校正图像以提高检测到的字符的质量。问题是 tesseract 提供的偏斜校正属性无法产生足够有吸引力的结果。因此,我尝试使用 AForge 和 Atalasoft 对图像进行歪斜校正,但无论怎样,每次图像都不是他们所需的格式。我究竟做错了什么?或者有更好的解决方案?

这是 AForge 的实现

        System.Drawing.Bitmap imageToBitmap = AForge.Imaging.Image.FromFile(imagePath);
        Console.WriteLine("before  " + imageToBitmap.PixelFormat);
        System.Drawing.Bitmap NewPicture = imageToBitmap.Clone(new System.Drawing.Rectangle(0, 0, imageToBitmap.Width, imageToBitmap.Height), System.Drawing.Imaging.PixelFormat.Format24bppRgb);
        var dop = AForge.Imaging.Image.Clone(imageToBitmap, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
        Console.WriteLine("after  " + dop.PixelFormat);

        AForge.Imaging.DocumentSkewChecker skewChecker = new AForge.Imaging.DocumentSkewChecker();
        // get documents skew angle
        double angle = skewChecker.GetSkewAngle(dop);
        // create rotation filter
        AForge.Imaging.Filters.RotateBilinear rotationFilter = new AForge.Imaging.Filters.RotateBilinear(-angle);
        rotationFilter.FillColor = System.Drawing.Color.White;
        // rotate image applying the filter
        System.Drawing.Bitmap rotatedImage = rotationFilter.Apply(imageToBitmap);

        rotatedImage.Save("deskewedImage");
Run Code Online (Sandbox Code Playgroud)

这是Atalasoft 的实现

        AtalaImage img = …
Run Code Online (Sandbox Code Playgroud)

c# tesseract image-processing aforge

2
推荐指数
1
解决办法
4197
查看次数

标签 统计

aforge ×1

c# ×1

image-processing ×1

tesseract ×1