Averaging of houghlines

asked 2019-03-11 07:59:57 -0600

twasnow gravatar image

Hey folks,

So I am detecting a line, ( florescent painted line). So it is quite easy to isolate and I get a pretty much perfect mask of the line.

I take my 10 best lines and I average them together then use the average line to do all further calculations. (I actually do some time weighted averaging as well but that isn't important.) This works great for all orientations except close to vertical.

The issue I'm having is the Hough transform only gives a theta between 0 and 180 degrees. So when averaging theta of 170 and say 0 degrees the output is 85, but what I really want is 175.

The only somewhat acceptable solution I can come up with is take the a average of all lines below 90 degrees and all lines above 90 degrees. Then if the difference between theta is >90 then I add 180 degrees to the avg line above 90 take the weighted average between that and the line that was below 90.

I hope that all makes sense .

Is there a better way that I am overlooking. maybe a way to compare the sin average and the cos average to decide if I should subtract 90 degrees from the average.

Thanks

edit retag flag offensive close merge delete

Comments

I have dealt with this type of situation by doing something like:

For all of the lines: angle = (angle + 45) mod 180

computeAverageLines() // whatever you are doing now to group the lines

for all average lines: angle = angle - 45

if angle < 0, angle = angle +180

This way lines with an angle of 170 are now 35 deg, and lines that were 0 are 45 deg...so when you compute an average line you will get something around 40, subtract off the 45 to get -5, and then add 180 to get 175.

swebb_denver gravatar imageswebb_denver ( 2019-03-11 13:59:37 -0600 )edit