how to find the sharp turn in a 2d-line (curve)?
Mostrar comentarios más antiguos
Hi all,
I am trying to find the sharp turn in a 2d-line (curve). Line is constructed with two vectors, X and Y. In following link you can find a sample line with realized point at which there is sharp turn (red solid point).
I appreciate if you could help me out with this.
Thanks, Payam
Respuesta aceptada
Más respuestas (3)
Jan
el 22 de Dic. de 2012
"Sharp" is relative. There is always a zoom level, which let a curve look smooth.
If you do not have a curve defined by a function, but a piecewise defined line, you are looking for neighboring elements with and included angle above a certain limit. But when such a piece has a length of 1e-200, while the others have a length of 1.0, can this have a "sharp turn"?!
But let's imagine, that you can control this fundamental problem by inventing some meaningful thresholds. Then this determines the angle between two lines:
angle = atan2(norm(cross(N1, N2)), dot(N1, N2))
Image Analyst
el 21 de Dic. de 2012
Well for that example, just do
yAtTurn = min(y);
xAtTurn = find(y == yAtTurn);
If you need something more general, flexible, and robust, then you need to say how other curves might look different than the one example you supplied.
6 comentarios
tafteh
el 21 de Dic. de 2012
Image Analyst
el 22 de Dic. de 2012
What is your data? Is it an image or a set of (x,y) coordinates?
tafteh
el 26 de Dic. de 2012
Image Analyst
el 26 de Dic. de 2012
Editada: Image Analyst
el 26 de Dic. de 2012
Perfect - then my code will work just fine. I put it under Roger's answer since it was really his idea for the algorithm - I just packaged it into a nice demo. Go ahead and mark it as the official "Answer".
Alessandro
el 30 de Mayo de 2014
Hi Image Analyst... your code works fine for me but i have a bw image instead of a set of (x,y) points... so that, i've not an ordered set of (x,y)... how can i figure out? (my purpose is still find inflection points)
Image Analyst
el 30 de Mayo de 2014
You can use bwboundaries() to get a list of (x,y) points.
Roger's Answer is in the FAQ http://matlab.wikia.com/wiki/FAQ#How_do_I_find_.22kinks.22_in_a_curve.3F
tafteh
el 21 de Dic. de 2012
0 votos
Categorías
Más información sobre Line Plots en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!