How to get the coordinates of the center of the ellipse after approximation

711 Views Asked by At

I create an algorithm recognizing ellipses in images.

enter image description here

I have five coordinates (points) possible ellipse.

(8.8) (7.4) (6.3) (3.6) and (2.2)

I use the formula of the conical section of the second order:

$Ax ^ 2 + Bxy + Cy ^ 2 + Dx + Ey + F = 0$

And determines the type of conic section by the value of the discriminant.

$B ^ 2-4AC$

Where, if the sign of the value < 0, then this ellipse.

On the basis of the coordinate values I find A, B, C, D, E, F. (Calculates them here)

A = 0.0763889 
B = -0.0902778 
C = 0.0763889 
D = -0.312500 
E = -0.312500 
F = 1.00000

But I do not know what to do next calculations.

How do I need to get the coordinates of the center of the ellipse, the length of its two axes, and rotation about the coordinate axes?

Thank you!

2

There are 2 best solutions below

9
On BEST ANSWER

For $U(x,y) = Ax ^ 2 + Bxy + Cy ^ 2 + Dx + Ey + F = 0$ the center is located at

$$ \left. \begin{align} \frac{\partial U}{\partial x} & = 0 \\\frac{\partial U}{\partial y} & = 0 \end{align} \right\} \begin{aligned} x_c & = \frac{B E - 2 C D}{4 A C - B^2} \\ y_c &= \frac{B D -2 A E}{4 A C - B^2} \end{aligned} $$

This transforms the equation into

$$ A (x-x_c)^2 + B (x-x_c) (y-y_c) + C (y-y_c)^2 + F^\star = 0 $$

where $$F^\star = F + \frac{D (B E-C D)-A E^2}{4 A C - B^2} $$

The rotation angle is then found by $$\theta = \frac{1}{2} \arctan \left( \frac{B}{A-C} \right) $$

The polar distance at angle $\theta$ is found by rotation of the axes. The major and minor axes are

$$r = \sqrt{ \frac{-2 F^\star}{A+C \pm \sqrt{B^2+(A-C)^2}} }$$

With the values from your question I get $r=4.2426406871192851 $ and $r=2.1514113001014558$

2
On

8,8 and 2,2 are the endpoints of the major axis.

The center is at (5,5)

the length major axis is 6 sqrt 2

The angle of rotation is 45 degrees.

Using the substitution u = x+y, v = x-y Our points in u,v space are (16,0),(11,3),(9,3),(9,-3),(4,0)

$\frac{(u-5)^2}{6^2} + \frac{v^2}{b^2} = 1\\ \frac {1}{36} + \frac{v^2}{b^2} = 1\\ b = \frac{18}{\sqrt{35}}$

And the length of the minor axis = $b \sqrt 2$

Had the points not been so carefully chosen to make this easy to solve, I don't think what I have done generalizes.

If you have the equation $A x^2 + Bxy + Cy^2 + Dx + Ey + F = 0$

$x = u \cos \theta - v \sin\theta\\ y = u \sin \theta + v \cos\theta$

Find $\theta$ such that the uv cross term drops away.

$(C-A) \sin 2\theta + B \cos 2\theta = 0\\ \theta = \frac 12 \tan^{-1} \frac B{C-A}$

Then complete the square to center (u,v). You will need to plug the coordinates of the center in (u,v) space back into the transformation to find them in x,y space.

Put into standard form to find the length of the major and minor axes.