How to find the endpoint?

13 views (last 30 days)
ZWY on 8 Jun 2022
Commented: ZWY on 10 Jun 2022
Hi, i have an image and wanted to find the location of endpoints as shown in red circle.
I am using the
however, it returns "0" instead of the location of endpoints.
How can I do with this? Thank you.
ZWY on 10 Jun 2022
Thanks Rik.

Sign in to comment.

Accepted Answer

DGM on 8 Jun 2022
Edited: DGM on 8 Jun 2022
% image recovered from screenshot
A = imread('vessel.png');
A = A>128; % binarize
% skeletonize
B = bwskel(A,'minbranchlength',50);
% fill loops
B = imfill(B,'holes');
% skeletonize to get rid of filled loops
B = bwskel(B,'minbranchlength',50);
imshow(B) % display interpolation makes fine lines look spotty
% get endpoints as a logical image
endpts = bwmorph(B,'endpoints');
imshow(endpts) % again, display interpolation hides most of the dots
That result can be used for logical indexing if needed. If for some reason, you can't use it directly and need indices instead, you can use find().
% if you really truly need indices instead
endptidx = find(endpts)
endptidx = 21×1
807 124117 134946 246304 371291 453988 479473 492705 497657 526278
ZWY on 10 Jun 2022
I got it. Thanks all for helping, really appreciate it!

Sign in to comment.

More Answers (0)




Community Treasure Hunt

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

Start Hunting!