MATLAB: How to find the distance between a reference point and other desired boundary points of an object in a binary image

distance calculationeuclideanImage Processing Toolboxpythagorean theorem

Hi,
I have a binary image of the human foot and need help in finding the distance between the centroid and the tip of the toes of the foot. In total, I need five measurements of distances between the centroid and the tip of each toe.
Thank you

Best Answer

Let's say (xctr, yctr) is the location of the centroid, and x and y are the coordinate arrays of the other points. Then the distances are:
boundaries = bwboundaries(binaryImage);
x = boundaries{1}(:, 2);
y = boundaries{1}(:, 1);
distances = sqrt((x-xctr).^2 + (y-yctr).^2);