The RANdom Sample And Consensus (RANSAC) algorithm is an iterative, nondeterministic algorithm for estimating model parameters in the presence of outliers (FB81). It is based on randomly selecting the elements that generate the model.
RANSAC and all its variants can be viewed as algorithms that iteratively alternate between two phases: hypothesis generation (hypothesis generation) and hypothesis evaluation (hypothesis evaluation).
In brief, the algorithm randomly selects samples from
the
input samples
, with
large enough to
estimate a model (the hypothesis).
Once a hypothesis has been obtained, the algorithm counts how many of the
elements of
are sufficiently close to it
to be considered compatible.
A sample
is classified as an inlier or
outlier with respect to the hypothesis under consideration if its
distance from the model
is, respectively, less than or greater
than a threshold
, which normally depends on the problem.
The threshold poses a problem in practical settings where additive
error is Gaussian and therefore has infinite support. In this case, a
probability of classifying samples as inliers must nevertheless be
specified to determine a threshold
.
All samples that satisfy the hypothesis are called inliers with respect to that hypothesis.
The set of these inliers is the consensus set associated
with the hypothesis
:
| (4.140) |
Among all the randomly generated models, the one that maximizes a given metric is selected; in classical RANSAC, this metric is the cardinality of the consensus set.
One problem is determining how many hypotheses to generate to obtain a good probability of finding the correct model.
There is a statistical relationship between the number of iterations and the
probability
that at least one of the generated hypotheses consists
exclusively of inliers. The number of trials
must satisfy
that is,
| (4.141) |
where is the probability that a single random sample consists
exclusively of inliers.
A common approximation for is
4.3
and therefore
| (4.142) |
where is the a priori probability of selecting an outlier and
is the number of elements required to define the model.
Assuming the outlier fraction is known, the expected number of
inliers in the dataset is
Normally, is set to the minimum number of elements required to
define the model. If a larger value is chosen, the model must be
estimated by numerical regression on the provided constraints. This
strategy can be useful when observation noise is high, but it
increases the risk of including outliers in the sample.