46
CS 664 Visual Motion (2) Daniel Huttenlocher

CS 664 Visual Motion (2) - Cornell University€¦ · Visual Motion (2) Daniel Huttenlocher. 2 Last Time ... iteration of Lucas and Kanade estimation ... cs664-14-motion2.ppt

Embed Size (px)

Citation preview

Page 1: CS 664 Visual Motion (2) - Cornell University€¦ · Visual Motion (2) Daniel Huttenlocher. 2 Last Time ... iteration of Lucas and Kanade estimation ... cs664-14-motion2.ppt

CS 664Visual Motion (2)

Daniel Huttenlocher

Page 2: CS 664 Visual Motion (2) - Cornell University€¦ · Visual Motion (2) Daniel Huttenlocher. 2 Last Time ... iteration of Lucas and Kanade estimation ... cs664-14-motion2.ppt

2

Last Time

Visual motion (optical flow)– Apparent motion of image pixels over time

Brightness constancy assumption and optical flow constraint equation (gradient constraint)

Direct and matching-based methods for estimating motion field (u,v)– Dense and sparse matching

0≈+⋅+⋅ tyx IvIuI

Page 3: CS 664 Visual Motion (2) - Cornell University€¦ · Visual Motion (2) Daniel Huttenlocher. 2 Last Time ... iteration of Lucas and Kanade estimation ... cs664-14-motion2.ppt

3

Matching vs. Gradient Based

Consider image I translated by

21

,00

2

,1

)),(),(),((

)),(),((),(

yxvvyuuxIyxI

vyuxIyxIvuE

yx

yx

η−+−+−−=

++−=

00 ,vu

),(),(),(),(),(

1001

0

yxyxIvyuxIyxIyxI

η+=++=

Discrete search methods search for the best estimate, u(x,y),v(x,y).Gradient methods linearize the intensity function and solve for the estimate.

Page 4: CS 664 Visual Motion (2) - Cornell University€¦ · Visual Motion (2) Daniel Huttenlocher. 2 Last Time ... iteration of Lucas and Kanade estimation ... cs664-14-motion2.ppt

4

Patch Matching

Determining correspondences

– Block matching or SSD (sum squared differences)

Page 5: CS 664 Visual Motion (2) - Cornell University€¦ · Visual Motion (2) Daniel Huttenlocher. 2 Last Time ... iteration of Lucas and Kanade estimation ... cs664-14-motion2.ppt

5

Dense Matching Based Methods

Block matching for larger displacements– Define a small area around a pixel as the

template– Match the template against each pixel within a

search area in next image.– Use a match measure such as correlation,

normalized correlation, or sum-of-squares difference

– Choose the maximum (or minimum) as the match

– Sub-pixel estimate (Lucas-Kanade)

Page 6: CS 664 Visual Motion (2) - Cornell University€¦ · Visual Motion (2) Daniel Huttenlocher. 2 Last Time ... iteration of Lucas and Kanade estimation ... cs664-14-motion2.ppt

6

Gradient Based Methods

Iterative refinementEstimate velocity at each pixel using one iteration of Lucas and Kanade estimationWarp one image toward the other using the estimated flow field(easier said than done)

Refine estimate by repeating the processCoarse-to-fine process for larger motions

Page 7: CS 664 Visual Motion (2) - Cornell University€¦ · Visual Motion (2) Daniel Huttenlocher. 2 Last Time ... iteration of Lucas and Kanade estimation ... cs664-14-motion2.ppt

7

Optical Flow: Iterative Estimation

xx0

Initial guess: Estimate:

estimate update

(using d for displacement here instead of u)

Page 8: CS 664 Visual Motion (2) - Cornell University€¦ · Visual Motion (2) Daniel Huttenlocher. 2 Last Time ... iteration of Lucas and Kanade estimation ... cs664-14-motion2.ppt

8

Optical Flow: Iterative Estimation

xx0

estimate update

Initial guess: Estimate:

Page 9: CS 664 Visual Motion (2) - Cornell University€¦ · Visual Motion (2) Daniel Huttenlocher. 2 Last Time ... iteration of Lucas and Kanade estimation ... cs664-14-motion2.ppt

9

Optical Flow: Iterative Estimation

xx0

Initial guess: Estimate:Initial guess: Estimate:

estimate update

Page 10: CS 664 Visual Motion (2) - Cornell University€¦ · Visual Motion (2) Daniel Huttenlocher. 2 Last Time ... iteration of Lucas and Kanade estimation ... cs664-14-motion2.ppt

10

Optical Flow: Iterative Estimation

xx0

Page 11: CS 664 Visual Motion (2) - Cornell University€¦ · Visual Motion (2) Daniel Huttenlocher. 2 Last Time ... iteration of Lucas and Kanade estimation ... cs664-14-motion2.ppt

11

Optical Flow: Iterative Estimation

Some issues:– Warping not easy (need to be sure errors in

warping are smaller than the estimate refinement)

– Warp one image, take derivatives of the other so you don’t need to re-compute the gradient after each iteration.

– Often useful to low-pass filter the images before motion estimation (for better derivative estimation, and linear approximations to image intensity)

Page 12: CS 664 Visual Motion (2) - Cornell University€¦ · Visual Motion (2) Daniel Huttenlocher. 2 Last Time ... iteration of Lucas and Kanade estimation ... cs664-14-motion2.ppt

12

Optical Flow: Aliasing

Temporal aliasing causes ambiguities in optical flow because images can have many pixels with the same intensity.I.e., how do we know which ‘correspondence’ is correct?

Nearest match correct (no aliasing)

Nearest match incorrect (aliasing)

To overcome aliasing: coarse-to-fine estimation.

actual shift

estimated shift

Page 13: CS 664 Visual Motion (2) - Cornell University€¦ · Visual Motion (2) Daniel Huttenlocher. 2 Last Time ... iteration of Lucas and Kanade estimation ... cs664-14-motion2.ppt

13

Robust Estimation

Noise distributions are often non-Gaussian, having much heavier tails. Noise samples from the tails are called outliers.

Sources of outliers (multiple motions):– specularities / highlights– jpeg artifacts / interlacing / motion blur– multiple motions (occlusion boundaries, transparency)

velocity spacevelocity space

u1

u2

++

Page 14: CS 664 Visual Motion (2) - Cornell University€¦ · Visual Motion (2) Daniel Huttenlocher. 2 Last Time ... iteration of Lucas and Kanade estimation ... cs664-14-motion2.ppt

14

Robust Estimation

Standard Least Squares Estimation allows too much influence for outlying points (similar in stereo and other correspondence problems)

)()

)()(

)()(

2

mxx

x

mxx

xmE

i

ii

ii

−=∂∂

=

−=

=∑

ρψ

ρ

ρ

( Influence

Page 15: CS 664 Visual Motion (2) - Cornell University€¦ · Visual Motion (2) Daniel Huttenlocher. 2 Last Time ... iteration of Lucas and Kanade estimation ... cs664-14-motion2.ppt

15

Robust Estimation

( )∑ ++= tsysxssd IvIuIvuE ρ),(

( )∑ ++−= ),(),(),( ssssd vyuxJyxIvuE ρ

IRLS (iteratively reweighted least squares)

Use of robust error functions– Robust gradient constraint

– Robust SSD

Page 16: CS 664 Visual Motion (2) - Cornell University€¦ · Visual Motion (2) Daniel Huttenlocher. 2 Last Time ... iteration of Lucas and Kanade estimation ... cs664-14-motion2.ppt

16

Robust Estimation

Problem: Least-squares estimators penalize deviations between data & model with quadratic error fn (extremely sensitive to outliers)

error penalty function influence function

Redescending error functions (e.g., Geman-McClure) help to reduce the influence of outlying measurements.

error penalty function influence function

Page 17: CS 664 Visual Motion (2) - Cornell University€¦ · Visual Motion (2) Daniel Huttenlocher. 2 Last Time ... iteration of Lucas and Kanade estimation ... cs664-14-motion2.ppt

17

“Global” (Nonlocal) Motion Estimation

Estimate motion vectors that are parameterized over some region– Each vector fits some low-order model of how

vector field changes spatially

Regions can be contiguous image patches or “layers” of some kindMost successful motion estimation techniques in practice use global motion estimates over patches and/or layers

Page 18: CS 664 Visual Motion (2) - Cornell University€¦ · Visual Motion (2) Daniel Huttenlocher. 2 Last Time ... iteration of Lucas and Kanade estimation ... cs664-14-motion2.ppt

18

“Global” Motion Models

Often referred to as parametric motion2D Models– Affine– Quadratic– Planar projective transform (Homography)

3D Models– Homography+epipole– Plane+Parallax

Page 19: CS 664 Visual Motion (2) - Cornell University€¦ · Visual Motion (2) Daniel Huttenlocher. 2 Last Time ... iteration of Lucas and Kanade estimation ... cs664-14-motion2.ppt

19

Motion Models

Translation

2 unknowns

Affine

6 unknowns

Perspective

8 unknowns

3D rotation

3 unknowns

Page 20: CS 664 Visual Motion (2) - Cornell University€¦ · Visual Motion (2) Daniel Huttenlocher. 2 Last Time ... iteration of Lucas and Kanade estimation ... cs664-14-motion2.ppt

20

0)()( 654321 ≈++++++ tyx IyaxaaIyaxaaI

Substituting into B.C. Equation:yaxaayxvyaxaayxu

654

321

),(),(

++=++=

Each pixel provides linear constraint on 6 (global) unknowns

0≈+⋅+⋅ tyx IvIuI

[ ] 2∑ ++++++= tyx IyaxaaIyaxaaIaErr )()()( 654321r

Least Squares Minimization (over all pixels):

Example: Affine Motion

Page 21: CS 664 Visual Motion (2) - Cornell University€¦ · Visual Motion (2) Daniel Huttenlocher. 2 Last Time ... iteration of Lucas and Kanade estimation ... cs664-14-motion2.ppt

21

Quadratic – instantaneous approximation to planar motion 2

87654

82

7321

yqxyqyqxqqv

xyqxqyqxqqu

++++=

++++=

yyvxxu

yhxhhyhxhhy

yhxhhyhxhhx

−=−=

++++

=

++++

=

',' and

'

'

987

654

987

321

Projective – exact planar motion

Other Global Motion Models

Page 22: CS 664 Visual Motion (2) - Cornell University€¦ · Visual Motion (2) Daniel Huttenlocher. 2 Last Time ... iteration of Lucas and Kanade estimation ... cs664-14-motion2.ppt

22

yyvxxuthyhxhthyhxhy

thyhxhthyhxhx

−=−=++++++

=

++++++

=

',' :and

'

'

3987

1654

3987

1321

γγγγ

)(1

)(1

233

133

tytt

xyv

txtt

xxu

w

w

−+

=−=

−+

=−=

γγγγ

Global parameters: 32191 ,,,,, ttthh K

),( yxγ

Homography+Epipole

Local Parameter:

Residual Planar Parallax MotionGlobal parameters: 321 ,, ttt

),( yxγLocal Parameter:

3D Motion Models

Page 23: CS 664 Visual Motion (2) - Cornell University€¦ · Visual Motion (2) Daniel Huttenlocher. 2 Last Time ... iteration of Lucas and Kanade estimation ... cs664-14-motion2.ppt

23

Page 24: CS 664 Visual Motion (2) - Cornell University€¦ · Visual Motion (2) Daniel Huttenlocher. 2 Last Time ... iteration of Lucas and Kanade estimation ... cs664-14-motion2.ppt

24

Page 25: CS 664 Visual Motion (2) - Cornell University€¦ · Visual Motion (2) Daniel Huttenlocher. 2 Last Time ... iteration of Lucas and Kanade estimation ... cs664-14-motion2.ppt

25

Multiple (Layered) Motions

Combining global parametric motion estimation with robust estimation– Calculate predominant parameterized motion

over entire image (e.g., affine)– Corresponds to largest planar surface in scene

under orthographic projection• If doesn’t occupy majority of pixels robust

estimator will probably fail to recover its motion

– Outlier pixels (low weights in IRLS) are not part of this surface• Recursively try estimating their motion• If no good estimate, then remain outliers

Page 26: CS 664 Visual Motion (2) - Cornell University€¦ · Visual Motion (2) Daniel Huttenlocher. 2 Last Time ... iteration of Lucas and Kanade estimation ... cs664-14-motion2.ppt

26

Limits of Gradient Based Methods

Fails when – Intensity structure in window is poor– Displacement is large (typical operating range

is motion of 1 pixel)• Linearization of brightness is suitable only for

small displacements

Brightness not strictly constant in images– Less problematic than appears, since can pre-

filter images to make them look similar

Large displacements can be addressed by coarse-to-fine (challenge to do locally)

Page 27: CS 664 Visual Motion (2) - Cornell University€¦ · Visual Motion (2) Daniel Huttenlocher. 2 Last Time ... iteration of Lucas and Kanade estimation ... cs664-14-motion2.ppt

27

image Iimage J

avJwwarp refine

av aΔ v+

Pyramid of image J Pyramid of image I

image Iimage J u=10 pixels

u=5 pixels

u=2.5 pixels

u=1.25 pixels

Coarse to Fine

Page 28: CS 664 Visual Motion (2) - Cornell University€¦ · Visual Motion (2) Daniel Huttenlocher. 2 Last Time ... iteration of Lucas and Kanade estimation ... cs664-14-motion2.ppt

28

Coarse to Fine Estimation

Compute Mk, estimate of motion at level k– Can be local motion estimate (uk,vk)

• Vector field with motion of patch at each pixel

– Can be global motion estimate• Parametric model (e.g., affine) of dominant

motion for entire image

– Choose max k such that motion about one pixel

Apply Mk at level k-1 and estimate remaining motion at that level, iterate– Local estimates: shift Ik by 2(uk,vk)– Global estimates: apply inverse transform to Jk-1

Page 29: CS 664 Visual Motion (2) - Cornell University€¦ · Visual Motion (2) Daniel Huttenlocher. 2 Last Time ... iteration of Lucas and Kanade estimation ... cs664-14-motion2.ppt

29

Global Motion Coarse to Fine

Compute transformation Tk mapping pixels of Ik to Jk

Warp image Jk-1 using Tk

– Apply inverse of Tk

– Double resolution of Tk (translations double)

Compute transformation Tk-1 mapping pixels of Ik to warped Jk-1

– Estimate of “residual” motion at this level– Total estimate of motion at this level is

composition of Tk-1 and resolution doubled Tk

• In case of translation just add them

Page 30: CS 664 Visual Motion (2) - Cornell University€¦ · Visual Motion (2) Daniel Huttenlocher. 2 Last Time ... iteration of Lucas and Kanade estimation ... cs664-14-motion2.ppt

30

Affine Mosaic Example

Coarse-to-fine affine motion – Pan tilt camera sweeping repeatedly over scene

Moving objects removed from background– Outliers in motion estimate removed

Page 31: CS 664 Visual Motion (2) - Cornell University€¦ · Visual Motion (2) Daniel Huttenlocher. 2 Last Time ... iteration of Lucas and Kanade estimation ... cs664-14-motion2.ppt

31

Motion Representations

How can we describe this scene?

Page 32: CS 664 Visual Motion (2) - Cornell University€¦ · Visual Motion (2) Daniel Huttenlocher. 2 Last Time ... iteration of Lucas and Kanade estimation ... cs664-14-motion2.ppt

32

Block-based Motion Prediction

Break image up into square blocksEstimate translation for each blockUse this to predict next frame, code difference (MPEG-2)

Page 33: CS 664 Visual Motion (2) - Cornell University€¦ · Visual Motion (2) Daniel Huttenlocher. 2 Last Time ... iteration of Lucas and Kanade estimation ... cs664-14-motion2.ppt

33

Layered Motion

Break image sequence up into “layers”:

Describe each layer’s motion (generally parametrically)

Page 34: CS 664 Visual Motion (2) - Cornell University€¦ · Visual Motion (2) Daniel Huttenlocher. 2 Last Time ... iteration of Lucas and Kanade estimation ... cs664-14-motion2.ppt

34

Layered Motion

Advantages:– Can represent occlusions / disocclusions– Each layer’s motion can be smooth– Video segmentation for semantic processing

Difficulties/challenges:– How do we determine the correct number of

layers (independent motions)?– How do we assign pixels to layers?– How do we model the motions?

Page 35: CS 664 Visual Motion (2) - Cornell University€¦ · Visual Motion (2) Daniel Huttenlocher. 2 Last Time ... iteration of Lucas and Kanade estimation ... cs664-14-motion2.ppt

35

Layers for Video Summarization

Page 36: CS 664 Visual Motion (2) - Cornell University€¦ · Visual Motion (2) Daniel Huttenlocher. 2 Last Time ... iteration of Lucas and Kanade estimation ... cs664-14-motion2.ppt

36

Background Modeling (MPEG-4)

Convert masked images into a background sprite for layered video coding

+ + +

=

Page 37: CS 664 Visual Motion (2) - Cornell University€¦ · Visual Motion (2) Daniel Huttenlocher. 2 Last Time ... iteration of Lucas and Kanade estimation ... cs664-14-motion2.ppt

37

What are Layers?

[Wang & Adelson, 1994]IntensitiesAlphasVelocities

Page 38: CS 664 Visual Motion (2) - Cornell University€¦ · Visual Motion (2) Daniel Huttenlocher. 2 Last Time ... iteration of Lucas and Kanade estimation ... cs664-14-motion2.ppt

38

Forming Layers

Page 39: CS 664 Visual Motion (2) - Cornell University€¦ · Visual Motion (2) Daniel Huttenlocher. 2 Last Time ... iteration of Lucas and Kanade estimation ... cs664-14-motion2.ppt

39

Forming Layers

Page 40: CS 664 Visual Motion (2) - Cornell University€¦ · Visual Motion (2) Daniel Huttenlocher. 2 Last Time ... iteration of Lucas and Kanade estimation ... cs664-14-motion2.ppt

40

How do we estimate the layers?

1. Compute coarse-to-fine flow2. Estimate affine motion in blocks

(regression)3. Cluster with k-means4. Assign pixels to best fitting affine region5. Re-estimate affine motions in each region

Page 41: CS 664 Visual Motion (2) - Cornell University€¦ · Visual Motion (2) Daniel Huttenlocher. 2 Last Time ... iteration of Lucas and Kanade estimation ... cs664-14-motion2.ppt

41

Layer Synthesis

For each layer:Stabilize the sequence with the affine motionCompute median value at each pixelDetermine occlusion relationships

Page 42: CS 664 Visual Motion (2) - Cornell University€¦ · Visual Motion (2) Daniel Huttenlocher. 2 Last Time ... iteration of Lucas and Kanade estimation ... cs664-14-motion2.ppt

42

Page 43: CS 664 Visual Motion (2) - Cornell University€¦ · Visual Motion (2) Daniel Huttenlocher. 2 Last Time ... iteration of Lucas and Kanade estimation ... cs664-14-motion2.ppt

43

Sparse Feature Matching

Shi-Tomasi feature tracker 1. Find good features (min eigenvalue of 2×2

Hessian)2. Use Lucas-Kanade to track with pure

translation3. Use affine registration with first feature patch4. Terminate tracks whose dissimilarity gets too

large5. Start new tracks “when needed”

Unmatched features

Page 44: CS 664 Visual Motion (2) - Cornell University€¦ · Visual Motion (2) Daniel Huttenlocher. 2 Last Time ... iteration of Lucas and Kanade estimation ... cs664-14-motion2.ppt

44

Feature Tracking Example

Page 45: CS 664 Visual Motion (2) - Cornell University€¦ · Visual Motion (2) Daniel Huttenlocher. 2 Last Time ... iteration of Lucas and Kanade estimation ... cs664-14-motion2.ppt

45

Feature Tracking: Motion Models

Page 46: CS 664 Visual Motion (2) - Cornell University€¦ · Visual Motion (2) Daniel Huttenlocher. 2 Last Time ... iteration of Lucas and Kanade estimation ... cs664-14-motion2.ppt

46

Feature Tracking Results