Filter löschen
Filter löschen

How to find distance between two curves?

2 Ansichten (letzte 30 Tage)
Jean Luo
Jean Luo am 13 Jul. 2016
Bearbeitet: Jean Luo am 1 Aug. 2016
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!
  3 Kommentare
Image Analyst
Image Analyst am 13 Jul. 2016
Do you want vertical distance or "radial"?
Jean Luo
Jean Luo am 13 Jul. 2016
I'm thinking maybe finding the tangent lines to the highest points on the curves would be a good way to go, but do you have any ideas as to how I can find where the highest points are?

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Image Analyst
Image Analyst am 13 Jul. 2016
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.
  9 Kommentare
Image Analyst
Image Analyst am 22 Jul. 2016
I gave you the formula for the radius. Here it is again:
meanRadii = mean(sqrt((x - xCenter).^2 + (y - yCenter).^2));
Recall that you said you have a known, specified center, so you know what xCenter and yCenter is. Don't you? I assume you did when you said "given the origin". Because if you just had the origin but not the center, then you'd just use the FAQ like I originally said.
No you don't need to use some circle fitting routine. The formula for radius I gave you is, in essence, the fitting code. It works because you have specified the center already so all we need to determine is the radius, which would just be the average of the distances of each point from your known center.
Jean Luo
Jean Luo am 22 Jul. 2016
Thank you so much for your help, I got it to work!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by