Fitting An Ellipse To A Set Of 2-D Points
I'm trying to fit an ellipse to a set of points described by x and y coordinates. I found a detailed explanation of how to do it here http://nicky.vanforeest.com/misc/fitEllipse/f
Solution 1:
Your code is absolutely fine, it is the patch
definition that makes the trouble here.
a
and b
of Ellipse
are the full width. So you have to multiply the result of your fit by 2
. Moreover the angle is in degree so you have to multiply by 180/np.pi
. Finally, the zero is not at the same position, so you have to add 90
.
Long story short change
Ellipse(center, a, b, phi)
to
ell = Ellipse(center, 2 * a, 2 * b, phi * 180 / np.pi + 90 )
and you are good.
Post a Comment for "Fitting An Ellipse To A Set Of 2-D Points"