6
$\begingroup$

Given a straight line that deviates from the horizontal by at most 15 degrees.

On this straight line there are bumps on top at random places on the line. The combined width of the bumps is at most 10% of the length of the straight line (but could be as little as 3 or 4 % of the length) and the height of the bumps is at most 5% of the length of the straight line. I can sample and get the x and y co-ordinates of the top of the line every 1% of the lines length.

I need a formula for how much the line deviates from the horizontal.

This is actually part of an Optical Character Recognition program, and I need this formula to write the software to align a page that was scanned not perfectly horizontally.

1 Answers 1

2

You can do a linear regression. The slope that comes out of it will be close to the tangent of the angle. Routines are available in any numerical analysis book, many computer packages, and Excel. Section 15.2 of Numerical Recipes has a discussion.

Added: if the bumps are rare enough and most of the line is correct, you could just pick a dozen or so points, form all the pairs, and calculate the slope for each pair. Most of them should agree, and that is the slope. You can use the two-point form for the line.

It still won't be exact-real numbers cannot generally be represented exactly in a computer and there are errors in the measurement of the points, the square root and tangent functions, etc.

  • 0
    On the other hand, from the looks of things OP will want to do *orthogonal regression/total least squares* instead of the conventional least squares, since it seems both horizontal and vertical coordinates are noisy...2012-05-08