ellipses on image

hi; I have a set of ellipses where each ellipse is defined by its center position (x,y) , an orientaion angle teta, major axe a and a minor axe b. i want to find a way in order to draw those ellipses on a given image* Img* . any idea please? thank you

1 comentario

Image Analyst
Image Analyst el 8 de Jul. de 2012
"Burn" it into the image pixels, or just display above the image in the overlay (without changing image pixel values at all)?

Iniciar sesión para comentar.

Respuestas (2)

Walter Roberson
Walter Roberson el 8 de Jul. de 2012

0 votos

One way is to calculate a circle such as is described in the FAQ. Make it a unit circle as you first calculate it. Multiply the x coordinates by (a/2) and the y coordinates by (b/2). Then use hgtransform() to rotate it around the angle. Finally, add the center coordinates to the transformed results.

4 comentarios

Richard Brown
Richard Brown el 9 de Jul. de 2012
almost easier to just do
theta = linspace(0, 2*pi, 100);
plot(a * cos(theta) + xc, b * sin(theta) + yc)
isn't it?
Walter Roberson
Walter Roberson el 9 de Jul. de 2012
That sequence does not allow the ellipse to be rotated. Also, it would use "a" and "b" as the size of the semi-major and semi-minor axis rather than as the size of the major and minor axis (that's why I divided by 2)
Richard Brown
Richard Brown el 9 de Jul. de 2012
Sorry, didn't read the question properly:
phi = linspace(0, 2*pi, 100);
Q = [cos(theta), -sin(theta); sin(theta), cos(theta)];
X = bsxfun(@plus, [xc; yc], Q * [a/2 * cos(phi); b/2 * sin(phi)]);
plot(X(1, :), X(2, :))
... yes, your way may be cleaner :)
Walter Roberson
Walter Roberson el 9 de Jul. de 2012
I have no objection to using a rotation matrix instead of hgtransform() :-)

Iniciar sesión para comentar.

Ryan
Ryan el 9 de Jul. de 2012
Editada: Ryan el 9 de Jul. de 2012

0 votos

Use pdeellip (if you have the PDE toolbox):
pdeellip(xc,yc,a,b,phi)
Where:
(xc,yc) = centroid
(a,b) = semiaxes
phi = rotation of ellipse

Categorías

Etiquetas

Preguntada:

el 20 de Jun. de 2012

Community Treasure Hunt

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

Start Hunting!

Translated by