08 Homographies Slides
08 Homographies Slides
• Motivation: panoramas.
PP3
PP1
Which kind of transformation is needed to warp
projective plane 1 into projective plane 2? PP2
Classification of 2D transformations
PP3
PP1
Which kind of transformation is needed to warp
projective plane 1 into projective plane 2? PP2
• A projective transformation (a.k.a. a homography).
Warping with different transformations
translation affine projective (homography)
View warping
original view synthetic top view synthetic side view
synthetic
rotations
original view
Image rectification
two
original
images
y
ph
ra
og
m
Ho
reconstruction from
rectified view
magnified view of floor rectified view
Understanding geometric patterns
Very popular in renaissance drawings (when perspective was discovered)
rectified view
of floor
reconstruction
A weird painting
Holbein, “The Ambassadors”
A weird painting
Holbein, “The Ambassadors”
What’s this???
A weird painting
Holbein, “The Ambassadors”
rectified view
3. … the scene is captured under camera rotation only (no translation or pose change)
PP3
PP1
Which kind of transformation is needed to warp
projective plane 1 into projective plane 2? PP2
• A projective transformation (a.k.a. a homography).
Applying a homography
𝑥 𝑥
1. Convert to homogeneous coordinates: 𝑝= 𝑦 ⇒ 𝑃= 𝑦
1
What is the size of the homography matrix?
𝑥 ( 𝑥 (, (
𝑤
3. Convert back to heterogeneous coordinates: 𝑃( = 𝑦 ( (
⇒ 𝑝 = (
𝑦,
𝑤( 𝑤(
Applying a homography
𝑥 𝑥
1. Convert to homogeneous coordinates: 𝑝= 𝑦 ⇒ 𝑃= 𝑦
1
What is the size of the homography matrix? Answer: 3 x 3
𝑥 ( 𝑥 (, (
𝑤
3. Convert back to heterogeneous coordinates: 𝑃( = 𝑦 ( (
⇒ 𝑝 = (
𝑦,
𝑤( 𝑤(
Applying a homography
𝑥 𝑥
1. Convert to homogeneous coordinates: 𝑝= 𝑦 ⇒ 𝑃= 𝑦
1
What is the size of the homography matrix? Answer: 3 x 3
𝑥 ( 𝑥 (, (
𝑤
3. Convert back to heterogeneous coordinates: 𝑃( = 𝑦 ( (
⇒ 𝑝 = (
𝑦,
𝑤( 𝑤(
The direct linear transform (DLT)
Create point correspondences
Given a set of matched feature points 𝑝1 , 𝑝1( find the best estimate of 𝐻 such that
𝑃( = 𝐻 ⋅ 𝑃
𝑝- 𝑝-( 𝑝.(
𝑝.
𝑝0 𝑝/ 𝑝0( 𝑝/(
𝑃( = 𝐻 ⋅ 𝑃 or
Determining the homography matrix
Write out linear equation for each correspondence:
𝑃( = 𝐻 ⋅ 𝑃 or
𝑃( = 𝐻 ⋅ 𝑃 or
Vectorize transformation
parameters:
T
A = U⌃V
n⇥m n⇥n n⇥m m⇥m
9
X
T
= i ui v i
n⇥1 1⇥m
i=1
General form of total least squares
(matrix form)
constraint
(Rayleigh quotient)
minimize
minimize
subject to
3. Compute SVD of
5. Reshape to get
Linear least squares estimation only works when the transform function is linear! (duh)
𝑝- 𝑝-( 𝑝.(
𝑝.
𝑝0 𝑝/ 𝑝0( 𝑝/(
3. Feature matching
The image correspondence pipeline
1. Feature point detection
• Detect corners using the Harris corner detector.
3. Feature matching
bad
cor
res
pon
den
ce
good correspondence
Random Sample Consensus (RANSAC)
Fitting lines
(with outliers)
Algorithm:
1. Sample (randomly) the number of points required to fit the model
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
Fitting lines
(with outliers)
Algorithm:
1. Sample (randomly) the number of points required to fit the model
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
Fitting lines
(with outliers)
Algorithm:
1. Sample (randomly) the number of points required to fit the model
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
Fitting lines
(with outliers)
Algorithm:
1. Sample (randomly) the number of points required to fit the model
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
Fitting lines
(with outliers)
Algorithm:
1. Sample (randomly) the number of points required to fit the model
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
How to choose parameters?
• Number of samples N
– Choose N so that, with probability p, at least one random sample is free from
outliers (e.g. p=0.99) (outlier ratio: e )
• Number of sampled points s
– Minimum number needed to fit the model
• Distance threshold δ
–Choose δ so that a good point with noise is likely (e.g., prob=0.95) within threshold
bad
cor
res
pon
den
ce
good correspondence
‘average’
transform
1 correspondence
Pick one correspondence, count inliers
2 inliers
Pick one correspondence, count inliers
1 correspondence
Pick one correspondence, count inliers
5 inliers
Pick one correspondence, count inliers
5 inliers
• RANSAC loop
1. Get four point correspondences (randomly)
2. Compute H (DLT)
3. Count inliers
4. Keep if largest number of inliers
• Recompute H using all inliers
Estimating homography using RANSAC
• RANSAC loop
1. Get four point correspondences (randomly)
2. Compute H using DLT
3. Count inliers
4. Keep if largest number of inliers
• Recompute H using all inliers
Estimating homography using RANSAC
• RANSAC loop
1. Get four point correspondences (randomly)
2. Compute H using DLT
3. Count inliers
4. Keep if largest number of inliers
• Recompute H using all inliers
Estimating homography using RANSAC
• RANSAC loop
1. Get four point correspondences (randomly)
2. Compute H using DLT
3. Count inliers
4. Keep H if largest number of inliers
• Recompute H using all inliers
Estimating homography using RANSAC
• RANSAC loop
1. Get four point correspondences (randomly)
2. Compute H using DLT
3. Count inliers
4. Keep H if largest number of inliers
• Recompute H using all inliers
Useful for…
The image correspondence pipeline
1. Feature point detection
• Detect corners using the Harris corner detector.