Detection of lines from an Image

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

A sample image would help.
Perhaps hough() or houghlines()? Perhaps RANSAC. Perhaps radon(). Who knows? Usually people attach an image when they ask for image processing advice. It's hard to work blind.
Sorry, no. So just try those suggestions I gave you. There is code examples there for finding lines and they may work for your images. Or else substitute a generic, non-classified image that looks similar and don't tell us what it is.
Hi, so here is the sample image. I want to detect the lines and measure the length of each line individually. I have used some techniques already to do it but it only detects 10 to 15% of the lengths but on that length measuring formula works well, but when I detect the lines directly with sobel or canny then the length detection algo does not work. Any kind of help from you would be much appreciated.
I see in most sections that continuity of the individual lines could reasonably be decided by assuming there are no sudden sharp turns. However I also see a couple of places where two lines come together and overlay each other for a while and then separate again, and without knowledge of the physical processes involved we have no information as to which side of the continuation to choose. I am looking in particular near the middle, where there is a section that looks sort of like
A B
A B
C
C
C
D E
D E
that might be either
A B
A B
BA
BA
BA
A B
A B
or
A B
A B
AB
AB
AB
B A
B A
What exactly do you want to know about them? The length of the line until it breaks apart? The curl or tortuosity? The total length? If you can't find the length of the lines, what do you really want to know? Maybe there is something else that can be measured, like area fraction or something that correlates with what you want to know but doesn't require finding each separate, individual line.
@Image Analyst.. At this point I am concerned to find out the length of lines until they break apart as you said! (of course if full line length is possible then yes i will do that). Secondly if finding the lengths of curly area is not possible then I will go for area fraction. But for now can you please help me out in detecting the lines and the lengths of lines until they break apart. Thank you so much.
@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.
Unfortunately the sample image appears to have disappeared.

Sign in to comment.

 Accepted Answer

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

Thanks I would check that and surely will come back to you with further question and to accept your answer :)
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)

Categories

Find more on Convert Image Type in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!