MATLAB: How to find distance between two curves

calculating distancecircle radiuscurve fittingdistance between linesfitting circlesimage processingImage Processing Toolbox

Hey guys, I have a set of binary images each consisting of two curves, one directly on top of the other. I want to find the normal distance between them. This is very similar to another question found here: https://www.mathworks.com/matlabcentral/answers/214151-how-to-find-the-distance-between-lines-in-a-image-in-matlab. I'm guessing I need to fit curves onto the image first. Any help would be much appreciated!

Best Answer

I'd invert the image so that the curves are white (foreground). Then I'd make masks for each curve by dilating the image a bunch and using bwareafilt() to extract the 2 largest blobs. Then for each blob, mask the image of the original, undilated image so that you have only that blob. Then I'd use find() to get all the coordinates and then fit it to a circle to get an average radius. Then do the same for the other masked blob. Subtract the two radii to get the average, overall separation.
Related Question