Be the first to rate this file! 88 downloads (last 30 days) File Size: 1.89 KB File ID: #22684

Ellipse Fit (Direct method)

by Nikolai Chernov

 

14 Jan 2009 (Updated 16 Jan 2009)

Code covered by the BSD License  

Fits an ellipse to a set of points on a plane; returns the coefficients of the ellipse's equation

Editor's Notes:

This file was selected as MATLAB Central Pick of the Week

Download Now | Watch this File

File Information
Description

This is a fast and non-iterative ellipse fit. Usage:

   A = EllipseDirectFit(XY)

Input: XY(n,2) is the array of coordinates of n points
            x(i)=XY(i,1), y(i)=XY(i,2)

 Output: A = [a b c d e f]' is the vector of coefficients
 of the equation of the best fitting ellipse:

   ax^2 + bxy + cy^2 + dx + ey + f = 0,

To convert this vector to the geometric parameters (semi-axes, center, etc.) use standard formulas, e.g., (19) - (24) in Wolfram Mathworld:
       http://mathworld.wolfram.com/Ellipse.html

This ellipse fit was proposed in article
A. W. Fitzgibbon, M. Pilu, R. B. Fisher
"Direct Least Squares Fitting of Ellipses"
IEEE Trans. PAMI, Vol. 21, pages 476-480 (1999)

The authors called it "Direct Ellipse Fit".

My code is based on a numerically stable version
of this fit published by R. Halir and J. Flusser. I only
added data centering to further improve performance.

Note: this fit returns ellipses only! You will get an ellipse
even if points can be better approximated by a hyperbola.

This fit is somewhat biased toward smaller ellipses.

Acknowledgements

The author wishes to acknowledge the following in the creation of this submission:
Ellipse Fit

MATLAB release MATLAB 6.0 (R12)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (4)
16 Jan 2009 OH

??? Input argument "XY" is undefined.

Error in ==> EllipseDirectFit at 17
centroid = mean(XY); % the centroid of the data set
 
??? Input argument "XY" is undefined.

Error in ==> EllipseDirectFit at 17
centroid = mean(XY); % the centroid of the data set

16 Jan 2009 Nikolai Chernov

from Author: XY is the Nx2 input array of coordinates of N points,
    x(i)=XY(i,1), y(i)=XY(i,2). To use the program, type
      A = EllipseDirectFit(XY)

30 Apr 2009 Francisco

The parameters in your equation (i.e.: a, b, c, d, e and f) do not fit with equation 15 in Wolfram's Mathworld.
This needs further explanation.

04 Sep 2009 Laurens

The Author (Fitzgibbon) posted some new code of his implementation at his site:

http://research.microsoft.com/en-us/um/people/awf/ellipse/

might be of interest

Please login to add a comment or rating.
Updates
16 Jan 2009

Added the description of input and output.

Tag Activity for this File
Tag Applied By Date/Time
image processing Nikolai Chernov 15 Jan 2009 14:34:20
statistics Nikolai Chernov 15 Jan 2009 14:34:20
least squares Nikolai Chernov 15 Jan 2009 14:34:20
optimization Nikolai Chernov 15 Jan 2009 14:34:20
potw Shari Freedman 20 Apr 2009 12:44:06
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com