I'm implementing a system that uses a least squares algorithm to fit an ellipse to a set of data points. I've successfully managed to obtain approximate locations for the centre of the ellipse but I am having trouble with the major and minor axes. I'm writing this in C++ using OpenCV so I need to be able to express them as some kind of equation so I can calculate them. Right now I am just testing it with very basic circles rather than what I'll actually be using the program for.
Result of my program, where the top image is the data points (3 contours) and the bottom image is my approximated ellipses. The solid circles are the original image, purple dot is the centre of my approximated ellipse and the green, blue and red curves my approximated ellipses for the contours. The ellipses have not been rotated to the approximated angle yet (I will do this later).
So, is there a way from the general conic
$Ax^2 + Bxy + Cy^2 + Dx + Ey + F = 0$
if I know the values of A,B,C,D,E and F and also the centre point $(x_0,y_0)$
That I can calculate the major and minor axes?
From what I understand. From the equation
${(x-x_0)^2 \over a^2} + {(y-y_0)^2 \over b^2} = 1$
The major axis is 2a and the minor is 2b.
Note: I do not have points on the ellipse that I can substitute in. In my actual application I am unlikely to have such points.
I came across this question and it helped me implement what I have done thus far Finding the angle of rotation of an ellipse from its general equation and the other way around
The 1st answer I used for the centre. And the 3rd for the axes/dimensions.
For example. The black circle with the blue 'ellipse' around it. I have
$A = 3.876e-013$ $B = 1.8819e-012$ $C = 1$ $D = -2.51108e-009$ $E = -484$ $F = 54663.6$
And I calculate theta from
${1 \over 2} \tan^{-1}\left({B \over A- C}\right)$
Which gives me $-9.40948e-013$
I am unsure if I am approaching this in the correct way.
Any help appreciated, cheers :).