Plot endpoints of skeleton inside each regionprops boundingbox

2 views (last 30 days)
I have a skeleton image of multiple detected boundingbox from regionprops. I want to measure the Euclidean distance from endpoint to endpoint of that particular skeleton inside the bbox. When I tried the bwmorph(skelimg, 'endpoint); I get different result. It measures endpoint from one skeleton to another which is not what I want.
Please help, thank you.
This is my current result: The endpoint:
What I want:
My code:
infor = regionprops(skelimg, 'Area', 'BoundingBox', 'Centroid');
% stats = regionprops(skelimg, 'area');
blobareas = [infor.Area];
fprintf('%3d: %5d\n', [1 : length(blobareas); blobareas]);
figure;imshow(skelimg);
hold on;
for k = 1 : length(infor)
BB = infor(k).BoundingBox;
area = infor(k).Area;
rectangle('Position', [BB(1),BB(2),BB(3),BB(4)],'EdgeColor','r','LineWidth',2) ;
text(infor(k).Centroid(1),infor(k).Centroid(2),num2str(infor(k).Area),'FontSize',15,'color','w');
End_p = bwmorph(skelimg,'endpoints');
[row,column] = find(End_p);
End_pts = [row column];
disp(k);
plot(End_pts(:,2),End_pts(:,1),'-b');
end

Answers (0)

Categories

Find more on Read, Write, and Modify Image in Help Center and File Exchange

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!