Line detect the length of a pixel in image processing

6 views (last 30 days)
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
  2 Comments
Image Analyst
Image Analyst on 29 Jun 2014
Usually when people want advice on image analysis, they attach and image. That would explain a lot, like whether the image is gray scale, color, computer graphics, blurry, lines are wiggly, etc. What can we say until we see your image?
roya a
roya a on 29 Jun 2014
Thanks for your help. I attached my image.
my code:
II=0;
for i=2:378
for j=1:377
if (image(i,j)==255 && image(i-1,j)==0)
ii=i;
I=0;
% ii,j
while(image(ii,j)==255)
I=I+1;
if (ii<377)
ii=ii+1;
end
end
I;
% ii,j
II=II+1;
end
end
end
II
But my code doesn't work correctly. Thanks

Sign in to comment.

Accepted Answer

Image Analyst
Image Analyst on 29 Jun 2014
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.
  4 Comments
Image Analyst
Image Analyst on 29 Jun 2014
Run the attached code to produce this image. Adapt as needed.
roya a
roya a on 30 Jun 2014
Thanks. It is great. Thank you so much for your help.

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!