Matching and Image Alignment Computer Vision Fall 2018 Columbia - - PowerPoint PPT Presentation

matching and image alignment
SMART_READER_LITE
LIVE PREVIEW

Matching and Image Alignment Computer Vision Fall 2018 Columbia - - PowerPoint PPT Presentation

Matching and Image Alignment Computer Vision Fall 2018 Columbia University Feature Matching 1. Find a set of distinctive key- points 2. Define a region around each keypoint 3. Extract and normalize the region content 4. Compute a


slide-1
SLIDE 1

Matching and Image Alignment

Computer Vision Fall 2018 Columbia University

slide-2
SLIDE 2
  • 1. Find a set of

distinctive key- points

  • 3. Extract and

normalize the region content

  • 2. Define a region

around each keypoint

  • 4. Compute a local

descriptor from the normalized region

  • 5. Match local

descriptors

Feature Matching

Slide credit: James Hays

slide-3
SLIDE 3

SIFT Review

slide-4
SLIDE 4

Corner Detector: Basic Idea

“flat” region:
 no change in any direction “edge”:
 no change along the edge direction “corner”:
 significant change in all directions

Defn: points are “matchable” if small shifts always produce a large SSD error

Source: Deva Ramanan

slide-5
SLIDE 5

Scaling

All points will be classified as edges Corner

slide-6
SLIDE 6

What Is A Useful Signature Function f ?

  • “Blob” detector is common for corners

– - Laplacian (2nd derivative) of Gaussian (LoG)

  • K. Grauman, B. Leibe

Image blob size Scale space Function response

slide-7
SLIDE 7

Coordinate frames

Represent each patch in a canonical scale and orientation (or general affine coordinate frame)

Source: Deva Ramanan

slide-8
SLIDE 8

Find dominant orientation

Compute gradients for all pixels in patch. Histogram (bin) gradients by orientation

Source: Deva Ramanan

slide-9
SLIDE 9

Computing the SIFT Descriptor

Histograms of gradient directions over spatial regions

\

Source: Deva Ramanan

slide-10
SLIDE 10

Post-processing

  • 1. Rescale 128-dim vector to have unit norm
  • 2. Clip high values

“invariant to linear scalings of intensity”

x = x ||x||, x ∈ R128

approximate binarization allows for for flat patches with small gradients to remain stable x := min(x, .2) x := x ||x||

Source: Deva Ramanan

slide-11
SLIDE 11

Matching

slide-12
SLIDE 12

Panoramas

Slide credit: Olga Russakovsky

slide-13
SLIDE 13

Gigapixel Images

danielhartz.com

slide-14
SLIDE 14

Look into the Past

Slide credit: Olga Russakovsky

slide-15
SLIDE 15

Can you find the matches?

NASA Mars Rover images

Slide credit: S. Lazebnik

slide-16
SLIDE 16

NASA Mars Rover images with SIFT feature matches
 Figure by Noah Snavely

Slide credit: S. Lazebnik

slide-17
SLIDE 17
  • Design a feature point matching scheme.
  • Two images, I1 and I2
  • Two sets X1 and X2 of feature points

– Each feature point x1 has a descriptor

  • Distance, bijective/injective/surjective, noise,

confidence, computational complexity, generality…

] , , [

) 1 ( ) 1 ( 1 1 d

x x

  • x

Discussion

Slide credit: James Hays

slide-18
SLIDE 18
  • Euclidean distance:
  • Cosine similarity:

Wikipedia

Distance Metric

slide-19
SLIDE 19

Locally, feature matches are ambiguous => need to fit a model to find globally consistent matches

?

Matching Ambiguity

Slide credit: James Hays

slide-20
SLIDE 20

Feature Matching

  • Criteria 1:

– Compute distance in feature space, e.g., Euclidean distance between 128-dim SIFT descriptors – Match point to lowest distance (nearest neighbor)

  • Problems:

– Does everything have a match?

Slide credit: James Hays

slide-21
SLIDE 21

Feature Matching

  • Criteria 2:

– Compute distance in feature space, e.g., Euclidean distance between 128-dim SIFT descriptors – Match point to lowest distance (nearest neighbor) – Ignore anything higher than threshold (no match!)

  • Problems:

– Threshold is hard to pick – Non-distinctive features could have lots of close matches, only one of which is correct

Slide credit: James Hays

slide-22
SLIDE 22

Nearest Neighbor Distance Ratio

Compare distance of closest (NN1) and second- closest (NN2) feature vector neighbor.

  • If NN1 ≈ NN2, ratio

𝑂𝑂1 𝑂𝑂2 will be ≈ 1 -> matches too close.

  • As NN1 << NN2, ratio

𝑂𝑂1 𝑂𝑂2 tends to 0.

Sorting by this ratio puts matches in order of confidence. Threshold ratio – but how to choose?

Slide credit: James Hays

slide-23
SLIDE 23

Nearest Neighbor Distance Ratio

  • Lowe computed a probability distribution functions of ratios
  • 40,000 keypoints with hand-labeled ground truth

Lowe IJCV 2004 Ratio threshold depends on your application’s view on the trade-off between the number of false positives and true positives!

slide-24
SLIDE 24

What is the transformation between these images?

slide-25
SLIDE 25

Transformation Models

  • T

ranslation only

  • Rigid body (translate+rotate)
  • Similarity (translate+rotate+scale)
  • AIne
  • Homography (projective)
slide-26
SLIDE 26

Homogenous Coordinates

P = (x, y)

Cartesian:

˜ P = (x, y,1)

Homogenous:

Slide credit: Peter Corke

slide-27
SLIDE 27

Homogenous Coordinates

P = (x, y)

Cartesian:

˜ P = (x, y,1)

Homogenous:

˜ P = (˜ x, ˜ y, ˜ z)

Homogenous:

Slide credit: Peter Corke

slide-28
SLIDE 28

Homogenous Coordinates

P = (x, y)

Cartesian:

˜ P = (x, y,1)

Homogenous:

˜ P = (˜ x, ˜ y, ˜ z) P = ( ˜ x ˜ z , ˜ y ˜ z )

Cartesian: Homogenous:

Slide credit: Peter Corke

slide-29
SLIDE 29

Lines and Points are Duals

˜ ℓ = (l1, l2, l3) ˜ p = (˜ x, ˜ y, ˜ z)

˜ ℓT ˜ p = 0

Point Equation of a Line:

l1˜ x + l2˜ y + l3˜ z = 0

Slide credit: Peter Corke

slide-30
SLIDE 30

˜ p1 = (˜ x1, ˜ y1, ˜ z1)

Cross product of two points is a line:

˜ ℓ = ˜ p1 × ˜ p2

˜ p2 = (˜ x2, ˜ y2, ˜ z2)

˜ ℓ

Slide credit: Peter Corke

slide-31
SLIDE 31

Cross product of two lines is a point:

˜ p = ˜ ℓ1 × ˜ ℓ2 ˜ ℓ1 ˜ ℓ2 ˜ p

Slide credit: Peter Corke

slide-32
SLIDE 32

Central Projection Model

f

Slide credit: Peter Corke

slide-33
SLIDE 33

Central Projection Model

f

p = ˜ x ˜ y ˜ z = f 0 0 f 0 0 1 ( X Y Z)

Slide credit: Peter Corke

slide-34
SLIDE 34

f

p = ˜ x ˜ y ˜ z = f 0 0 f 0 0 1 ( X Y Z)

Slide credit: Peter Corke

Central Projection Model

What if the camera moves?

slide-35
SLIDE 35

Review: 3D Transformations

Slide credit: Deva Ramanan

slide-36
SLIDE 36

Change of Coordinate System

Slide credit: Deva Ramanan

slide-37
SLIDE 37

Camera Projection

˜ x ˜ y ˜ z = f f 0 0 1 r11 r12 r13 tx r21 r22 r23 ty r31 r32 r33 tx X Y Z 1 World Coordinates Camera Extrinsics Camera Intrinsics

slide-38
SLIDE 38

Camera Matrix

˜ x ˜ y ˜ z = C11 C12 C13 C14 C21 C22 C23 C24 C31 C32 C33 C34 X Y Z 1 Mapping points from the world to image coordinates is matrix multiplication in homogenous coordinates

slide-39
SLIDE 39

Scale Invariance

˜ x ˜ y ˜ z = λ C11 C12 C13 C14 C21 C22 C23 C24 C31 C32 C33 C34 X Y Z 1 x = ˜ x ˜ z = λ˜ x λ˜ z y = ˜ y ˜ z = λ˜ y λ˜ z

slide-40
SLIDE 40

Normalized Camera Matrix

˜ x ˜ y ˜ z = C11 C12 C13 C14 C21 C22 C23 C24 C31 C32 C33 1 X Y Z 1

slide-41
SLIDE 41

Homography

Slide credit: Deva Ramanan

slide-42
SLIDE 42

Projection of 3D Plane

All points on the plane have Z = 0 ˜ x ˜ y ˜ z = C11 C12 C13 C14 C21 C22 C23 C24 C31 C32 C33 1 X Y 1

Slide credit: Peter Corke

slide-43
SLIDE 43

Projection of 3D Plane

All points on the plane have Z = 0 ˜ x ˜ y ˜ z = C11 C12 0 C14 C21 C22 0 C24 C31 C32 1 X Y 1

Slide credit: Peter Corke

slide-44
SLIDE 44

All points on the plane have Z = 0 ˜ x ˜ y ˜ z = H11 H12 H14 H21 H22 H24 H31 H32 1 ( X Y 1) = H ( X Y 1)

Planar Homography

Slide credit: Peter Corke

slide-45
SLIDE 45

Two-views of Plane

˜ x1 ˜ y1 ˜ z1 = H1 ( X Y 1) ˜ x2 ˜ y2 ˜ z2 = H2 ( X Y 1) If you know both H and (x1, y1), what is (x2, y2)?

Slide credit: Deva Ramanan

slide-46
SLIDE 46

Two-views of Plane

˜ x2 ˜ y2 ˜ z2 = H2H−1

1

˜ x1 ˜ y1 ˜ z1 ˜ x1 ˜ y1 ˜ z1 = H1 ( X Y 1) ˜ x2 ˜ y2 ˜ z2 = H2 ( X Y 1)

Slide credit: Deva Ramanan

slide-47
SLIDE 47

Estimating Homography

How many corresponding points do you need to estimate H? ˜ x2 ˜ y2 ˜ z2 = H ˜ x1 ˜ y1 ˜ z1

Slide credit: Deva Ramanan

slide-48
SLIDE 48

Estimating Homography (details)

Slide credit: Antonio Torralba

slide-49
SLIDE 49

Estimating Homography (details)

Slide credit: Antonio Torralba

slide-50
SLIDE 50

Rectification

Slide credit: Peter Corke

slide-51
SLIDE 51

Rectification

Slide credit: Peter Corke

slide-52
SLIDE 52

Rectification

Slide credit: Peter Corke

slide-53
SLIDE 53

Rectification

Slide credit: Peter Corke

slide-54
SLIDE 54

Warping

Slide credit: Peter Corke

slide-55
SLIDE 55

Virtual Camera

Slide credit: Peter Corke

slide-56
SLIDE 56

Panoramas

Slide credit: Olga Russakovsky

slide-57
SLIDE 57

Special case of 2 views: rotations about camera center

Can be modeled as planar transformations, regardless of scene geometry!

Slide credit: Deva Ramanan

slide-58
SLIDE 58

Derivation

K2

  X2 Y2 Z2   = R   X1 Y1 Z1   λ2   x2 y2 1   =   f2 f2 1     X2 Y2 Z2  

λ   x2 y2 1   = K2RK−1

1

  x1 y1 1  

Relation between 3D camera coordinates: 3D->2D projection: 
 Combining both:

Slide credit: Deva Ramanan

slide-59
SLIDE 59

Take-home points for homographies

  • If camera rotates about its center, then the images are related by a

homography irrespective of scene depth.

  • If the scene is planar, then images from any two cameras are related

by a homography.

  • Homography mapping is a 3x3 matrix with 8 degrees of freedom.

λ   x2 y2 1   =   a b c d e f g h i     x1 y1 1  

Slide credit: Deva Ramanan

slide-60
SLIDE 60

VLFeat’s 800 most confident matches among 10,000+ local features.

Which matches should we use to estimate homography?

slide-61
SLIDE 61

Least squares: Robustness to noise

  • Least squares fit to the red points:

Slide credit: James Hays

slide-62
SLIDE 62

Least squares: Robustness to noise

  • Least squares fit with an outlier:

Problem: squared error heavily penalizes outliers

Slide credit: James Hays

slide-63
SLIDE 63

Robust least squares (to deal with outliers)

General approach: minimize ui (xi, θ) – residual of ith point w.r.t. model parameters ϴ

  • ;

,

i i i

x u

  • The robust function ρ
  • Favors a configuration

with small residuals

  • Constant penalty for large

residuals

  • n

i i i

b x m y u

1 2 2

) (

Slide from S. Savarese

ρ – robust function with scale parameter σ

slide-64
SLIDE 64

Choosing the scale: Just right

The effect of the outlier is minimized

Slide credit: James Hays

slide-65
SLIDE 65

The error value is almost the same for every point and the fit is very poor

Choosing the scale: Too small

Slide credit: James Hays

slide-66
SLIDE 66

Choosing the scale: Too large

Behaves much the same as least squares

Slide credit: James Hays

slide-67
SLIDE 67

RANSAC

Fischler & Bolles in ‘81.

(RANdom SAmple Consensus) :

Slide credit: James Hays

slide-68
SLIDE 68

RANSAC

Fischler & Bolles in ‘81.

(RANdom SAmple Consensus) :

This data is noisy, but we expect a good fit to a known model.

Slide credit: James Hays

slide-69
SLIDE 69

RANSAC

Fischler & Bolles in ‘81.

(RANdom SAmple Consensus) :

This data is noisy, but we expect a good fit to a known model. Here, we expect to see a line, but least- squares fitting will produce the wrong result due to strong outlier presence.

Slide credit: James Hays

slide-70
SLIDE 70

RANSAC

Algorithm:

  • 1. Sample (randomly) the number of points s 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

Fischler & Bolles in ‘81.

(RANdom SAmple Consensus) :

Slide credit: James Hays

slide-71
SLIDE 71

RANSAC

Algorithm:

  • 1. Sample (randomly) the number of points required to fit the model (s=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

Line fitting example

slide-72
SLIDE 72

RANSAC

Algorithm:

  • 1. Sample (randomly) the number of points required to fit the model (s=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 Line fitting example

Slide credit: James Hays

slide-73
SLIDE 73
  • RANSAC

6

  • Inliers

N

Algorithm:

  • 1. Sample (randomly) the number of points required to fit the model (s=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 Line fitting example

Slide credit: James Hays

slide-74
SLIDE 74
  • RANSAC

14

  • Inliers

N

Algorithm:

  • 1. Sample (randomly) the number of points required to fit the model (s=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

Slide credit: James Hays

slide-75
SLIDE 75

RANSAC for alignment

Slide credit: Deva Ramanan

slide-76
SLIDE 76

RANSAC for alignment

Slide credit: Deva Ramanan

slide-77
SLIDE 77

RANSAC for alignment

Slide credit: Deva Ramanan

slide-78
SLIDE 78

Blending

Slide credit: Olga Russakovsky

slide-79
SLIDE 79

Blending

Slide credit: Davis ‘98

slide-80
SLIDE 80

Blending

Slide credit: Davis ‘98