Excluding Hough transform artifacts at 45 and -45 degrees

16 次查看(过去 30 天)
I am following steps in this example to find lines in my image, which contains a lot of nearly-horizontal lines. The Hough transform identifies several lines correctly, but there are additional incorrect lines at exactly 45 and -45 degrees, making an 'X' in my square image. I think these are a mathematical artifact (see Samuel Liew's answer here), and I would like to exclude them. The following works, but is there a better way? Or if you understand this artifact, could you please explain it?
angleList = -90:89; % All the permissable angles (note 90 can't be included)
angleList(angleList==45 | angleList==-45) = []; % Remove problematic -45, 45 degree angles
[H,T,R] = hough(BW, 'Theta', angleList);
  1 个评论
Jordan Kennedy
Jordan Kennedy 2020-10-22
In my dataset, I have true 45 degree artificats that are falsly amplified by the 45 degree angle artificat. So I did not want to remove 45 entirely. I still needed to maintain the true signal. With Michael Knetzger's explaination for the error I decided to use a 1D median filter on the H output of the Hough Transform. This is apart of the Signal Processing Toolbox. This seemed to work well for me.
tempangle = medfilt1(H,10,'truncate');

请先登录,再进行评论。

采纳的回答

Michael Knetzger
Michael Knetzger 2019-12-5
Dear KAE,
since I had also issues with the 45 degree artifacts and your idea helped me I'll give you an explanation on how I see those artifacts.
You're following the examples in the documentation, so at one point you have am edge detected image. Although the lines have a preferred direction, the pixels are discret. So every step of your line from a horrizontal (or vertical) direction in order to form an inclined line is your 45 degree artifact.
So what you detect is this:
hough4matlab.png
Therefore your soultion is sufficient, if you insist on having the full angular range, you need to alter your edge detection.
  1 个评论
KAE
KAE 2019-12-9
Very nice detective work, thanks. This must be a common occurance for line detection in raster images.

请先登录,再进行评论。

更多回答(0 个)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by