Compute binary line thickness in normal direction

1 vue (au cours des 30 derniers jours)
Jan Kubicek
Jan Kubicek le 4 Juil 2019
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

Réponses (1)

Image Analyst
Image Analyst le 4 Juil 2019
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.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by