ellipses on image

조회 수: 2 (최근 30일)
thoraya
thoraya 2012년 6월 20일
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
Image Analyst
Image Analyst 2012년 7월 8일
"Burn" it into the image pixels, or just display above the image in the overlay (without changing image pixel values at all)?

댓글을 달려면 로그인하십시오.

답변 (2개)

Walter Roberson
Walter Roberson 2012년 7월 8일
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
Richard Brown
Richard Brown 2012년 7월 9일
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 2012년 7월 9일
I have no objection to using a rotation matrix instead of hgtransform() :-)

댓글을 달려면 로그인하십시오.


Ryan
Ryan 2012년 7월 9일
편집: Ryan 2012년 7월 9일
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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by