MATLAB: Line detect the length of a pixel in image processing

image processingImage Processing Toolboxline detection

Hi, I have one image with a lot of vertical lines. I want to know number of lines and length of each of the lines. Please help me. Thanks

Best Answer

There are thousands of vertical lines there, if you call a vertical line a series of white pixels in a single column with no breaks in it. You can count them simply by labeling the image using 4-connectivity
[labeledImage, numberOfRegions] = bwlabel(binaryImage, 4);
Now, some of those white blobs may be horizontal, or rounded blobs, so you might want to call regionprops and check the PixelIdxList property to make sure all the pixels in each blob are in the same column. Use unique on the x (column) coordinates for that.
Related Question