You can try to use the bwmorph
function.
Example:
skel=bwmorph(bwmorph(YourImage,'erode', 6),'skel', Inf);
imshow(skel)
Result:
Edit If you are after the position and length of the lines, you can use regionprops
, like this:
Framed = padarray(YourImage,[3 3],0,'both');
(This adds a black frame around the image to isolate the individual lines).
props=regionprops(Framed, 'Centroid', 'BoundingBox');
centroids={props.Centroid};
BBoxes={props.BoundingBox};
The positions of the lines are in the second element of each vector in centroids
, the length of the lines can be deduced from the bounding boxes in BBoxes
.
You can plot the results like this:
imshow(Framed)
hold on;
for k=1:length(centroids)
line([1 BBoxes{k}(3)],[centroids{k}(2) centroids{k}(2)])
end
hold off;
Result: