csce 643 computer vision: lucas-kanade registration
Post on 22-Jan-2016
78 Views
Preview:
DESCRIPTION
TRANSCRIPT
CSCE 643 Computer Vision: Lucas-Kanade Registration
Jinxiang Chai
Appearance-based Tracking
Slide from Robert Collins
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.
Pixel-based Registration: Optical flow
Will start by estimating motion of each pixel separatelyThen will consider motion of entire image
Problem Definition: Optical Flow
How to estimate pixel motion from image H to image I?
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
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
Optical Flow Constraints
Let’s look at these constraints more closely– brightness constancy: Q: what’s the equation?
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
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
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
Optical Flow EquationCombining these two equations
Optical Flow EquationCombining these two equations
Optical Flow EquationCombining these two equations
Optical Flow EquationCombining these two equations
Optical Flow EquationCombining these two equations
In the limit as u and v go to zero, this becomes exact
Optical Flow Equation
How many unknowns and equations per pixel?
Optical Flow Equation
How many unknowns and equations per pixel?
Intuitively, what does this constraint mean?
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
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
Ambiguity
Ambiguity
Stripes moved upwards 6 pixels
Stripes moved left 5 pixels
Ambiguity
Stripes moved upwards 6 pixels
Stripes moved left 5 pixels
How to address this problem?
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!
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!
Lukas-Kanade Flow
Prob: we have more equations than unknowns
Lukas-Kanade Flow
Prob: we have more equations than unknowns
Solution: solve least squares problem
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:
Lukas-Kanade Flow
– The summations are over all pixels in the K x K window– This technique was first proposed by Lukas & Kanade (1981)
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)
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?
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!
Edge
Bad for motion estimation
- large1, small 2
Low Texture Region
Bad for motion estimation: - gradients have small magnitude
- small1, small 2
High Textured Region
Good for motion estimation: - gradients are different, large magnitudes
- large1, large 2
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
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
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.
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.
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?
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
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
Idea II: Reduce the Resolution!
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
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
.
.
.
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.
Lucas Kanade Tracking
• Assumption of constant flow (pure translation) for all pixels in a larger window might be unreasonable
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)
Beyond Translation
So far, our patch can only translate in (u,v)
What about other motion models?– rotation, affine, perspective
Warping Review
Figure from Szeliski book
Geometric Image Warping
w(x;p) describes the geometric relationship between two images:
);(
);();('
pxw
pxwpxwx
y
x
Transformed ImageInput Image
x’x
Geometric Image Warping
w(x;p) describes the geometric relationship between two images:
);(
);();('
pxw
pxwpxwx
y
x
Transformed ImageInput Image
(x’)
(x)
Warping parameters
Warping Functions
Translation:
Affine:
Perspective:
2
1);(py
pxpxw
1
1);(
87
654
87
321
ypxp
pypxpypxp
pypxp
pxw
654
321);(pypxp
pypxppxw
Image Registration
Find the warping parameter p that minimizes the intensity difference between template image and the warped input image
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
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
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
Image Registration
Mathematically, we can formulate this as an optimization problem:
x
pxHpxwI 2)());((minarg
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:
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:
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:
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
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:
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
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
Gauss-newton Optimization
Rearrange
xp
xHpp
WIpxwI
2
)());((minarg
Gauss-newton Optimization
xp
pxwIxHpp
WI
2
)));(()((minarg
Rearrange
xp
xHpp
WIpxwI
2
)());((minarg
Gauss-newton Optimization
xp
pxwIxHpp
WI
2
)));(()((minarg
Rearrange
A
xp
xHpp
WIpxwI
2
)());((minarg
b
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
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
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
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
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
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
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
Lucas-Kanade Algorithm
Iteration 1:H(x) I(w(x;p)) H(x)-I(w(x;p))
Lucas-Kanade Algorithm
Iteration 2:H(x) I(w(x;p)) H(x)-I(w(x;p))
Lucas-Kanade Algorithm
Iteration 3:H(x) I(w(x;p)) H(x)-I(w(x;p))
Lucas-Kanade Algorithm
Iteration 4:H(x) I(w(x;p)) H(x)-I(w(x;p))
Lucas-Kanade Algorithm
Iteration 5:H(x) I(w(x;p)) H(x)-I(w(x;p))
Lucas-Kanade Algorithm
Iteration 6:H(x) I(w(x;p)) H(x)-I(w(x;p))
Lucas-Kanade Algorithm
Iteration 7:H(x) I(w(x;p)) H(x)-I(w(x;p))
Lucas-Kanade Algorithm
Iteration 8:H(x) I(w(x;p)) H(x)-I(w(x;p))
Lucas-Kanade Algorithm
Iteration 9:H(x) I(w(x;p)) H(x)-I(w(x;p))
Lucas-Kanade Algorithm
Final result:H(x) I(w(x;p)) H(x)-I(w(x;p))
How to Break Assumptions
• Small motion
• Constant optical flow in the window
• Color constancy
Break the Color Constancy
How to deal with illumination change?
xp
xHpxwI 2)());((minarg
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?
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
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 )()()(
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
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
Linear ModelCan also model the appearance of a face under different illumination using a linear combination of base images (PCA):
mean face
lighting variation
Image Registration
Similarly, we can formulate this as an optimization problem:
x
B
iii
pxHpxwApxwA
2
10
,)());(());((minarg
Image Registration
Similarly, we can formulate this as an optimization problem:
x
B
iii
pxHpxwApxwA
2
10
,)());(());((minarg
Geometric warping Illumination variations
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
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
Gauss-newton optimization
x
B
iiii
B
iii
pxHp
p
WApxwApxwAp
p
WApxwA
2
1100
,)()));((());(());((minarg
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
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
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
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 ));(());(()(
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:
Results with Illumination Changes
[Hagar and Belhumeur 98]
Applications: 2D Face Registration
Face registration using active appearance models
AAM for Image registration
• Goal: automatic detection of facial features from a single image
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
AAM: database construction
http://www2.imm.dtu.dk/~aam/datasets/datasets.html
• Construct a database of images (e.g., faces) with variations
AAM: Feature Labeling
• Label all database images by identifying key facial features
AAM: Feature Labeling
• Label all database images by identifying key facial features
• So how to build a template based on labeled database images?
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
Shape Variation
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 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
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
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
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
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.
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)!
Model Instantiations • A new image can be generated via AAM
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
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
Iterative Approach
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)
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
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)
top related