Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find rotation angle of image?

I'm feeding in a Bitmap image to my C# program to be able to perform OCR to identify the characters in the image. I can do this fairly well if the image is not rotated. One of the program requirements, however, is that the program automatically determines if the image has been rotated, and that it automatically corrects these rotations.

I've tried implementing a simple method where lines are traced across the image and points which contact a character are recorded, and then performing a simple linear regression on the line points. This works to an extent, although it has not proven very accurate due to curvature of characters, etc.

I was wondering if there was a better method to solve this problem? Many thanks in advance! :)

like image 786
Mac Sigler Avatar asked Nov 14 '12 21:11

Mac Sigler


People also ask

How do you calculate rotation angle?

The angle of rotation between the two points or vertices is the number of central angles times the measure of a single central angle: angle of rotation =m×α = m × α .

How do you rotate an image at an angle?

Manually rotate a picture or shape Select the picture or shape. Manually rotate the text box by selecting the shape or picture rotation handle and dragging in the direction you want. To keep the rotation to 15 degree angles, press and hold Shift while you drag the rotation handle.


3 Answers

I use gmseDeskew algorithm to deskew an image in my program. It works very well.

like image 122
nguyenq Avatar answered Oct 29 '22 15:10

nguyenq


It's an interesting problem to be sure. I'd look for certain letters that are easier to tell rotation for. For example, a capital A or R or K should have both of the lower parts are roughly the same horizontal plane. Another option is to take letters that cannot be identified and rotate them in various ways and re-attempt to identify them. If a letter than could not be identified in the raw scan CAN be identified when you rotate it, that's a pretty big clue. Once you have identified the "correction" rotation that makes a non-recognizable character into a recognizable one, apply the same rotation value to the others.

like image 45
Heather Avatar answered Oct 29 '22 15:10

Heather


If it recognizes lines of text, then try to blur the image so that lines are mostly solid and find direction of the lines (either with analysis of Fourier transform or by ridge detection).

like image 21
maxim1000 Avatar answered Oct 29 '22 14:10

maxim1000