views:

241

answers:

2

We want a c# solution to correct the scanned image because it is rotated. To solve this problem we must detect the rotation angle first and then rotate the image. This was our first thought for our problem. But then we thought image warping would be more accurate as I think it would make the scanned image like our template. Then we can process it as we know all the coordinates of our template... I searched for a free SDK or a free solution in c#. Helping me in this will be great as it is the last task in our work. Really, thanks for all.

A: 

We used the PrimeOCR product to do this. It's not free, but we couldn't find a free program that was comparable.

David
A: 

So, the hard part is to detect the angle of the page.

If you have full control over the template, the simplest way to do this is probably to come up with an easily-detectable symbol (e.g. a solid black circle) and stick 3 of them on the template. Then, detect them (just look for big blocks of pixels with high saturation, in the case of a solid black circle).

So, you'll then have 3 sets of coordinates. If you have a top circle, a left circle, and a right circle with all 3 circles at difference distances from one another, detecting which circle is the top circle should be pretty easy.

Then just call a rotation function. This part is easy and has been done before (e.g. http://www.switchonthecode.com/tutorials/csharp-tutorial-image-editing-rotate ).

Edit: I suggested a circle because it's easier to find the center, but a rectangle should work, too.

To be more explicit about how to actually locate the rectangles/circles, take the average Brightness value of every a*a group of pixels. If that value is greater than b, then that a*a group of pixels is part of a rectangle. a and b are varables you'll want to come up with yourself.

Use flood-fill (or, more precisely, Connected Component Labeling) group the resulting pixels together. The end result should give you your rectangles.

Brian
we allready put 3 rectangles on our template now but how to detect these rectangles in the scanned image and get thier location for calculating the rotation angle this is what we face now but we can use the code of rotation well.still have ap roblem in detect the rotation anglethanxxxxxxxxxxx in advance
ahmed fouad
@ahmed: I have added further detail.
Brian
thanxxxxxxxxxx very much
ahmed fouad