扫描图像纠偏
我正在 OMR 项目工作,我们使用 C#。当我们扫描答题纸时,图像是倾斜的。我们如何去校正它们?
I am working in OMR project and we are using C#. When we come to scan the answer sheets, the images are skewed. How can we deskew them?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
VB.Net 代码可在 此处 获取,但是由于您在此处要求使用 C#是他们的 Deskew 类的 C# 翻译(注意:二值化(严格来说不是必需的,但效果更好)和旋转是留给用户的练习)。
VB.Net Code for this is available here, however since you asked for C# here is a C# translation of their Deskew class (note: Binarize (strictly not necessary, but works much better) and Rotate are exercises left to the user).
扫描的文档总是倾斜平均 [-10;+10] 度的角度。
正如 Lou Franco 所说,使用霍夫变换很容易消除它们的偏斜。此变换可检测图像上多个角度的线条。您只需选择与文档水平线相对应的像素,然后旋转它。
尝试隔离与文档水平线相对应的像素(例如,底部有白色像素的黑色像素) .
运行霍夫变换。不要忘记在 C# 中使用“不安全”模式,通过使用指针来加快整个图像的处理。
就像二进制文档上的魅力一样(可以轻松扩展到灰度级)
Scanned document are always skewed for an average [-10;+10] degrees angle.
It's easy to deskew them using the Hough transform, like Lou Franco said. This transform detects lines on your image for several angles. You just have to select the corresponding one to your document horizontal lines, then rotate it.
try to isolate the pixel corresponding to your document horizontal lines (for instance, black pixels that have a white pixel at their bottom).
Run Hough transform. Do not forget to use 'unsafe' mode in C# to fasten the process of your whole image by using a pointor.
Works like a charm on binary documents (easily extendable to grey level ones)
免责声明:我在 Atalasoft 工作,DotImage Document Imaging 只需几行代码即可完成此操作。
相差校正是一个专业术语,用于描述您正在尝试执行的操作。正如 Ben Voigt 所说,从技术上讲,这是旋转,而不是倾斜——但是,如果您进行搜索,您会发现自动倾斜校正下的算法。
执行此操作的正常方法是执行 hough 变换以查找常见行图像。对于普通文档,其中许多将与纸张的侧面正交。
Disclaimer: I work at Atalasoft, DotImage Document Imaging can do this with a couple of lines of code.
Deskew is a term of art that describes what you are trying to do. As Ben Voigt said, it's technically rotation, not skew -- however, you will find algorithms under automatic deskew if you search.
The normal way to do this is to do a hough transform to look for the prevalent lines in the image. With normal documents, many of them will be orthogonal to the sides of the paper.
您确定它是“倾斜”而不是“旋转”(旋转保留角度,倾斜则不保留)。
Are you sure it's "skew" rather than "rotation" (rotation preserves angles, skew doesn't).