How to find distance between boundary pixels and centroid?
Show older comments

Hi I'm new in matlab and I want to find the distance between the boundary pixels of each connected component and the centroid. I'm using the following algorithm.I have found centroid but dont know how to find the boundary pixels and distance. Looking forward to your reply.
for i=1:count(boundary pixels)
distance between centroid and boundary pixels
end
sum=sum/count
Accepted Answer
More Answers (1)
Image Analyst
on 10 May 2016
0 votes
You can use bwboundaries() to get a list of x,y coordinates of your perimeters. You can use bwdist() or bwdistgeodesic() to get the distance of every pixel in each blob to the closest perimeter point. Or you can use the Pythagorean theorem and the coordinates from bwboundaries if you want an "as the crow flies" distance, which in general is different than you'll get from either bwdist function..
Categories
Find more on Region and Image Properties 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!