0% found this document useful (0 votes)
22 views

Lec19 RANSAC

The document discusses camera calibration and fitting homographies. It describes how homographies can map points on a plane to pixels in an image and can be used to align images. It also covers topics like RANSAC for robust fitting and the Hough transform for finding lines and curves in images.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views

Lec19 RANSAC

The document discusses camera calibration and fitting homographies. It describes how homographies can map points on a plane to pixels in an image and can be used to align images. It also covers topics like RANSAC for robust fitting and the Hough transform for finding lines and curves in images.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 46

A special case of

calibration
Camera calibration

Y
Y’

Z O

O’ X’ X

Z’
Camera calibration = pose
estimation
• Estimating where camera is relative to object in
world
• = Estimating where object is relative to camera
Y
Y’

Z O

O’ X’ X

Z’
What if object of interest is
plane?
• Not that uncommon….
What if object of interest is
plane?
Y

Z O

X
What if object of interest is a
plane?
• Imagine that plane is equipped with two axes.
• Points on the plane are represented by two
euclidean coordinates
• …Or 3 homogenous coordinates

3D object 2D object (plane)

3x4 3x3
What if object of interest is a
plane?
Homography

3x3

• Homography maps
points on the plane to
pixels in the image
Fitting homographies
• How many parameters does a homography have?
• Given a single point on the plane and
corresponding image location, what does that tell
us?
Fitting homographies
• How many parameters does a homography have?
• Given a single point on the plane and
corresponding image location, what does that tell
us?

• Convince yourself that this gives 2 linear equations!


Fitting homographies
• Homography has 9 parameters
• But can’t determine scale factor, so only 8: 4 points!

• Or because we will have noise:


Fitting homographies
Homographies for image
alignment
• A general mapping from one plane to another!
• Can also be used to align one photo of a plane to
another photo of the same plane

Image 2
Image 1

Original plane
Homographies for image
alignment
• Can also be used to align one photo of a plane to
another photo of the same plane

http://www.wired.com/gadgetlab/2010/07/camera-software-lets-you-see-into-the-past/
Image Alignment Algorithm
Given images A and B

1. Compute image features for A and B


2. Match features between A and B
3. Compute homography between A and B
What could go wrong?
Fitting in general
• Fitting: find the parameters of a model that best fit
the data
• Other examples:
• least squares linear regression
Least squares: linear regression
12

10

8
(yi, xi)
Mileage

4
y = mx + b

0
0 1 2 3 4 5 6
Time
Linear regression
12

10

residual error
Mileage

0
0 1 2 3 4 5 6
Time
Linear regression
Outliers outliers

inliers
Robustness

Problem: Fit a line to these datapoints Least squares fit


Idea
• Given a hypothesized line
• Count the number of points that “agree” with the
line
• “Agree” = within a small distance of the line
• I.e., the inliers to that line

• For all possible lines, select the one with the largest
number of inliers
Counting inliers
Counting inliers

Inliers: 3
Counting inliers

Inliers: 20
How do we find the best line?

• Unlike least-squares, no simple closed-form


solution

• Hypothesize-and-test
• Try out many lines, keep the best one
• Which lines?
RANSAC (Random Sample Consensus)

Line fitting example

Algorithm:
1. Sample (randomly) the number of points required to fit the model (#=2)
2. Solve for model parameters using samples
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

Illustration by Savarese
RANSAC

Line fitting example

Algorithm:
1. Sample (randomly) the number of points required to fit the model (#=2)
2. Solve for model parameters using samples
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
RANSAC

Line fitting example


NI  6

Algorithm:
1. Sample (randomly) the number of points required to fit the model (#=2)
2. Solve for model parameters using samples
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
RANSAC


N I  14
Algorithm:
1. Sample (randomly) the number of points required to fit the model (#=2)
2. Solve for model parameters using samples
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
RANSAC
• Idea:
• All the inliers will agree with each other on the translation
vector; the (hopefully small) number of outliers will
(hopefully) disagree with each other
• RANSAC only has guarantees if there are < 50% outliers

• “All good matches are alike; every bad match is bad in its
own way.”
– Tolstoy via Alyosha Efros
Translations
RAndom SAmple Consensus

Select one match at random, count inliers


RAndom SAmple Consensus

Select another match at random, count inliers


RAndom SAmple Consensus

Output the translation with the highest number of inliers


Final step: least squares fit

Find average translation vector over all inliers


RANSAC
• Inlier threshold related to the amount of noise we
expect in inliers
• Often model noise as Gaussian with some standard
deviation (e.g., 3 pixels)
• Number of rounds related to the percentage of
outliers we expect, and the probability of success
we’d like to guarantee
• Suppose there are 20% outliers, and we want to find the
correct answer with 99% probability
• How many rounds do we need?
How many rounds?
• If we have to choose k samples each time
• with an inlier ratio p
• and we want the right answer with probability P

proportion of inliers p
k 95% 90% 80% 75% 70% 60% 50%
2 2 3 5 6 7 11 17
3 3 4 7 9 11 19 35
4 3 5 9 13 17 34 72
5 4 6 12 17 26 57 146
6 4 7 16 24 37 97 293
7 4 8 20 33 54 163 588
8 5 9 26 44 78 272 1177

P = 0.99
Source: M. Pollefeys
proportion of inliers p
k 95% 90% 80% 75% 70% 60% 50%
2 2 3 5 6 7 11 17
3 3 4 7 9 11 19 35
4 3 5 9 13 17 34 72
5 4 6 12 17 26 57 146
6 4 7 16 24 37 97 293
7 4 8 20 33 54 163 588
8 5 9 26 44 78 272 1177

P = 0.99
How big is k?
• For alignment, depends on the motion model
• Here, each sample is a correspondence (pair of matching
points)
RANSAC pros and cons
• Pros
• Simple and general
• Applicable to many different problems
• Often works well in practice
• Cons
• Parameters to tune
• Sometimes too many iterations are required
• Can fail for extremely low inlier ratios
RANSAC
• An example of a “voting”-based fitting scheme
• Each hypothesis gets voted on by each data point,
best hypothesis wins

• There are many other types of voting schemes


• E.g., Hough transforms…
Hough transform
P.V.C. Hough, Machine Analysis of Bubble Chamber Pictures, Proc. Int. Conf. High Energy
Accelerators and Instrumentation, 1959

Given a set of points, find the curve or line that explains the
data points best

y m

x b
Hough space

y=mx+b
Slide from S. Savarese
Hough Transform: Outline

1. Create a grid of parameter values

2. Each point votes for a set of parameters,


incrementing those values in grid

3. Find maximum or local maxima in grid


Hough transform

y m

x b

y m
3 5 3 3 2 2
3 7 11 10 4 3
2 3 1 4 5 2
2 1 0 1 3 3

x b
Slide from S. Savarese
Hough transform

You might also like