Lecture 3.3 Robust estimation with RANSAC...RANdom SAmple Consensus - RANSAC β’ RANSAC is an...
Transcript of Lecture 3.3 Robust estimation with RANSAC...RANdom SAmple Consensus - RANSAC β’ RANSAC is an...
Lecture 3.3 Robust estimation with RANSAC
Thomas Opsahl
Motivation
β’ Two images, captured by perspective cameras, of the same planar scene are related by a homography π»
β’ This homography can be estimated from 4 or more point-correspondences between the images
β’ Point-correspondences can be established automatically β Find key points in both images β Represent key points by a descriptor (a
vector of parameters) β Establish point correspondences by
comparing descriptors
β’ The resulting set of point pairs typically contains several wrong correspondences
β’ A robust estimation method provides a good estimate of π» despite the presence of erroneous correspondences (outliers)
2
Image 1 Image 2
π» ποΏ½1 ποΏ½2
RANdom SAmple Consensus - RANSAC
β’ RANSAC is an iterative method for estimating the parameters of a mathematical model from a set of observed data containing outliers
3
π
Observed data
π = π π;πΆ
Mathematical model with parameters πΆ = πΌ1, β¦ ,πΌπ
Estimation method ππ ,ππ
RANdom SAmple Consensus - RANSAC
β’ RANSAC is an iterative method for estimating the parameters of a mathematical model from a set of observed data containing outliers
4
π
Observed data
π = π π;πΆ
Mathematical model with parameters πΆ = πΌ1, β¦ ,πΌπ
Estimation method ππ ,ππ
π¦ = ππ + π
ππ + ππ¦ + π = 0
π¦ = ππ2 + ππ + π
π2
π2 +π¦2
π2 = 1
RANdom SAmple Consensus - RANSAC
β’ RANSAC is an iterative method for estimating the parameters of a mathematical model from a set of observed data containing outliers β Robust method (handles up to 50% outliers)
5
π
Observed data
π = π π;πΆ
Mathematical model with parameters πΆ = πΌ1, β¦ ,πΌπ
Estimation method ππ ,ππ
RANdom SAmple Consensus - RANSAC
β’ RANSAC is an iterative method for estimating the parameters of a mathematical model from a set of observed data containing outliers β Robust method (handles up to 50% outliers) β The estimated model is random but reasonable
6
π
Observed data
π = π π;πΆ Estimation
method ππ ,ππ Mathematical model with parameters πΆ = πΌ1, β¦ ,πΌπ
RANdom SAmple Consensus - RANSAC
β’ RANSAC is an iterative method for estimating the parameters of a mathematical model from a set of observed data containing outliers β Robust method (handles up to 50% outliers) β The estimated model is random but reasonable β The estimation process divides the observed data into inliers and outliers
7
π
Observed data
π = π π;πΆ Estimation
method ππ ,ππ Mathematical model with parameters πΆ = πΌ1, β¦ ,πΌπ
Inliers
Outliers
RANdom SAmple Consensus - RANSAC
β’ RANSAC is an iterative method for estimating the parameters of a mathematical model from a set of observed data containing outliers β Robust method (handles up to 50% outliers) β The estimated model is random but reasonable β The estimation process divides the observed data into inliers and outliers β Usually an improved estimate of the model is determined based on the inliers using a less robust
estimation method, e.g. least squares 8
π
Observed data
π = π π;πΆ Estimation
method ππ ,ππ Mathematical model with parameters πΆ = πΌ1, β¦ ,πΌπ
Inliers
Outliers
Basic RANSAC
Objective To robustly fit a model π = π π;πΆ to a data set π containing outliers Algorithm 1. Estimate the model parameters πΆπ‘π‘π‘ from a randomly sampled subset of π data points
from π
2. Determine the set of inliers ππ‘π‘π‘ β π to be the data points within a distance π‘ of the model
3. If this set of inliers is the largest so far, let ππΌπΌ = ππ‘π‘π‘ and let πΆ = πΆπ‘π‘π‘
4. If ππΌπΌ < π , where π is some threshold value, repeat steps 1-3, otherwise stop
5. After π trials, stop
Basic RANSAC
Comments β’ Typically the number of random samples,
π, is the smallest number of data points required to estimate the model
β’ Assuming Gaussian noise in the data, the threshold value π‘ should be in the region of 2π were π is the expected noise in the data set
β’ The threshold value π is set large enough to return a satisfactory inlier set, or simply omitted
β’ The maximal number of tests, π, can be chosen according to how certain we want to be of sampling at least one π-tuple with no outliers If π is the desired probability of sampling at least one πtuple with no outliers and π is the probability of a random data point to be an inlier, then
π =πππ 1 β ππππ 1 β ππ
π = 0.99 is standard
Basic RANSAC
Comments
β’ π = πππ 1βππππ 1βππ with π = 0.99
β’ Typically we do not know the ratio of outliers in our data set, hence we do not know the probability π or the number π
β’ Instead of operating with a larger than necessary π we can modify RANAC to adaptively estimate π as we perform the iterations
π π 90 80 70 60 50
π
2 3 5 7 11 17 3 4 7 11 19 35 4 5 9 17 34 72 5 6 12 26 57 146 6 7 16 37 97 293 7 8 20 54 163 588 8 9 26 78 272 1177
Adaptive RANSAC
Objective To robustly fit a model π = π π;πΆ to a data set π containing outliers Algorithm 1. Let π = β, ππΌπΌ = β and #ππ‘ππππ‘ππππ = 0
2. while π > #ππ‘ππππ‘ππππ repeat 3-5
3. Estimate parameters πΆπ‘π‘π‘ from a random π-tuple from π
4. Determine inlier set ππ‘π‘π‘, i.e. data points within a distance π‘ of the model π = π π;πΆπ‘π‘π‘
5. If ππ‘π‘π‘ > ππΌπΌ , set ππΌπΌ = ππ‘π‘π‘, πΆ = πΆπ‘π‘π‘, π = ππΌπΌ
π and π = πππ 1βπ
πππ 1βππ with π = 0.99 Increase #ππ‘ππππ‘ππππ by 1
Example
β’ Fit a circle π β π0 2 + π¦ β π¦0 2 = π2 to these data points by estimating the 3 parameters π0, π¦0 and π
Example
β’ Fit a circle π β π0 2 + π¦ β π¦0 2 = π2 to these data points by estimating the 3 parameters π0, π¦0 and π
β’ The data consists of some points on a circle with Gaussian noise and some random points
Circle + Gaussian noise Random points
Example
β’ Least-squares approach Separate observables from parameters:
β’ So for each observation ππ ,π¦π we get one equation
β’ From all our π observations we get a system of linear equations
( ) ( )
[ ]
[ ]
2 2 20 0
2 2 2 2 20 0 0 0
2 2 2 2 20 0 0 0
02 2
02 2 2
0 0
12 2
2
3
2 2
2 22
1 2
1
x x y y r
x xx x y yy y r
xx yy r x y x yx
x y y x yr x y
px y p x y
p
β + β =
β + + β + =
+ + β β = +
= + β β
= +
[ ]1
2 22
3
1i i i i
px y p x y
p
= +
2 21 1 1 1
1 2 22 2 2 2
2
3 2 2
11
1N N N N
x y x yp
x y x ypp
x y x yA
+ + = +
=p b
β’ We can solve this using the pseudo inverse π = π΄ππ΄ β1π΄ππ β This is the solution that minimize π΄π β π
Example
β’ We can solve this using the pseudo inverse π = π΄ππ΄ β1π΄ππ β This is the solution that minimize π΄π β π
β’ NOT GOOD! All points are treated equally, so the random points shifts the estimated circle away from the desired solution
Example
Example
β’ To estimate the circle using RANSAC, we need two things 1. A way to estimate a circle from n-points, where n is as small as possible 2. A way to determine which of the points are inliers for an estimated circle
Example
β’ To estimate the circle using RANSAC, we need two things 1. A way to estimate a circle from n-points, where n is as small as possible 2. A way to determine which of the points are inliers for an estimated circle
β’ The smallest number of points required to determine a circle is 3, i.e. π = 3, and the algorithm for computing the circle is quite simple
Example
β’ To estimate the circle using RANSAC, we need two things 1. A way to estimate a circle from n-points, where n is as small as possible 2. A way to determine which of the points are inliers for an estimated circle
β’ The distance from a point ππ ,π¦π to a circle π β π0 2 + π¦ β π¦0 2 = π2 is given by ππ β π0 2 + π¦π β π¦0 2 β π
ππ ,π¦π
ππ β π0 2 + π¦π β π¦0 2
π π0,π¦0
Example
β’ To estimate the circle using RANSAC, we need two things 1. A way to estimate a circle from n-points, where n is as small as possible 2. A way to determine which of the points are inliers for an estimated circle
β’ The distance from a point ππ ,π¦π to a circle π β π0 2 + π¦ β π¦0 2 = π2 is given by ππ β π0 2 + π¦π β π¦0 2 β π
β’ So for a threshold value π‘, we say that ππ ,π¦π is an inlier if ππ β π0 2 + π¦π β π¦0 2 β π < π‘
Example
Objective To robustly fit the model π β π0 2 + π¦ β π¦0 2 = π2 to our data set π = ππ ,π¦π Algorithm 1. Let π = β, ππΌπΌ = β , π = 0.99, π‘ = 2 β ππππππ‘ππ πππππ and #ππ‘ππππ‘ππππ = 0
2. while π > #ππ‘ππππ‘ππππ repeat 3-5
3. Estimate parameters ππ‘π‘π‘ ,π¦π‘π‘π‘ , ππ‘π‘π‘ from three random points from π
4. Determine inlier set ππ‘π‘π‘ = ππ ,π¦π β π such that ππ β π0 2 + π¦π β π¦0 2 β π < π‘
5. If ππ‘π‘π‘ > ππΌπΌ , set ππΌπΌ = ππ‘π‘π‘, π0,π¦0, π = ππ‘π‘π‘,π¦π‘π‘π‘, ππ‘π‘π‘ , π = ππΌπΌ
π and π = πππ 1βπ
πππ 1βππ Increase #ππ‘ππππ‘ππππ by 1
β’ The RANSAC algorithm evaluates many different circles and returns the circle with the largest inlier set
Example
β’ The RANSAC algorithm evaluates many different circles and returns the circle with the largest inlier set
β’ Inliers can be used to get an improved estimate of the circle
Example
Inliers
Robust estimation
β’ RANSAC is not perfectβ¦
β’ Several other robust estimation methods exist β Least Median Squares (LMS) β Preemptive RANSAC β PROgressive Sample and Consensus
(PROSAC) β M-estimator Sample and Consensus
(MSAC) β Maximum Likelihood Estimation Sample
and Consensus (MLESAC) β Randomized RANSAC (R-RANSAC) β KALMANSAC β +++
Summary
β’ RANSAC β A robust iterative method for estimating the parameters of a mathematical model from a set of
observed data containing outliers β Separates the observed data into βinliersβ and βoutliersβ β Very useful if we want to use better, but less robust, estimation methods β Not perfect
β’ Additional reading
β Szeliski: 6.1.4
β’ Homework? β Implement a RANSAC algorithm for estimating a line
27