Algorithm Search⌘K

Problemcore

Robust model fitting

Also called outlier-robust estimation, robust geometric estimation.

Fit a model such as a homography or an essential matrix to data that contain a large fraction of outliers, which ordinary least squares cannot tolerate.

Robust model fitting is the problem of finding the parameters of a model, such as a line, a plane, a homography or an essential matrix, from measurements of which a large part are wrong. The wrong measurements, the outliers, do not follow the model at all, and they can be anywhere. In computer vision they come mostly from wrong matches between two images, and it is common that half of the matches or more are wrong. Ordinary least squares cannot handle this: a single outlier that is far enough away can move the fit as far as it likes. A robust method must give the outliers a bounded influence, and usually it must also find out which measurements they are. The best known methods, such as RANSAC, fit the model to many small random samples and keep the model that most of the data agree with. Finding the model with the most agreeing data exactly is NP-hard.

In plain words

Suppose you want to draw the best straight line through a set of dots. If all dots are close to one line, the usual method works: it makes the sum of the squared distances small. Now add a few dots that are far away and have nothing to do with the line. The usual method tries to please them too, and the line tilts toward them. One dot that is far enough can pull the line anywhere.

A robust method asks a different question: which line passes close to the largest number of dots? The far dots then do not count, because no good line passes near them. The hard part is to find that line without trying every possible line.

Definition

The input is data D={x1,…,xn}D = \{x_1, \ldots, x_n\}, a set Θ\Theta of model parameters and a residual r(θ,x)≥0r(\theta, x) \ge 0 that says how far xx is from the model θ\theta. Some unknown subset I⊆DI \subseteq D, the inliers, follows a true model θ0\theta_0 up to noise, and the other items are outliers with no structure. The main forms of the goal are:

  • Maximum consensus. With an inlier threshold TT, find θ\theta that maximizes Ψ(θ)=∣{i:r(θ,xi)≤T}∣\Psi(\theta) = |\{i : r(\theta, x_i) \le T\}|, the number of inliers.
  • M-estimation with a bounded loss. Find θ\theta that minimizes ∑iρ(r(θ,xi))\sum_i \rho(r(\theta, x_i)) for a loss ρ\rho that grows like r2r^2 near 0 and is bounded, such as min⁡(r2,T2)\min(r^2, T^2). Maximum consensus is the case where ρ\rho is 0 up to TT and 1 after.
  • Least median of squares. Find θ\theta that minimizes the median of r(θ,xi)2r(\theta, x_i)^2. It needs no threshold.

The breakdown point of an estimator is the smallest fraction of the data that, when replaced by arbitrary values, can move the estimate arbitrarily far. Least squares has breakdown point 1/n1/n. Least median of squares has breakdown point close to 1/21/2 (Rousseeuw, 1984), and maximum consensus can work with more than half outliers when the outliers have no common structure.

Variants

  • Known or unknown noise level. Maximum consensus and the truncated quadratic need a threshold TT, which comes from the noise level. MAGSAC needs only an upper bound on it, and least median of squares needs none.
  • One model or several. When the data contain several structures, such as several planes, the problem is to find all of them and their number. J-linkage and the Hough transform solve this form.
  • Linear and non-linear models. For a line or a plane the residual is linear in θ\theta. For a fundamental matrix or a camera pose it is not, which makes exact methods harder.
  • Prior information. Matches often come with a quality score, which PROSAC uses to sample good matches first.
  • Time limits. In real-time systems the time is fixed in advance, as in preemptive RANSAC.

Examples

Take the 10 points (x,2x+1)(x, 2x + 1) for x=0,1,…,9x = 0, 1, \ldots, 9, which lie exactly on the line y=2x+1y = 2x + 1, and the 3 outliers (1,20)(1, 20), (5,−10)(5, -10) and (8,40)(8, 40). The least squares line of the 13 points is y=2.091x+2.048y = 2.091x + 2.048. All 10 inliers are 1.05 to 1.87 below it, so with the threshold T=0.5T = 0.5 on the vertical distance it has no inliers at all. Move the outlier (8,40)(8, 40) to (8,400)(8, 400), and the least squares line becomes y=13.71x−23.00y = 13.71x - 23.00: one point moves the fit as far as it likes.

Maximum consensus with T=0.5T = 0.5 gives y=2x+1y = 2x + 1 with 10 inliers, and no line has more. Moving an outlier does not change this answer, as long as the outlier does not land within TT of the line. RANSAC finds it by drawing pairs of points. A pair of two inliers gives the true line, and with 10/1310/13 of the points inliers the iteration bound asks for ⌈log⁡0.01/log⁡(1−(10/13)2)⌉=6\lceil \log 0.01 / \log(1 - (10/13)^2) \rceil = 6 pairs to find such a pair with probability 0.99.

Known algorithms

algorithm goal type
RANSAC maximum consensus random sampling, no optimality guarantee
MSAC truncated quadratic RANSAC loop with a different score
MLESAC likelihood of a mixture of inliers and outliers RANSAC loop
LO-RANSAC maximum consensus or truncated quadratic RANSAC loop with local refinement
PROSAC maximum consensus sampling guided by match quality
Preemptive RANSAC additive score fixed time budget
MAGSAC loss marginalized over the noise scale RANSAC loop, no threshold
Least median of squares median squared residual random sampling in practice
M-estimators by IRLS robust loss local descent from a start model
Hough transform votes in a parameter grid exhaustive over the grid
J-linkage several models random hypotheses and clustering

Exact methods for maximum consensus, such as branch and bound and tree search, also exist. They find the best model with a guarantee, but their time grows exponentially in the dimension or in the number of outliers.

AlgorithmTimeSpacePropertiesCode
J-linkageΘ(n^3 M) worstΘ(n M) extrarandomizednot exactofflineiterative1 language
LO-RANSACΘ(k n) worst · average · bestΘ(n) extrarandomizednot exactofflineiterative1 language
MAGSACΘ(k n) worst · average · bestΘ(n) extrarandomizednot exactofflineiterative1 language
MLESACΘ(k m n) worst · average · bestΘ(n) extrarandomizednot exactofflineiterative1 language
MSACΘ(k n) worst · average · bestΘ(n) extrarandomizednot exactofflineiterative1 language
Preemptive RANSACO(M (c + 2B) + M log M + N) worst · average · bestΘ(M + N) extrarandomizednot exactofflineiterative1 language
PROSACΘ(k n + n²) worst · average · bestΘ(n) extrarandomizednot exactofflineiterative1 language
RANSACΘ(k n) worst · average · bestΘ(n) extrarandomizednot exactofflineiterative1 language

Bounds

Chin, Cai and Neumann (2018) studied maximum consensus for linear models, with residuals ∣ai⊤θ−bi∣|a_i^\top \theta - b_i| and θ∈Rd\theta \in \mathbb{R}^d. They proved these results:

  • The decision version is NP-complete (Theorem 1), by a reduction from the k-SLAB problem. So no algorithm solves maximum consensus in time polynomial in nn and dd, unless P = NP.
  • The problem is W[1]-hard in the dimension dd. So no algorithm runs in time f(d)⋅poly(n)f(d) \cdot \mathrm{poly}(n) for any function ff, unless FPT = W[1].
  • The problem is APX-hard, so it has no polynomial-time approximation scheme, unless P = NP.
  • The problem is fixed-parameter tractable in the number of outliers oo and the dimension dd: it can be solved in time O(d o) poly(n,d)O(d^{\,o})\,\mathrm{poly}(n, d).

Random sampling has no worst-case guarantee, but its expected cost is simple. If a fraction ww of the items are inliers and a sample of ss inliers gives a good model, about w−sw^{-s} samples are needed on average, and the iteration bound gives the number of samples for a confidence pp. Each sample costs Θ(n)\Theta(n) to score, so the time is Θ(nlog⁡(1−p)/log⁡(1−ws))\Theta(n \log(1-p)/\log(1 - w^s)) under these assumptions.

Reductions

  • Maximum consensus and k-SLAB. For linear models, maximum consensus with threshold TT is the same as finding a slab of width 2T2T that contains the most points, and the minimal width of a slab that holds kk points is the decision problem k-SLAB. Chin, Cai and Neumann use this to prove NP-hardness.
  • Least median of squares and slabs. Least median of squares asks for the thinnest slab that contains half the points, the case k=n/2k = n/2 of the same geometry.
  • From robust fitting to least squares. Once the inliers are known, the problem becomes an ordinary least squares problem on the inliers. This is why most robust methods end with a refit.
  • M-estimation to weighted least squares. A robust loss can be minimized by iteratively reweighted least squares, a sequence of weighted least squares problems.

Applications

References

  1. Martin A. Fischler and Robert C. Bolles, Random sample consensus: a paradigm for model fitting with applications to image analysis and automated cartography, Communications of the ACM 24(6), 1981, 381-395, The statement of the fitting problem with gross errors, the argument against least squares and the RANSAC paradigm
  2. Tat-Jun Chin, Zhipeng Cai and Frank Neumann, Robust fitting in computer vision: easy or hard?, European Conference on Computer Vision (ECCV 2018), arXiv:1802.06464, Section 1.1 (summary of results), Section 2 (Theorem 1, NP-completeness of the decision version of maximum consensus by reduction from k-SLAB), Section 3 (W[1]-hardness in the dimension and the FPT algorithm in the number of outliers) and Section 4 (APX-hardness)
  3. Peter J. Rousseeuw, Least median of squares regression, Journal of the American Statistical Association 79(388), 1984, 871-880, The breakdown point of least squares and the 50 percent breakdown point of least median of squares
  4. Richard Hartley and Andrew Zisserman, Multiple View Geometry in Computer Vision, second edition, Cambridge University Press, 2004, Section 4.7, Robust estimation (RANSAC, the distance threshold, the number of samples and the robust cost functions)

Where this leads

About this page

The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.

LadderLevelWhat the next level needs
Human proofH0 no proof
  • add a proof in proofs/ (06.5)
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW2 basic
  • a contract.yaml