Ellipse Fitting

The ellipse is one more model of the RANSAC family, as the circle (Circle Fitting): EllipseProblem is the MinimalSolveProblem of an Ellipse{Float64} through one image's points, with VisualGeometryToolkitCore's minimal solver Ellipse5pt (the conic through five points, kept when it is a real ellipse), the point-on-ellipse constraint constraint_with_jacobians(e, x) with g = (x − c)ᵀ Q (x − c) − 1, and the chart EllipseManifold (the centre and the log shape). The residual is the family's Sampson distance g/‖∂g/∂x‖, the geometric distance to first order, in pixels, and it scores; the refit rows every local optimization descends are the points' ORTHOGONAL distances to the ellipse (the distance to the foot point), the maximum-likelihood objective under isotropic Gaussian noise on the points, which the Sampson distance approximates only to first order (on a high-curvature ellipse the Sampson least squares is measurably the worse estimator). find_ellipse is its RANSAC, with the robustified LM (Triggs) as its local optimization; refine_ellipse refines a given ellipse — with optimization_strategy = nothing, the orthogonal-distance least squares, its covariance s²·solver_covariance(problem, e, eachindex(points)).

VisualGeometryToolkitEstimation.EllipseProblem — Type
EllipseProblem

The RANSAC problem of a 2D ellipse through points: the MinimalSolveProblem whose model is an Ellipse{Float64} (VisualGeometryToolkitCore's). Minimal sample 5 (VisualGeometryToolkitCore's Ellipse5pt), codimension 1 (the Sampson distance of (x − c)ᵀ Q (x − c) − 1, in the points' units), a 5-dof chart (VisualGeometryToolkitCore's EllipseManifold: the centre and the log shape). Build it with EllipseProblem(points); the public estimator is find_ellipse.

source
VisualGeometryToolkitEstimation.find_ellipse — Function
find_ellipse(points; scoring,
    max_trials, min_trials,
    local_optimization_strategy, config = nothing)

Robust estimation of a 2D ellipse through points (a contour, edge points) by RANSAC on the EllipseProblem: 5-point samples (VisualGeometryToolkitCore's Ellipse5pt, the conic through them when it is an ellipse), MSAC scoring of the Sampson distance of (x − c)ᵀ Q (x − c) − 1 — the geometric distance to the ellipse to first order — and, as local optimization, the robustified LM (Triggs) on the centre and log shape of the points' ORTHOGONAL distances to the ellipse (the problem's refit rows): one Levenberg–Marquardt solve from the hypothesis over all the points under the Welsch loss at efficiency_constant·ŝ, ŝ the Student-t scale of the hypothesis's Sampson errors. Every default is configs/default.toml's ([ransac], [pipelines.ellipse]); a keyword overrides. The circle's counterpart is find_circle.

Returns a RansacEstimate (its estimate an Ellipse{Float64}), the :no_model result (iterations 0) for fewer than 5 points. iterations(result) is the number of trials (hypotheses drawn); test found_model(result) before reading the model (see RansacEstimate). From a given ellipse, the same step without the sampling: refine_ellipse.

Arguments

  • points: 2D points, AbstractVector of StaticVector{2} (Point2{Float64} storage canonicalized internally), plain: unit isotropic noise.
  • scoring: the scorer, its width in PIXELS (the points' unit), as find_homography; default [pipelines.ellipse] scoring.
  • workspace: as find_homography, built with RansacWorkspace([T,] EllipseProblem, n_data).
  • local_optimization_strategy: default [pipelines.ellipse] local_optimization_strategy; any other strategy as find_homography.
  • the other keywords as find_homography.
source
VisualGeometryToolkitEstimation.refine_ellipse — Function
refine_ellipse(ellipse, points; optimization_strategy, scale | width, workspace = nothing)
    -> FitResult{M, RefineMetadata}

The 2D ellipse through points refined from the given ellipse. Every strategy descends the problem's refit rows, the points' ORTHOGONAL distances to the ellipse (the distance to the foot point, the closest boundary point; codimension 1), on the log-shape chart (VisualGeometryToolkitCore's EllipseManifold, smooth at a circle): the keywords, the result and the refusals are those of every refine_*, documented on refine_homography (default strategy: [refine.ellipse] optimization_strategy). Fewer than 5 points: the guess back unrefined, record (ReturnCode.InitialFailure, NoRule) (retcode_symbol:degenerate).

The maximum-likelihood ellipse under isotropic Gaussian noise on outlier-free points is refine_ellipse(direct_ellipse(points), points; optimization_strategy = nothing): least squares over every point. Its covariance is the one model covariance, s²·solver_covariance(EllipseProblem(points), e, eachindex(points)) (in ambient_coordinates(e)), s² the residual variance.

source