Ellipse Fitting: Fitzgibbon's Method and the 120Β° Triplet Strategy
How VisionLab fits ellipses robustly using algebraic constrained least-squares (Fitzgibbon) combined with a 120Β° sector-triplet sampling strategy for outlier rejection.
Ellipses appear wherever a circle is viewed at an angle β camera apertures, round holes on tilted surfaces, coin inspection, bearing outer rings under perspective. Fitting them robustly requires handling the same challenges as circle fitting (partial occlusion, noise, outliers) plus one more: the algebraic ellipse fitting problem is numerically ill-conditioned without the right constraint.
The General Conic and the Ellipse Constraint
Any conic section satisfies the degree-2 polynomial:
An ellipse is distinguished from a hyperbola or parabola by the condition:
NaΓ―ve least-squares minimises algebraic distance (where is the design matrix of point coordinates) without enforcing this constraint β the solution frequently degenerates to a hyperbola or line pair.
Fitzgibbon's Constrained Algebraic Fit
Fitzgibbon (1999) enforces the ellipse constraint directly as a quadratic constraint , turning the problem into a generalised eigenvalue problem:
where the constraint matrix encodes . The solution is the eigenvector corresponding to the unique positive eigenvalue β guaranteed to be an ellipse.
The algebraic coefficients are then converted to geometric parameters:
This yields semi-axes and rotation angle without any iterative solver.
The 120Β° Triplet Strategy
Fitzgibbon's fit requires at least 5 points and is sensitive to their distribution. If all 5 points come from the same small arc segment, the fit degenerates. VisionLab addresses this with the 120Β° triplet strategy:
The ellipse contour is divided into 24 angular sectors (15Β° each). Valid sectors (those containing edge points) are identified. For each valid sector , sectors at (120Β°) and (240Β°) are checked:
for i in valid_sectors:
j = (i + 8) % 24 # 120Β° away
k = (i + 16) % 24 # 240Β° away
if j and k are valid:
fit ellipse from centroids of sectors i, j, k, + 2 more
count global inliers
keep best
Three sectors separated by 120Β° are guaranteed to span the ellipse without collinearity β a natural generalisation of the three-point circle condition. The best-scoring triplet is refined using all inliers with a global least-squares step.
Eccentricity Constraint
Ellipses with eccentricity close to 1 (nearly degenerate) or 0 (circles) can be filtered using:
VisionLab exposes eccentricity_min and eccentricity_max parameters. Set eccentricity_max = 0.3 to reject near-circles; set eccentricity_min = 0.1 to reject near-degenerate fits.
Accuracy vs Circle Fitting
| Algorithm | Min points | Typical accuracy | Use case |
|---|---|---|---|
| Circle fitting | 3 | Β±0.1 px | Symmetric holes, calibration targets |
| Ellipse fitting | 5 | Β±0.3 px | Perspective-distorted circles, oval parts |
Ellipse fitting is inherently less accurate because it has more degrees of freedom (5 vs 3) for the same edge point count. If the part is truly circular, always prefer FitCircle.
When to Use Ellipse vs Circle
- Use FitCircle if the camera is mounted perpendicular to the part surface and the feature is nominally circular.
- Use FitEllipse if there is significant perspective tilt (> 15Β°), or if the feature is geometrically elliptical.