brief introduction
Correction algorithm
For the overall tilt correction, the average pixel height on the left and right sides of the image can be counted, and the correction can be performed by calculating the overall tilt.
That is to find out how many angles need to be adjusted to minimize the gradient of the image. It can be seen that the gradient determines the quality of the final image. The characteristics of the numbers considered are all narrow and long. We can consider the aspect ratio of the image as the basis for the gradient of the image.
1. Set the maximum adjustment angle. Generally, the inclination will not exceed 45 degrees. If it exceeds the adjustment, it will be meaningless. 2. Calculate the aspect ratio of the image, that is, the gradient. If the gradient is less than the last one, adjust the angle by half and continue searching. If the gradient tends to be stable, exit the search and use the current adjustment angle to adjust. 3. For the actual adjustment process, the rotation transformation operation is generally selected, which is relatively simple. However, considering that the tilt of actual people when writing numbers is not caused by rotation, but may be caused by incorrect posture, so it can not achieve good results only through rotation, so it can be achieved through horizontal lateral correction, That is, keep the height of the pixel unchanged, and make appropriate adjustments only by adjusting the horizontal position.
experimental result
summary
Because the lateral stretching will lead to the deformation of the image, the processing effect of the relatively slender image is poor, and the connectivity may be damaged by faults.