89
Image alignment 16-385 Computer Vision Spring 2018, Lecture 23 http://www.cs.cmu.edu/~16385/

Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

  • Upload
    others

  • View
    6

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

Image alignment

16-385 Computer VisionSpring 2018, Lecture 23http://www.cs.cmu.edu/~16385/

Page 2: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

• Homework 6 has been posted and is due on April 20th. - Any questions about the homework?- How many of you have looked at/started/finished homework 6?

• This week Yannis’ office hours will be on Wednesday 3-6 pm.- Added an extra hour to make up for change.

Course announcements

Page 3: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

• Leftover from last time: Horn-Schunck flow.

• Motion magnification using optical flow.

• Image alignment.

• Lucas-Kanade alignment.

• Baker-Matthews alignment.

• Inverse alignment.

Overview of today’s lecture

Page 4: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

Slide credits

Most of these slides were adapted from:

• Kris Kitani (16-385, Spring 2017).

Page 5: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

Motion magnification using

optical flow

Page 6: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

original motion-magnified

How would you achieve this effect?

• Compute optical flow from frame to frame.

• Magnify optical flow velocities.

• Appropriately warp image intensities.

Page 7: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

naïvely motion-magnified motion-magnified

How would you achieve this effect?

• Compute optical flow from frame to frame.

• Magnify optical flow velocities.

• Appropriately warp image intensities.

In practice, many additional steps

are required for a good result.

Page 8: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

Some more examples

Page 9: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

Some more examples

Page 10: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

Image alignment

Page 11: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal
Page 12: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal
Page 13: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

http://www.humansensing.cs.cmu.edu/intraface/

Page 14: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal
Page 15: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

How can I find in the image?

Page 16: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

Idea #1: Template Matching

Slow, combinatory, global solution

Page 17: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

Idea #2: Pyramid Template Matching

Faster, combinatory, locally optimal

Page 18: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

Idea #3: Model refinement

Fastest, locally optimal

(when you have a good initial solution)

Page 19: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

Some notation before we get into the math…

2D image transformation

2D image coordinate

Parameters of the transformation

Translation

Affine

Pixel value at a coordinate

Warped image

Page 20: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

Some notation before we get into the math…

2D image transformation

2D image coordinate

Parameters of the transformation

Translation

transform coordinate

Affine

Pixel value at a coordinate

Warped image

Page 21: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

Some notation before we get into the math…

2D image transformation

2D image coordinate

Parameters of the transformation

Translation

transform coordinate

Affine

Pixel value at a coordinate

affine transformcoordinate

Warped image

can be written in matrix form when linearaffine warp matrix can also be 3x3 when last row is [0 0 1]

Page 22: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

is a function of ____ variables

takes a ________ as input and returns a _______

returns a ______ of dimension ___ x ___

where N is _____ for an affine model

this warp changes pixel values?

Page 23: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

Image alignment(problem definition)

warped image template image

Find the warp parameters p such that the

SSD is minimized

Page 24: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

Find the warp parameters p such that the

SSD is minimized

Page 25: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

Image alignment(problem definition)

warped image template image

Find the warp parameters p such that the

SSD is minimized

How could you find a solution to this problem?

Page 26: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

This is a non-linear (quadratic) function of a

non-parametric function!

(Function I is non-parametric)

Hard to optimize

What can you do to make it easier to solve?

Page 27: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

Hard to optimize

What can you do to make it easier to solve?

assume good initialization,

linearized objective and update incrementally

This is a non-linear (quadratic) function of a

non-parametric function!

(Function I is non-parametric)

Page 28: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

Lucas-Kanade alignment

Page 29: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

If you have a good initial guess p…

can be written as …

(a small incremental adjustment)

(pretty strong assumption)

(this is what we are solving for now)

Page 30: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

How can we linearize the function I for a really small perturbation of p?

This is still a non-linear (quadratic) function of a

non-parametric function!

(Function I is non-parametric)

Page 31: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

How can we linearize the function I for a really small perturbation of p?

Taylor series approximation!

This is still a non-linear (quadratic) function of a

non-parametric function!

(Function I is non-parametric)

Page 32: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

Multivariable Taylor Series Expansion

(First order approximation)

Page 33: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

Multivariable Taylor Series Expansion

(First order approximation)

Recall:

chain rule

short-hand

short-hand

Page 34: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

Linear approximation

Multivariable Taylor Series Expansion

(First order approximation)

What are the unknowns here?

Page 35: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

Linear approximation

Multivariable Taylor Series Expansion

(First order approximation)

Now, the function is a linear function of the unknowns

Page 36: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

is a function of _____ variables

is a _________ of dimension ___ x ___

is a _________ of dimension ___ x ___

is a __________ of dimension ___ x ___

output of

Page 37: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

The Jacobian

Affine transform

Rate of change of the warp

(A matrix of partial derivatives)

Page 38: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

is a _________ of dimension ___ x ___

is a _________ of dimension ___ x ___

is a _________ of dimension ___ x ___

Page 39: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal
Page 40: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

pixel coordinate

(2 x 1)

Page 41: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

pixel coordinate

(2 x 1)

image intensity

(scalar)

Page 42: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

pixel coordinate

(2 x 1)

image intensity

(scalar)

warp function

(2 x 1)

Page 43: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

pixel coordinate

(2 x 1)

image intensity

(scalar)

warp function

(2 x 1)

warp parameters

(6 for affine)

Page 44: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

pixel coordinate

(2 x 1)

image intensity

(scalar)

warp function

(2 x 1)

warp parameters

(6 for affine)

image gradient

(1 x 2)

Page 45: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

pixel coordinate

(2 x 1)

image intensity

(scalar)

warp function

(2 x 1)

warp parameters

(6 for affine)

image gradient

(1 x 2)

Partial derivatives of warp function

(2 x 6)

Page 46: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

pixel coordinate

(2 x 1)

image intensity

(scalar)

warp function

(2 x 1)

warp parameters

(6 for affine)

image gradient

(1 x 2)

Partial derivatives of warp function

(2 x 6)

incremental warp

(6 x 1)

Page 47: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

pixel coordinate

(2 x 1)

image intensity

(scalar)

warp function

(2 x 1)

warp parameters

(6 for affine)

image gradient

(1 x 2)

Partial derivatives of warp function

(2 x 6)

incremental warp

(6 x 1)

template image intensity

(scalar)

When you implement this, you will compute everything in parallel and store as matrix … don’t loop over x!

Page 48: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

Summary(of Lucas-Kanade Image Alignment)

Solve for increment

Taylor series approximation

Linearize

Difficult non-linear optimization problem

Assume known approximate solution

Strategy:

Problem:

then solve for

warped image template image

Page 49: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

OK, so how do we solve this?

Page 50: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

Another way to look at it…

(moving terms around)

Have you seen this form of optimization problem before?

vector of

variables

vector of

constantsconstant

Page 51: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

Another way to look at it…

How do you solve this?

Looks like

variableconstant constant

Page 52: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

Least squares approximation

is solved by

is optimized when

where

Applied to our tasks:

after applying

Page 53: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

Solve for increment

Taylor series approximation

Linearize

Difficult non-linear optimization problem

Assume known approximate solution

Strategy:

Solve:

warped image template image

Solution:Solution to least squares

approximation

Hessian

Page 54: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

Gauss-Newton gradient decent

non-linear optimization!

This is called…

Page 55: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

1. Warp image

2. Compute error image

3. Compute gradient

4. Evaluate Jacobian

5. Compute Hessian

6. Compute

7. Update parameters

Lucas Kanade (Additive alignment)

Just 8 lines of code!

x’coordinates of the warped image

(gradients of the warped image)

Page 56: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

Baker-Matthews alignment

Page 57: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

Image Alignment(start with an initial solution, match the image and template)

Page 58: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

Additive Alignment

incremental perturbation of parameters

Image Alignment Objective Function

Given an initial solution…several possible formulations

Page 59: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

Compositional Alignment

incremental warps of image

Image Alignment Objective Function

Given an initial solution…several possible formulations

Additive Alignment

incremental perturbation of parameters

Page 60: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

Additive strategy

go back, adjust and try

again

first shot

second shot

Page 61: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

Compositional strategy

start from herefirst shot

second shot

Page 62: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

Additive

I(x)

W(x;p)

Page 63: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

T(x)Additive

I(x)

W(x;p+Dp)

W(x;p)

Page 64: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

W(x;0 + Dp) = W(x;Dp) W(x;p)

Compositional

I(x)

T(x)Additive

I(x)

W(x;p+Dp)

W(x;p)

Page 65: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

W(x;0 + Dp) = W(x;Dp)

T(x)

W(x;p)

W(x;p) o W(x;Dp)Compositional

I(x)

T(x)Additive

I(x)

W(x;p)

W(x;p+Dp)

Page 66: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

Compositional Alignment

Assuming an initial solution p and a compositional warp increment

Original objective function (SSD)

Page 67: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

Compositional Alignment

Assuming an initial solution p and a compositional warp increment

Original objective function (SSD)

Another way to write the composition Identity warp

Page 68: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

Compositional Alignment

Assuming an initial solution p and a compositional warp increment

Original objective function (SSD)

Another way to write the composition

Skipping over the derivation…the new update rule is

Identity warp

Page 69: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

So what’s so great about this compositional form?

Page 70: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

linearized form linearized form

Additive Alignment Compositional Alignment

Page 71: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

The Jacobian is constant.

Jacobian can be precomputed!

linearized form linearized form

Jacobian of W(x;p) Jacobian of

W(x;0)

Additive Alignment Compositional Alignment

Page 72: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

Compositional Image Alignment

Minimize

W(x;0 + Dp) = W(x;Dp)

T(x)

W(x;p)

W(x;p) o W(x;Dp)

Jacobian is simple and can be precomputed

Page 73: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

1. Warp image

2. Compute error image

3. Compute gradient

4. Evaluate Jacobian

5. Compute Hessian

6. Compute

7. Update parameters

Lucas Kanade (Additive alignment)

Page 74: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

1. Warp image

2. Compute error image

3. Compute gradient

4. Evaluate Jacobian

5. Compute Hessian

6. Compute

7. Update parameters

Shum-Szeliski (Compositional alignment)

Page 75: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

Any other speed up techniques?

Page 76: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

Inverse alignment

Page 77: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

Why not compute warp updates on the template?

Additive Alignment Compositional Alignment

Page 78: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

Why not compute warp updates on the template?

Additive Alignment Compositional Alignment

What happens if you let the template be

warped too?

Inverse Compositional Alignment

Page 79: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

W(x;0 + Dp) = W(x;Dp)

T(x)

W(x;p)

W(x;p) o W(x;Dp)

T(x)W(x;0 + Dp) = W(x;Dp)W(x;p)

Compositional

Inverse compositionalW(x;p) o W(x;Dp)-1

I(x)

I(x)

Page 80: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

Compositional strategy

start from herefirst shot

second shot

Page 81: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

Inverse Compositional strategy

first shotmove the hole

Page 82: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

So what’s so great about this inverse compositional form?

Page 83: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

Inverse Compositional Alignment

Minimize

Solution

Update

can be precomputed from template!

Page 84: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

Properties of inverse compositional alignment

Jacobian can be precomputedIt is constant - evaluated at W(x;0)

Gradient of template can be precomputedIt is constant

Hessian can be precomputed

Warp must be invertible

(main term that needs to be computed)

Page 85: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

1. Warp image

2. Compute error image

3. Compute gradient

4. Evaluate Jacobian

5. Compute Hessian

6. Compute

7. Update parameters

Lucas Kanade (Additive alignment)

Page 86: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

1. Warp image

2. Compute error image

3. Compute gradient

4. Evaluate Jacobian

5. Compute Hessian

6. Compute

7. Update parameters

Shum-Szeliski (Compositional alignment)

Page 87: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

1. Warp image

2. Compute error image

3. Compute gradient

4. Evaluate Jacobian

5. Compute Hessian

6. Compute

7. Update parameters

Baker-Matthews (Inverse Compositional alignment)

Page 88: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

Algorithm Efficient Authors

Forwards Additive No Lucas, Kanade

Forwards

compositionalNo Shum, Szeliski

Inverse Additive Yes Hager, Belhumeur

Inverse

CompositionalYes Baker, Matthews

Page 89: Image Alignment16385/s18/lectures/lecture23.pdf · Idea #1: Template Matching Slow, combinatory, global solution. Idea #2: Pyramid Template Matching Faster, combinatory, locally optimal

References

Basic reading:• Szeliski, Section 8.1.