Tilt correction of handwritten digit recognition system

Introduction

There are two main types of tilt correction, one is overall tilt correction, and the other is partial tilt correction.

Since this article mainly studies the multi-digit recognition with irregular distribution, it only needs to pay attention to the problem of digital correction after extraction, that is, the local correction of the image.

Correction algorithm

There are many current correction algorithms, for example:

对于整体倾斜校正可以采用统计图像左右两边的平均像素高度,通过计算整体倾斜度来进行校正。

This method has obvious processing effects for images with more pixels, and is simple and fast to implement, but it is not suitable for those single digital images that have been extracted, because the images at this time are generally small and the strokes are thinner. The result of statistics is not correct if there is too little information.

In fact, the core of the correction is to make the tilt of the image close to 0, so it can be regarded as an optimization problem:

即寻找需要调整多少角度,才能使图像的倾斜度最小,可见倾斜度决定了最终图像的好坏,考虑的数字的特征,都是具有狭长的特点,我们可以考虑将图像的高宽比最为图像倾斜度的依据。

And how much adjustment is appropriate? The method used in this article does not estimate the tilt of the image, but uses 二分搜索the idea to perform a binary search within the range of tilt 45 degrees to find the best adjustment point to make the result approximate Optimal, the specific steps are as follows:

1. 设置最大调整角度,一般倾斜度不会超过45度,如果超过调整也就没有意义了。
2. 计算图像高宽比,也就是倾斜度,如果倾斜度比上次的有所减小,则调整角度减半,继续搜索,如果倾斜度趋于稳定,则退出查找,并使用此时的调整角度进行调整。
3. 对于实际的调整过程,一般会选择进行旋转变换操作,比较简单,但是考虑到实际人们书写数字时的倾斜往往并不是旋转造成的,而是可能姿势不正而引起的侧斜,因此仅仅通过旋转并不能达到较好的效果,因此可以通过水平侧向校正来实现,即保持像素点的高度不变,仅仅通过调整水平位置,进行适当的调整。

Experimental result

correct_slope

to sum up

It can be seen that the correction results for most digital images are still quite satisfactory, but there are still some shortcomings:

由于侧向拉伸会导致图像的变形,因此对于较为细长的图像的处理效果较差,可能会出现断层这些破坏连通性的情况。

In order to solve this kind of problem, proper dilation operation can be performed before the correction, so the effect will be better.


Personal homepage: TBOOX open source project
Original source: http://tboox.org/cn/2016/08/01/hnr-correct-slope/

Guess you like

Origin blog.csdn.net/waruqi/article/details/53201643