Detection of lines from an Image

2 views (last 30 days)
Hello I have an image from which many lines are being dropping down from top to bottom.. some are straight and some are random. I have a code that works well but the problem is it detects only 10 to 15% of the lines from top to bottom and rest of them are just blank pixels nothing is detected. Can you suggest me what should I do to detect all the lines. PS: Image is very clear and lines are very clear on the image.
  9 Comments
Image.Processor
Image.Processor on 8 Oct 2017
@Walter Roberson.. Yes you are right, I will make an assumption that the lines are continues and there are no sharp breaks or else I will try to fit some points where there are breaks. But as I said in my above comment for now I am concerned with the lengths of lines until they are pretty straight.
Walter Roberson
Walter Roberson on 9 Oct 2017
Unfortunately the sample image appears to have disappeared.

Sign in to comment.

Accepted Answer

Image Analyst
Image Analyst on 8 Oct 2017
I'd first correct for the background by dividing by a blank one. If you can't do that then I'd try a bottom hat filter, imbothat(), or adapthisteq(), so that you can get to an image that you can threshold to get a binary image.
binaryImage = filteredImage < threshold;
Then I'd erode the binary image to get rid of the little lines and have just the big black thing at the top.
bigBlob = imerode(binaryImage, ones(5));
Then I'd use that to subtract from the original binary image so that now you're just left with a binary image of the fibers.
binaryImage = binaryImage & ~bigBlob;
Then I'd skeletonize them with bwmorph()
binaryImage = bwmorph(binaryImage, 'skel', inf);
and then call regionprops to get the area, which for skeletons is the length of the skeletonized line.
props = regionprops(binaryImage, 'Area');
allLengths = [props.Area];
  2 Comments
Image.Processor
Image.Processor on 8 Oct 2017
Thanks I would check that and surely will come back to you with further question and to accept your answer :)
Image.Processor
Image.Processor on 9 Oct 2017
Hi Image Analyst. I have tried a lot but I can not find the way to get that. Is it possible for you to give me a sample code for what you explained. I am new may be I am making a lots of mistakes. Thank you so much.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!