How to find the index of a specific point on a bwlabeled image

1 view (last 30 days)
After you use bwlabel on an image, if you use [x,y] = ginput and find certain points on an image. What code can you use to get the index of that point?
Example: [x,y] = ginput (you get: x = 154.3 244.6 546.2 y = 345.7 120.3 45.0)

Accepted Answer

Image Analyst
Image Analyst on 11 Aug 2011
What do you mean by index? The linear index? Then use subs2ind(). Or the numerical label of the blob? If you want the label, just do
labelYouPointedTo = labeledImage(round(y), round(x));

More Answers (0)

Community Treasure Hunt

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

Start Hunting!