Acta Mathematica Academiae Paedagogicae Nyı́regyháziensis 19 (2003), 221–225 www.emis.de/journals CALIBRATION OF AN ELLIPSE’S ALGEBRAIC EQUATION AND DIRECT DETERMINATION OF ITS PARAMETERS MOHAMED ALI SAID Abstract. The coefficients of an ellipse’s algebraic equation are not unique. Multiplying these coefficients by a number δ 6= 0 does not affect the ellipse’s shape. In this paper it is shown that at a certain δ , called calibration number, direct relations between the coefficients and the parameters of the ellipse are found. This value of δ is found and is shown to be invariant. Useful results concerning invariants of an ellipse’s equation are found using calibration. 1. Introduction 1.1. Motivation and Statement of the problem. Ellipses are of the most commonly used primitive models in applications fields like pattern recognition. Several aspects of ellipses still in active research see for example [3, 4, 2]. The algebraic equation of an ellipse is given by (1) Ax2 + Bxy + Cy 2 + Dx + Ey + F = 0, B 2 − 4AC < 0 The coefficients A, B, C, D, E, and F provide little direct insight into the ellipse’s shape. Moreover, these coefficients are not unique since they can be multiplied by a number δ 6= 0 and still describe the same ellipse. So, extracting the parameters of an ellipse from the coefficients of its algebraic equation is an important issue. The five ellipse parameters are: the coordinates of its center x0 and y0 , the lengths of the semi-major axis a and of the semi-minor axis b, and the angle θ between the x-axis and the major-axis. The ellipse’s parametric equation [7] is: a cos t cos θ − sin θ x0 x 0 ≤ t ≤ 2π + = (2) b sin t sin θ cos θ y0 y So, the problems to be considered here are i. To find an ellipse’s parameters in terms of its algebraic equation coefficients, ii. To investigate the invariants of the ellipse’s algebraic equation. 1.2. Previous Work. In [5] the parameters are determined as follow: Find the ellipse’s center (x0 , y0 ) by solving the two equations: Ax0 + (B/2)y0 = −D/2 and (B/2)x0 + Cy0 = −E/2. Translate the coordinate system xy to x0 y 0 so that the origin (0, 0) is translated to the center (x0 , y0 ). The equation of the ellipse takes the form: Ax02 + Bx0 y 0 + Cy 02 + F 0 = 0. Find the angle θ using cot θ = (A − C)/B. Rotate the system x0 y 0 to x00 y 00 through the angle θ. The equation of the ellipse 2000 Mathematics Subject Classification. 51M04. Key words and phrases. Calibration, Ellipse’s parameters. 221 222 MOHAMED ALI SAID takes the form: A00 x002 + C 00 y 002 + F 0 = 0. Find the invariants of the equation: A B/2 D/2 A B/2 B/2 C E/2 (3) I1 = A + C, I2 = , I = 3 B/2 C D/2 E/2 F ellipse’s the semi axes lengths are determined from: a2 = −I3 /(I2 A00 ) and b2 = −I3 /(I2 C 00 ). In [6], the parameters are determined as follows: The angle θ is determined from cot 2θ = (A − C)/B. Rotate the coordinates system xy to x0 y 0 through the angle θ. The algebraic equation of the ellipse takes the form A0 x02 + C 0 y 02 + D0 x0 + E 0 y 0 + F = 0. Then, x0 = −D0 /(2A0 ), y0 = −E 0 /(2C 0 ), a2 = G/A0 , and b2 = G/C 0 , where G = −F + G02 /(4A0 ) + E 02 /(4C 0 ). In [1] the parameters are determined as follows: Find the eigenvalues λ1 and λ2 for the matrix A B/2 . B/2 C Let ϕ(x, y) = Ax2 +Bxy+Cy 2 +Dx+Ey+F . Find the center (x0 , y0 ) by solving the two equations (∂ϕ/∂x) |x0 ,y0 = 0 and (∂ϕ/∂y) |x0 ,y0 = 0. Find d = ϕ(x0 , y0 ). The lengths of the semi axes are a2 = −d/λ1 and b2 = −d/λ2 . The angle θ is obtained by comparing the orthonormalized modal matrix with the standard rotation matrix. In the next section an alternative to the above methods is introduced and several useful subsidiary results are also provided. 2. The proposed method The following theorem introduces the calibration number δ and the calibrated algebraic equation of the ellipse, hence the ellipse’s parameters are determined. Theorem. Let the algebraic equation of an ellipse be Ax2 + Bxy + Cy 2 + Dx + Ey + F = 0, where B 2 − 4AC < 0, then the parameters of that ellipse are obtained as follows: 1. Calibrate the equation by multiplying it by the calibration number δ, where δ=4 (CD2 + AE 2 − BDE) − F (4AC − B 2 ) , (4AC − B 2 )2 then the calibrated equation will be Āx2 + B̄xy + C̄y 2 + D̄x + Ēy + F̄ = 0. 2. The lengths of the semi-major axis a and the semi-minor axis b are given by p Ā + C̄ + (Ā − C̄)2 + B̄ 2 2 a = 2 and p Ā + C̄ − (Ā − C̄)2 + B̄ 2 2 . b = 2 3. The center (x0 , y0 ) of the ellipse is given by x0 = BE − 2CD B̄ Ē − 2C̄ D̄ = 2 4AC − B 4ĀC̄ − B̄ 2 y0 = B̄ D̄ − 2ĀĒ BD − 2AE = . 4AC − B 2 4ĀC̄ − B̄ 2 and CALIBRATION OF AN ELLIPSE’S ALGEBRAIC EQUATION. . . 223 4. The angle θ between the x-axis and the major-axis of the ellipse is given by 2θ = cot−1 [(A − C)/B] = cot−1 [(Ā − C̄)/B̄]. Proof. Eliminate the parameter t from equation (2) of the ellipse, the result is 2 2 (x − x0 )(− sin θ) + (y − y0 ) cos θ (x − x0 ) cos θ + (y − y0 ) sin θ + =1 (4) a b On expanding equation (4) and comparing the result with equation (1) we get (5) A = a2 sin2 θ + b2 cos2 θ, (6) B = 2(b2 − a2 ) sin θ cos θ, D = −2x0 A − y0 B, C = a2 cos2 θ + b2 sin2 θ E = −2y0 C − x0 B F = Ax20 + Bx0 y0 + Cy02 − a2 b2 (7) solving equations (6) simultaneously for x0 and y0 , then BD − 2AE BE − 2CD , y0 = 4AC − B 2 4AC − B 2 Replacing x0 and y0 in equation (7) by their values in equations (8), then (8) x0 = CD2 + AE 2 − BDE − a 2 b2 4AC − B 2 Using equations (5), the following is obtained (9) F = 4AC − B 2 = 4a2 b2 , (10) A + C = a 2 + b2 (A − C)2 + B 2 = (a2 − b2 )2 A−C cot 2θ = (12) B 2 2 Now, replace a b in equation (9) by its value in the first of equations (10), then (11) (13) A2 + B 2 /2 + C 2 = a4 + b4 , (4AC − B 2 )2 + 4F (4AC − B 2 ) − 4(CD2 + AE 2 − BDE) = 0 Equation (13) is an important equation since it depends only on the coefficients of equation (1), the algebraic equation of the ellipse. If the coefficients of equation (1) satisfy equation (13), then equations (5–12) are valid. But if the coefficients of equation (1) do not satisfy equation (13) then equation (1) should be multiplied by a number δ 6= 0 to force their coefficients to satisfy equation (13). This process is called calibration of the algebraic equation of the ellipse. Thus, to define the calibration number δ replace A, B, C, D, E, and F in equation (13) by δA, δB, δC, δD, δE, and δF respectively and solve for δ excluding δ = 0 , then: (14) δ=4 CD2 + AE 2 − BDE) − F (4AC − B 2 ) (4AC − B 2 )2 Now, let the calibrated equation be Āx2 + B̄xy + C̄y 2 + D̄x + Ēy + F̄ = 0, then in equations (5–12) the coefficients of the algebraic equation are replaced by the coefficients of the calibrated algebraic equation. Thus, the center (x0 , y0 ) is obtained as in equations (8): BE − 2CD B̄ Ē − 2C̄ D̄ BD − 2AE B̄ D̄ − 2ĀĒ = = , y0 = 2 2 2 4AC − B 4AC − B 4ĀC̄ − B̄ 4ĀC̄ − B̄ 2 Solving simultaneously equations (10) calibrated, the lengths of the semi-axes are: p p Ā + C̄ − (Ā − C̄)2 + B̄ 2 Ā + C̄ + (Ā − C̄)2 + B̄ 2 , b2 = (16) a2 = 2 2 (15) x0 = 224 MOHAMED ALI SAID The angle θ between the major-axis and the x-axis is determined as in equation (12): A−C Ā − C̄ = B B̄ The proof of the theorem is completed (17) cot 2θ = It can be seen from equations (15–17) that only two parameters of the five parameters of the ellipse, namely the lengths of the semi axes, need the calibration of the equation. However, the calibration of the algebraic equation of the ellipse helps in deducing many useful relations like those in equations (10–12). Some variants of such relations are used as constraints in ellipse fitting method. For example in [4] the constraint used is 4AC − B 2 = 1, also in other papers A + C = 1, and A2 + B 2 /2 + C 2 = 1 are used. The goodness of such constraints can now be seen in the light of the calibration process. Lemma 1. The invariants of the calibrated algebraic equation of an ellipse are: I1 = a2 + b2 , I2 = a2 b2 , and I3 = −a4 b4 . Thus, the invariants are functions of the lengths of the semi axes and only two of them are independent, namely I 1 and I2 . Proof. I1 = Ā + C̄ = a2 + b2 , where use is made for the second in equations (10) calibrated. For I2 take account of equation (3) and the first of equations (10) calibrated, then I2 = ĀC̄ − B̄ 2 /4 = (4a2 b2 )/4 = a2 b2 as required. For I3 make use of equations (3), (5), and (6–7) calibrated, then I3 = F̄ (4ĀC̄ − B̄ 2 ) − (ĀĒ 2 + C̄ D̄2 − B̄ D̄ Ē) = −a4 b4 = −(I2 )2 4 as required. This lemma agrees with the intuition that an ellipse’s shape is completely determined by lengths of its semi axes regardless of its position in the plane. Lemma 2. For an ellipse’s algebraic equation, the calibration number δ = −I 3 /(I2 )2 and thus is invariant. Proof. Since δ=4 (CD2 + AE 2 − BDE) − F (4AC − B 2 ) , (4AC − B 2 )2 I2 = (4AC − B 2 )/4, and I3 = F (4AC − B 2 ) − (AE 2 + CD2 − BDE) , 4 then 4I3 I3 = − 2. (4I2 )2 I2 Since I2 and I3 are invariants then δ is invariant under the same coordinates transformations. δ = −4 Lemma 3. For the calibrated equation of an ellipse: i. Ā2 + B̄ 2 /2 + C̄ 2 = a4 + b4 , and (Ā − C̄)2 + B̄ 2 = (a2 − b2 )2 both are invariants. ii. The eigenvalues of the matrix Ā B̄/2 B̄/2 C̄ 2 are λ1 = a2 and λp 2 =b . p iii. a2 = [I1 + (I1 )2 − 4I2 ]/2 and b2 = [I1 − (I1 )2 − 4I2 ]/2. CALIBRATION OF AN ELLIPSE’S ALGEBRAIC EQUATION. . . 225 Proof. i. a4 + b4 = (I1 )2 − 2I2 and (a2 − b2 )2 = a4 + b4 − 2a2 b2 = (I1 )2 − 2I2 − 2I2 ii. Simple. iii. Use the definition of I1 and I2 in lemma 1 and solve for a2 and b2 . Special Cases. As mentioned before δ = −I3 /(I2 )2 . If δ < 0 then I3 > 0 and the ellipse is imaginary. While if δ = 0, the ellipse degenerates to a point since I3 = 0. Conclusion. The concept of calibration introduced here allows a deeper insight to ellipses and helps in solving some problems related to them. The concept of calibration can be extended directly to hyperbolas and almost the same results can be obtained. References [1] M. Afwat. Algebra and Analytic Geometry. Zagazig University, 1999. [2] N. Bennet et al. A method to detect and characterize ellipses using hough transform. IEEE Trans. Pattern Anal. & Machine Intel., 22(4), April 2000. [3] G. Farin. From conics to NURBS: A tutorial and survey. IEEE Computer Graphics & Applications, September 1992. [4] A. Fitzgibbon et al. Direct least squares fitting of ellipses. IEEE Trans. Pattern Analysis & Machine Intelligence, 21(5), May 1999. [5] V. A. Ilyin and E. G. Poznyak. Analytic Geometry. Mir Pub., 1984. pp. 176–190. [6] D. F. Rogers. Mathematical Elements For Computer Graphics. McGraw-Hill, 1976. pp. 94–115. [7] I. Zeid. CAD/CAM Theory and Practice. McGraw-Hill, 1991. pp. 187–212. Received September 20, 2002.; in revised form April 7, 2003. Dept, Faculty of Engineering, Zagazig University, Zagazig, Egypt E-mail address: mmamsaid@hotmail.com