Photogrammetry & Robotics Lab
RANSAC –
Random Sample Consensus
Cyrill Stachniss
1
Notre-Dame
2
Notre-Dame: SIFT All Matches
[Image courtesy: Barulic] 3
Notre-Dame: SIFT Inliers
[Image courtesy: Barulic] 4
Fitting Example: Ground Plane
From Aerial Laser Scans
5
Fitting Example: Ground Plane
From Aerial Laser Scans
6
RANSAC
RANdom SAmple Consensus
[Fischler & Bolles 81]
7
RANdom SAmple Consensus
§ Trial-and-error approach
§ Approach to deal with high fractions of
outliers in the data
§ Key idea: Find the best partition of
points in inlier set and outlier and
estimate the model from the inlier set
§ Standard approach for fitting in the
presence of outliers
8
RANSAC Algorithm
1. Sample the number of data points
required to fit the model
2. Compute model parameters using
the sampled data points
3. Score by the fraction of inliers within
a preset threshold of the model
Repeat 1-3 until the best model is
found with high confidence
9
RANSAC
1. Sample the number of data points required to fit
the model
2. Compute model parameters using the samples
3. Score by the fraction of inliers within a preset
threshold of the model
Repeat 1-3 until the best model is found
Illustration by Savarese 10
RANSAC
Line fitting example
1. Sample the number of data points required to fit
the model (here: 2 points)
2. Compute model parameters using the samples
3. Score by the fraction of inliers within a preset
threshold of the model
Repeat 1-3 until the best model is found
Illustration by Savarese 11
RANSAC
Line fitting example
1. Sample the number of data points required to fit
the model (here: 2 points)
2. Compute model parameters using the samples
3. Score by the fraction of inliers within a preset
threshold of the model
Repeat 1-3 until the best model is found
Illustration by Savarese 12
RANSAC
Line fitting example
#inliers: 4
δ
1. Sample the number of data points required to fit
the model (here: 2 points)
2. Compute model parameters using the samples
3. Score by the fraction of inliers within a preset
threshold of the model
Repeat 1-3 until the best model is found
Illustration by Savarese 13
RANSAC
Line fitting example
#inliers: 12
δ
1. Sample the number of data points required to fit
the model (here: 2 points)
2. Compute model parameters using the samples
3. Score by the fraction of inliers within a preset
threshold of the model
Repeat 1-3 until the best model is found
Illustration by Savarese 14
RANSAC Example: Translation
extracted features correspondences
Slide courtesy: Snavely/Efros 15
RANSAC Example: Translation
select random match
Slide courtesy: Snavely/Efros 16
RANSAC Example: Translation
count inliers (0)
Slide courtesy: Snavely/Efros 17
RANSAC Example: Translation
select another random match
Slide courtesy: Snavely/Efros 18
RANSAC Example: Translation
count inliers (4)
Slide courtesy: Snavely/Efros 19
RANSAC Example: Translation
Repeat N times: select match, count inliers
Slide courtesy: Snavely/Efros 20
RANSAC Example: Translation
Return translation with the most inliers
Slide courtesy: Snavely/Efros 21
Feature-Based Alignment
22
Feature-Based Alignment
§ Extract features
23
Feature-Based Alignment
§ Extract features
§ Compute putative matches
24
Feature-Based Alignment
§ Extract features
§ Compute putative matches
§ Loop:
§ Hypothesize transformation T
§ Verify transformation (search for
other matches consistent with T)
25
Feature-Based Alignment
§ Extract features
§ Compute putative matches
§ Loop:
§ Hypothesize transformation T
§ Verify transformation (search for
other matches consistent with T)
26
Feature-Based Alignment
§ Extract features
§ Compute putative matches
§ Loop:
§ Hypothesize transformation T
§ Verify transformation (search for
other matches consistent with T)
27
Notre-Dame
28
Notre-Dame: Harris Keypoints
29
Notre-Dame: Keypoint Matches
30
Notre-Dame: After RANSAC
31
How Often Do We Need to Try?
32
How to Choose the Parameters?
§ Number of sampled points s
(minimum number needed to fit the model)
§ Outlier ratio e (e=#outliers/#datapoints)
How many trials to we need?
33
How to Choose the Parameters?
§ Number of sampled points s
(minimum number needed to fit the model)
§ Outlier ratio e (e=#outliers/#datapoints)
§ Number of trials T
Choose T so that, with probability p, at least
one random sample set is free from outliers
34
How to Choose the Parameters?
§ Number of sampled points s
(minimum number needed to fit the model)
§ Outlier ratio e (e=#outliers/#datapoints)
§ Number of trials T
Choose T so that, with probability p, at least
one random sample set is free from outliers
p(fail once) = do not select only inliers
35
How to Choose the Parameters?
§ Number of sampled points s
(minimum number needed to fit the model)
§ Outlier ratio e (e=#outliers/#datapoints)
§ Number of trials T
Choose T so that, with probability p, at least
one random sample set is free from outliers
p(fail T times) = select at least one
outlier in all T trials
36
How to Choose the Parameters?
§ Number of sampled points s
(minimum number needed to fit the model)
§ Outlier ratio e (e=#outliers/#datapoints)
§ Number of trials T
Choose T so that, with probability p, at least
one random sample set is free from outliers
37
How to Choose the Parameters?
§ Number of sampled points s
(minimum number needed to fit the model)
§ Outlier ratio e (e=#outliers/#datapoints)
§ Number of trials T
Choose T so that, with probability p, at least
one random sample set is free from outliers
38
Required Number of Trials
39
Required Number of Trials
40
Required Number of Trials
41
Required Number of Trials
42
Number of Sampled Points (s)
Matter
§ Estimation algorithms require different
numbers of sampled points
§ 8-point vs. 5-point algorithm (Nister)
§ The small s, the better, especially with
high outlier ratios
43
How to Choose the Parameters?
§ Number of sampled points s
(minimum number needed to fit the model)
§ Outlier ratio e (e=#outliers/#datapoints)
§ Number of trials T
Choose T so that, with probability p, at least
one random sample set is free from outliers
§ Distance threshold δ
Choose δ so that a good point with noise is
likely (e.g., prob=0.95) within threshold
44
RANSAC: Pros and Cons
Pros
§ Robustly deal with outliers
§ Works well for 1 to roughly 10 parameters
(depending on the number of outliers)
§ Easy to implement and understand
Cons
§ Computational time grows quickly with
fraction of outliers and number of
parameters needed to fit the model
§ Not good for getting multiple fits
45
Common RANSAC Applications
§ Finding point correspondences
§ Estimating fundamental matrix
(relating two views)
§ Visual odometry
§ Computing a homography
(e.g., image stitching)
§ Laser scan matching
§…
46
Summary
§ RANSAC – the standard tool for model
fitting with outliers
§ Trial-and-error approach
“RANSAC in 30 seconds”
§ Guess inliers
§ Compute model given guess
§ Score the model by testing the data
points and model for consistency
§ Repeat
47