Compute binary line thickness in normal direction
조회 수: 1 (최근 30일)
이전 댓글 표시
Dear colleagues,
I would like to kindly ask you for the help with the definition of the line thickness. I have the binary curve. I need to find out a distance of each point of the curve skeleton to line edge in the direction of the normal. So, I firstly computed skeleton of the binary curve. Consequently, for each pixel of the skeleton I computed normal. This situation is depicted on the figure, showing the skeleton and a map of normal vectors from each pixel. In this point, I do not know how to compute the distance for each skeleton pixel to curve edge in the normal direction. Practically, I need to count number of the pixels (logical 1) from the skeleton pixels to the line edge in the normal direction. It means I need to obtain the vector, containing distance for each skeleton point. I would like to thank you in advance for your help.
Code for generating skeleton with normals:
i=rgb2gray(imread('Bin_Lines.bmp'));
BW=bwskel(logical(i));
% BW = image sceleton
Orientations = skeletonOrientation(BW,5); %5x5 box
Onormal = Orientations+90; %easier to view normals
Onr = sind(Onormal); %vv
Onc = cosd(Onormal); %uu
[r,c] = find(BW); %row/cols
idx = find(BW); %Linear indices into Onr/Onc
figure()
imshow(BW,[]);
%Plotting normals of binary skeleton
hold on
quiver(c,r,-Onc(idx),Onr(idx));
Here is the link where I store source codes and binary line image:
![normals.png](https://www.mathworks.com/matlabcentral/answers/uploaded_files/227552/normals.png)
댓글 수: 0
답변 (1개)
Image Analyst
2019년 7월 4일
I'd probably use polyfit() to get a centerline through the blob (I've done this with my images and it works pretty well). Then get the area of the blob using regionprops(), then divide that area by the length of the centerline to get the average width of the blob.
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!