csce 643 computer vision: lucas-kanade registration jinxiang chai

126
CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Upload: ramiro-grigson

Post on 01-Apr-2015

232 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

CSCE 643 Computer Vision: Lucas-Kanade Registration

Jinxiang Chai

Page 2: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Appearance-based Tracking

Slide from Robert Collins

Page 3: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Image Registration

• This requires solving image registration problems

• Lucas-Kanade is one of the most popular frameworks for image registration

- gradient based optimization

- iterative linear system solvers - applicable to a variety of scenarios, including optical flow

estimation, parametric motion tracking, AAMs, etc.

Page 4: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Pixel-based Registration: Optical flow

Will start by estimating motion of each pixel separatelyThen will consider motion of entire image

Page 5: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Problem Definition: Optical Flow

How to estimate pixel motion from image H to image I?

Page 6: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Problem Definition: Optical Flow

How to estimate pixel motion from image H to image I?– Solve pixel correspondence problem

• given a pixel in H, look for nearby pixels of the same color in I

Page 7: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Problem Definition: Optical Flow

How to estimate pixel motion from image H to image I?– Solve pixel correspondence problem

• given a pixel in H, look for nearby pixels of the same color in I

Key assumptions– color constancy: a point in H looks the same in I

• For grayscale images, this is brightness constancy– small motion: points do not move very far

This is called the optical flow problem

Page 8: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Optical Flow Constraints

Let’s look at these constraints more closely– brightness constancy: Q: what’s the equation?

Page 9: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Optical Flow Constraints

Let’s look at these constraints more closely– brightness constancy: Q: what’s the equation?

H(x,y) - I(x+u,v+y) = 0

Page 10: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Optical Flow Constraints

Let’s look at these constraints more closely– brightness constancy: Q: what’s the equation?

– small motion: (u and v are less than 1 pixel)• suppose we take the Taylor series expansion of I:

H(x,y) - I(x+u,v+y) = 0

Page 11: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Optical Flow Constraints

Let’s look at these constraints more closely– brightness constancy: Q: what’s the equation?

– small motion: (u and v are less than 1 pixel)• suppose we take the Taylor series expansion of I:

H(x,y) - I(x+u,v+y) = 0

Page 12: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Optical Flow EquationCombining these two equations

Page 13: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Optical Flow EquationCombining these two equations

Page 14: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Optical Flow EquationCombining these two equations

Page 15: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Optical Flow EquationCombining these two equations

Page 16: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Optical Flow EquationCombining these two equations

In the limit as u and v go to zero, this becomes exact

Page 17: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Optical Flow Equation

How many unknowns and equations per pixel?

Page 18: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Optical Flow Equation

How many unknowns and equations per pixel?

Intuitively, what does this constraint mean?

Page 19: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Optical Flow Equation

How many unknowns and equations per pixel?

Intuitively, what does this constraint mean?– The component of the flow in the gradient direction is determined– The component of the flow parallel to an edge is unknown

Page 20: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Optical Flow Equation

How many unknowns and equations per pixel?

Intuitively, what does this constraint mean?– The component of the flow in the gradient direction is determined– The component of the flow parallel to an edge is unknown

I

Page 21: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Ambiguity

Page 22: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Ambiguity

Stripes moved upwards 6 pixels

Stripes moved left 5 pixels

Page 23: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Ambiguity

Stripes moved upwards 6 pixels

Stripes moved left 5 pixels

How to address this problem?

Page 24: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Solving the Aperture Problem

How to get more equations for a pixel?– Basic idea: impose additional constraints

• most common is to assume that the flow field is smooth locally

• one method: pretend the pixel’s neighbors have the same (u,v)

– If we use a 5x5 window, that gives us 25 equations per pixel!

Page 25: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

RGB Version

How to get more equations for a pixel?– Basic idea: impose additional constraints

• most common is to assume that the flow field is smooth locally

• one method: pretend the pixel’s neighbors have the same (u,v)

– If we use a 5x5 window, that gives us 25 equations per pixel!

Page 26: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Lukas-Kanade Flow

Prob: we have more equations than unknowns

Page 27: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Lukas-Kanade Flow

Prob: we have more equations than unknowns

Solution: solve least squares problem

Page 28: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Lukas-Kanade Flow

Prob: we have more equations than unknowns

Solution: solve least squares problem– minimum least squares solution given by solution (in d) of:

Page 29: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Lukas-Kanade Flow

– The summations are over all pixels in the K x K window– This technique was first proposed by Lukas & Kanade (1981)

Page 30: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Lukas-Kanade Flow

When is this Solvable?• ATA should be invertible • ATA should not be too small due to noise

– eigenvalues 1 and 2 of ATA should not be too small• ATA should be well-conditioned

– 1/ 2 should not be too large (1 = larger eigenvalue)

Page 31: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Lukas-Kanade Flow

When is this Solvable?• ATA should be invertible • ATA should not be too small due to noise

– eigenvalues 1 and 2 of ATA should not be too small• ATA should be well-conditioned

– 1/ 2 should not be too large (1 = larger eigenvalue)

Look familiar?

Page 32: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Lukas-Kanade Flow

When is this Solvable?• ATA should be invertible • ATA should not be too small due to noise

– eigenvalues 1 and 2 of ATA should not be too small• ATA should be well-conditioned

– 1/ 2 should not be too large (1 = larger eigenvalue)

Look familiar? Harris Corner detection criterion!

Page 33: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Edge

Bad for motion estimation

- large1, small 2

Page 34: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Low Texture Region

Bad for motion estimation: - gradients have small magnitude

- small1, small 2

Page 35: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

High Textured Region

Good for motion estimation: - gradients are different, large magnitudes

- large1, large 2

Page 36: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Good Features to Track

This is a two image problem BUT– Can measure sensitivity by just looking at one of the

images!– This tells us which pixels are easy to track, which are

hard• very useful later on when we do feature tracking...

For more detail, check

“Good feature to Track”, Shi and Tomasi, CVPR 1994

Page 37: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Errors in Lucas-Kanade

What are the potential causes of errors in this procedure?– Suppose ATA is easily invertible– Suppose there is not much noise in the image

Page 38: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Errors in Lucas-Kanade

What are the potential causes of errors in this procedure?– Suppose ATA is easily invertible– Suppose there is not much noise in the image

When our assumptions are violated– Brightness constancy is not satisfied– The motion is not small– A point does not move like its neighbors

• Optical flow in local window is not constant.

Page 39: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Errors in Lucas-Kanade

What are the potential causes of errors in this procedure?– Suppose ATA is easily invertible– Suppose there is not much noise in the image

When our assumptions are violated– Brightness constancy is not satisfied– The motion is not small– A point does not move like its neighbors

• Optical flow in local window is not constant.

Page 40: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Revisiting the Small Motion Assumption

Is this motion small enough?– Probably not—it’s much larger than one pixel (2nd order terms dominate)– How might we solve this problem?

Page 41: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Iterative RefinementIterative Lukas-Kanade Algorithm

1. Estimate velocity at each pixel by solving Lucas-Kanade equations

2. Warp H towards I using the estimated flow field- use image warping techniques

3. Repeat until convergence

Page 42: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Idea I: Iterative RefinementIterative Lukas-Kanade Algorithm

1. Estimate velocity at each pixel by solving Lucas-Kanade equations

2. Warp H towards I using the estimated flow field- use image warping techniques

3. Repeat until convergence

Page 43: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Idea II: Reduce the Resolution!

Page 44: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

image Iimage H

Gaussian pyramid of image H Gaussian pyramid of image I

image Iimage H u=10 pixels

u=5 pixels

u=2.5 pixels

u=1.25 pixels

Coarse-to-fine Motion Estimation

Page 45: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

image Iimage J

Gaussian pyramid of image H Gaussian pyramid of image I

image Iimage H

Coarse-to-fine Optical Flow Estimation

run iterative L-K

run iterative L-K

Upsample & warp

.

.

.

Page 46: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Errors in Lucas-Kanade

What are the potential causes of errors in this procedure?– Suppose ATA is easily invertible– Suppose there is not much noise in the image

When our assumptions are violated– Brightness constancy is not satisfied– The motion is not small– A point does not move like its neighbors

• Optical flow in local window is not constant.

Page 47: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Lucas Kanade Tracking

• Assumption of constant flow (pure translation) for all pixels in a larger window might be unreasonable

Page 48: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Lucas Kanade Tracking

• Assumption of constant flow (pure translation) for all pixels in a larger window might be unreasonable

• However, we can easily generalize Lucas-Kanade approach to other 2D parametric motion models (like affine or projective)

Page 49: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Beyond Translation

So far, our patch can only translate in (u,v)

What about other motion models?– rotation, affine, perspective

Page 50: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Warping Review

Figure from Szeliski book

Page 51: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Geometric Image Warping

w(x;p) describes the geometric relationship between two images:

);(

);();('

pxw

pxwpxwx

y

x

Transformed ImageInput Image

x’x

Page 52: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Geometric Image Warping

w(x;p) describes the geometric relationship between two images:

);(

);();('

pxw

pxwpxwx

y

x

Transformed ImageInput Image

(x’)

(x)

Warping parameters

Page 53: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Warping Functions

Translation:

Affine:

Perspective:

2

1);(py

pxpxw

1

1);(

87

654

87

321

ypxp

pypxpypxp

pypxp

pxw

654

321);(pypxp

pypxppxw

Page 54: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Image Registration

Find the warping parameter p that minimizes the intensity difference between template image and the warped input image

Page 55: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Image Registration

Find the warping parameter p that minimizes the intensity difference between template image and the warped input image

Again, we can formulate this as an optimization problem:

x

pxHpxwI 2)());((minarg

Page 56: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Image Registration

Find the warping parameter p that minimizes the intensity difference between template image and the warped input image

Again, we can formulate this as an optimization problem:

The above problem can be solved by many gradient-based optimization algorithms:

- Steepest descent

- Gauss-newton

- Levenberg-marquardt, etc. 

x

pxHpxwI 2)());((minarg

Page 57: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Image Registration

Find the warping parameter p that minimizes the intensity difference between template image and the warped input image

Again, we can formulate this as an optimization problem:

The above problem can be solved by many gradient-based optimization algorithms:

- Steepest descent

- Gauss-newton

- Levenberg-marquardt, etc

x

pxHpxwI 2)());((minarg

Page 58: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Image Registration

Mathematically, we can formulate this as an optimization problem:

x

pxHpxwI 2)());((minarg

Page 59: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Image Registration

Mathematically, we can formulate this as an optimization problem:

x

pxHpxwI 2)());((minarg

xp

xHppxwI 2)());((minarg Taylor series expansion

Similar to optical flow:

Page 60: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Image Registration

Mathematically, we can formulate this as an optimization problem:

x

pxHpxwI 2)());((minarg

xp

xHppxwI 2)());((minarg

xx

pxHp

p

WIpxwI

2

)());((minarg

Taylor series expansion

Similar to optical flow:

Page 61: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Image Registration

Mathematically, we can formulate this as an optimization problem:

x

pxHpxwI 2)());((minarg

xp

xHppxwI 2)());((minarg

xx

pxHp

p

WIpxwI

2

)());((minarg

y

I

x

II

Taylor series expansion

Image gradient

Similar to optical flow:

Page 62: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Image Registration

Mathematically, we can formulate this as an optimization problem:

xp

xHpxwI 2)());((minarg

xp

xHppxwI 2)());((minarg

xx

pxHp

p

WIpxwI

2

)());((minarg

y

I

x

II

21

1

...

...

p

w

p

wp

w

p

w

p

w

yy

n

xx

10

01

p

w

Taylor series expansion

Image gradient

1000

0001

yx

yx

p

w

translation

affine

……

Similar to optical flow:

Jacobian matrix

Page 63: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Image Registration

Mathematically, we can formulate this as an optimization problem:

xp

xHpxwI 2)());((minarg

xp

xHppxwI 2)());((minarg

xp

xHpp

WIpxwI

2

)());((minarg

Taylor series expansion

- Intuition?

Similar to optical flow:

Page 64: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Image Registration

Mathematically, we can formulate this as an optimization problem:

xp

xHpxwI 2)());((minarg

xp

xHppxwI 2)());((minarg

xp

xHpp

WIpxwI

2

)());((minarg

Taylor series expansion

- Intuition: a delta change of p results in how much change of pixel values at pixel w(x;p)!

Similar to optical flow:

p x I

Page 65: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Image Registration

Mathematically, we can formulate this as an optimization problem:

xp

xHpxwI 2)());((minarg

xp

xHppxwI 2)());((minarg

xp

xHpp

WIpxwI

2

)());((minarg

Taylor series expansion

- Intuition: a delta change of p results in how much change of pixel values at pixel w(x;p)!

- An optimal that minimizes color inconsistency between the images.

Similar to optical flow:

p x I

p

Page 66: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Gauss-newton Optimization

Rearrange

xp

xHpp

WIpxwI

2

)());((minarg

Page 67: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Gauss-newton Optimization

xp

pxwIxHpp

WI

2

)));(()((minarg

Rearrange

xp

xHpp

WIpxwI

2

)());((minarg

Page 68: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Gauss-newton Optimization

xp

pxwIxHpp

WI

2

)));(()((minarg

Rearrange

A

xp

xHpp

WIpxwI

2

)());((minarg

b

Page 69: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Gauss-newton Optimization

xp

pxwIxHpp

WI

2

)));(()((minarg

)));(()((()( 1 pxwIxHp

WI

p

WI

p

WIp

T

xx

T

Rearrange

A

ATb

xp

xHpp

WIpxwI

2

)());((minarg

b

(ATA)-1

Page 70: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Lucas-Kanade Registration

Initialize p=p0:

Iterate: 1. Warp I with w(x;p) to compute I(w(x;p))

));(()(()( 1 pxwIxHp

WI

p

WI

p

WIp

T

xx

T

Page 71: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Lucas-Kanade Registration

Initialize p=p0:

Iterate: 1. Warp I with w(x;p) to compute I(w(x;p))

2. Compute the error image

));(()(()( 1 pxwIxHp

WI

p

WI

p

WIp

T

xx

T

Page 72: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Lucas-Kanade Registration

Initialize p=p0:

Iterate: 1. Warp I with w(x;p) to compute I(w(x;p))

2. Compute the error image

3. Warp the gradient with w(x;p)

));(()(()( 1 pxwIxHp

WI

p

WI

p

WIp

T

xx

T

I

Page 73: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Lucas-Kanade Registration

Initialize p=p0:

Iterate: 1. Warp I with w(x;p) to compute I(w(x;p))

2. Compute the error image

3. Warp the gradient with w(x;p)

4. Evaluate the Jacobian at (x;p)

));(()(()( 1 pxwIxHp

WI

p

WI

p

WIp

T

xx

T

I

p

w

Page 74: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Lucas-Kanade Registration

Initialize p=p0:

Iterate: 1. Warp I with w(x;p) to compute I(w(x;p))

2. Compute the error image

3. Warp the gradient with w(x;p)

4. Evaluate the Jacobian at (x;p)

5. Compute the using linear system solvers

));(()(()( 1 pxwIxHp

WI

p

WI

p

WIp

T

xx

T

I

p

w

p

Page 75: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Lucas-Kanade Registration

Initialize p=p0:

Iterate: 1. Warp I with w(x;p) to compute I(w(x;p))

2. Compute the error image

3. Warp the gradient with w(x;p)

4. Evaluate the Jacobian at (x;p)

5. Compute the using linear system solvers

6. Update the parameters

));(()(()( 1 pxwIxHp

WI

p

WI

p

WIp

T

xx

T

I

p

w

p

ppp

Page 76: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Lucas-Kanade Algorithm

Iteration 1:H(x) I(w(x;p)) H(x)-I(w(x;p))

Page 77: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Lucas-Kanade Algorithm

Iteration 2:H(x) I(w(x;p)) H(x)-I(w(x;p))

Page 78: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Lucas-Kanade Algorithm

Iteration 3:H(x) I(w(x;p)) H(x)-I(w(x;p))

Page 79: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Lucas-Kanade Algorithm

Iteration 4:H(x) I(w(x;p)) H(x)-I(w(x;p))

Page 80: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Lucas-Kanade Algorithm

Iteration 5:H(x) I(w(x;p)) H(x)-I(w(x;p))

Page 81: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Lucas-Kanade Algorithm

Iteration 6:H(x) I(w(x;p)) H(x)-I(w(x;p))

Page 82: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Lucas-Kanade Algorithm

Iteration 7:H(x) I(w(x;p)) H(x)-I(w(x;p))

Page 83: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Lucas-Kanade Algorithm

Iteration 8:H(x) I(w(x;p)) H(x)-I(w(x;p))

Page 84: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Lucas-Kanade Algorithm

Iteration 9:H(x) I(w(x;p)) H(x)-I(w(x;p))

Page 85: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Lucas-Kanade Algorithm

Final result:H(x) I(w(x;p)) H(x)-I(w(x;p))

Page 86: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

How to Break Assumptions

• Small motion

• Constant optical flow in the window

• Color constancy

Page 87: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Break the Color Constancy

How to deal with illumination change?

xp

xHpxwI 2)());((minarg

Page 88: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Break the Color Constancy

How to deal with illumination change?

xp

xHpxwI 2)());((minarg

Issue: corresponding pixels do not have consistent values due to illumination changes?

Page 89: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Break the Color Constancy

How to deal with illumination change?

- linear models

- can model gain and bias (H1=H0, H2= const., other zeros)

B

iii xHxHxH

10 )()()(

cxHxH )()( 0

Page 90: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Linear ModelCan also model the appearance of a face under different illumination using a linear combination of base images (PCA):

- recording images under different illumination

- applying PCA to recorded images to model illumination in recorded images

- Images under unknown illuminations can be represented as a weighted combination of precomputed illumination image templates

B

iii xHxHxH

10 )()()(

Page 91: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Linear ModelCan also model the appearance of a face under different illumination using a linear combination of base images (PCA):

- recording images under different illumination

- applying PCA to recorded images to model illumination in recorded images

- Images under unknown illuminations can be represented as a weighted combination of precomputed illumination image templates

B

iii xHxHxH

10 )()()(

Mean Eigen vectors

Page 92: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Linear ModelCan also model the appearance of a face under different illumination using a linear combination of base images (PCA):

- recording images under different illumination

- applying PCA to recorded images to model illumination in recorded images

- Images under unknown illuminations can be represented as a weighted combination of precomputed illumination image template

B

iii xHxHxH

10 )()()(

Mean Eigen vectors

Unknown weights/parameters

Page 93: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Linear ModelCan also model the appearance of a face under different illumination using a linear combination of base images (PCA):

mean face

lighting variation

Page 94: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Image Registration

Similarly, we can formulate this as an optimization problem:

x

B

iii

pxHpxwApxwA

2

10

,)());(());((minarg

Page 95: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Image Registration

Similarly, we can formulate this as an optimization problem:

x

B

iii

pxHpxwApxwA

2

10

,)());(());((minarg

Geometric warping Illumination variations

Page 96: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Image Registration

Similarly, we can formulate this as an optimization problem:

x

B

iii

pxHpxwApxwA

2

10

,)());(());((minarg

x

B

iiii

pxHppxwAppxwA

2

10

,)());(()());((minarg

For iterative registration, we have

Page 97: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Image Registration

Similarly, we can formulate this as an optimization problem:

x

B

iii

pxHpxwApxwA

2

10

,)());(());((minarg

x

B

iiii

pxHppxwAppxwA

2

10

,)());(()());((minarg

orderhighxHpp

WAxApxwAp

p

WApxwA

x

B

iiii

B

iii

p

2

1100

,)())(());(());((minarg

Taylor series expansion

For iterative registration, we have

Page 98: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Gauss-newton optimization

x

B

iiii

B

iii

pxHp

p

WApxwApxwAp

p

WApxwA

2

1100

,)()));((());(());((minarg

Page 99: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Gauss-newton optimization

x

B

iiii

B

iii

pxHp

p

WApxwApxwAp

p

WApxwA

2

1100

,)()));((());(());((minarg

x

B

iii

B

iiii

B

ii

pxHpxwApxwAp

p

WApxwAp

p

WA

2

10

110

,)());(());(());((minarg

Page 100: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Gauss-newton optimization

x

B

iiii

B

iii

pxHp

p

WApxwApxwAp

p

WApxwA

2

1100

,)()));((());(());((minarg

p

q

p

q

x

B

iii

B

iiii

B

ii

pxHpxwApxwAp

p

WApxwAp

p

WA

2

10

110

,)());(());(());((minarg

let similarly

Page 101: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Gauss-newton optimization

x

B

iiii

B

iii

pxHp

p

WApxwApxwAp

p

WApxwA

2

1100

,)()));((());(());((minarg

p

q

p

q

x

B

iii

B

iiii

B

ii

pxHpxwApxwAp

p

WApxwAp

p

WA

2

10

110

,)());(());(());((minarg

xp

bqJ 2

,minarg

let similarly

Page 102: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Gauss-newton optimization

x

B

iiii

B

iii

pxHp

p

WApxwApxwAp

p

WIpxwA

2

110

,)()));((());(());((minarg

p

q

p

q

x

B

iii

B

iiii

B

ii

pxHpxwApxwAp

p

WApxwAp

p

WI

2

10

11,

)());(());(());((minarg

xp

bqJ 2

,minarg

);(()),...,;((,) 11

0 pxwApxwAp

WAAJ B

B

iii

let similarly

Jacobian matrix Error image

B

iii pxwApxwAxHb

10 ));(());(()(

Page 103: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Gauss-newton optimization

x

B

iiii

B

iii

pxHp

p

WApxwApxwAp

p

WIpxwA

2

110

,)()));((());(());((minarg

p

q

p

q

x

B

iii

B

iiii

B

ii

pxHpxwApxwAp

p

WApxwAp

p

WI

2

10

11,

)());(());(());((minarg

xp

bqJ 2

,minarg

);(()),...,;((,) 11

0 pxwApxwAp

WAAJ B

B

iii

let similarly

Jacobian matrix Error image

B

iii pxwApxwAxHb

10 ));(());(()(

bJJJq TT 1)( Update equation:

Page 104: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Results with Illumination Changes

[Hagar and Belhumeur 98]

Page 105: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Applications: 2D Face Registration

Face registration using active appearance models

Page 106: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

AAM for Image registration

• Goal: automatic detection of facial features from a single image

Page 107: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

AAM for Image registration

• Goal: automatic detection of facial features from a single image

• Solution: register input image against a template constructed from a prerecorded facial image database

Page 108: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

AAM: database construction

http://www2.imm.dtu.dk/~aam/datasets/datasets.html

• Construct a database of images (e.g., faces) with variations

Page 109: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

AAM: Feature Labeling

• Label all database images by identifying key facial features

Page 110: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

AAM: Feature Labeling

• Label all database images by identifying key facial features

• So how to build a template based on labeled database images?

Page 111: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Key idea

• Decouple image variation into shape variation and appearance variation

• Model each of them using PCA

• A combined model consists of a linear shape model and a linear appearance model

Page 112: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Shape Variation

Page 113: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Shape Variation modeling

• A linear shape model consists of a triangle base face mesh s0 plus a linear combination of shape vectors, s1,

…,sn

Page 114: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Shape Variation modeling

• A linear shape model consists of a triangle base face mesh s0 plus a linear combination of shape vectors, s1,

…,sn

A long vector stacking positions of vertices

Page 115: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Shape Variation modeling

• A linear shape model consists of a triangle base face mesh s0 plus a linear combination of shape vectors, s1,

…,sn

Mean shape

Page 116: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Shape Variation modeling

• A linear shape model consists of a triangle base face mesh s0 plus a linear combination of shape vectors, s1,

…,sn

Eigen vectors

Page 117: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Shape Variation modeling

• A linear shape model consists of a triangle base face mesh s0 plus a linear combination of shape vectors, s1,

…,sn

Shape parameter

Page 118: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Appearance Variation modeling

• A linear appearance model consists of a base appearance image A0 defined on the pixels inside the base mesh s0 plus a linear combination of m appearance images Ai also defined on the same set of pixels.

Page 119: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Appearance Variation modeling

• A linear appearance model consists of a base appearance image A0 defined on the pixels inside the base mesh s0 plus a linear combination of m appearance images Ai also defined on the same set of pixels.

Defined in base mesh (mean shape)!

Page 120: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Model Instantiations • A new image can be generated via AAM

Page 121: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Image Registration with AAM

• Analysis by synthesis: estimate the optimal parameters by minimizing the difference between input image and synthesized image

-

2

minp

Input image Synthesized image

Page 122: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Image Registration with AAM• Analysis by synthesis: estimate the optimal parameters by

minimizing the difference between input image and synthesized image

• Solve the problem with iterative linear system solvers - for details, check “active appearance model revisited”, Iain Matthews and Simon Baker , IJCV 2004

-

2

minp

Input image Synthesized image

Page 123: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Iterative Approach

Page 124: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Pros and Cons of AAM Registration

• It can register facial images from different peoples, different facial expressions and different illuminations

• The quality of results heavily depends on training datasets

• Gradient-based optimization is prone to local minima

• It often fails when face is under extreme deformation, pose, or illumination

• Needs to figure out a better way to measure the distance between input image and template image (e.g., gradients and edges)

Page 125: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Lucas-Kanade for Image Alignment

Pros:– All pixels get used in matching– Can get sub-pixel accuracy (important for good

mosaicing!)– Relatively fast and simple– Applicable to optical flow estimation, parametric

motion tracking, and AAM registration

Cons:– Prone to local minima– Relative small movement

Page 126: CSCE 643 Computer Vision: Lucas-Kanade Registration Jinxiang Chai

Beyond 2D Tracking/Registration

So far, we focus on registration between 2D images

The same idea can be used in registration between 3D and 2D (model-based tracking)

We will go back to this when we talk about model-based 3D tracking (e.g., head, human body and hand gesture)