RANSAC

RANSAC (Random Sample Consensus) is a robust model-fitting algorithm that recovers the parameters of a geometric model from data contaminated by a large fraction of outliers. It is the dominant outlier-rejection scheme in computer vision and underlies robust homography, fundamental-matrix, and pose estimation inside every feature-based pipeline.

Given a data set and a model class whose fit requires at least data points, RANSAC proceeds iteratively:

  1. Sample. Randomly select a minimal subset of points from .
  2. Fit. Compute the candidate model from this minimal sample.
  3. Score. Count the inliers: points in whose residual under is below a threshold .
  4. Keep. If the inlier count exceeds the best so far, store .
  5. Repeat for iterations, then refit the final on all inliers.

The number of iterations needed to find at least one outlier-free sample with probability is

where is the expected outlier ratio and is the minimal sample size. RANSAC handles outlier rates above 50% gracefully — the bottleneck is the minimal sample size , not the outlier fraction.

Intuition

Standard least-squares fitting averages over all data points. A single gross outlier can pull the fit arbitrarily far from the true model — the breakdown point of least squares is essentially zero. In feature-based vision, “outliers” are the norm: descriptor-based matches mistake repeated textures, moving objects, and local image ambiguity for correct correspondences.

RANSAC sidesteps the problem by gambling on small subsets. Most small random samples contain at least one outlier and produce garbage models, but occasionally a sample lands on genuine inliers, producing a model that many other inliers also support. That model wins the consensus vote. The trick is that we only need to be lucky once in tries, and the success probability compounds favorably.

The key parameters — minimal sample size , threshold , and iterations — are all determined by the geometry: by the degrees of freedom of the model, by the expected measurement noise, and by the target success probability and the worst-case outlier ratio.

Properties

Algorithm Parameters

(Minimal sample size) is the smallest number of points that determines the model uniquely.

For a 2D line, ; a homography, ; an essential matrix via the 5-point algorithm, ; a fundamental matrix via the 8-point algorithm, ; a 3D rigid transform via P3P, . Smaller dramatically reduces the iterations needed.

(Inlier threshold) is chosen so that inliers agree with the model to within the expected measurement noise.

A common rule: set to , where is the per-measurement noise (e.g., 1-2 pixels for SIFT matches) and is the 95th-percentile chi-square value for residual degrees of freedom. For 2D pixel error with two DoF, .

(Iteration count) is set from the target success probability and the assumed outlier ratio .

For , , and , . For (homography) with the same , . RANSAC is cheap when the minimal sample is small.

Performance Characteristics

(Adaptive iteration count) The outlier ratio is rarely known in advance; RANSAC can update online as better consensuses are found.

Start with (or a large ceiling). Each time a better model is found, re-estimate as the fraction of outliers in the current best fit, and recompute . Exit once the iteration counter reaches the new .

(Graceful degradation with outliers) RANSAC works well up to very high outlier rates but requires more iterations.

At , , , the required explodes past . Modern feature-matching pipelines use degeneracy-aware or guided-sampling variants (PROSAC, LO-RANSAC) to reduce this bound.

(Minimal-sample bias) Fitting on only points yields a noisy model; the final refit on all inliers is essential.

The initial minimal-sample fit is used only to score inliers. Once the best consensus is found, the model is re-estimated from all its inliers by least squares — this is where the numerical quality of the final fit comes from.

Variants and Extensions

(MSAC / MLESAC) Replace the 0/1 inlier count with a bounded residual cost to make the inlier threshold less sharp.

MSAC scores each point as , turning the inlier count into a clipped squared-error sum. MLESAC models outliers as uniform and inliers as Gaussian, giving a probabilistic likelihood to maximize. Both outperform vanilla RANSAC when the threshold is hard to tune.

(PROSAC) Uses match quality (e.g., SIFT ratio-test score) to sample better matches first.

Draws minimal samples preferentially from the top-ranked correspondences, which converges faster in practice while retaining the RANSAC guarantees in the worst case.

(Locally Optimized RANSAC — LO-RANSAC) After finding a good consensus, refits on the inliers and iterates locally.

Adds a local refinement step inside the RANSAC loop that tightens the model before moving on, reducing the total iteration count.

Application Patterns

(Robust homography for mosaicing) point correspondences; inlier threshold px.

Used to align overlapping images for panoramas. The 4-point minimal sample makes this very fast.

(Robust essential / fundamental matrix) (calibrated) or (uncalibrated); inlier threshold based on epipolar distance.

A match is an inlier iff the point-to-line distance from to (and its symmetric counterpart) is below . This is the outlier-rejection step inside every SfM pipeline.

(Robust pose estimation — PnP + RANSAC) (P3P) 2D-3D correspondences; inlier threshold on reprojection error.

Used when registering a new image to an existing reconstruction. Outliers include descriptor mismatches and points on moving objects.

Examples

See Also