We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 6
wane RANSAG - Wikipada, he ree enqyclopedia
RANSAC
From Wikipedia, the free encyclopedia
RANSAC is an abbreviation for "RANdom SAmple Consensus": It is an iterative method to estimate parameters
ofa mathematical model from a set of observed data which contains outliers. It is a non-deterministic algorithm in
‘the sense that it produces a reasonable result only with a certain probability, with this probability increasing as more.
iterations are allowed. The algorithm was first published by Fischler and Bolles at SRI Intemational in 1981.
A basie assumption is that the data consists of "inlets", ie., data whose distribution can be explained by some set of
model parameters, though may be subject to noise, and "outliers" which are data that do not fit the model, The
outliers can come, e.g., ffom extreme values of the noise or ffom erroneous measurements or incorrect hypotheses
about the interpretation of data, RANSAC ako assumes that, given a (usually small) set of iniers, there exists a
procedure which can estimate the parameters of'a model that optimally explains or fits this data.
Contents
1 Example
= 2 Overview
= 3 The algorithm,
= 4 The parameters
= 5 Advantages and disadvantages
= 6 Applications
= 7 References
= 8 External links
Example
A simple example is fiting of a line in two dimensions to a set of observations. Assuming that this set contains both.
inliers, ie., points which approximately can be fitted to a line, and outliers, points which cannot be fitted to this line,
a simple least squares method for line fitting will in general produce a line with a bad fit to the infers. The reason is
that itis optimally fited to all points, including the outliers. RANSAC, on the other hand, can produce a model
which is only computed fiom the inliers, provided that the probability of choosing only inliers in the selection of data
is sufficiently high. There is no guarantee for this situation, however, and there are a number of algorithm parameters
which must be carefully chosen to keep the level of probability reasonably high.
‘enhipedia.orgidK/RANSAC Wewane RANSAG - Wikipada, he ree enqyclopedia
A data set with many outliers for which a line has to Fitted line with RANSAC; outliers have no influence
be fitted. on the result
Overview
The input to the RANSAC algorithm is a set of observed data values, a parameterized model which can explain or
be fitted to the observations, and some confidence parameters.
RANSAC achieves its goal by iteratively selecting a random subset of the original data, These data are
hypothetical inliers and this hypothesis is then tested as follows:
1. A models fitted to the sample of hypothetical ins, i. all fee parameters of the model are fitted from this
sample,
2. Allother data are then tested against the fitted model and, those points that ft the estimated model well are
considered as part of the consensus set.
3. The estimated model is reasonably good if sufficiently many points have been classified as part of the
consensus set.
4. Afterwards, the model may be improved by reestimating it using all members of the consensus set.
This procedure is repeated a fixed number of times, each time producing either a model which is rejected because
too few points are part of the consensus set, or a refined model together with a corresponding consensus set size.
Inthe latter case, we keep the refined model ifits consensus set is larger than the previously saved model.
The algorithm
Someone's favorite RANSAC hack (the original method instead picks the model with the largest consensus set), in
pseudocode, works as follows:
‘enhipedia.orgidK/RANSAC 28wane RANSAG - Wikipada, he ree enqyclopedia
model — 2 model that can be fitted to data
n- the minimum nurber of data required to fit the model
k- the number of iterations performed by the algorithm
te threshold value for determining when a datum fite a model
d= the number of close data values required to assert that a model fits well to data
ueput:
best_odel - model parameters which best fit the data (or nil if ne good model is found)
best_consensus_set ~ data pointe from which this model hag been estimated
besterror - the exror of this model relative to the data
hterations
oest_model
pul
consensus_set := maybe_inliers
fest consensus set := ail
best_eeror := Infinity
inde itecations < k
(rv maybe inliers t= n randomly selected values from data
| maybe model := model pazaneters fitted to maybe iniiers
for every point in data not in maybe _ialiers
Af point fits maybe_nodel with an error smaller than t
add point te consensus_set
Af the number of elements in consensus set is > a
(this implies that we may have found a good models
now test how good it 1s)
this_model := model pazaneters fitted co all points in consensus_ses
this error i= a measure of how well this_mode! fite these pointe
§ The Line above contains the bug. This error should be replaced by a score that is either
Af this_ersor < beats
(we have found a model which
keep it until a better one is found)
best_model := this model
Ehis_error
is better than any of the previo
feturn best_nodel, best_consensus_set, best_error
Waming: Note that the above algorithm is not RANSAC according to Fischler and Bolles. A proper
implementation should instead pick the model with the largest consensus set. A possible improvement is to instead
use a robust error norm score.
Possible variants of the RANSAC algorithm include
= Break the main loop ifa sufficiently good model has been found, that is, one with sufficiently small error. May
save some computation time at the expense of an additional parameter.
* Compute chis_error directly frommaybe_mode1 without re-estimating a model ffom the consensus set.
May save some time at the expense of comparing errors related to models which are estimated ffom a small
number of points and therefore more sensitive to noise.
‘er hipedia.orgiviK/RANSAC 36wane RANSAG - Wikipada, he ree enqyclopedia
The parameters
The vahies of parameters ¢ and d have to be determined fom specific requirements related to the application and
the data set, possibly based on experimental evaluation, The parameter k (the number of iterations), however, can
be determined fiom a theoretical result. Let p be the probability that the RANSAC algorithm in some iteration
selects only infers from the input data set when it chooses the m points from which the model parameters are
estimated. When this happens, the resulting model i likely to be useful so p gives the probability that the algorithm
produces a usefil result. Let w be the probability of choosing an inlier each time a single point is selected, that i,
w= number of inlers in data / number of points in data
A.common case is that 1) is not well known beforehand, but some rough value can be given. Assuming that the n
points needed for estimating a model are selected independently, 4" is the probability that all points are infers
and | — 1p is the probability that at least one of the n points is an outlier, a case which implies that a bad model
willbe estimated ffom this point set. That probability to the power of k is the probabilty that the algorithm never
selects a set of n points which all are inliers and this must be the same as | — pp. Consequently,
1-p=(1-w")*
which, after taking the logarithm of both sides, leads to
This result assumes that the » data points are selected independently, that is, a point which has been selected once
is replaced and can be selected again in the same iteration. This is often not a reasonable approach and the derived
value for k should be taken as an upper limit in the case that the points are selected without replacement. For
example, in the case of finding a line which fits the data set ilustrated in the above figure, the RANSAC algorithm
typically chooses 2 points in each iteration and computes maybe_mode1 as the line between the points and itis then
critical that the two points are distinct
To gain additional confidence, the standard deviation or muiiples thereof can be added to f:. The standard
deviation of fis defined as
/T—wr
we
SD(k) =
Advantages and disadvantages
An advantage of RANSAC ‘és its ability to do robust estimation of the model parameters, i., it can estimate the
parameters with a high degree of accuracy even when a significant number of outliers are present in the data set. A
disadvantage of RANSAC is that there is no upper bound on the time it takes to compute these parameters. When
the number of iterations computed is limited the solution obtained may not be optimal, and it may not even be one
that fits the data in a good way. In this way RANSAC offers a trade-off by computing a greater number of
iterations the probability of a reasonable model being produced is increased. Moreover, RANSAC is not always
able to find the optimal set even for moderately contaminated sets and it usually performs badly when the number of
‘enhipedia.orgidK/RANSAC 46wa RANSAC - Wied, be fee eneytopedia
inliers is ess than 50%. Optimal RANSAC was proposed to handle both these problems and is capable of finding
the optimal set for heavily contaminated sets, even for an inlier ratio under 5%, Another disadvantage of RANSAC
is that it requires the setting of problem- specific thresholds
RANSAC can only estimate one model for a particular data set. As for any one-model approach when two (or
more) model instances exist, RANSAC may fal to find either one, The Hough transform is one alternative robust
estimation technique that may be usefill when more than one model instance is present. Another approach for muti
model fitting is known as PEARL, which combines model sampling ffom data points as in RANSAC with iterative
re-estimation ofinliers and the muli-model fiting being formated as an optimization problem with a global energy
functional describing the quality of the overall sokution
Applications
The RANSAC algorithm is offen used in computer vision, e.g., to sinukaneously solve the correspondence
problem and estimate the fimdamental matrix related to a pair of stereo cameras.
References
= Martin A. Fischler and Robert C. Bolks (June 1981). "Random Sample Consensus: A Paradigm for Model
Fitting with Applications to Image Analysis and Automated Cartography" (httpz/www.tu-
chemnitz.de/etivproau/paperdb/downloadfischler8 1 pdf). Comm. of the ACM 24 (
doi 0.1145/358669.358692 (hitp://dx.doiorg/10.1145%2F358669.358692).
= David A. Forsyth and Jean Ponce (2003). Computer Vision, a modern approach. Prentice Hall. ISBN 0-
13-085198-1
= Richard Hartley and Andrew Zisserman (2003). Multiple View Geometry in Computer Vision (2nd ed.).
Cambridge University Press.
= PHS. Torr and D.W. Murray (1997). "The Development and Comparison of Robust Methods for
Estimating the Fundamental Matrix", International Journal of Computer Vision 24 (3): 271-300.
doi:10.1023/A:1007927408552 (hitp://dx.doi org/10.1023%2FA%3A 1007927408552).
* Ondrej Chum (2005). "Two- View Geometry Estimation by Random Sample and Consensus"
(http://cmp felk.cvut.cz!~chunyTeze/Chum-PhD.pdi). PaD Thesis
= Sunglok Choi, Taemin Kim, and Wonpil Yu (2009). "Performance Evaluation of RANSAC Family"
(httpAvww.bmva.org/bmve/2009/Papers/Paper355/Paper355.pdi). In Proceedings of the British
Machine Vision Conference (BMVC).
= Anders Hast, Johan Nysjé, Andrea Marchetti (2013). "Optimal RANSAC ~ Towards a Repeatable
Algorithm for Finding the Optimal Set" (http2/www.cb.uu.se/~ah/articles/A53-fullpdf). Journal of WSCG.
21(1):21-30,
= Hossam Isack, Yuri Boykov (2012). "Energy-based Geometric Multi Model Fitting"
(http:/Awww.esd.uwo.cal~yuriPapers/tt735,pdf). International Journal of Computer Vision. 97(2): 1:
23-147.
External links
= RANSAC Toolbox for MATLAB (hitp:/'vision.ece.uesb.edu~zuliani/Code/Code.htmi). A research (and
‘enhipedia.orgidK/RANSAC 56wa RANSAC - Wied, be fee eneytopedia
didactic) oriented toolbox to explore the RANSAC algorithm in MATLAB. It is highly configurable and
contains the routines to solve a few relevant estimation problems.
= ransac.m (http /wvww.csse.uwa.edu.aw~pk/research’matlabfns/) The RANSAC algorithm in MATLAB.
= optimalRansac.m (hitp?//www.cb.tmse/~aht/code. html) The Optimal RANSAC algorithm in MATLAB.
= Implementation in C++ (httpziwww.mrptorg/RANSAC_C++_examples) as a generic template.
= RANSAC for Dummies
(httpz/vision.ece.uesb edu/~zuliani/Researcl/RANSAC/docs/RANSAC4Dummies.pdf) A simple tutorial
with many examples that uses the RANSAC Toolbox for MATLAB.
= Source code for RANSAC in (hitp//www.csse.uwa.edu.aw~pk/Research/MatlabFns/#robust) MATLAB
= Ransac,js (hitp/Avww. visual experiments.com/demo/ransac.j/) Javascript implementation with visual
representation of the iterations (Example of 2D Line fiting).
= ransae.py (hitp//www.scipy.org/Cookbook/RANSAC) Python implementation for Seipy/Numpy.
= GML RANSAC Matlab Toolbox
(http://graphics.cs.msu,rwen/science/research/machineleaming/ransactoolbox) — a set of MATLAB scripts,
implementing RANSAC algorithm family
Retrieved from "http//en. wikipedia. org/w/index. php tile-RANSAC&oldid=583866975"
Categories: Geometry in computer vision | Statistical algorithms | Statistical outliers | Robust statistics
SRI International
= This page was last modified on 30 November 2013 at 03:58.
= Text is available under the Creative Commons Attribution-ShareAlike License; additional terms may apply.
By using this site, you agree to the Terms of Use and Privacy Policy.
Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc., a non-profit organization.
‘enhipedia.orgidK/RANSAC