Split skeleton in a binary and measure its length
Show older comments
I want to split the skeleton of a binarized image like what is stated here
I tried the solutions suggested such as interpar() but the result is not what I wanted. And when I tried the bwtraceboundaries() and based on the code presented here https://www.mathworks.com/matlabcentral/answers/1593279-splitting-a-skeleton-in-a-binary-object-to-equal-lengths#comment_1849284 , I receive errors such as:
Index in position 1 exceeds array bounds (must not exceed 3).
y = trace(1:skel_L,1);
This is the code I recently tried. I was looking to measure the entire length per line connected by points created along the skeleton but I can't seem to understand how to make it work. Hoping for any help and suggestions. Thank you.
im = imread('crack-image.png'); %crack is the object
I = rgb2gray(im);
I = im2bw(I);
skel = bwskel(I);
skel_L = length(find(skel));
[endpointsX, endpointsY] = find(bwmorph(skel == 1, 'endpoints') );
trace = bwtraceboundary(skel, [endpointsX(1), endpointsY(1)],'N');
y = trace(1:skel_L,1);
x = trace(1:skel_L,2);
imshow(skel);
Answers (0)
Categories
Find more on Morphological Operations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!