The object is to auto-straighten an image. I have written some test code that tries to figure out the dominant angles in an image. A dominant angle near horizontal or vertical tells us that we should rotate the image by the right amount to make that angle *be* horiz/vert.

There's no production code yet. I think what's needed right now is a more precise way of estimating the dominant angle.

Get the code with anonymous CVS:

cvs -z3 -d co straighten

ViewCVS is available

Some results. The graph is some popularity measure vs angle. The peak in the middle is near 90, but isn't exactly 90. I'd like to know, to perhaps .1 degree, what that peak angle is.
more files

A search based on the Hough transform may also be useful. I have not looked into how other auto-straighteners work at all. I think they just use the derivative method that I'm using.