扫描后c#图像修复 [英] c# image fixing after scanning

查看:87
本文介绍了扫描后c#图像修复的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如您所知,扫描后的图像会在一定程度上旋转。

我们如何找到扫描图像相对于原始图像的旋转角度以及我们如何将扫描图像旋转到相同的位置原始的一个在GDI C#?

As you know images after scanning get rotated to some extent.
how we can find the angle of rotation of scanned image with respect to original image and how we can rotate scanned image to become same as original one in GDI C#?

推荐答案

检测图像上文本的边界框。根据扫描质量,您可能需要调整背景和文本构成的参数。一旦你有了边界框你有四个坐标(顶部,左边)(顶部,右边)(底部,左边)(底部,右边)。

让我们首先考虑简单的部分:在某些TBD epsilon中,左上角和左下角值相同。因此,盒子已经处于直立状态,尽管它仍然可能需要分别翻转180°或+ 90°-90°(== + 270°)。

其余的是基本数学:使用顶部和底部之间的差异(例如从左侧)确定盒子的倾斜度,并使用三角函数确定旋转图像的角度。



这是一个简短的示意图,可以让您按正确的方向设置:使用边界框确定旋转角度。



此公式仅在实际涉及旋转时才有效,即|对| > 0.

旋转180°以及90°的时钟/逆向旋转也可能是必要的。您可以针对每个对齐测试OCR过程。如果您知道纸张已经处于正确的直立位置并且仅需要一些小于| 90°|的微小调整,那么该部分当然可以跳过。



问候,

- Manfred
Detect the bounding box of what text that is on the image. Depending on the quality of your scan you may have to tweak the parameters of what is considered background and what constitutes text. Once you have the bounding box you have the four coordinates (top,left) (top,right) (bottom, left) (bottom, right).
Let''s consider the easy part first: The top and bottom left values are identical within some TBD epsilon. Ergo the box is already in an upright position, albeit it still might have to be flipped 180° or +90° respectively -90° ( == +270°).
The rest is basic maths: determine the inclination of the box using the difference between top and bottom (from the left side for instance) and use trigonometric functions to figure out what angle to rotate the Image.

Here is a short schematic sketch that should set you in the right direction: Determine angle of rotation by using the bounding box.

This formula only works if there is in fact a rotation involved i.e. |opposite| > 0.
The rotation by 180° as well as clock/counterclokwise rotation of 90° may also be nescessary. You can test the OCR process for every alignment. That part can be skipped of course if you know that the paper was already in the correct upright position and only needs some minor adjustments less than |90°|.

Regards,
— Manfred


这篇关于扫描后c#图像修复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆