In the name of Allah the compassionate, the merciful Digital Video - - PowerPoint PPT Presentation

in the name of allah
SMART_READER_LITE
LIVE PREVIEW

In the name of Allah the compassionate, the merciful Digital Video - - PowerPoint PPT Presentation

In the name of Allah the compassionate, the merciful Digital Video Systems S. Kasaei S. Kasaei Room: CE 307 Department of Computer Engineering Sharif University of Technology E-Mail: skasaei@sharif.edu Webpage: http://sharif.edu/~skasaei


slide-1
SLIDE 1
slide-2
SLIDE 2

In the name of Allah

the compassionate, the merciful

slide-3
SLIDE 3

Digital Video Systems

  • S. Kasaei
  • S. Kasaei

Room: CE 307 Department of Computer Engineering Sharif University of Technology E-Mail: skasaei@sharif.edu Webpage: http://sharif.edu/~skasaei

  • Lab. Website: http://mehr.sharif.edu/~ipl
slide-4
SLIDE 4

Acknowledgment

Most of the slides used in this course have been provided by: Prof. Yao Wang (Polytechnic University, Brooklyn) based on the book: Video Processing & Communications written by: Yao Wang, Jom Ostermann, & Ya-Oin Zhang Prentice Hall, 1st edition, 2001, ISBN: 0130175471. [SUT Code: TK 5105 .2 .W36 2001]

slide-5
SLIDE 5

Chapter 6

2-D Motion Estimation

Part I: Fundamentals & Basic Techniques

slide-6
SLIDE 6

Outline

2-D motion vs. optical flow Optical flow equation & ambiguity in motion

estimation

General methodologies in motion estimation

Motion representation Motion estimation criterion Optimization methods Gradient descent methods

Pixel-based motion estimation Block-based motion estimation

EBMA algorithm

slide-7
SLIDE 7

2-D Motion vs. Optical Flow

(a) A sphere is rotating under a constant ambient illumination, but the observed image does not change. (b) A A point light source is rotating around a stationary sphere, causing the highlight point on the sphere to rotate.

2-D Motion: Projection of 3-D motion depends on 3-D object motion &

projection operator (physical aspects).

Optical flow: “Perceived” 2-D motion based on changes in image pattern,

also depends on illumination & object surface texture. (a) (b)

slide-8
SLIDE 8

Correspondence & Optical Flow

2-D displacement & velocity fields are

projections of respective 3-D fields into the image plane.

The correspondence & optical flow fields are the

displacement & velocity functions perceived from the time-varying image intensity pattern.

slide-9
SLIDE 9

Correspondence & Optical Flow

The correspondence field & the optical flow field

are also called “apparent 2-D displacement” field & “apparent 2-D velocity” field.

Since we can only observe correspondence &

  • ptical flow fields, we assume that they are the

same as the 2-D motion field.

slide-10
SLIDE 10

Optical Flow Equation

When illumination condition is unknown,

the best one can do is to estimate the

  • ptical flow.

Constant intensity assumption (CIA) ->

Optical flow (OF) equation.

slide-11
SLIDE 11

Optical Flow Equation

  • r
  • r

: equation flow

  • ptical

the have we two, above the Compare ) , , ( ) , , ( : expansion s Taylor' using But, ) , , ( ) , , ( : " assumption intensity constant " Under = ∂ ∂ + ∇ = ∂ ∂ + ∂ ∂ + ∂ ∂ = ∂ ∂ + ∂ ∂ + ∂ ∂ ∂ ∂ + ∂ ∂ + ∂ ∂ + = + + + = + + + t t v y v x d t d y d x d y d y d x t y x d t d y d x t y x d t d y d x

T y x t y x t y x t y x t y x

ψ ψ ψ ψ ψ ψ ψ ψ ψ ψ ψ ψ ψ ψ ψ v

slide-12
SLIDE 12

Ambiguities in Motion Estimation

Optical flow equation only

constrains the flow vector in the gradient direction ( ).

The flow vector in the tangent

direction ( ) is under- determined.

In regions with constant

brightness ( ), the flow is indeterminate -> Motion estimation is unreliable in regions with flat texture, & more reliable near edges.

n

v = ∇ψ

= ∂ ∂ + ∇ + = t v v v

n t t n n

ψ ψ e e v

t

v

slide-13
SLIDE 13

General Considerations for Motion Estimation

Two categories of approaches:

Feature-based: More often used in object

tracking, 3-D reconstruction from 2-D.

Intensity-based: Based on constant intensity

  • assumption. More often used for motion

compensated prediction (required in video coding), frame interpolation -> Our focus.

slide-14
SLIDE 14

General Considerations for Motion Estimation

Three important questions:

How to represent the motion field? What criteria to use to estimate motion

parameters?

How to search motion parameters?

slide-15
SLIDE 15

Motion Representation

Global: Entire motion field is represented by a few global parameters (camera motion). Pixel-based: One MV at each pixel, with some smoothness constraint between adjacent MVs. Region-based: Entire frame is divided into regions, each region corresponding to an object or sub-

  • bject with consistent

motion, represented by a few parameters. Block-based: Entire frame is divided into blocks, and motion in each block is characterized by a few parameters. Other representation: mesh-based (control grid) (to be discussed later).

slide-16
SLIDE 16

Notations

Anchor frame: Target frame: Motion parameters: Motion vector at a pixel in the anchor frame: Motion field: Mapping function:

) (

1 x

ψ ) (

2 x

ψ ) (x d Λ ∈ x a x d ), ; ( a Λ ∈ + = x a x d x a x w ), ; ( ) ; (

slide-17
SLIDE 17

Motion Estimation Criterion

To minimize the displaced frame difference (DFD): To satisfy the optical flow equation:

MSE : 2 MAD; : 1 min ) ( )) ; ( ( ) (

1 2 DFD

= = → − + = ∑

Λ ∈

P p E

x p

x a x d x a ψ ψ

( )

min ) ( ) ( ) ; ( ) ( ) (

1 2 1 OF

→ − + ∇ = ∑

Λ ∈ x p T

E x x a x d x a ψ ψ ψ

slide-18
SLIDE 18

Motion Estimation Criterion

To impose additional smoothness constraint using

regularization technique (Important in pixel- & block

  • based representation):

Bayesian (MAP) criterion: to maximize the a posteriori

probability:

max ) , (

1 2

→ = ψ ψ d D P

min ) ( ) ( ) ; ( ) ; ( ) (

DFD 2

→ + − = ∑ ∑

Λ ∈ ∈

a a a y d a x d a

x y s s DFD N s

E w E w E

x

slide-19
SLIDE 19

Relation Among Different Criteria

OF criterion is good only if motion is small. OF criterion can often yield closed

  • form solution as the
  • bjective function is quadratic in MVs.

When the motion is not small, can iterate the solution

based on the OF criterion to satisfy the DFD criterion.

Bayesian criterion can be reduced to the DFD criterion

plus motion smoothness constraint.

More in the textbook. [DFD: displaced frame difference]

slide-20
SLIDE 20

Optimization Methods

Exhaustive search:

Typically used for the DFD criterion with p=1 (MAD). Guarantees reaching the global optimal. Required computation may be unacceptable when

number of parameters to search simultaneously is large!

Fast search algorithms reach sub

  • ptimal solution in

shorter time.

slide-21
SLIDE 21

Optimization Methods

Gradient-based search:

Typically used for the DFD or OF criterion with p=2

(MSE)

The gradient can often be calculated analytically. When used with the OF criterion, closed-form solution may

be obtained.

Reaches the local optimal point closest to the initial

solution.

Multi-resolution search:

Searches from coarse to fine resolution, faster than

exhaustive search.

Avoids being trapped into a local minimum.

slide-22
SLIDE 22

Gradient Descent Method

Iteratively updates the current estimate in the

direction opposite to the gradient direction.

Not a good initial. A good initial. Appropriate Stepsize. Too big Stepsize.

slide-23
SLIDE 23

Gradient Descent Method

The solution depends on the initial condition.

Reaches the local minimum closest to the initial condition.

Choice of step side:

Fixed stepsize: Stepsize must be small to avoid

  • scillation, requires many iterations.

Steepest gradient descent: Adjusts stepsize

  • ptimally.
slide-24
SLIDE 24

Newton’s Method

Newton’s method:

slide-25
SLIDE 25

Newton’s Method

Converges faster than 1st order method (i.e., requires

fewer number of iterations to reach convergence).

Requires more calculations in each iteration. More prone to noise (gradient calculation is subject to

noise, more with 2nd order than with 1st order).

May not converge if a >=1. Should choose it

appropriate to reach a good compromise between guaranteeing convergence & the convergence rate.

slide-26
SLIDE 26

Newton-Raphson Method

Newton-Ralphson method:

Approximates 2nd order gradient with a product of 1st

  • rder gradients.

Applicable when the objective function is a sum of

squared errors.

Only needs to calculate 1st order gradients, yet

converge at a rate similar to Newton’s method.

slide-27
SLIDE 27

Newton-Raphson Method

slide-28
SLIDE 28

Pixel-Based Motion Estimation

Horn-Schunck method:

OF + smoothness criterion.

Multipoint neighborhood method:

Assumes that every pixel in a small block surrounding

a pixel has the same MV.

Pel-recurrsive method:

MV for a current pel is updated from those of its

previous pels, so that the MV does not need to be coded.

Developed for early generation of video coders.

slide-29
SLIDE 29

Multipoint Neighborhood Method

Estimates the MV at each pixel

independently, by minimizing the DFD error

  • ver a neighborhood surrounding this pixel.

Every pixel in the neighborhood is assumed

to have the same MV.

Minimizing function:

min ) ( ) ( ) ( ) (

) ( 2 1 2 n DFD

→ − + = ∑

n

B n

w E

x x

x d x x d ψ ψ

slide-30
SLIDE 30

Multipoint Neighborhood Method

Optimization method:

Exhaustive search (feasible as one only needs to

search one MV at a time).

Needs to select the appropriate search range & the

search step-size.

Gradient

  • b

ased method.

slide-31
SLIDE 31

Example: Gradient Descent Method

[ ]

[ ]

) ( ) ( : method Raphson

  • Newton

) ( : descent gradient

  • rder

First ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( min ) ( ) ( ) ( ) (

) ( n 1 ) ( n ) ( n ) 1 ( n ) ( n ) ( n ) 1 ( n 2 2 ) ( 2 2 2 2 2 ) ( 2 n 2 n 2 ) ( n n ) ( 2 1 2 n DFD l l l l l l l T B n T B B n B n

n n n n n n n n

w e w w E e w E w E d g d H d d d g d d x x x x d x x x x x d d H x d x x d d g x d x x d

d x x x d x d x x x d x x x x x − + + + ∈ + + ∈ + ∈ ∈

− = − =       ∂ ∂ ∂ ∂ ≈ ∂ ∂ + +       ∂ ∂ ∂ ∂ = ∂ ∂ = ∂ ∂ + = ∂ ∂ = → − + =

∑ ∑ ∑ ∑

α α ψ ψ ψ ψ ψ ψ ψ ψ

slide-32
SLIDE 32

Simplification using OF Criterion

( ) ( )

( )

( ) ( )

        ∇ −         ∇ ∇ = = ∇ − + ∇ = ∂ ∂ → − + ∇ =

∑ ∑ ∑ ∑

∈ − ∈ ∈ ∈ ) ( 1 2 1 1 ) ( 1 1

  • pt

n, 1 ) ( 1 2 1 n ) ( 2 1 2 1 n OF

) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( min ) ( ) ( ) ( ) ( ) (

n n n n

B B T B n T B n T

w w w E w E

x x x x x x x x

x x x x x x x d x x x d x x d x x d x x d ψ ψ ψ ψ ψ ψ ψ ψ ψ ψ ψ ψ The solution is good only if the actual MV is small. When this is not the case, one should iterate the above solution, with the following update:

iteration at that found MV the denote ) ( ) (

) 1 ( ) 1 ( ) ( n ) 1 ( n ) ( n 2 ) 1 ( 2 + + + +

∆ ∆ + = + =

l n l n l l l l

where d d d x x ψ ψ

slide-33
SLIDE 33

Block-Based Motion Estimation: A Brief Overview

Assums that all pixels in a block undergo a

coherent motion & searches for the motion parameters for each block independently.

Block matching algorithm (BMA): assumes a

translational motion, 1 MV per block (2 parameters):

Exhaustive BMA (EBMA). Fast algorithms.

Deformable block matching algorithm (DBMA):

allows more complex motion (affine, bilinear), to be discussed later.

slide-34
SLIDE 34

Block Matching Algorithm

Overview:

Assumes that all pixels in a block undergo a

translation, denoted by a single MV.

Estimate the MV for each block independently, by

minimizing the DFD error over this block.

Minimizing function:

min ) ( ) ( ) (

1 2 m DFD

→ − + = ∑

m

B p m

E

x

x d x d ψ ψ

slide-35
SLIDE 35

Block Matching Algorithm

Optimization method:

Exhaustive search (feasible as one only needs to

search one MV at a time), using MAD criterion (p=1).

Fast search algorithms. Integer vs. fractional pel accuracy search.

slide-36
SLIDE 36

Exhaustive Block Matching Algorithm (EBMA)

slide-37
SLIDE 37

Complexity of Integer-Pel EBMA

Assumption:

Image size: MxM. Block size: NxN. Search range: (- R

,R) in each dimension.

Search stepsize: 1 pixel (assuming integer MV).

Operation counts (1 operation=1 “-”, 1 “+”, 1 “*”):

Each candidate position: N^2. Each block going through all candidates: (2R+1)^2

N^2.

Entire frame: (M/N)^2 (2R+1)^2 N^2=M^2 (2R+1)^2.

Independent of block size!

slide-38
SLIDE 38

Complexity of Integer-Pel EBMA

Example: M=512, N=16, R=16, 30 fps.

Total operation count = 2.85x10^8/frame

=8.55x10^9/second.

Regular structure suitable for VLSI

implementation.

Challenging for software-only implementation.

slide-39
SLIDE 39

Sample Matlab Script for Integer-pel EBMA

%f1: anchor frame; f2: target frame, fp: predicted image; %mvx,mvy: store the MV image %widthxheight: image size; N: block size, R: search range for i=1:N:height-N, for j=1:N:width-N %for every block in the anchor frame MAD_min=256*N*N;mvx=0;mvy=0; for k=-R:1:R, for l=-R:1:R %for every search candidate MAD=sum(sum(abs(f1(i:i+N-1,j:j+N-1)-f2(i+k:i+k+N-1,j+l:j+l+N-1)))); % calculate MAD for this candidate if MAD<MAX_min MAD_min=MAD,dy=k,dx=l; end; end;end; fp(i:i+N-1,j:j+N-1)= f2(i+dy:i+dy+N-1,j+dx:j+dx+N-1); %put the best matching block in the predicted image iblk=(floor)(i-1)/N+1; jblk=(floor)(j-1)/N+1; %block index mvx(iblk,jblk)=dx; mvy(iblk,jblk)=dy; %record the estimated MV end;end;

Note: A real working program needs to check whether a pixel in the candidate matching block falls outside the image boundary and such pixel should not count in MAD. This program is meant to illustrate the main operations involved. Not the actual working Matlab script.

slide-40
SLIDE 40

Fractional Accuracy EBMA

Real MV may not always be multiples of pixels.

To allow sub-pixel MV, the search stepsize must be less than 1 pixel.

Half-pel EBMA: stepsize=1/2 pixel in both

dimensions.

Difficulty:

Target frame only has integer pels.

Solution:

Interpolate the target frame by factor of two before

searching.

Bilinear interpolation is typically used.

slide-41
SLIDE 41

Fractional Accuracy EBMA

Complexity:

4 times of integer

  • p

e l, plus additional operations for interpolation.

Fast algorithms:

Searches in integer precisions first, then refines in a

small search region in half- p el accuracy.

slide-42
SLIDE 42

Half-Pel Accuracy EBMA

slide-43
SLIDE 43

Bilinear Interpolation

(x+1,y) (x,y) (x+1,y+1) (x,y+!) (2x,2y) (2x+1,2y) (2x,2y+1) (2x+1,2y+1)

O[2x,2y]=I[x,y] O[2x+1,2y]=(I[x,y]+I[x+1,y])/2 O[2x,2y+1]=(I[x,y]+I[x+1,y])/2 O[2x+1,2y+1]=(I[x,y]+I[x+1,y]+I[x,y+1]+I[x+1,y+1])/4

slide-44
SLIDE 44

Predicted anchor frame (29.86 dB) Anchor frame Target frame Motion field Example: Half-pel EBMA

slide-45
SLIDE 45

Pros and Cons with EBMA

Blocking effect (discontinuity across block

boundary) in the predicted image:

Because the block

  • wise translation model is not

accurate.

Fix: Deformable BMA (next lecture).

Motion field somewhat chaotic:

Because MVs are estimated independently from block

to block.

Fix 1: Mesh

  • b

ased motion estimation (next lecture).

Fix 2: Imposing smoothness constraint explicitly.

slide-46
SLIDE 46

Pros and Cons with EBMA

Wrong MV in flat regions:

Because motion is indeterminate when spatial

gradient is near zero.

Nonetheless, widely used for motion

compensated prediction in video coding.

Because its simplicity and optimality in minimizing

prediction error.

slide-47
SLIDE 47

Fast Algorithms for BMA

Key idea to reduce the computation in EBMA:

Reduce # of search candidates:

Only search for those that are likely to produce small errors. Predict possible remaining candidates, based on previous

search result.

Simplify the error measure (DFD) to reduce the

computation involved for each candidate.

Classical fast algorithms:

Three

  • s

tep

2

  • D

log

Conjugate direction

slide-48
SLIDE 48

Fast Algorithms for BMA

Many new fast algorithms have been developed

since then.

Some suitable for software implementation, others for

VLSI implementation (memory access, etc).

slide-49
SLIDE 49

2-D Log Search

The best matching MVs in steps 1-5 are: (0,2), (0,4), (2,4), (2,6), & (2,6). The final MV is (2,6).

slide-50
SLIDE 50

Three-Step Search Algorithm

The best matching MVs in steps 1–3 are: (3,3), (3,5), & (2,6). The final MV is (2,6).

slide-51
SLIDE 51

VcDemo Example

VcDemo: Image & Video Compression Learning Tool Developed at Delft University of Technology: http://www-ict.its.tudelft.nl/~inald/vcdemo/ Use the ME tool to show the motion estimation results with different parameter choices.

slide-52
SLIDE 52

Summary

Optical flow equation:

Derived from constant intensity & small motion assumption.. Ambiguity in motion estimation

How to represent motion:

Pixel-based, block-based, region-based, global, etc.

Estimation criterion:

DFD (constant intensity). OF (constant intensity+small motion). Bayesian (MAP, DFD+motion smoothness).

Search method:

Exhaustive search, gradient-descent, multi-resolution (next

lecture).

slide-53
SLIDE 53

Summary

Pixel

  • based motion estimation:

Most accurate representation, but also most costly to estimate.

Block- b

ased motion estimation:

Good trade-off between accuracy & speed. EBMA and its fast but suboptimal variant is widely used in video

coding for motion-compensated temporal prediction.

slide-54
SLIDE 54

Homework

Reading assignment:

Chap 6: Sec. 6.1

  • 6

.4 (Sec. 6.4.5,6.4.6 not required), &

  • Apx. A & B.

Written assignment:

  • Prob. 6.4, 6.5, 5.6
slide-55
SLIDE 55

Homework 4

Computer assignment:

  • Prob. 6.12, 6.13

Optional: Prob.6.14 Note: you can download sample video frames from

the course webpage. When applying your motion estimation algorithm, you should choose two frames that have sufficient motion in between so that it is easy to observe effect of motion estimation

  • inaccuracy. If necessary, choose two frames that are

several frames apart. For example, foreman: frame 100 & frame 103.

slide-56
SLIDE 56

The End