VC 1415 TP 12 Optical Flow Mestrado em

  • Slides: 41
Download presentation
VC 14/15 – TP 12 Optical Flow Mestrado em Ciência de Computadores Mestrado Integrado

VC 14/15 – TP 12 Optical Flow Mestrado em Ciência de Computadores Mestrado Integrado em Engenharia de Redes e Sistemas Informáticos Miguel Tavares Coimbra

Outline • Optical Flow Constraint Equation • Aperture problem. • The Lucas & Kanade

Outline • Optical Flow Constraint Equation • Aperture problem. • The Lucas & Kanade Algorithm Acknowledgements: Most of this course is based on the excellent courses offered by Prof. Shree Nayar at Columbia University, USA and by Prof. Srinivasa Narasimhan at CMU, USA. Please acknowledge the original source when reusing these slides for academic purposes. VC 14/15 - TP 12 - Optical Flow

Topic: Optical Flow Constraint Equation • Aperture problem. • The Lucas & Kanade Algorithm

Topic: Optical Flow Constraint Equation • Aperture problem. • The Lucas & Kanade Algorithm VC 14/15 - TP 12 - Optical Flow

Optical Flow and Motion • We are interested in finding the movement of scene

Optical Flow and Motion • We are interested in finding the movement of scene objects from time-varying images (videos). • Lots of uses – – – Track object behavior Correct for camera jitter (stabilization) Align images (mosaics) 3 D shape reconstruction Special effects VC 14/15 - TP 12 - Optical Flow

Exemplo 14/15 - TP 12 - Optical Flow Where can i find. VCmotion?

Exemplo 14/15 - TP 12 - Optical Flow Where can i find. VCmotion?

14/15 - TP 12 - Optical Flow Lucas & Kanade. VCOptical Flow method

14/15 - TP 12 - Optical Flow Lucas & Kanade. VCOptical Flow method

Optical Flow – What is that? Optical flow is “the distribution of apparent velocities

Optical Flow – What is that? Optical flow is “the distribution of apparent velocities of movement of brightness patterns in an image” – Horn and Schunck 1980 The optical flow field approximates the true motion field which is a “purely geometrical concept. . . , it is the [2 D] projection into the image [plane] of [the sequence’s] 3 D motion vectors” – Horn and Schunk 1993 y Motion Plane Image Plane z x What can i use it for? VC 14/15 - TP 12 - Optical Flow

VC 14/15 - TP 12 - Optical Flow Tracking Rigid Objects (Simon Baker, CMU)

VC 14/15 - TP 12 - Optical Flow Tracking Rigid Objects (Simon Baker, CMU)

VC 14/15 - TP 12 - Optical Flow Tracking – Non-rigid Objects (Comaniciu et

VC 14/15 - TP 12 - Optical Flow Tracking – Non-rigid Objects (Comaniciu et al, Siemens)

Face Tracking (Simon Baker et al, CMU) VC 14/15 - TP 12 - Optical

Face Tracking (Simon Baker et al, CMU) VC 14/15 - TP 12 - Optical Flow

3 D Structure from Motion VC 14/15 - TP 12 - Optical Flow (David

3 D Structure from Motion VC 14/15 - TP 12 - Optical Flow (David Nister, Kentucky)

Motion Field • Image velocity of a point moving in the scene Scene point

Motion Field • Image velocity of a point moving in the scene Scene point velocity: Image velocity: Perspective projection: Motion field VC 14/15 - TP 12 - Optical Flow

Optical Flow • Motion of brightness pattern in the image • Ideally Optical flow

Optical Flow • Motion of brightness pattern in the image • Ideally Optical flow = Motion field VC 14/15 - TP 12 - Optical Flow

Optical Flow Motion field exists but no optical flow VC 14/15 - TP 12

Optical Flow Motion field exists but no optical flow VC 14/15 - TP 12 - Optical Flow Motion Field No motion field but shading changes

Problem Definition: Optical Flow • How to estimate pixel motion from image H to

Problem Definition: Optical Flow • How to estimate pixel motion from image H to image I? – Find pixel correspondences • Given a pixel in H, look for nearby pixels of the same color in I • Key assumptions – color constancy: a point in H looks “the same” in image I • For grayscale images, this is brightness constancy – small motion: points do not move very far VC 14/15 - TP 12 - Optical Flow

Optical Flow Constraint Equation Optical Flow: Velocities Displacement: – Assume brightness of patch remains

Optical Flow Constraint Equation Optical Flow: Velocities Displacement: – Assume brightness of patch remains same in both images: – Assume small motion: (Taylor expansion of LHS up to first order) VC 14/15 - TP 12 - Optical Flow

Optical Flow Constraint Equation Divide by and take the limit Constraint Equation NOTE: must

Optical Flow Constraint Equation Divide by and take the limit Constraint Equation NOTE: must lie on a straight line We can compute using gradient operators! VC 14/15 - Optical Flow But, (u, v) cannot be- TP 12 found uniquely with this constraint!

Optical Flow Constraint • Intuitively, what does this constraint mean? – The component of

Optical Flow Constraint • Intuitively, what does this constraint mean? – The component of the flow in the gradient direction is determined. – The component of the flow parallel to an edge is unknown. VC 14/15 - TP 12 - Optical Flow

Topic: Aperture problem • Optical Flow Constraint Equation • Aperture problem. • The Lucas

Topic: Aperture problem • Optical Flow Constraint Equation • Aperture problem. • The Lucas & Kanade Algorithm VC 14/15 - TP 12 - Optical Flow

Optical Flow Constraint VC 14/15 - TP 12 - Optical Flow

Optical Flow Constraint VC 14/15 - TP 12 - Optical Flow

How does this show up visually? Known as the “Aperture Problem” [Gary Bradski, Intel

How does this show up visually? Known as the “Aperture Problem” [Gary Bradski, Intel Research and Stanford SAIL] VC 14/15 - TP 12 - Optical Flow

Aperture Problem Exposed [Gary Bradski, Intel Research and Stanford SAIL] Motion along just an

Aperture Problem Exposed [Gary Bradski, Intel Research and Stanford SAIL] Motion along just an edge is ambiguous VC 14/15 - TP 12 - Optical Flow

Computing Optical Flow • Formulate Error in Optical Flow Constraint: • We need additional

Computing Optical Flow • Formulate Error in Optical Flow Constraint: • We need additional constraints! • Smoothness Constraint (as in shape from shading and stereo): Usually motion field varies smoothly in the image. So, penalize departure from smoothness: • Find (u, v) at each image point that MINIMIZES: VC 14/15 - TP 12 - Optical Flow weighting factor

Example VC 14/15 - TP 12 - Optical Flow

Example VC 14/15 - TP 12 - Optical Flow

VC 14/15 - TP 12 - Optical Flow

VC 14/15 - TP 12 - Optical Flow

Revisiting the Small Motion Assumption • Is this motion small enough? – Probably not—it’s

Revisiting the Small Motion Assumption • Is this motion small enough? – Probably not—it’s much larger than one pixel (2 nd order terms dominate) VC 14/15 - TP 12 - Optical Flow – How might we solve this problem?

Reduce the Resolution! VC 14/15 - TP 12 - Optical Flow

Reduce the Resolution! VC 14/15 - TP 12 - Optical Flow

Coarse-to-fine Optical Flow Estimation u=1. 25 pixels u=2. 5 pixels u=5 pixels image. HH

Coarse-to-fine Optical Flow Estimation u=1. 25 pixels u=2. 5 pixels u=5 pixels image. HH u=10 pixels VC 14/15 - TP 12 - Optical Flow Gaussian pyramid of image H image II image Gaussian pyramid of image I

Coarse-to-fine Optical Flow Estimation run iterative OF upsample run iterative OF. . . image

Coarse-to-fine Optical Flow Estimation run iterative OF upsample run iterative OF. . . image HJ image VC 14/15 - TP 12 - Optical Flow Gaussian pyramid of image H image II image Gaussian pyramid of image I

Types of OF methods • Differential – Horn and Schunck [HS 80], Lucas Kanade

Types of OF methods • Differential – Horn and Schunck [HS 80], Lucas Kanade [LK 81], Nagel [83]. • Region-based matching – Anandan [Anan 87], Singh [Singh 90], Digital video encoding standards. • Energy-based – Heeger [Heeg 87] • Phase-based – Fleet and Jepson [FJ 90] VC 14/15 - TP 12 - Optical Flow Open problem! Current solutions are not good enough!

Topic: The Lucas & Kanade Algorithm • Optical Flow Constraint Equation • Aperture problem.

Topic: The Lucas & Kanade Algorithm • Optical Flow Constraint Equation • Aperture problem. • The Lucas & Kanade Algorithm VC 14/15 - TP 12 - Optical Flow

The Lucas & Kanade Method • How to get more equations for a pixel?

The Lucas & Kanade Method • 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 5 x 5 window, that gives us 25 equations per pixel! VC 14/15 - TP 12 - Optical Flow * From Khurram Hassan-Shafique CAP 5415 Computer Vision 2003

Lukas-Kanade flow • Prob: we have more equations than unknowns • Solution: solve least

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) VC 14/15 - TP 12 - Optical Flow • described in Trucco & Verri reading * From Khurram Hassan-Shafique CAP 5415 Computer Vision 2003

Conditions for solvability – Optimal (u, v) satisfies Lucas-Kanade equation When is This Solvable?

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 l 1 and l 2 of ATA should not be too small • ATA should be well-conditioned – l 1/ l 2 should not be too large (l 1 = larger eigenvalue) VC 14/15 - TP 12 - Optical Flow * From Khurram Hassan-Shafique CAP 5415 Computer Vision 2003

Eigenvectors of ATA • Suppose (x, y) is on an edge. What is ATA?

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 ATA- Optical relate. Flow to edge direction and magnitude VC 14/15 of - TP 12 * From Khurram Hassan-Shafique CAP 5415 Computer Vision 2003

Edge – large gradients, all the same – large l 1, small l 2

Edge – large gradients, all the same – large l 1, small l 2 VC 14/15 - TP 12 - Optical Flow * From Khurram Hassan-Shafique CAP 5415 Computer Vision 2003

Low texture region – gradients have small magnitude – small l 1, small l

Low texture region – gradients have small magnitude – small l 1, small l 2 VC 14/15 - TP 12 - Optical Flow * From Khurram Hassan-Shafique CAP 5415 Computer Vision 2003

High textured region – gradients are different, large magnitudes – large l 1, large

High textured region – gradients are different, large magnitudes – large l 1, large l 2 VC 14/15 - TP 12 - Optical Flow * From Khurram Hassan-Shafique CAP 5415 Computer Vision 2003

Sparse Motion Field • We are only confident in motion vectors of areas with

Sparse Motion Field • We are only confident in motion vectors of areas with two strong eigenvectors. – Optical flow. • Not so confident when we have one or zero strong eigenvectors. – Normal flow (apperture problem). – Unknown flow (blank-wall problem). VC 14/15 - TP 12 - Optical Flow

Summing all up • Optical flow: – Algorithms try to approximate the true motion

Summing all up • Optical flow: – Algorithms try to approximate the true motion field of the image plane. – The Optical Flow Constraint Equation needs an additional constraint (e. g. smoothness, constant local flow). – The Lucas Kanade method is the most popular Optical Flow Algorithm. • What applications is this useful for? • What about block matching? VC 14/15 - TP 12 - Optical Flow

Resources • Barron, “Tutorial: Computing 2 D and 3 D Optical Flow. ”, http:

Resources • Barron, “Tutorial: Computing 2 D and 3 D Optical Flow. ”, http: //www. tina-vision. net/docs/memos/2004 -012. pdf • CVonline: Optical Flow http: //homepages. inf. ed. ac. uk/cgi/rbf/CVONLINE/entries. pl? TAG 518 • Fast Image Motion Estimation Demo http: //extra. cmis. csiro. au/IA/changs/motion/ VC 14/15 - TP 12 - Optical Flow