1 of 43

Image transformations and image warping

CSC606: Intro Computer Vision

These slides are taken from Cornell university

2 of 43

Reading

  • Szeliski: Chapter 3.6

3 of 43

Image alignment

Why don’t these image line up exactly?

4 of 43

What is the geometric relationship between these two images?

?

Answer: Similarity transformation (translation, rotation, uniform scale)

5 of 43

What is the geometric relationship between these two images?

?

6 of 43

What is the geometric relationship between these two images?

Very important for creating mosaics!

First, we need to know what this transformation is.

Second, we need to figure out how to compute it using feature matches.

7 of 43

Image Warping

  • image filtering: change range of image
  • g(x) = h(f(x))

  • image warping: change domain of image
  • g(x) = f(h(x))

Image Stitching

7

Richard Szeliski

f

x

h

g

x

f

x

h

g

x

8 of 43

Image Warping

  • image filtering: change range of image
  • g(x) = h(f(x))

  • image warping: change domain of image
  • g(x) = f(h(x))

Image Stitching

8

Richard Szeliski

h

h

f

f

g

g

9 of 43

Parametric (global) warping

  • Examples of parametric warps:

Image Stitching

9

Richard Szeliski

translation

rotation

aspect

10 of 43

Parametric (global) warping

  • Transformation T is a coordinate-changing machine:

p’ = T(p)

  • What does it mean that T is global?
    • Is the same for any point p
    • can be described by just a few numbers (parameters)
  • Let’s consider linear xforms (can be represented by a 2x2 matrix):

T

p = (x,y)

p’ = (x’,y’)

11 of 43

Common linear transformations

  • Uniform scaling by s:

(0,0)

(0,0)

What is the inverse?

12 of 43

Common linear transformations

  • Rotation by angle θ (about the origin)

(0,0)

(0,0)

What is the inverse?

For rotations:

θ

13 of 43

2x2 Matrices

  • What types of transformations can be �represented with a 2x2 matrix?

2D mirror across Y axis?

2D mirror across line y = x?

14 of 43

2x2 Matrices

  • What types of transformations can be �represented with a 2x2 matrix?

2D mirror across Y axis?

2D mirror across line y = x?

15 of 43

2x2 Matrices

  • What types of transformations can be �represented with a 2x2 matrix?

2D Translation?

16 of 43

2x2 Matrices

  • What types of transformations can be �represented with a 2x2 matrix?

2D Translation?

Translation is not a linear operation on 2D coordinates

NO!

17 of 43

All 2D Linear Transformations

  • Linear transformations are combinations of …
    • Scale,
    • Rotation,
    • Shear, and
    • Mirror
  • Properties of linear transformations:
    • Origin maps to origin
    • Lines map to lines
    • Parallel lines remain parallel
    • Ratios are preserved
    • Closed under composition

18 of 43

Homogeneous coordinates

Trick: add one more coordinate:

homogeneous image

coordinates

Converting from homogeneous coordinates

x

y

w

(x, y, w)

w = 1

(x/w, y/w, 1)

homogeneous plane

19 of 43

Translation

  • Solution: homogeneous coordinates to the rescue

20 of 43

Affine transformations

any transformation represented by a 3x3 matrix with last row [ 0 0 1 ] we call an affine transformation

21 of 43

Basic affine transformations

Translate

2D in-plane rotation

Shear

Scale

22 of 43

Affine transformations

  • Affine transformations are combinations of …
    • Linear transformations, and
    • Translations

  • Properties of affine transformations:
    • Origin does not necessarily map to origin
    • Lines map to lines
    • Parallel lines remain parallel
    • Ratios are preserved
    • Closed under composition

23 of 43

Is this an affine transformation?

24 of 43

Where do we go from here?

affine transformation

what happens when we mess with this row?

25 of 43

Projective Transformations aka Homographies aka Planar Perspective Maps

Called a homography

(or planar perspective map)

26 of 43

Homographies

What happens when the denominator is 0?

27 of 43

Points at infinity

28 of 43

Image warping with homographies

image plane in front

image plane below

black area

where no pixel

maps to

29 of 43

Homographies

30 of 43

Homographies

  • Homographies …
    • Affine transformations, and
    • Projective warps

  • Properties of projective transformations:
    • Origin does not necessarily map to origin
    • Lines map to lines
    • Parallel lines do not necessarily remain parallel
    • Ratios are not preserved
    • Closed under composition

31 of 43

Alternate formulation for homographies

where the length of the vector [h00 h01 … h22] is 1

32 of 43

2D image transformations

These transformations are a nested set of groups

    • Closed under composition and inverse is a member

33 of 43

Implementing image warping

  • Given a coordinate xform (x’,y’) = T(x,y) and a source image f(x,y), how do we compute a transformed image g(x’,y’) = f(T(x,y))?

f(x,y)

g(x’,y’)

x

x’

T(x,y)

y

y’

34 of 43

Forward Warping

  • Send each pixel (x,y) to its corresponding location (x’,y’) = T(x,y) in g(x’,y’)

x

x’

T(x,y)

  • What if pixel lands “between” two pixels?

y

y’

f(x,y)

g(x’,y’)

35 of 43

Forward Warping

  • Send each pixel (x,y) to its corresponding location (x’,y’) = T(x,y) in g(x’,y’)

x

x’

T(x,y)

  • What if pixel lands “between” two pixels?
  • Answer: add “contribution” to several pixels, normalize later (splatting)
  • Can still result in holes

y

y’

f(x,y)

g(x’,y’)

36 of 43

Inverse Warping

  • Get each pixel g(x’,y’) from its corresponding location (x,y) = T-1(x,y) in f(x,y)

x

x’

T-1(x,y)

  • Requires taking the inverse of the transform
  • What if pixel comes from “between” two pixels?

y

y’

f(x,y)

g(x’,y’)

37 of 43

Inverse Warping

  • Get each pixel g(x’,y’) from its corresponding location (x,y) = T-1(x’,y’) in f(x,y)
  • What if pixel comes from “between” two pixels?
  • Answer: resample color value from interpolated (prefiltered) source image

x

x’

y

y’

f(x,y)

g(x’,y’)

T-1(x,y)

38 of 43

39 of 43

40 of 43

41 of 43

42 of 43

Interpolation

  • Possible interpolation filters:
    • nearest neighbor
    • bilinear
    • bicubic
    • sinc
  • Needed to prevent “jaggies”� and “texture crawl”

(with prefiltering)

43 of 43

Questions?