Administrivia And now the winners of homework #3 hybrid images as - - PowerPoint PPT Presentation

administrivia
SMART_READER_LITE
LIVE PREVIEW

Administrivia And now the winners of homework #3 hybrid images as - - PowerPoint PPT Presentation

Administrivia And now the winners of homework #3 hybrid images as decided by the graders CMPSCI 370: Intro. to Computer Vision Image alignment University of Massachusetts, Amherst March 22/24, 2016 Instructor: Subhransu Maji 2


slide-1
SLIDE 1

CMPSCI 370: Intro. to Computer Vision

Image alignment

University of Massachusetts, Amherst March 22/24, 2016 Instructor: Subhransu Maji

  • And now the winners of homework #3 hybrid images
  • as decided by the graders …

Administrivia

2

Winner (#3): John Williams

3

Winner (#2): Joshua Espinosa

4

slide-2
SLIDE 2

Winner (#1): Alan Rusell

5

Honorable mention: Matthew Lydigsen

6

lighthouse + dalek

Honorable mention: Makenzie Schwartz

7

hillary + trump

Honorable mention: Nathan Greenberg

8

?? + simon pegg

slide-3
SLIDE 3

Honorable mention: David Carlson

9

snoop dogg + dog

  • But first are there any questions?

Image alignment

10

  • Matching local features
  • Local information used, can contain outliers
  • But hopefully enough of these matches are good

A framework for alignment

11

  • Matching local features
  • Local information used, can contain outliers
  • But hopefully enough of these matches are good
  • Consensus building
  • Aggregate the good matches and find a transformation that

explains these matches

A framework for alignment

12

slide-4
SLIDE 4

Generating putative correspondences

13

?

  • Need to find regions and compare their feature descriptors

Generating putative correspondences

14

( ) ( )

=

?

feature
 descriptor feature
 descriptor

?

  • We want to extract features with characteristic scale that

matches the image transformation such as scaling and translation (a.k.a. covariance)

Feature detection with scale selection

15

Matching regions across scales

Source: L. Lazebnik

Scaling

16

All points will be classified as edges Corner

Corner detection is sensitive to the image scale!

Source: L. Lazebnik

slide-5
SLIDE 5
  • Convolve the image with a “blob filter” at multiple scales
  • Look for extrema (maxima or minima) of filter response in

the resulting scale space

  • This will give us a scale and space covariant detector

Blob detection: basic idea

17 Source: L. Lazebnik

Find maxima and minima of blob filter response in space and scale

Blob detection: basic idea

18

*

=

maxima minima

Source: N. Snavely

Laplacian of Gaussian: Circularly symmetric operator for blob detection in 2D

Blob detection in 2D

19

! ! " # $ $ % & ∂ ∂ + ∂ ∂ = ∇

2 2 2 2 2 2 norm

y g x g g σ

Scale-normalized:

Source: L. Lazebnik

  • At what scale does the Laplacian achieve a maximum

response to a binary circle of radius r?

  • To get maximum response, the zeros of the Laplacian have to

be aligned with the circle

  • The Laplacian is given by (up to scale):


  • Therefore, the maximum response occurs at

Scale selection

20

r

image

2 2 2

2 / ) ( 2 2 2

) 2 (

σ

σ

y x

e y x

+ −

− + . 2 / r = σ

circle Laplacian

Source: L. Lazebnik

slide-6
SLIDE 6
  • We define the characteristic scale of a blob as the scale

that produces peak of Laplacian response in the blob center

Characteristic scale

21

characteristic scale

  • T. Lindeberg (1998). "Feature detection with automatic scale

selection." International Journal of Computer Vision 30 (2): pp 77--116.

Source: L. Lazebnik

  • 1. Convolve image with scale-normalized Laplacian at

several scales

Scale-space blob detector

22 Source: L. Lazebnik

Scale-space blob detector: Example

23

Scale-space blob detector: Example

24

slide-7
SLIDE 7
  • 1. Convolve image with scale-normalized Laplacian at

several scales

  • 2. Find maxima of squared Laplacian response in scale-

space

Scale-space blob detector

25 Source: L. Lazebnik

Scale-space blob detector: Example

26 Source: L. Lazebnik

  • Need to find regions and compare their feature descriptors

Generating putative correspondences

27

( ) ( )

=

?

feature
 descriptor feature
 descriptor

?

  • Scaled and rotated versions of the same neighborhood will

give rise to blobs that are related by the same transformation

  • What to do if we want to compare the appearance of these

image regions?

  • Normalization: transform these regions into same-size

circles

  • Problem: rotational ambiguity

From feature detection to description

28 Source: L. Lazebnik

slide-8
SLIDE 8
  • To assign a unique orientation to circular image windows:
  • Create histogram of local gradient directions in the patch
  • Assign canonical orientation at peak of smoothed histogram

Eliminating rotation ambiguity

29

2 π

Source: L. Lazebnik

  • Detected features with characteristic scales and
  • rientations:

SIFT features

30

David G. Lowe. "Distinctive image features from scale-invariant keypoints.” IJCV 60 (2), pp. 91-110, 2004.

Source: L. Lazebnik

From feature detection to description

31 Source: L. Lazebnik

how should we represent the patches?

  • Simplest descriptor: vector of raw intensity values
  • How to compare two such vectors?
  • Sum of squared differences (SSD) — this is a distance measure



 


  • Not invariant to intensity change

  • Normalized correlation — this is a similarity measure



 
 
 
 


  • Invariant to affine (translation + scaling) intensity change

Feature descriptors

32

( )

− =

i i i

v u

2

) SSD( v u, ! ! " # $ $ % & − ! ! " # $ $ % & − − − = − − ⋅ − − =

∑ ∑ ∑

j j j j i i i

v u v u

2 2

) ( ) ( ) )( ( || || ) ( || || ) ( ) ( v u v u v v v v u u u u v u, ρ

slide-9
SLIDE 9
  • Small deformations can affect the matching score a lot



 
 
 
 
 
 


Problem with intensity vectors as descriptors

33

  • Descriptor computation:
  • Divide patch into 4x4 sub-patches
  • Compute histogram of gradient orientations (8 reference angles) inside

each sub-patch

  • Resulting descriptor: 4x4x8 = 128 dimensions

Feature descriptors: SIFT

34

David G. Lowe. "Distinctive image features from scale-invariant keypoints.” IJCV 60 (2),

  • pp. 91-110, 2004.
  • Descriptor computation:
  • Divide patch into 4x4 sub-patches
  • Compute histogram of gradient orientations (8 reference angles) inside

each sub-patch

  • Resulting descriptor: 4x4x8 = 128 dimensions

  • Advantage over raw vectors of pixel values
  • Gradients less sensitive to illumination change
  • Pooling of gradients over the sub-patches achieves robustness to small

shifts, but still preserves some spatial information

Feature descriptors: SIFT

35

David G. Lowe. "Distinctive image features from scale-invariant keypoints.” IJCV 60 (2),

  • pp. 91-110, 2004.

Problem: Ambiguous putative matches

36

Source: Y. Furukawa

slide-10
SLIDE 10
  • How can we tell which putative matches are more reliable?
  • Heuristic: compare distance of nearest neighbor to that of

second nearest neighbor

  • Ratio of closest distance to second-closest distance will be high 


for features that are not distinctive

Rejection of unreliable matches

37

David G. Lowe. "Distinctive image features from scale-invariant keypoints.” IJCV 60 (2),

  • pp. 91-110, 2004.

Threshold of 0.8 provides good separation

  • Random Sample Consensus
  • Choose a small subset of points uniformly at random
  • Fit a model to that subset
  • Find all remaining points that are “close” to the model and

reject the rest as outliers

  • Do this many times and choose the best model
  • For rigid transformation we can estimate the parameters of

the transformation, e.g., rotation angle, scaling, translation, etc, from putative correspondence matches

  • Lets see how RANSAC works for a simple example.

RANSAC

38

  • M. A. Fischler, R. C. Bolles. Random Sample Consensus: A Paradigm for Model Fitting with

Applications to Image Analysis and Automated Cartography. Comm. of the ACM, Vol 24, pp 381-395, 1981.

RANSAC for line fitting example

39

Source: R. Raguram

RANSAC for line fitting example

40

Least-squares fit

Source: R. Raguram

min

a,b

X

i

(axi + b − yi)2

slide-11
SLIDE 11
  • Data:
  • Line equation:

Least-squares line fitting

41

(x1, y1), (x2, y2), . . . , (xn, yn) yi = axi + b yi = axi + b (xi, yi) E =

n

X

i=1

(axi + b − yi)2

dE da =

n

X

i=1

2 (axi + b − yi) xi = 0 Pn

dE db =

n

X

i=1

2 (axi + b − yi) = 0 b = Pn

i=1 yi

Pn

i=1 x2 i − Pn i=1 xi

Pn

i=1 xiyi

n Pn

i=1 x2 i − (Pn i=1 xi)2

a = n Pn

i=1 xiyi − (Pn i=1 xi)(Pn i=1 yi)

n Pn

i=1 x2 i − (Pn i=1 xi)2

42

  • 1. Randomly select

minimal subset of points

Source: R. Raguram

RANSAC for line fitting example

43

  • 1. Randomly select

minimal subset of points

  • 2. Hypothesize a

model

Source: R. Raguram

RANSAC for line fitting example

44

  • 1. Randomly select

minimal subset of points

  • 2. Hypothesize a

model

  • 3. Compute error

function

Source: R. Raguram

RANSAC for line fitting example

slide-12
SLIDE 12

45

  • 1. Randomly select

minimal subset of points

  • 2. Hypothesize a

model

  • 3. Compute error

function

  • 4. Select points

consistent with model

Source: R. Raguram

RANSAC for line fitting example

46

  • 1. Randomly select

minimal subset of points

  • 2. Hypothesize a

model

  • 3. Compute error

function

  • 4. Select points

consistent with model

  • 5. Repeat hypothesize-

and-verify loop

Source: R. Raguram

RANSAC for line fitting example

47

  • 1. Randomly select

minimal subset of points

  • 2. Hypothesize a

model

  • 3. Compute error

function

  • 4. Select points

consistent with model

  • 5. Repeat hypothesize-

and-verify loop

Source: R. Raguram

RANSAC for line fitting example

48

  • 1. Randomly select

minimal subset of points

  • 2. Hypothesize a

model

  • 3. Compute error

function

  • 4. Select points

consistent with model

  • 5. Repeat hypothesize-

and-verify loop

Uncontaminated sample

Source: R. Raguram

RANSAC for line fitting example

slide-13
SLIDE 13

49

  • 1. Randomly select

minimal subset of points

  • 2. Hypothesize a

model

  • 3. Compute error

function

  • 4. Select points

consistent with model

  • 5. Repeat hypothesize-

and-verify loop

Source: R. Raguram

RANSAC for line fitting example

Repeat N times:

  • Draw s points uniformly at random
  • Fit line to these s points
  • Find inliers to this line among the remaining points (i.e., points

whose distance from the line is less than t)

  • If there are d or more inliers and the number of inliers is higher

than the previous best, accept the line and refit using all inliers.

RANSAC for line fitting

50

  • Given a number of putative matches, select inliers based on

their agreement with an underlying transformation

  • How do we represent image transformations?

RANSAC for image matching

51

Families of transformation

52

slide-14
SLIDE 14
  • Think about moving coordinates, not pixels.

How do we move pixels?

53

Points in 2D

54

Translation

55

Scaling

56

slide-15
SLIDE 15

Rotation

57

Shear

58

Arbitrary linear transformation

59

Families of linear transforms

60

slide-16
SLIDE 16
  • Affine = linear + translation
  • Approximates viewpoint changes for roughly planar objects

and roughly orthographic cameras

  • Can be used to initialize fitting for more complex models

Affine transformations

61

x → Mx + t

  • Assume we know the correspondences, how do we get the

transformation?

Fitting an affine transformation

62

) , (

i i y

x ! ! ) , (

i i y

x

! " # $ % & + ! " # $ % & ! " # $ % & = ! " # $ % & ' '

2 1 4 3 2 1

t t y x m m m m y x

i i i i

t Mx x + = !

i i

Want to find M, t to minimize

=

− − #

n i i i 1 2

|| || t Mx x

  • Assume we know the correspondences, how do we get the

transformation?

Fitting an affine transformation

63

) , (

i i y

x ! ! ) , (

i i y

x

! " # $ % & + ! " # $ % & ! " # $ % & = ! " # $ % & ' '

2 1 4 3 2 1

t t y x m m m m y x

i i i i

! ! ! ! " # $ $ $ $ % & ' ' = ! ! ! ! ! ! ! ! " # $ $ $ $ $ $ $ $ % & ! ! ! ! " # $ $ $ $ % & ! ! ! !

i i i i i i

y x t t m m m m y x y x

2 1 4 3 2 1

1 1

  • Linear system with six unknowns
  • Each match gives us two linearly independent equations:

need at least three to solve for the transformation parameters

Fitting an affine transformation

64

! ! ! ! " # $ $ $ $ % & ' ' = ! ! ! ! ! ! ! ! " # $ $ $ $ $ $ $ $ % & ! ! ! ! " # $ $ $ $ % & ! ! ! !

i i i i i i

y x t t m m m m y x y x

2 1 4 3 2 1

1 1

slide-17
SLIDE 17

Application: Panorama stitching

65 Source: Hartley & Zisserman

  • Approach
  • Local feature matching
  • RANSAC for alignment

Panoramic stitching

66

?

Panoramic stitching

67

  • Extract features
  • corner/blob detector

Panoramic stitching

68

slide-18
SLIDE 18
  • Extract features
  • Compute putative matches

Panoramic stitching

69

  • Extract features
  • Compute putative matches
  • Loop:
  • Hypothesize transformation T

Panoramic stitching

70

  • Extract features
  • Compute putative matches
  • Loop:
  • Hypothesize transformation T
  • Verify transformation (search for other matches consistent with T)

Panoramic stitching

71

To shift an image (dx, dy)

  • Let (ox, oy) be the coordinates of a pixel in the original

image with a particular appearance

  • Let (nx, ny) be the new coordinates, i.e., where we want that

pixel

  • For each pixel

nx = ox + dx ny = oy + dy newIm(ny, nx) = im(oy, ox);

Warping images

72

slide-19
SLIDE 19

Mechanics of transformation

73

  • Problems with this transformation
  • Leaves gaps in the target image
  • Interpolation less intuitive

Mechanics of transformation

74

  • Rotation by 45 degrees

Example of forward warp

75

Mechanics of transformation

76

slide-20
SLIDE 20
  • Rotation by 45 degrees

Example of inverse warp

77

Panoramic stitching warping

78