Top Banner
Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256 / K.H. Shafique, UCSF, CAP5415 / S. Narasimhan, CMU / Bahadir K. Gunturk, EE 7730 / Bradski&Thrun, Stanford CS223
78

Optical Flow I - Scientific Computing and Imaging …gerig/CS6320-S2013/Materials/CS6320-CV...Optical Flow and Motion •We are interested in finding the movement of scene objects

Jul 08, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Optical Flow I - Scientific Computing and Imaging …gerig/CS6320-S2013/Materials/CS6320-CV...Optical Flow and Motion •We are interested in finding the movement of scene objects

Optical Flow I

Guido Gerig

CS 6320, Spring 2013

(credits: Marc Pollefeys UNC Chapel Hill, Comp 256 / K.H. Shafique, UCSF, CAP5415 / S. Narasimhan, CMU / Bahadir

K. Gunturk, EE 7730 / Bradski&Thrun, Stanford CS223

Page 2: Optical Flow I - Scientific Computing and Imaging …gerig/CS6320-S2013/Materials/CS6320-CV...Optical Flow and Motion •We are interested in finding the movement of scene objects

Materials

• Gary Bradski & Sebastian Thrun, Stanford CS223 http://robots.stanford.edu/cs223b/index.html

• S. Narasimhan, CMU: http://www.cs.cmu.edu/afs/cs/academic/class/15385-s06/lectures/ppts/lec-16.ppt

• M. Pollefeys, ETH Zurich/UNC Chapel Hill: http://www.cs.unc.edu/Research/vision/comp256/vision10.ppt

• K.H. Shafique, UCSF: http://www.cs.ucf.edu/courses/cap6411/cap5415/

– Lecture 18 (March 25, 2003), Slides: PDF/ PPT

• Jepson, Toronto: http://www.cs.toronto.edu/pub/jepson/teaching/vision/2503/opticalFlow.pdf

• Original paper Horn&Schunck 1981: http://www.csd.uwo.ca/faculty/beau/CS9645/PAPERS/Horn-Schunck.pdf

• MIT AI Memo Horn& Schunck 1980: http://people.csail.mit.edu/bkph/AIM/AIM-572.pdf

• Bahadir K. Gunturk, EE 7730 Image Analysis II

• Some slides and illustrations from L. Van Gool, T. Darell, B. Horn, Y. Weiss, P. Anandan, M. Black, K. Toyama

Page 3: Optical Flow I - Scientific Computing and Imaging …gerig/CS6320-S2013/Materials/CS6320-CV...Optical Flow and Motion •We are interested in finding the movement of scene objects

Optical Flow and Motion

• We are interested in finding the movement of scene objects from time-

varying images (videos).

• Lots of uses

– Motion detection

– Track objects

– Correct for camera jitter (stabilization)

– Align images (mosaics)

– 3D shape reconstruction

– Special effects

– Games: http://www.youtube.com/watch?v=JlLkkom6tWw

– User Interfaces: http://www.youtube.com/watch?v=Q3gT52sHDI4

– Video compression

Page 4: Optical Flow I - Scientific Computing and Imaging …gerig/CS6320-S2013/Materials/CS6320-CV...Optical Flow and Motion •We are interested in finding the movement of scene objects

Tracking – Rigid Objects

Page 5: Optical Flow I - Scientific Computing and Imaging …gerig/CS6320-S2013/Materials/CS6320-CV...Optical Flow and Motion •We are interested in finding the movement of scene objects

Tracking – Non-rigid Objects

(Comaniciu et al, Siemens)

Page 6: Optical Flow I - Scientific Computing and Imaging …gerig/CS6320-S2013/Materials/CS6320-CV...Optical Flow and Motion •We are interested in finding the movement of scene objects

Tracking – Non-rigid Objects

Page 7: Optical Flow I - Scientific Computing and Imaging …gerig/CS6320-S2013/Materials/CS6320-CV...Optical Flow and Motion •We are interested in finding the movement of scene objects

7

Optical Flow: Where do pixels move to?

Page 8: Optical Flow I - Scientific Computing and Imaging …gerig/CS6320-S2013/Materials/CS6320-CV...Optical Flow and Motion •We are interested in finding the movement of scene objects

Optical Flow: Where do pixels move to?

Page 9: Optical Flow I - Scientific Computing and Imaging …gerig/CS6320-S2013/Materials/CS6320-CV...Optical Flow and Motion •We are interested in finding the movement of scene objects

)1( tI

What is Optical Flow (OF)?

Optical Flow

}{),( iptI

1p

2p

3p

4p

1v

2v

3v

4v

}{ iv

Velocity vectors

Common assumption:

The appearance of the image patches do not change (brightness constancy)

)1,(),( tvpItpI iii

Note: more elaborate tracking models can be adopted if more frames are process all at once

Optical flow is the relation of the motion field: • the 2D projection of the physical movement of points relative to the observer

to 2D displacement of pixel patches on the image plane.

Page 10: Optical Flow I - Scientific Computing and Imaging …gerig/CS6320-S2013/Materials/CS6320-CV...Optical Flow and Motion •We are interested in finding the movement of scene objects

Optical Flow: Correspondence

Basic question: Which Pixel went where?

Page 11: Optical Flow I - Scientific Computing and Imaging …gerig/CS6320-S2013/Materials/CS6320-CV...Optical Flow and Motion •We are interested in finding the movement of scene objects

Structure from Motion?

• Known: optical flow (instantaneous velocity)

• Motion of camera / object?

Page 12: Optical Flow I - Scientific Computing and Imaging …gerig/CS6320-S2013/Materials/CS6320-CV...Optical Flow and Motion •We are interested in finding the movement of scene objects

Optical Flow is NOT 3D motion field

http://of-eval.sourceforge.net/

Optical flow: Pixel motion field as observed in image.

Page 13: Optical Flow I - Scientific Computing and Imaging …gerig/CS6320-S2013/Materials/CS6320-CV...Optical Flow and Motion •We are interested in finding the movement of scene objects

Optical Flow is NOT 3D motion field

http://en.wikipedia.org/wiki/File:Opticfloweg.png

Page 14: Optical Flow I - Scientific Computing and Imaging …gerig/CS6320-S2013/Materials/CS6320-CV...Optical Flow and Motion •We are interested in finding the movement of scene objects

14

Definition of optical flow

OPTICAL FLOW = apparent motion of brightness patterns

Ideally, the optical flow is the projection of the three-dimensional velocity vectors on the image

Page 15: Optical Flow I - Scientific Computing and Imaging …gerig/CS6320-S2013/Materials/CS6320-CV...Optical Flow and Motion •We are interested in finding the movement of scene objects

Optical Flow - Agenda

• Brightness Constancy

• The Aperture problem

• Regularization

• Lucas-Kanade

• Coarse-to-fine

• Parametric motion models

• Direct depth

• SSD tracking

• Robust flow

• Bayesian flow

Page 16: Optical Flow I - Scientific Computing and Imaging …gerig/CS6320-S2013/Materials/CS6320-CV...Optical Flow and Motion •We are interested in finding the movement of scene objects

16

Optical Flow - Agenda

• Brightness Constancy

• The Aperture problem

• Regularization

• Lucas-Kanade

• Coarse-to-fine

• Parametric motion models

• Direct depth

• SSD tracking

• Robust flow

• Bayesian flow

Page 17: Optical Flow I - Scientific Computing and Imaging …gerig/CS6320-S2013/Materials/CS6320-CV...Optical Flow and Motion •We are interested in finding the movement of scene objects

Start with an Equation: Brightness Constancy

Point moves (small), but its brightness remains constant: 𝐼𝑡1(𝑥, 𝑦) = 𝐼𝑡2(𝑥 + 𝑢, 𝑦 + 𝑣)

𝐼 = 𝑐𝑜𝑛𝑠𝑡𝑎𝑛𝑡 → 𝑑𝐼

𝑑𝑡= 0

𝐼1 𝐼2

Time: t Time: t + dt

Page 18: Optical Flow I - Scientific Computing and Imaging …gerig/CS6320-S2013/Materials/CS6320-CV...Optical Flow and Motion •We are interested in finding the movement of scene objects

Mathematical formulation

I (x(t),y(t),t) = brightness at (x,y) at time t

Optical flow constraint equation (chain rule):

0

t

I

dt

dy

y

I

dt

dx

x

I

dt

dI

),,(),,( tyxItttdt

dyyt

dt

dxxI

Brightness constancy assumption (shift of location

but brightness stays same):

Page 19: Optical Flow I - Scientific Computing and Imaging …gerig/CS6320-S2013/Materials/CS6320-CV...Optical Flow and Motion •We are interested in finding the movement of scene objects

The aperture problem

0 tyx IvIuI

1 equation in 2 unknowns

dt

dxu

dt

dyv

, x

II x

y

II y

t

II t

Horn and Schunck optical flow equation

Page 20: Optical Flow I - Scientific Computing and Imaging …gerig/CS6320-S2013/Materials/CS6320-CV...Optical Flow and Motion •We are interested in finding the movement of scene objects

Optical Flow: 1D Case Brightness Constancy Assumption:

)),(()),(()( dttdttxIttxItf

0)(

txt t

I

t

x

x

I

Ix v It

x

t

I

Iv

{0)(

t

xfBecause no change in brightness with time

Gary Bradski & Sebastian Thrun, Stanford CS223 http://robots.stanford.edu/cs223b/index.html

Page 21: Optical Flow I - Scientific Computing and Imaging …gerig/CS6320-S2013/Materials/CS6320-CV...Optical Flow and Motion •We are interested in finding the movement of scene objects

21

v

?

Tracking in the 1D case:

x

),( txI )1,( txI

p

Gary Bradski & Sebastian Thrun, Stanford CS223 http://robots.stanford.edu/cs223b/index.html

Page 22: Optical Flow I - Scientific Computing and Imaging …gerig/CS6320-S2013/Materials/CS6320-CV...Optical Flow and Motion •We are interested in finding the movement of scene objects

v

xI

Spatial derivative

Temporal derivative tI

Tracking in the 1D case:

x

),( txI )1,( txI

p

t

xx

II

px

tt

II

x

t

I

Iv

Assumptions:

• Brightness constancy

• Small motion

Page 23: Optical Flow I - Scientific Computing and Imaging …gerig/CS6320-S2013/Materials/CS6320-CV...Optical Flow and Motion •We are interested in finding the movement of scene objects

Tracking in the 1D case:

x

),( txI )1,( txI

p

xI

tI

Temporal derivative at 2nd iteration

Iterating helps refining the velocity vector

Can keep the same estimate for spatial derivative

x

tprevious

I

Ivv

Converges in about 5 iterations

Page 24: Optical Flow I - Scientific Computing and Imaging …gerig/CS6320-S2013/Materials/CS6320-CV...Optical Flow and Motion •We are interested in finding the movement of scene objects

From 1D to 2D tracking

0)(

txt t

I

t

x

x

I1D:

0)(

txtt t

I

t

y

y

I

t

x

x

I2D:

0)(

txtt t

Iv

y

Iu

x

I

Shoot! One equation, two velocity (u,v) unknowns…

Page 25: Optical Flow I - Scientific Computing and Imaging …gerig/CS6320-S2013/Materials/CS6320-CV...Optical Flow and Motion •We are interested in finding the movement of scene objects

25

Optical Flow

• Brightness Constancy

• The Aperture problem

• Regularization

• Lucas-Kanade

• Coarse-to-fine

• Parametric motion models

• Direct depth

• SSD tracking

• Robust flow

• Bayesian flow

Page 26: Optical Flow I - Scientific Computing and Imaging …gerig/CS6320-S2013/Materials/CS6320-CV...Optical Flow and Motion •We are interested in finding the movement of scene objects

How does this show up visually? Known as the “Aperture Problem”

Gary Bradski & Sebastian Thrun, Stanford CS223 http://robots.stanford.edu/cs223b/index.html

Page 27: Optical Flow I - Scientific Computing and Imaging …gerig/CS6320-S2013/Materials/CS6320-CV...Optical Flow and Motion •We are interested in finding the movement of scene objects

Aperture Problem Exposed

Motion along just an edge is ambiguous Gary Bradski & Sebastian Thrun, Stanford CS223 http://robots.stanford.edu/cs223b/index.html

Page 28: Optical Flow I - Scientific Computing and Imaging …gerig/CS6320-S2013/Materials/CS6320-CV...Optical Flow and Motion •We are interested in finding the movement of scene objects

How does this show up visually? Known as the “Aperture Problem”

Gary Bradski & Sebastian Thrun, Stanford CS223 http://robots.stanford.edu/cs223b/index.html

Page 29: Optical Flow I - Scientific Computing and Imaging …gerig/CS6320-S2013/Materials/CS6320-CV...Optical Flow and Motion •We are interested in finding the movement of scene objects

Optical Flow vs. Motion: Aperture Problem

Barber shop pole: http://www.youtube.com/watch?v=VmqQs613SbE

Page 30: Optical Flow I - Scientific Computing and Imaging …gerig/CS6320-S2013/Materials/CS6320-CV...Optical Flow and Motion •We are interested in finding the movement of scene objects

Normal Flow What we can get !!

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.

Page 31: Optical Flow I - Scientific Computing and Imaging …gerig/CS6320-S2013/Materials/CS6320-CV...Optical Flow and Motion •We are interested in finding the movement of scene objects

Recall: Aperture Problem

Page 32: Optical Flow I - Scientific Computing and Imaging …gerig/CS6320-S2013/Materials/CS6320-CV...Optical Flow and Motion •We are interested in finding the movement of scene objects

Recall: Aperture Problem

Page 33: Optical Flow I - Scientific Computing and Imaging …gerig/CS6320-S2013/Materials/CS6320-CV...Optical Flow and Motion •We are interested in finding the movement of scene objects

33

Page 34: Optical Flow I - Scientific Computing and Imaging …gerig/CS6320-S2013/Materials/CS6320-CV...Optical Flow and Motion •We are interested in finding the movement of scene objects

Aperture Problem and Normal Flow

Page 35: Optical Flow I - Scientific Computing and Imaging …gerig/CS6320-S2013/Materials/CS6320-CV...Optical Flow and Motion •We are interested in finding the movement of scene objects

Computing True Flow

• Schunck

• Horn & Schunck

• Lukas and Kanade

Page 36: Optical Flow I - Scientific Computing and Imaging …gerig/CS6320-S2013/Materials/CS6320-CV...Optical Flow and Motion •We are interested in finding the movement of scene objects

Possible Solution: Neighbors

Two adjacent pixels which are part of the same rigid

object: • we can calculate normal flows vn1 and vn2

• Two OF equations for 2 parameters of flow: 𝑣 = 𝑣𝑢

𝛻𝐼1. 𝑣 − 𝐼𝑡1 = 0 𝛻𝐼2 . 𝑣 − 𝐼𝑡2 = 0

Page 37: Optical Flow I - Scientific Computing and Imaging …gerig/CS6320-S2013/Materials/CS6320-CV...Optical Flow and Motion •We are interested in finding the movement of scene objects

Schunck: Considering Neighbor Pixels

Page 38: Optical Flow I - Scientific Computing and Imaging …gerig/CS6320-S2013/Materials/CS6320-CV...Optical Flow and Motion •We are interested in finding the movement of scene objects

Schunck: Considering Neighbor Pixels

Jepson, Toronto: http://www.cs.toronto.edu/pub/jepson/teaching/vision/2503/opticalFlow.pdf

Cluster center provides velocity vector common for all pixels in patch.

Page 39: Optical Flow I - Scientific Computing and Imaging …gerig/CS6320-S2013/Materials/CS6320-CV...Optical Flow and Motion •We are interested in finding the movement of scene objects

39

Optical Flow

• Brightness Constancy

• The Aperture problem

• Regularization: Horn & Schunck

• Lucas-Kanade

• Coarse-to-fine

• Parametric motion models

• Direct depth

• SSD tracking

• Robust flow

• Bayesian flow

Page 40: Optical Flow I - Scientific Computing and Imaging …gerig/CS6320-S2013/Materials/CS6320-CV...Optical Flow and Motion •We are interested in finding the movement of scene objects

40

Horn & Schunck algorithm

Page 41: Optical Flow I - Scientific Computing and Imaging …gerig/CS6320-S2013/Materials/CS6320-CV...Optical Flow and Motion •We are interested in finding the movement of scene objects

41

Additional smoothness constraint (usually motion field varies smoothly in the image → penalize departure from smoothness) :

,))()(( 2222 dxdyvvuue yxyxs

OF constraint equation term (formulate error in optical flow constraint) : ,)( 2dxdyIvIuIe tyxc minimize es+ec

Horn & Schunck algorithm

Page 42: Optical Flow I - Scientific Computing and Imaging …gerig/CS6320-S2013/Materials/CS6320-CV...Optical Flow and Motion •We are interested in finding the movement of scene objects

42

Variational calculus: Pair of second order differential equations that can be solved iteratively.

Horn & Schunck algorithm

Page 43: Optical Flow I - Scientific Computing and Imaging …gerig/CS6320-S2013/Materials/CS6320-CV...Optical Flow and Motion •We are interested in finding the movement of scene objects

43

Horn & Schunck algorithm 𝐼𝑥 𝐼𝑥𝑢 + 𝐼𝑦𝑣 + 𝐼𝑡 + 𝜆Δ𝑢 = 0

𝐼𝑦 𝐼𝑥𝑢 + 𝐼𝑦𝑣 + 𝐼𝑡 + 𝜆Δ𝑣 = 0

Δ𝑢 𝑥, 𝑦 = 𝑢 𝑥, 𝑦 − 𝑢 𝑥, 𝑦 Δ𝑣 𝑥,𝑦 = 𝑣 𝑥, 𝑦 − 𝑣 𝑥, 𝑦

Approximate Laplacian by weight averaged computed in a neighborhood around the pixel (x,y):

Rearranging terms: 0 = 𝐼𝑥 𝐼𝑥𝑢 + 𝐼𝑦𝑣 + 𝐼𝑡 + 𝜆 𝑢 − 𝑢

= 𝑢 𝜆 + 𝐼𝑥2 + 𝑣𝐼𝑥𝐼𝑦 + 𝐼𝑥𝐼𝑡 − 𝜆𝑢

0 = 𝐼𝑦 𝐼𝑥𝑢 + 𝐼𝑦𝑣 + 𝐼𝑡 + 𝜆 𝑣 − 𝑣

= 𝑣 𝜆 + 𝐼𝑦2 + 𝑢𝐼𝑥𝐼𝑦 + 𝐼𝑦𝐼𝑡 − 𝜆𝑣

2 equations in 2 unknowns, write v in terms of u and plug it in the other equation

Page 44: Optical Flow I - Scientific Computing and Imaging …gerig/CS6320-S2013/Materials/CS6320-CV...Optical Flow and Motion •We are interested in finding the movement of scene objects

44

Horn & Schunck algorithm

𝑢 =𝜆𝑢 − 𝑣𝐼𝑥𝐼𝑦 − 𝐼𝑥𝐼𝑡

𝜆 + 𝐼𝑥2

𝑣 =𝜆𝑣 − 𝑢𝐼𝑥𝐼𝑦 − 𝐼𝑦𝐼𝑡

𝜆 + 𝐼𝑦2

2 equations in 2 unknowns, write v in terms of u and plug it in the other equation

Page 45: Optical Flow I - Scientific Computing and Imaging …gerig/CS6320-S2013/Materials/CS6320-CV...Optical Flow and Motion •We are interested in finding the movement of scene objects

45

The Euler-Lagrange equations :

0

0

yx

yx

vvv

uuu

Fy

Fx

F

Fy

Fx

F

In our case ,

,)()()( 22222tyxyxyx IvIuIvvuuF

so the Euler-Lagrange equations are

,)(,)(

ytyx

xtyx

IIvIuIv

IIvIuIu

2

2

2

2

yx

is the Laplacian operator

Horn & Schunck algorithm

Page 46: Optical Flow I - Scientific Computing and Imaging …gerig/CS6320-S2013/Materials/CS6320-CV...Optical Flow and Motion •We are interested in finding the movement of scene objects

46

Remarks :

1. Coupled PDEs solved using iterative methods and finite differences

2. More than two frames allow a better estimation of It

3. Information spreads from corner-type patterns

,)(

,)(

ytyx

xtyx

IIvIuIvt

v

IIvIuIut

u

Horn & Schunck algorithm

Page 47: Optical Flow I - Scientific Computing and Imaging …gerig/CS6320-S2013/Materials/CS6320-CV...Optical Flow and Motion •We are interested in finding the movement of scene objects

Discrete Optical Flow Algorithm

Consider image pixel

• Departure from Smoothness Constraint:

•Error in Optical Flow constraint equation: • We seek the set that minimize:

i j

ijij cse )(

])()(

)()[(41

2,1,

2,,1

2,1,

2,,1

jijijiji

jijijijiij

vvvv

uuuus

2)( ij

tij

ij

yij

ij

xij IvIuIc

}{&}{ ijij vu

NOTE: show up in more than one term

}{&}{ ijij vu

),( ji

Page 48: Optical Flow I - Scientific Computing and Imaging …gerig/CS6320-S2013/Materials/CS6320-CV...Optical Flow and Motion •We are interested in finding the movement of scene objects

Discrete Optical Flow Algorithm

• Differentiating w.r.t and setting to zero:

• are averages of around pixel

e

0)(2)(2

kl

x

kl

tkl

kl

ykl

kl

xklkl

kl

IIvIuIuuu

e

0)(2)(2

kl

y

kl

tkl

kl

ykl

kl

xklkl

kl

IIvIuIvvv

e

klkl uv &

klkl uv & ),( lk),( vu

kl

xkl

y

kl

x

kl

t

n

kl

kl

y

n

kl

kl

xn

kl

n

kl III

IvIuIuu

])()[(1 221

kl

ykl

y

kl

x

kl

t

n

kl

kl

y

n

kl

kl

xn

kl

n

kl III

IvIuIvv

])()[(1 221

Update Rule:

Page 49: Optical Flow I - Scientific Computing and Imaging …gerig/CS6320-S2013/Materials/CS6320-CV...Optical Flow and Motion •We are interested in finding the movement of scene objects

Horn-Schunck Algorithm : Discrete Case

• Derivatives (and error functionals) are approximated by difference operators

• Leads to an iterative solution:

y

n

ij

n

ij

x

n

ij

n

ij

Ivv

Iuu

1

1

)(1 22yx

t

n

ijy

n

ijx

II

IvIuI

neighbors of valuesof average theis ,vu

Page 50: Optical Flow I - Scientific Computing and Imaging …gerig/CS6320-S2013/Materials/CS6320-CV...Optical Flow and Motion •We are interested in finding the movement of scene objects

Intuition of the Iterative Scheme

u

v (Ex,Ey)

Constraint line

(u,v)

),( vu

The new value of (u,v) at a point is equal to the average of surrounding values minus an adjustment in the direction of the brightness gradient

Page 51: Optical Flow I - Scientific Computing and Imaging …gerig/CS6320-S2013/Materials/CS6320-CV...Optical Flow and Motion •We are interested in finding the movement of scene objects

Horn - Schunck Algorithm

Page 52: Optical Flow I - Scientific Computing and Imaging …gerig/CS6320-S2013/Materials/CS6320-CV...Optical Flow and Motion •We are interested in finding the movement of scene objects

Example

http://of-eval.sourceforge.net/

Page 53: Optical Flow I - Scientific Computing and Imaging …gerig/CS6320-S2013/Materials/CS6320-CV...Optical Flow and Motion •We are interested in finding the movement of scene objects

Results

Page 54: Optical Flow I - Scientific Computing and Imaging …gerig/CS6320-S2013/Materials/CS6320-CV...Optical Flow and Motion •We are interested in finding the movement of scene objects

Results

Page 55: Optical Flow I - Scientific Computing and Imaging …gerig/CS6320-S2013/Materials/CS6320-CV...Optical Flow and Motion •We are interested in finding the movement of scene objects

Optical Flow Result

Page 56: Optical Flow I - Scientific Computing and Imaging …gerig/CS6320-S2013/Materials/CS6320-CV...Optical Flow and Motion •We are interested in finding the movement of scene objects

57

Horn & Schunck, remarks

1. Errors at boundaries

2. Example of regularisation

(selection principle for the solution of illposed problems)

Page 57: Optical Flow I - Scientific Computing and Imaging …gerig/CS6320-S2013/Materials/CS6320-CV...Optical Flow and Motion •We are interested in finding the movement of scene objects

Results of an enhanced system

Page 59: Optical Flow I - Scientific Computing and Imaging …gerig/CS6320-S2013/Materials/CS6320-CV...Optical Flow and Motion •We are interested in finding the movement of scene objects

Results http://www.cs.utexas.edu/users/jmugan/GraphicsProject/OpticalFlow/

Page 60: Optical Flow I - Scientific Computing and Imaging …gerig/CS6320-S2013/Materials/CS6320-CV...Optical Flow and Motion •We are interested in finding the movement of scene objects

61

Optical Flow

• Brightness Constancy

• The Aperture problem

• Regularization

• Lucas-Kanade

• Coarse-to-fine

• Parametric motion models

• Direct depth

• SSD tracking

• Robust flow

• Bayesian flow

Page 61: Optical Flow I - Scientific Computing and Imaging …gerig/CS6320-S2013/Materials/CS6320-CV...Optical Flow and Motion •We are interested in finding the movement of scene objects

Lucas & Kanade

•Assume single velocity for all pixels within a patch. •Integrate over a patch.

Page 62: Optical Flow I - Scientific Computing and Imaging …gerig/CS6320-S2013/Materials/CS6320-CV...Optical Flow and Motion •We are interested in finding the movement of scene objects

Lucas & Kanade

Page 63: Optical Flow I - Scientific Computing and Imaging …gerig/CS6320-S2013/Materials/CS6320-CV...Optical Flow and Motion •We are interested in finding the movement of scene objects

Lucas & Kanade

Page 64: Optical Flow I - Scientific Computing and Imaging …gerig/CS6320-S2013/Materials/CS6320-CV...Optical Flow and Motion •We are interested in finding the movement of scene objects

65

02),(

02),(

tyxy

tyxx

IvIuIIdv

vudE

IvIuIIdu

vudE

Page 65: Optical Flow I - Scientific Computing and Imaging …gerig/CS6320-S2013/Materials/CS6320-CV...Optical Flow and Motion •We are interested in finding the movement of scene objects

66

Page 66: Optical Flow I - Scientific Computing and Imaging …gerig/CS6320-S2013/Materials/CS6320-CV...Optical Flow and Motion •We are interested in finding the movement of scene objects

Discussion • Horn-Schunck: Add smoothness constraint.

• Lucas-Kanade: Provide constraint by minimizing over local neighborhood:

• Horn-Schunck and Lucas-Kanade optical methods work only for small motion.

• If object moves faster, the brightness changes rapidly, derivative masks fail to estimate spatiotemporal derivatives.

• Pyramids can be used to compute large optical flow vectors.

Page 67: Optical Flow I - Scientific Computing and Imaging …gerig/CS6320-S2013/Materials/CS6320-CV...Optical Flow and Motion •We are interested in finding the movement of scene objects

Iterative Refinement (Iterative Lucas-Kanade)

• Estimate velocity at each pixel using one iteration of Lucas and Kanade estimation

• Warp one image toward the other using the estimated flow field

(easier said than done)

• Refine estimate by repeating the process

Page 68: Optical Flow I - Scientific Computing and Imaging …gerig/CS6320-S2013/Materials/CS6320-CV...Optical Flow and Motion •We are interested in finding the movement of scene objects

Reduce the Resolution!

Page 69: Optical Flow I - Scientific Computing and Imaging …gerig/CS6320-S2013/Materials/CS6320-CV...Optical Flow and Motion •We are interested in finding the movement of scene objects

70

Optical Flow

• Brightness Constancy

• The Aperture problem

• Regularization

• Lucas-Kanade

• Coarse-to-fine

• Parametric motion models

• Direct depth

• SSD tracking

• Robust flow

• Bayesian flow

Page 70: Optical Flow I - Scientific Computing and Imaging …gerig/CS6320-S2013/Materials/CS6320-CV...Optical Flow and Motion •We are interested in finding the movement of scene objects
Page 71: Optical Flow I - Scientific Computing and Imaging …gerig/CS6320-S2013/Materials/CS6320-CV...Optical Flow and Motion •We are interested in finding the movement of scene objects

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 72: Optical Flow I - Scientific Computing and Imaging …gerig/CS6320-S2013/Materials/CS6320-CV...Optical Flow and Motion •We are interested in finding the movement of scene objects

image I image H

Gaussian pyramid of image H Gaussian pyramid of image I

image I image H u=10 pixels

u=5 pixels

u=2.5 pixels

u=1.25 pixels

Coarse-to-fine Optical Flow Estimation

Page 73: Optical Flow I - Scientific Computing and Imaging …gerig/CS6320-S2013/Materials/CS6320-CV...Optical Flow and Motion •We are interested in finding the movement of scene objects

image I image J

Gaussian pyramid of image H Gaussian pyramid of image I

image I image H

run iterative OF

run iterative OF

upsample

.

.

.

Coarse-to-fine Optical Flow Estimation

Page 74: Optical Flow I - Scientific Computing and Imaging …gerig/CS6320-S2013/Materials/CS6320-CV...Optical Flow and Motion •We are interested in finding the movement of scene objects

75

Page 75: Optical Flow I - Scientific Computing and Imaging …gerig/CS6320-S2013/Materials/CS6320-CV...Optical Flow and Motion •We are interested in finding the movement of scene objects

Video Segmentation

Page 76: Optical Flow I - Scientific Computing and Imaging …gerig/CS6320-S2013/Materials/CS6320-CV...Optical Flow and Motion •We are interested in finding the movement of scene objects

Next: Motion Field

Structure from Motion

Page 77: Optical Flow I - Scientific Computing and Imaging …gerig/CS6320-S2013/Materials/CS6320-CV...Optical Flow and Motion •We are interested in finding the movement of scene objects

Motion Field

X

Y

or

ir

'f

• Image velocity of a point moving in the scene

Perspective projection: Zf

o

o

oi

r

Zr

rr

ˆ'

1

22 ''

Zr

Zvr

Zr

rZvvZrrv

o

oo

o

ooooii ff

dt

d

Motion field

tov

tiv Scene point velocity:

Image velocity: dt

d oo

rv

dt

d ii

rv

Z

Z

Page 78: Optical Flow I - Scientific Computing and Imaging …gerig/CS6320-S2013/Materials/CS6320-CV...Optical Flow and Motion •We are interested in finding the movement of scene objects