有没有人在 C# 中看到过任何图像校正算法?我已经发现: http://www.codeproject.com/KB/graphics/Deskew_an_Image.aspx
但不幸的是,它对没有文本的图像作用不大。我专门尝试对具有纯边但文字最少的书籍图像进行自动校正。
有没有人见过可以做到这一点的东西?
最佳答案
基本算法是使用霍夫变换找到线条,然后尝试使大部分线条水平。这是一些基本代码 http://www.sydlogan.com/deskew.html
对于您的情况,您可能希望将变换定位在您知道可能具有最佳信息的图像片段上。例如,如果有页面边框 - 我需要查看示例以提供更好的建议。
免责声明,我在 Atalasoft 工作。
我们的 DotImage toolkit 为 .NET 内置了它,并且对于桌面应用程序来说运行时是免版税的。代码将是:
AtalaImage img = new AtalaImage("imagefile.tif");
AutoDeskewCommand cmd = new AutoDeskewCommand();
AtalaImage resultImage = cmd.Apply(img).Image;
resultImage.Save("result.tif", new TiffEncoder(), null);
或类似的多页或其他类型的图像。
我们在此视频中展示了如何将它与我们的查看器控件集成(在 1:14)
http://www.atalasoft.com/products/dotimage/tutorials/capture/lesson4.aspx
这些视频是构建文档扫描应用程序系列的一部分:
http://www.atalasoft.com/products/dotimage/tutorials/capture/lesson1.aspx http://www.atalasoft.com/products/dotimage/tutorials/capture/lesson2.aspx http://www.atalasoft.com/products/dotimage/tutorials/capture/lesson3.aspx
关于C# 图像去歪斜,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2562260/