Skip to contents

fitEllipse calculates the ellipse that fits a set of 2D points.

Usage

fitEllipse(x, y, method = "original")

Arguments

x

A vector of x coordinates.

y

A vector of y coordinates of the same lenght as x.

method

A character string indicating the method to use in order to fit the ellipse. It can take the following values:

'original':

least square.

'ams':

Approximate Mean Square (AMS) proposed in Taubin (1991).

'direct':

Direct least square method proposed in Fitzgibbon, Pilu, and Fisher (1999).

Value

A list containing the height and width (in pixels) of the ellipse, the angle (in degrees) of its main axis with respect to the vertical axis, and the x and y coordinates of its center.

References

Taubin G. Estimation of planar curves, surfaces, and nonplanar space curves defined by implicit equations with applications to edge and range image segmentation. IEEE Trans Pattern Anal Mach Intell. 1991;13: 1115–1138. doi:10.1109/34.103273

Fitzgibbon A, Pilu M, Fisher RB. Direct least square fitting of ellipses. IEEE Trans Pattern Anal Mach Intell. 1999;21: 476–480. doi:10.1109/34.765658

Author

Simon Garnier, garnier@njit.edu

Examples

fitEllipse(rnorm(100), rnorm(100))
#> $angle
#> [1] 54.46844
#> 
#> $height
#> [1] 4.125383
#> 
#> $width
#> [1] 3.275702
#> 
#> $center
#> [1]  0.2803737 -0.1137554
#>