1 of 82

2 of 82

3 of 82

What’s an edge?

  • Image is a function
  • Edges are rapid changes in this function

4 of 82

Image derivatives

  • Recall:
  • We don’t have an “actual”�Function, must estimate
  • Possibility: set h = 2
  • What will that look like?

5 of 82

Image derivatives

  • Recall:
  • Want smoothing too!

6 of 82

Laplacian (2nd derivative)!

  • Crosses zero at extrema
  • Recall:
  • Laplacian:
  • Again, have to�estimate f’’(x):

7 of 82

Laplacians also sensitive to noise

  • Again, use gaussian smoothing
  • Can just use one kernel since convs commute
  • Laplacian of Gaussian, LoG
  • Can get good approx. with�5x5 - 9x9 kernels

8 of 82

Difference of Gaussian (DoG)

  • Gaussian is a low pass filter
  • Strongly reduce components with frequency f < σ
  • (g*I) low frequency components
  • I - (g*I) high frequency components
  • g(σ1)*I - g(σ2)*I
    • Components in between these frequencies
  • g(σ1)*I - g(σ2)*I = [g(σ1) - g(σ2)]*I
  • =

σ = 1

σ = 2

9 of 82

DoGs

10 of 82

Another approach: gradient magnitude

  • Don’t need 2nd derivatives
  • Just use magnitude of gradient
  • Are we done? No!

11 of 82

Canny Edge Detection

http://bigwww.epfl.ch/demo/ip/demos/edgeDetector/

  • Your first image processing pipeline!
    • Old-school CV is all about pipelines

Algorithm:

  • Smooth image (only want “real” edges, not noise)
  • Calculate gradient direction and magnitude
  • Non-maximum suppression perpendicular to edge
  • Threshold into strong, weak, no edge
  • Connect together components

12 of 82

Smooth image

http://bigwww.epfl.ch/demo/ip/demos/edgeDetector/

  • You know how to do this, gaussians!

13 of 82

Gradient magnitude and direction

http://bigwww.epfl.ch/demo/ip/demos/edgeDetector/

  • Sobel filter

14 of 82

Non-maximum suppression

15 of 82

Non-maximum suppression

16 of 82

Non-maximum suppression

http://bigwww.epfl.ch/demo/ip/demos/edgeDetector/

17 of 82

Threshold edges

http://bigwww.epfl.ch/demo/ip/demos/edgeDetector/

  • Still some noise
  • Only want strong edges
  • 2 thresholds, 3 cases
    • R > T: strong edge
    • R < T but R > t: weak edge
    • R < t: no edge
  • Why two thresholds?

18 of 82

Connect ‘em up!

http://bigwww.epfl.ch/demo/ip/demos/edgeDetector/

  • Strong edges are edges!
  • Weak edges are edges �iff they connect to strong
  • Look in some neighborhood�(usually 8 closest)

19 of 82

Canny Edge Detection

http://bigwww.epfl.ch/demo/ip/demos/edgeDetector/

20 of 82

21 of 82

Features!

  • Highly descriptive local regions
  • Ways to describe those regions
  • Useful for:
    • Matching
    • Recognition
    • Detection

22 of 82

How to panorama

  • Say we are stitching a panorama
  • Want patches in image to match to other image
  • Hopefully only match one spot

23 of 82

How close are two patches?

  • Sum squared difference
  • Images I, J
  • Σx,y (I(x,y) - J(x,y))2

24 of 82

How can we find unique patches?

  • Sky: bad
    • Very little variation
    • Could match any other sky

25 of 82

How can we find unique patches?

  • Sky: bad
    • Very little variation
    • Could match any other sky
  • Edge: ok
    • Variation in one direction
    • Could match other patches�along same edge

26 of 82

How can we find unique patches?

  • Sky: bad
    • Very little variation
    • Could match any other sky
  • Edge: ok
    • Variation in one direction
    • Could match other patches�along same edge
  • Corners: good!
    • Only one alignment matches

27 of 82

How can we find unique patches?

  • Want a patch that is unique in the image
  • Can calculate distance between patch and every other patch, lot of computation
  • Instead, we could think about auto-correlation:
    • How well does image match shifted version of itself?
  • ΣdΣx,y (I(x,y) - I(x+dx,y+dy))2

  • Measure of self-difference (how am I not myself?)

28 of 82

Self-difference

Sky: low everywhere

29 of 82

Self-difference

Edge: low along edge

30 of 82

Self-difference

Corner: mostly high

31 of 82

Self-difference

Sky: low everywhere

Edge: low along edge

Corner: mostly high

32 of 82

Self-difference is still expensive

  • ΣdΣx,y (I(x,y) - I(x+dx,y+dy))2
  • Lots of summing
  • Need an approximation
    • If you want the mathy details, Szeliski pg 212

33 of 82

Approximate self-difference

  • Look at nearby gradients Ix and Iy
  • If gradients are mostly zero, not a lot going on
    • Low self-difference
  • If gradients are mostly in one direction, edge
    • Still low self-difference
  • If gradients are in twoish directions, corner!
    • High self-difference, good patch!

34 of 82

Approximate self-difference

  • How do we tell what’s going on with gradients?
  • Eigen vectors/values!
  • Need structure matrix for patch, just a weighted sum of nearby gradient information

  • Not as complex as it looks, weighted sum of gradients near pixel

35 of 82

Structure matrix

  • Weighted sum of gradient information
    • | ΣiwiIx(i)Ix(i) ΣiwiIx(i)Iy(i) |
    • | ΣiwiIx(i)Iy(i) ΣiwiIy(i)Iy(i) |
  • Can use Gaussian weighting (so many gaussians)
  • Eigen vectors/values of this matrix summarize the distribution of the gradients nearby
  • λ1 and λ2 are eigenvalues
    • λ1 and λ2 both small: no gradient
    • λ1 >> λ2: gradient in one direction
    • λ1 and λ2 similar: multiple gradient directions, corner

36 of 82

Estimating smallest eigen value

  • A few methods:
    • det(S) = λ12
    • trace(S) = λ12
  • det(S) - α trace(S)2 = λ1λ2 - α(λ12)2
  • det(S) / trace(S) = λ1λ2/(λ12)
  • If these estimates are large, λ2 is large

37 of 82

Harris Corner Detector

  • Calculate derivatives Ix and Iy
  • Calculate 3 measures IxIx, IyIy, IxIy
  • Calculate weighted sums
    • Want a weighted sum of nearby pixels, guess what this is?
    • Gaussian!
  • Estimate response based on smallest eigen value
  • Non-max suppression (just like canny)

38 of 82

39 of 82

40 of 82

Ok, we found corners, now what?

  • Need to match image patches to each other
  • Need to figure out transform between images

41 of 82

Ok, we found corners, now what?

  • Need to match image patches to each other
    • What is a patch? How do we look for matches? Pixels?
  • Need to figure out transform between images
    • How can we transform images?
    • How do we solve for this transformation given matches?

42 of 82

Matching patches: descriptors!

  • We want a way to represent an image patch
  • Can be very simple, just pixels!
  • Finding matching patch is easy, distance metric:
    • Σx,y (I(x,y) - J(x,y))2
    • What problems are there with just using pixels?

43 of 82

Matching patches: descriptors!

  • We want a way to represent an image patch
  • Can be very simple, just pixels!
  • Finding matching patch is easy, distance metric:
    • Σx,y (I(x,y) - J(x,y))2
    • What problems are there with just using pixels?

44 of 82

Matching patches: descriptors!

  • We want a way to represent an image patch
  • Can be very simple, just pixels!
  • Finding matching patch is easy, distance metric:
    • Σx,y (I(x,y) - J(x,y))2
    • What problems are there with just using pixels?
  • Descriptors can be more complex
    • Gradient information
    • How much context?
    • Edges, etc. we’ll talk more about descriptors later!

45 of 82

Matching patches: descriptors!

  • Already have our patches that are likely “unique”-ish
  • Loop over good patches in one image
    • Find best match in other image
  • Do something with them?

46 of 82

How can we transform images?

  • Need to warp one image into the other
  • Many different image transforms
    • Nested hierarchy of transformations
  • Need to learn some new notation to make math easier!

47 of 82

How can we transform images?

  • x is a point in our image where:
    • x = (x, y) or in matrix terms

48 of 82

Say we want new coordinate system

  • Map points from one image into another
  • Often we can use matrix operations
  • Given a point x, map to new point x’ using M

49 of 82

Scaling is just a matrix operation

  • Map points from one image into another
  • Often we can use matrix operations
  • Given a point x, map to new point x’ using M

50 of 82

Translation is harder...

  • x = M x
    • Want to move x’ by dx and y’ by dy
    • How do we pick M?
    • Can only add up multiples of x or y
    • No easy way to add a constant!

51 of 82

Translation: add another row

  • is x but with an added 1
  • Augmented vector

52 of 82

Translation: add another row

  • is x but with an added 1
  • Augmented vector
  • Now translation is easy

53 of 82

Reminder, I = Identity

Common to just use I as a generic, whatever size identity fits here.

54 of 82

Translation: add another row

  • is x but with an added 1
  • Augmented vector
  • Now translation is easy

55 of 82

Translation: add another row

  • is x but with an added 1
  • Augmented vector
  • Now translation is easy
  • x’ = 1*x + 0*y + dx*1
  • y’ = 0*x + 1*y + dy*1

56 of 82

Translation: add another row

  • is x but with an added 1
  • Augmented vector
  • Now translation is easy
  • x’ = 1*x + 0*y + dx*1
  • y’ = 0*x + 1*y + dy*1

57 of 82

Euclidean: rotation + translation

  • Want to translate and rotate at same time
  • Still just matrix operation

58 of 82

Euclidean: rotation + translation

  • Want to translate and rotate at same time
  • Still just matrix operation

59 of 82

Euclidean: rotation + translation

  • Want to translate and rotate at same time
  • Still just matrix operation
  • R is rotation matrix, t is translation

60 of 82

Euclidean: rotation + translation

  • Want to translate and rotate at same time
  • Still just matrix operation
  • R is rotation matrix, t is translation

61 of 82

Similarity: scale, rotate, translate

62 of 82

Similarity: scale, rotate, translate

63 of 82

Similarity: scale, rotate, translate

64 of 82

Affine: scale, rotate, translate, shear

65 of 82

Affine: scale, rotate, translate, shear

66 of 82

Affine: scale, rotate, translate, shear

General case of 2x3 matrix

67 of 82

Combinations are still affine

Say you want to translate, then rotate, then translate back, then scale.

x’ = S t R t x̄ = M x̄,

If M = (S t R t)

M is still affine transformation

Wait, but these are all 2x3, how to we multiply them together?

68 of 82

Added row to transforms

69 of 82

Projective transform

  • AKA perspective transform or homography
  • Wait but affine was any 2x3 matrix...

70 of 82

Need some new coordinates!

  • Homogeneous coordinate system
    • Useful because we can do this kind of transform
  • Each point in 2d is actually a vector in 3d
  • Equivalent up to scaling factor
  • Have to normalize to get back to 2d

71 of 82

Why does this make sense?

  • Remember our pinhole camera model
  • Every point in 3d projects onto our viewing plane through our aperture
  • Points along a vector are indistinguishable

72 of 82

Projective transform

  • AKA perspective transform or homography
  • Wait but affine was any 2x3 matrix…
  • Homography is general 3x3 matrix
  • Multiplication by scalar is equivalent

73 of 82

Projective transform

  • AKA perspective transform or homography
  • Wait but affine was any 2x3 matrix…
  • Homography is general 3x3 matrix
  • Multiplication by scalar: equivalent projection
    • 3*H ~ H

74 of 82

Using homography to project point

  • Multiply x~ by H~ to get x’~
  • Convert to x’ by dividing by w’~

75 of 82

Lots to choose from

  • What do each of them do?
  • Which is right for panorama stitching?

76 of 82

How hard are they to recover?

77 of 82

Lots to choose from

78 of 82

Say we want affine transformation

  • Have our matched points
  • Want to estimate A that maps from x to x’
  • xA = x’

79 of 82

Say we want affine transformation

  • Have our matched points
  • Want to estimate A that maps from x to x’
  • xA = x’
  • How many degrees of freedom?

80 of 82

Say we want affine transformation

  • Have our matched points
  • Want to estimate A that maps from x to x’
  • xA = x’
  • How many degrees of freedom?
    • 6
  • How many knowns do we get with one match? mX = n

81 of 82

Say we want affine transformation

  • Have our matched points
  • Want to estimate A that maps from x to x’
  • xA = x’
  • How many degrees of freedom?
    • 6
  • How many knowns do we get with one match? mA = n
    • 2
    • nx = a00*mx + a01*my + a02*1
    • ny = a10*mx + a11*my + a12*1

82 of 82

Say we want affine transformation

  • How many knowns do we get with one match? mA = n
    • nx = a00*mx + a01*my + a02*1
    • ny = a10*mx + a11*my + a12*1
    • Solve M a = b
      • MT M a = MT b
      • a = (MT M)-1 MT b
    • Still works if overdetermined
      • WHY???