%Given a monochrome object, calculates its centroid distance function.
%Also returns the centroid's coordinates in a second parameter and
%the traced boundary in a third.
function [distance, centroid, boundary] = centdist(inImg)
    %Trace the object and find the centroid.
    [starty, startx] = find(inImg, 1);
    boundary = bwtraceboundary(inImg, [starty startx], 'SE');
    
    centroid = median(boundary);
    
    %Why is the Euclidean distance function in the neural net toolbox?
    distance = dist(centroid, boundary');
end