How to remove bridged lines/branches between lines in image?

2 views (last 30 days)
Hi,
I would like to remove certain lines which are not the main parallel lines, that is, all the horizontally connected bridges and spurs.
This is my thinedImage:
I have tried disconnecting the branches by using:
bp=bwlookup(thinedImage, makelut(@(x) sum(x(:))>=4 & x(5)==1,3)); %branch points?
filteredIm=thinedImage&~bp;
I then try to perform a bwareaopen(filteredIm, 50) and get this:
Basically everything on the left hand side is fine, but I have removed too much from the right hand side. How do I keep the major line, removing only the smaller branches?
I have also tried using
thinedImage - bwmorph(thinedImage, 'spur', Inf);
in the 2nd step, but that doesnt turn out too wel either.
  2 Comments
Walter Roberson
Walter Roberson on 23 Jan 2019
Perhaps use hough() with a range of theta that are close to 0, and then houghlines() to detect lines at those angles?
Edwin Sun
Edwin Sun on 29 Jan 2019
Sorry, didnt get a chance to test it till now.
The hough transform only fit to certain sections of the line, not the whole line. Basically the output from hough() is a whole bunch of lines which make up the the line. Is there a way for the hough transform to be a bit more lenient?
Also the image in the question is one of the better ones from a set of data, and not all the datas are as straight.. some are a bit more zig zaggy.
Thanks

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!