Motion estimation Parametric motion (image alignment) Tracking Optical flow.

95
Motion estimation Parametric motion (image alignment) • Tracking Optical flow

Transcript of Motion estimation Parametric motion (image alignment) Tracking Optical flow.

Page 1: Motion estimation Parametric motion (image alignment) Tracking Optical flow.

Motion estimation

• Parametric motion (image alignment)• Tracking• Optical flow

Page 2: Motion estimation Parametric motion (image alignment) Tracking Optical flow.

Tracking

Page 3: Motion estimation Parametric motion (image alignment) Tracking Optical flow.

Three assumptions

• Brightness consistency• Spatial coherence• Temporal persistence

Page 4: Motion estimation Parametric motion (image alignment) Tracking Optical flow.

Brightness consistency

Image measurement (e.g. brightness) in a small region remain the same although their location may change.

Page 5: Motion estimation Parametric motion (image alignment) Tracking Optical flow.

Spatial coherence

• Neighboring points in the scene typically belong to the same surface and hence typically have similar motions.

• Since they also project to nearby pixels in the image, we expect spatial coherence in image flow.

Page 6: Motion estimation Parametric motion (image alignment) Tracking Optical flow.

Temporal persistence

The image motion of a surface patch changes gradually over time.

Page 7: Motion estimation Parametric motion (image alignment) Tracking Optical flow.

Image registration

Goal: register a template image T(x) and an input image I(x), where x=(x,y)T. (warp I so that it matches T)

Image alignment: I(x) and T(x) are two images

Tracking: T(x) is a small patch around a point p in the image at t. I(x) is the image at time t+1.

Optical flow: T(x) and I(x) are patches of images at t and t+1.T

fixed

I

warp

Page 8: Motion estimation Parametric motion (image alignment) Tracking Optical flow.

Simple approach (for translation)

• Minimize brightness difference

yx

yxTvyuxIvuE,

2),(),(),(

Page 9: Motion estimation Parametric motion (image alignment) Tracking Optical flow.

Simple SSD algorithm

For each offset (u, v)

compute E(u,v);

Choose (u, v) which minimizes E(u,v);

Problems:• Not efficient• No sub-pixel accuracy

Page 10: Motion estimation Parametric motion (image alignment) Tracking Optical flow.

Lucas-Kanade algorithm

yx

yxTvyuxIvuE,

2),(),(),(

yx vIuIyxIvyuxI ),(),(

yx

yx vIuIyxTyxI,

2),(),(

Page 11: Motion estimation Parametric motion (image alignment) Tracking Optical flow.
Page 12: Motion estimation Parametric motion (image alignment) Tracking Optical flow.

Linear image registration in medical images

rigid (rotation + translation)

3+3 DOF

Linear registration = similarity (rotation + translation+scale)

3+3+3 DOF

affine (rotation+translation+scale+shear)

3+3+3+3 DOF Used when regsitering images of a same patient

Theoretically a similarity transform should be enough bt in practice an affine transformation is use to account for other

image/scan artefacts.

Page 13: Motion estimation Parametric motion (image alignment) Tracking Optical flow.

x

p)W(x;xp

WHΔp )()(1 ITI

T

Page 14: Motion estimation Parametric motion (image alignment) Tracking Optical flow.

x

p)W(x;xp

WHΔp )()(1 ITI

T

Page 15: Motion estimation Parametric motion (image alignment) Tracking Optical flow.

x

p)W(x;xp

WHΔp )()(1 ITI

T

Page 16: Motion estimation Parametric motion (image alignment) Tracking Optical flow.

x

p)W(x;xp

WHΔp )()(1 ITI

T

Page 17: Motion estimation Parametric motion (image alignment) Tracking Optical flow.

x

p)W(x;xp

WHΔp )()(1 ITI

T

Page 18: Motion estimation Parametric motion (image alignment) Tracking Optical flow.

x

p)W(x;xp

WHΔp )()(1 ITI

T

Page 19: Motion estimation Parametric motion (image alignment) Tracking Optical flow.

x

p)W(x;xp

WHΔp )()(1 ITI

T

Page 20: Motion estimation Parametric motion (image alignment) Tracking Optical flow.

x

p)W(x;xp

WHΔp )()(1 ITI

T

Page 21: Motion estimation Parametric motion (image alignment) Tracking Optical flow.

x

p)W(x;xp

WHΔp )()(1 ITI

T

Page 22: Motion estimation Parametric motion (image alignment) Tracking Optical flow.

x

p)W(x;xp

WHΔp )()(1 ITI

T

Page 23: Motion estimation Parametric motion (image alignment) Tracking Optical flow.

x

p)W(x;xp

WHΔp )()(1 ITI

T

Page 24: Motion estimation Parametric motion (image alignment) Tracking Optical flow.

Lucas-Kanade algorithm

iterate1) warp I with W(x;p)2) compute error image T(x,y)-I(W(x,p))3) compute gradient image with W(x,p)4) evaluate Jacobian at (x;p)5) compute 6) compute Hessian7) compute 8) solve 9) update p by p+until converge

p

W

p

W

I

x

p)W(x;xp

W)()( ITI

T

Δp

Δp

x

p)W(x;xp

WHΔp )()(1 ITI

T

I

Page 25: Motion estimation Parametric motion (image alignment) Tracking Optical flow.

Coarse-to-fine strategy

J Jw Iwarp refine

ina

a

+

J Jw Iwarp refine

a

a+

J

pyramid construction

J Jw Iwarp refine

a+

I

pyramid construction

outa

Page 26: Motion estimation Parametric motion (image alignment) Tracking Optical flow.

Application of image alignment

Page 27: Motion estimation Parametric motion (image alignment) Tracking Optical flow.

Direct vs feature-based

• Direct methods use all information and can be very accurate, but they depend on the fragile “brightness constancy” assumption.

• Iterative approaches require initialization.• Not robust to illumination change and

noise images.• In early days, direct method is better.

• Feature based methods are now more robust and potentially faster.

• Even better, it can recognize panorama without initialization.

Page 28: Motion estimation Parametric motion (image alignment) Tracking Optical flow.

Tracking

Page 29: Motion estimation Parametric motion (image alignment) Tracking Optical flow.

Tracking

I(x,y,t) I(x+u,y+v,t+1)(u, v)

Page 30: Motion estimation Parametric motion (image alignment) Tracking Optical flow.

Tracking

0),,()1,,( tyxItvyuxI

0),,(),,(),,(),,(),,( tyxItyxItyxvItyxuItyxI tyx

0),,(),,(),,( tyxItyxvItyxuI tyx

0 tyx IvIuI optical flow constraint equation

brightness constancy

Page 31: Motion estimation Parametric motion (image alignment) Tracking Optical flow.

Optical flow constraint equation

Page 32: Motion estimation Parametric motion (image alignment) Tracking Optical flow.

Multiple constraints

Page 33: Motion estimation Parametric motion (image alignment) Tracking Optical flow.

Area-based method• Assume spatial smoothness

Page 34: Motion estimation Parametric motion (image alignment) Tracking Optical flow.

Area-based method

• Assume spatial smoothness

yx

tyx IvIuIvuE,

2),(

Page 35: Motion estimation Parametric motion (image alignment) Tracking Optical flow.

Area-based method

must be invertible

Page 36: Motion estimation Parametric motion (image alignment) Tracking Optical flow.

Area-based method• The eigenvalues tell us about the local

image structure.• They also tell us how well we can estimate

the flow in both directions.• Link to Harris corner detector.

Page 37: Motion estimation Parametric motion (image alignment) Tracking Optical flow.

Textured area

Page 38: Motion estimation Parametric motion (image alignment) Tracking Optical flow.

Edge

Page 39: Motion estimation Parametric motion (image alignment) Tracking Optical flow.

Homogenous area

Page 40: Motion estimation Parametric motion (image alignment) Tracking Optical flow.

KLT tracking

• Select features by • Monitor features by measuring

dissimilarity

),( 21min

Page 41: Motion estimation Parametric motion (image alignment) Tracking Optical flow.

Aperture problem

Page 42: Motion estimation Parametric motion (image alignment) Tracking Optical flow.

Aperture problem

Page 43: Motion estimation Parametric motion (image alignment) Tracking Optical flow.

Aperture problem

Page 44: Motion estimation Parametric motion (image alignment) Tracking Optical flow.

Demo for aperture problem

• http://www.sandlotscience.com/Distortions/Breathing_Square.htm

• http://www.sandlotscience.com/Ambiguous/Barberpole_Illusion.htm

Page 45: Motion estimation Parametric motion (image alignment) Tracking Optical flow.

Aperture problem

• Larger window reduces ambiguity, but easily violates spatial smoothness assumption

Page 46: Motion estimation Parametric motion (image alignment) Tracking Optical flow.
Page 47: Motion estimation Parametric motion (image alignment) Tracking Optical flow.
Page 48: Motion estimation Parametric motion (image alignment) Tracking Optical flow.

KLT tracking

http://www.ces.clemson.edu/~stb/klt/

Page 49: Motion estimation Parametric motion (image alignment) Tracking Optical flow.

KLT tracking

http://www.ces.clemson.edu/~stb/klt/

Page 50: Motion estimation Parametric motion (image alignment) Tracking Optical flow.

SIFT tracking (matching actually)

Frame 0 Frame 10

Page 51: Motion estimation Parametric motion (image alignment) Tracking Optical flow.

SIFT tracking

Frame 0 Frame 100

Page 52: Motion estimation Parametric motion (image alignment) Tracking Optical flow.

SIFT tracking

Frame 0 Frame 200

Page 53: Motion estimation Parametric motion (image alignment) Tracking Optical flow.

KLT vs SIFT tracking

• KLT has larger accumulating error; partly because our KLT implementation doesn’t have affine transformation?

• SIFT is surprisingly robust• Combination of SIFT and KLT (example)

http://www.frc.ri.cmu.edu/projects/buzzard/smalls/

Page 54: Motion estimation Parametric motion (image alignment) Tracking Optical flow.

Rotoscoping (Max Fleischer 1914)

1937

Page 55: Motion estimation Parametric motion (image alignment) Tracking Optical flow.

Tracking for rotoscoping

Page 56: Motion estimation Parametric motion (image alignment) Tracking Optical flow.

Tracking for rotoscoping

Page 57: Motion estimation Parametric motion (image alignment) Tracking Optical flow.

Waking life (2001)

Page 58: Motion estimation Parametric motion (image alignment) Tracking Optical flow.

A Scanner Darkly (2006)

• Rotoshop, a proprietary software. Each minute of animation required 500 hours of work.

Page 59: Motion estimation Parametric motion (image alignment) Tracking Optical flow.

Optical flow

Page 60: Motion estimation Parametric motion (image alignment) Tracking Optical flow.

Single-motion assumption

Violated by• Motion discontinuity• Shadows• Transparency• Specular reflection• …

Page 61: Motion estimation Parametric motion (image alignment) Tracking Optical flow.

Multiple motion

Page 62: Motion estimation Parametric motion (image alignment) Tracking Optical flow.

Multiple motion

Page 63: Motion estimation Parametric motion (image alignment) Tracking Optical flow.

Simple problem: fit a line

Page 64: Motion estimation Parametric motion (image alignment) Tracking Optical flow.

Least-square fit

Page 65: Motion estimation Parametric motion (image alignment) Tracking Optical flow.

Least-square fit

Page 66: Motion estimation Parametric motion (image alignment) Tracking Optical flow.

Robust statistics

• Recover the best fit for the majority of the data

• Detect and reject outliers

Page 67: Motion estimation Parametric motion (image alignment) Tracking Optical flow.

Approach

Page 68: Motion estimation Parametric motion (image alignment) Tracking Optical flow.

Robust weighting

Truncated quadratic

Page 69: Motion estimation Parametric motion (image alignment) Tracking Optical flow.

Robust weighting

Geman & McClure

Page 70: Motion estimation Parametric motion (image alignment) Tracking Optical flow.

Robust estimation

Page 71: Motion estimation Parametric motion (image alignment) Tracking Optical flow.

Fragmented occlusion

Page 72: Motion estimation Parametric motion (image alignment) Tracking Optical flow.
Page 73: Motion estimation Parametric motion (image alignment) Tracking Optical flow.
Page 74: Motion estimation Parametric motion (image alignment) Tracking Optical flow.

Regularization and dense optical flow

• Neighboring points in the scene typically belong to the same surface and hence typically have similar motions.

• Since they also project to nearby pixels in the image, we expect spatial coherence in image flow.

Page 75: Motion estimation Parametric motion (image alignment) Tracking Optical flow.
Page 76: Motion estimation Parametric motion (image alignment) Tracking Optical flow.
Page 77: Motion estimation Parametric motion (image alignment) Tracking Optical flow.
Page 78: Motion estimation Parametric motion (image alignment) Tracking Optical flow.
Page 79: Motion estimation Parametric motion (image alignment) Tracking Optical flow.
Page 80: Motion estimation Parametric motion (image alignment) Tracking Optical flow.
Page 81: Motion estimation Parametric motion (image alignment) Tracking Optical flow.

Input image Horizontal motion

Vertical motion

Page 82: Motion estimation Parametric motion (image alignment) Tracking Optical flow.
Page 83: Motion estimation Parametric motion (image alignment) Tracking Optical flow.
Page 84: Motion estimation Parametric motion (image alignment) Tracking Optical flow.

Application of optical flow

videomatching

Page 85: Motion estimation Parametric motion (image alignment) Tracking Optical flow.
Page 86: Motion estimation Parametric motion (image alignment) Tracking Optical flow.

Input for the NPR algorithm

Page 87: Motion estimation Parametric motion (image alignment) Tracking Optical flow.

Brushes

Page 88: Motion estimation Parametric motion (image alignment) Tracking Optical flow.

Edge clipping

Page 89: Motion estimation Parametric motion (image alignment) Tracking Optical flow.

Gradient

Page 90: Motion estimation Parametric motion (image alignment) Tracking Optical flow.

Smooth gradient

Page 91: Motion estimation Parametric motion (image alignment) Tracking Optical flow.

Textured brush

Page 92: Motion estimation Parametric motion (image alignment) Tracking Optical flow.

Edge clipping

Page 93: Motion estimation Parametric motion (image alignment) Tracking Optical flow.

Temporal artifacts

Frame-by-frame application of the NPR algorithm

Page 94: Motion estimation Parametric motion (image alignment) Tracking Optical flow.

Temporal coherence

Page 95: Motion estimation Parametric motion (image alignment) Tracking Optical flow.

References• B.D. Lucas and T. Kanade, An Iterative Image Registration Technique

with an Application to Stereo Vision, Proceedings of the 1981 DARPA Image Understanding Workshop, 1981, pp121-130.

• Bergen, J. R. and Anandan, P. and Hanna, K. J. and Hingorani, R., Hierarchical Model-Based Motion Estimation, ECCV 1992, pp237-252.

• J. Shi and C. Tomasi, Good Features to Track, CVPR 1994, pp593-600. • Michael Black and P. Anandan, The Robust Estimation of Multiple

Motions: Parametric and Piecewise-Smooth Flow Fields, Computer Vision and Image Understanding 1996, pp75-104.

• S. Baker and I. Matthews, Lucas-Kanade 20 Years On: A Unifying Framework, International Journal of Computer Vision, 56(3), 2004, pp221 - 255.

• Peter Litwinowicz, Processing Images and Video for An Impressionist

Effects, SIGGRAPH 1997. • Aseem Agarwala, Aaron Hertzman, David Salesin and Steven Seitz,

Keyframe-Based Tracking for Rotoscoping and Animation, SIGGRAPH 2004, pp584-591.