I want to find the width of a line...how to do?
7 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
First i have done hough transformation. My code runs good , i have derived also the no. of line and the length.
T=graythresh(new_detected_line_width(:,:,2));
IB = im2bw(new_detected_line_width(:,:,2),T);
figure;imshow(IB),title('Thresholded Image')
s=strel('disk',15,8);
IB=imclose(IB,s);
figure;imshow(IB),title('Dilated Image')
[B L N C]=bwboundaries(IB,'noholes');
imshow(label2rgb(L, @jet, [.5 .5 .5]))
hold on
for k = 1:length(B)
boundary = B{k};
plot(boundary(:,2), boundary(:,1), 'w', 'LineWidth', 2)
mn=min(boundary);
mx=max(boundary);
lineln(k)=sqrt((mn(1,1)-mx(1,1))^2+(mx(1,2)-mx(1,2))^2);
end
sprintf('No of lines = %d', N)
sprintf('Length %d\n', lineln)
*** I also want to find out the width of the line -how to do that
0 Commenti
Risposte (2)
Walter Roberson
il 8 Nov 2023
When you have an open object -- a line that does not loop back to cross itself, and does not enclose an area -- then you can use regionprops or bwferet to calculate the feret distances for the line. That will basically give you the minimum thickness of the line.
For example the right hand curved line does not quite meet itself so you can ask its feret distances. At the top right of it there is a little spur that is thinner than the rest of the line, so we would have to conclude that the true "width" of the line is the same as the width at its thinnest -- anywhere else on the line can be assumed to "not really" be thicker and instead to just appear locally thicker due to the curvature of the line.
You cannot apply the same feret distance test for the closed loop at the left, as that would tell you about the width of the object rather than of the line.
0 Commenti
Image Analyst
il 8 Nov 2023
Not sure what you're calling a line? Is it the one short little one-pixel-wide green line? Or do you want the widths of the irregularly shaped blobs? If it's the latter, see my attached demo.
0 Commenti
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!