How to find distance between two curves?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Jean Luo
el 13 de Jul. de 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 comentarios
Image Analyst
el 13 de Jul. de 2016
Do you want vertical distance or "radial"?
Have you seen the FAQ for fitting a circle: http://matlab.wikia.com/wiki/FAQ#How_can_I_fit_a_circle_to_a_set_of_XY_data.3F
Respuesta aceptada
Image Analyst
el 13 de Jul. de 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 comentarios
Image Analyst
el 22 de Jul. de 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.
Más respuestas (0)
Ver también
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!