2003.03.12 10:56 "skew detection", by Carter John-jcarte01
this isn't strictly a tiff question but seeing as there are so many graphics type people on this alias I thought it might be worth a shot.
I've written a skew detection function based on dividing the image into a grid (100 pixel x 100 pixel squares) then producing a horizontal and vertical histogram of each square so that on a "perfectly scanned" page a horizontal histogram would have a skyscraper skyline type contour, groups of high values separated by gaps of low or no values. on this "perfectly scanned" page the location of these features are in the same place on the page (since the line of text would be in the same place in each square).
so by comparing the outline of each feature (skyscraper) in each square with the square to its north-east,east and south-east the differences can be stored in another histogram. on the "perfectly scanned" page the resulting histogram would have a spike around the -1 0 +1 difference, since the outlines more or less line up.
when a image is skewed this difference drifts -ively or +ively depending on if its skew clockwise or anticlock wise.
this work fine for up to ~ +/- 15 degree skew, the problem I'm having is that between 20 and 45 degrees there is an overcompensation so that at ~45 anti clockwise skew gets rotated clockwise by about 47 clockwise. ok i can adopt a 2 pass approach but it would be nice to figure out why is over compensating and get it right 1st time
any had experience with better / faster / more accurate skew detection algorithms
BSS O&M Development group,
Mahon Industrial Estate,
Tel: +353 21 4807 637 (direct)
Fax: +353 21 4357635 ( reception )
Mobile: +353 86 3947920
Email <mailto:firstname.lastname@example.org> www <http://www.cork.cig.mot.com/~jcarte01/> <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
Homer: There's 3 ways to do things, the right way, the wrong way, and the max power way.
Bart: isn't that the wrong way.
Homer: yea but faster.