Alper Yilmaz, Fall 2005 UCF
CAP 5415 Computer Vision Fall 2005
Dr. Alper Yilmaz
Univ. of Central Florida
www.cs.ucf.edu/courses/cap5415/fall2005 Office: CSB 250
Alper Yilmaz, Fall 2005 UCF
Recap Motion
z
Brightness constancy constraint
z
Optical flow equation, brightness constancy equation
– Normal flow can be computed
– Parallel flow cannot
) , ,
( ) , ,
(x y t I x x y y t t
I = +∆ +∆ +∆
=0 + + y t
x vI I
uI = + =0 lineequation
y t y x
I I I u I v
Alper Yilmaz, Fall 2005 UCF
Recap
Computing Optical Flow
z
Define energy function
– Brightness constancy + smooth solution (Horn&Schuck)
– Common flow (Schuck)
– Brightness constancy (Lucas&Kanade)
zLeast squares fitting
Recap
Global Motion
z
Common motion of pixels observed in frame
– Camera motion or rigid object motion
z
Affine Model
– Affine Transformation
– Affine Motion
Alper Yilmaz, Fall 2005 UCF
Recap
Affine Transformation
z
Direct relation between pixel positions
2 4
3
1 2
1
'' ''
b y a x a y
b y a x a x
+ +
=
+ +
=
image at time t
(x,y)
image at time t+1
(x’’,y’’)
Alper Yilmaz, Fall 2005 UCF
Recap
Affine Motion
image at time t
(x,y)
image at time t+1
(x’’,y’’) (u,v)
x x
u= ''− v= ''y −y
1 2
) 1
,
(x y a x a y b
u = + + v(x,y)=a3x+a4y+b2
1 2
'' x a1x a y b
x − = + +
1 2 1 1) (
'' a x a y b
x = + + + y ''=a3x+(a4+1)y+b2
Alper Yilmaz, Fall 2005 UCF
Recap
Affine Motion and Transformation
z
Transformation Motion
2 4 3
1 2 1
'' ''
b y a x a y
b y a x a x
+ +
=
+ +
=
2 4
3
1 2 1
) 1 ( ''
) 1 ( ''
b y a
x a y
b y a x a
x
+ + +
=
+ +
+
=
translation rotation
Rigid (rotation and translation) Affine
shear
Recap
Anandan’s Approach (Affine Motion)
2 4 3
1 2 1
) , (
) , (
b y a x a y x v
b y a x a y x u
+ +
=
+ +
=
⎥⎥
⎥⎥
⎥⎥
⎥⎥
⎦
⎤
⎢⎢
⎢⎢
⎢⎢
⎢⎢
⎣
⎡
⎥⎦
⎢ ⎤
⎣
=⎡
⎥⎦
⎢ ⎤
⎣
⎡
2 4 3 1 2 1
1 0
0 0
0 0 0 1 )
, (
) , (
b a a b a a
y x y x y x v
y x u
Xa u =
James R. Bergen, P. Anandan, Keith J. Hanna, Rajesh Hingorani: “Hierarchical Model-Based Motion Estimation," ECCV 1992: 237-252
= 0 +
∆ I u
TI
t= 0 +
∆ I Xa
TI
t( )
∑
∆ += IT It 2
E Xa
minimize
0 ) (
) (
2 ∆ +∆ =
∂ =
∂Ea
∑
ITX T It ITXa∑
∑
∆ ∆ =− ∆pixels all pixels
all
t T T
T I I Xa X I I
X
Alper Yilmaz, Fall 2005 UCF
Algorithm
Alper Yilmaz, Fall 2005 UCF
Block Based Optical Flow
Alper Yilmaz, Fall 2005 UCF
Block Based
z
Select a patch P image at time t
z
Search for P at frame t+1 in a larger neighborhood
P
Block Search
z Search for patch in overlapping windows
z Compute similarity of intensity values between original patch and search patch
z Select the location with highest similarity
z Distance vector between centroids give optical flow vector
Alper Yilmaz, Fall 2005 UCF
Computing Similarity
( )
∑∑
−= It+1 It 2 SSD
( )|
| 1
∑∑
−= It+ It AD
∑∑
+= It 1It CC
( )
∑∑ ∑∑
+=
t t
t t
I I
I I
.
1. NC
Sum of square differences
Absolute difference
Cross correlation
Normalized correlation
( )( )
∑∑
− −= + +
+ t t t t
t t
I
I µ µ
σ
σ 1 1 1
64
MC 1 Mutual correlation
µ, σare region mean and stdv
Alper Yilmaz, Fall 2005 UCF
Correlation Surface
z
Using Cross correlation
CC=∑∑
It+1Itmission reference Correlation surface
Find peak in correlation surface
Alper Yilmaz, Fall 2005 UCF
Issues With Correlation
z Patch Size
z Search Area
z How many peaks
z Computationally expensive
– Same operations in Fourier domain takes less time
zTake FFT of image patch and search area
zMultiply Fourier coefficients to construct corr. surface
zFind maximum
z Should use pyramids here too for large displacements
Token Based Optical Flow
Alper Yilmaz, Fall 2005 UCF
Tokens
z
Interest points
– Movarec’s operator
z
Corners
– Harris corner detector
z
Edges
– Any edge detection algorithm
Alper Yilmaz, Fall 2005 UCF
Overview
z
Given two consecutive images
z
Find tokens in both images
z
Find token correspondences
Frame at time t Frame at time t+1
Alper Yilmaz, Fall 2005 UCF
Representing the Correspondence
z
A graph G(V,E) is a triple consisting of a vertex set V an edge set E and a relation that associates two vertices with an edge.
Representing the Correspondence
z Bipartite graph: A graph G is bipartite if its
vertex set can be partitioned in two subsets
such that no two vertex in same set have a
common edge.
Alper Yilmaz, Fall 2005 UCF
Finding Correspondence
z Finding matching: Matching is a set of edges such that no two of them have a common vertex
w11
wkl
M M
w11
wkl
M M
Alper Yilmaz, Fall 2005 UCF
Token Based Optical Flow
z
Tokens corresponds to vertices in the bipartite graph
z
Tokens at time instants t and t+1 form partite sets of graph.
z
The cost of corresponding a point at instant t
to a point at instant t+1 is the weight of edge
between the corresponding vertices.
Alper Yilmaz, Fall 2005 UCF
Defining Weights
Maximum Speed
Consistent Match
Common Motion Minimum Velocity
Model
Weights
i j
ij y x
w = −
( )
( )( )
( )
⎥⎥⎦
⎤
⎢⎢
⎣
⎡
−
− −
−
⎥+
⎥
⎦
⎤
⎢⎢
⎣
⎡
−
− −
=
i i
i i
x i j
x i j
x i j
x i j
ij AM y x v
v x y c GM
v x y
v x c y
w
, 1 ,
. 1 1
( ) ( ), 2
, b b a a AM
ab b a GM
= +
= mean
aritmetic mean geometric
( )
( )
∑ ∑
∑ ∑
= = = = − + −−
−
−
= − p
k q
l l p
i j p
k q
l x l k
i j x
ij y x
x y x
y v
x y w v
k i
1 1
1 1
Ullman:
Sethi & Jain:
Rangarajan &
Shah:
(Absolute distance between points)
Alper Yilmaz, Fall 2005 UCF
Algorithm
Find initial correspondences using correlation
Compute costs wijfor each pair of points xi, yj
z Construct a bipartite graph based on computed costs
z Prune all edges having weights exceeding certain threshold
– Define cost matrix
z Find the minimum matching of constructed graph.
– Hungarian Algorithm
– Greedy search
Alper Yilmaz, Fall 2005 UCF