OpticalFlow_1_
Document Sample


Stanford CS223B Computer Vision, Winter 2006
Lecture 7
Optical Flow
1
Optical Flow: Outline
• Examples
• Formal definition, 1D case
• From 1D to 2D: Aperture Problem
• Course motion and pyramids
2
Optical Flow
3
* Picture from Khurram Hassan-Shafique CAP5415 Computer Vision 2003
Optical Flow: Outline
• Examples
• Formal definition, 1D case
• From 1D to 2D: Aperture Problem
• Course motion and pyramids
• Flow Segmentation
4
Optical Flow
Image tracking
3D computation
Image sequence Tracked sequence 3D structure
(single camera)
+
3D trajectory
5
What is Optical Flow?
p2
v2
p3
v3
p1 v1
Optical Flow
p4
v4
I (t 1)
I (t ), { pi }
Velocity vectors {vi }
Common assumption:
The appearance of the image patches do not change (brightness constancy)
I ( pi , t ) I ( pi vi , t 1)
6
Optical Flow Assumptions:
Brightness Constancy
7
* Slide from Michael Black, CS143 2003
Optical Flow Assumptions:
8
* Slide from Michael Black, CS143 2003
Optical Flow Assumptions:
9
* Slide from Michael Black, CS143 2003
Optical Flow: 1D Case
Brightness Constancy Assumption:
f (t ) I ( x(t ), t ) I ( x(t dt), t dt)
{
f ( x )
0 Because no change in brightness with time
t
I x I
0
x t t t x(t )
Ix v It
It
v
Ix
10
Tracking in the 1D case:
I ( x, t ) I ( x, t 1)
v?
p
x
11
Tracking in the 1D case:
I ( x, t ) I ( x, t 1)
It
Temporal derivative
p
v
x
Ix
Spatial derivative
Assumptions:
I I I
Ix It v t • Brightness constancy
x t t x p
Ix • Small motion 12
Tracking in the 1D case:
Iterating helps refining the velocity vector
I ( x, t ) I ( x, t 1)
Temporal derivative at 2nd iteration
It
p
x
Ix
Can keep the same estimate for spatial derivative
I
v v previous t Converges in about 5 iterations
Ix 13
Algorithm for 1D tracking:
For all pixel of interest p:
Compute local image derivative at p: I x
Initialize velocity vector: v 0
Repeat until convergence:
Compensate for current velocity vector: I ' ( x, t 1) I ( x v , t 1)
Compute temporal derivative: I t I ' ( p, t 1) I ( p, t )
Update velocity vector: v v I t
Ix
Requirements:
Need access to neighborhood pixels round p to compute I x
Need access to the second image patch, for velocity compensation:
The pixel data to be accessed in next image depends on current
velocity estimate (bad?)
Compensation stage requires a bilinear interpolation (because v is
not integer)
The image derivative I x needs to be kept in memory throughout the 14
iteration process
Optical Flow: Outline
• Examples
• Formal definition, 1D case
• From 1D to 2D: Aperture Problem
• Course motion and pyramids
• Flow Segmentation
15
From 1D to 2D tracking
I x I
1D: 0
x t t t x(t )
I x I y I
2D: 0
x t t y t t t x(t )
I I I
u v 0
x t y t t x(t )
Shoot! One equation, two velocity (u,v) unknowns…
16
From 1D to 2D tracking
We get at most ―Normal Flow‖ – with one point we can only detect movement
perpendicular to the brightness gradient. Solution is to take a patch of pixels
Around the pixel of interest. 17
* Slide from Michael Black, CS143 2003
How does this show up visually?
Known as the ―Aperture Problem‖
18
Aperture Problem Exposed
Motion along just an edge is ambiguous 19
Aperture Problem: Example
20
Aperture Problem in Real Life
21
From 1D to 2D tracking
I ( x, y, t 1)
y
v2
I ( x, t ) I ( x, t 1)
v3
v1
v
v4
x I ( x, y , t )
x
The Math is very similar:
v G 1b
It
v Ix 2
IxI y
Ix G
windowaround p I x I y
2
Iy
I x It
b
windowaround p I y I t
22
Window size here ~ 5x5 or 11x11
More Detail:
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!
23
* From Khurram Hassan-Shafique CAP5415 Computer Vision 2003
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:
– The summations are over all pixels in the K x K window
– This technique was first proposed by Lukas & Kanade (1981)
24
• described in Trucco & Verri reading
* From Khurram Hassan-Shafique CAP5415 Computer Vision 2003
Conditions for solvability
– Optimal (u, v) satisfies Lucas-Kanade equation
When is This Solvable?
• ATA should be invertible
• ATA should not be too small due to noise
– eigenvalues l1 and l2 of ATA should not be too small
• ATA should be well-conditioned
– l1/ l2 should not be too large (l1 = larger eigenvalue)
25
* From Khurram Hassan-Shafique CAP5415 Computer Vision 2003
Eigenvectors of ATA
• Suppose (x,y) is on an edge. What is ATA?
– gradients along edge all point the same direction
– gradients away from edge have small magnitude
– is an eigenvector with eigenvalue
– What’s the other eigenvector of ATA?
• let N be perpendicular to
• N is the second eigenvector with eigenvalue 0
• The eigenvectors of ATA relate to edge direction and magnitude 26
* From Khurram Hassan-Shafique CAP5415 Computer Vision 2003
Edge
– large gradients, all the same
– large l1, small l2
27
* From Khurram Hassan-Shafique CAP5415 Computer Vision 2003
Low texture region
– gradients have small magnitude
– small l1, small l2
28
* From Khurram Hassan-Shafique CAP5415 Computer Vision 2003
High textured region
– gradients are different, large magnitudes
– large l1, large l2
29
* From Khurram Hassan-Shafique CAP5415 Computer Vision 2003
Observation
• 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...
– Once suggestion: Track Harris Corners!
30
* From Khurram Hassan-Shafique CAP5415 Computer Vision 2003
Optical Flow, Example
Harris Corners
31
David Stavens, Andrew Lookingbill, David Lieb (CS223B 2004)
Optical Flow, Example
Optical flow
32
David Stavens, Andrew Lookingbill, David Lieb (CS223B 2004)
Optical Flow: Outline
• Examples
• Formal definition, 1D case
• From 1D to 2D: Aperture Problem
• Course motion and pyramids
• Flow Segmentation
33
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? 34
* From Khurram Hassan-Shafique CAP5415 Computer Vision 2003
Reduce the resolution!
35
* From Khurram Hassan-Shafique CAP5415 Computer Vision 2003
Coarse-to-fine optical flow
estimation
u=1.25 pixels
u=2.5 pixels
u=5 pixels
u=10 pixels
image It-1 image I
36
Gaussian pyramid of image It-1 Gaussian pyramid of image I
Coarse-to-fine optical flow
estimation
run iterative L-K
warp & upsample
run iterative L-K
.
.
.
I
image Jt-1 image I
37
Gaussian pyramid of image It-1 Gaussian pyramid of image I
Multi-resolution Lucas Kanade
Algorithm
38
Get documents about "