Facial Expression Recognition YING SHEN SSE, TONGJI UNIVERSITY - - PowerPoint PPT Presentation

facial expression
SMART_READER_LITE
LIVE PREVIEW

Facial Expression Recognition YING SHEN SSE, TONGJI UNIVERSITY - - PowerPoint PPT Presentation

Facial Expression Recognition YING SHEN SSE, TONGJI UNIVERSITY Facial expression recognition Page 1 Outline Introduction Facial expression recognition Appearance-based vs. model based Active appearance model (AAM)


slide-1
SLIDE 1

Facial Expression Recognition

YING SHEN SSE, TONGJI UNIVERSITY

Facial expression recognition Page 1

slide-2
SLIDE 2

Outline

  • Introduction
  • Facial expression recognition
  • Appearance-based vs. model based
  • Active appearance model (AAM)
  • Pre-requisite
  • Principle component analysis (PCA)
  • Procrustes analysis
  • ASM
  • Delaunay triangulation
  • AAM

Facial expression recognition Page 2

slide-3
SLIDE 3

Outline

  • Introduction
  • Facial expression recognition
  • Appearance-based vs. model based
  • Active appearance model (AAM)
  • Pre-requisite
  • Principle component analysis (PCA)
  • Procrustes analysis
  • ASM
  • Delaunay triangulation
  • AAM

Facial expression recognition Page 3

slide-4
SLIDE 4

Introduction

  • Smile detection

Facial expression recognition Page 4

slide-5
SLIDE 5

Introduction

  • Facial expression recognition

Happy Surprise Angry Disgust Sad Fear

Facial expression recognition Page 5

slide-6
SLIDE 6

Introduction

  • Facial expression recognition

Happy: 83% Disgusted: 9% Fearful: 6% Angry: 2%

Facial expression recognition Page 6

slide-7
SLIDE 7

Introduction

  • Factors affect facial expression recognition

accuracy

  • Pose
  • Illumination

Facial expression recognition Page 7

slide-8
SLIDE 8

Outline

  • Introduction
  • Facial expression recognition
  • Appearance-based vs. model-based
  • Active appearance model (AAM)
  • Pre-requisite
  • Principle component analysis
  • Procrustes analysis
  • ASM
  • Delaunay triangulation
  • AAM

Facial expression recognition Page 8

slide-9
SLIDE 9

Facial expression recognition

  • Framework of automatic facial expression

recognition

Facial Feature Extraction Face Acquisition Facial Expression Classification Whole Face Deformation Extraction Appearance-based Model-based

Facial expression recognition Page 9

slide-10
SLIDE 10

Facial expression recognition

  • Appearance-based methods
  • E.g. Features are extracted using Garbor filter

Facial expression recognition Page 10

slide-11
SLIDE 11

Facial expression recognition

  • CMU facial expression database (CK, CK+

database)

  • 8000+ images
  • Six basic expressions
  • Training preparation
  • create positive examples
  • prepare negative examples
  • Training
  • Train Haar-like features using OpenCV
  • Or train a NN classifier using extracted features

Facial expression recognition Page 11

slide-12
SLIDE 12

Facial expression recognition

  • Angry Positive Examples for Training

Facial expression recognition Page 12

slide-13
SLIDE 13

Facial expression recognition

  • Model-based methods

Facial expression recognition Page 13

slide-14
SLIDE 14

Outline

  • Introduction
  • Facial expression recognition
  • Appearance-based vs. model-based
  • Active appearance model (AAM)
  • Pre-requisite
  • Principle component analysis (PCA)
  • Procrustes analysis
  • ASM
  • Delaunay triangulation
  • AAM

Facial expression recognition Page 14

slide-15
SLIDE 15

Pre-requisite: Lagrange multiplier

  • Single-variable function

( ) f x is differentiable in (a, b). At , f(x) achieves an

extremum

( , ) x a b 

|

x

df dx 

  • Two-variables function

( , ) f x y is differentiable in its domain. At , f(x, y) achieves

an extremum

( , ) x y

( , ) ( , )

| 0, |

x y x y

f f x y      

Facial expression recognition Page 15

slide-16
SLIDE 16

Pre-requisite: Lagrange multiplier

  • In general case

1

( ),

n

f

 x x

If is a stationary point of

x

1 2

| 0, | 0,..., |

n

f f f x x x         

x x x

Facial expression recognition Page 16

slide-17
SLIDE 17

Pre-requisite: Lagrange multiplier

  • Lagrange multiplier is a strategy for finding the local

extremum of a function subject to equality constraints

Problem: find stationary points for under m constraints

( ) 0, 1,2,...,

k

g k m   x

is a stationary point of with constraints Solution:

1 1

( ; ,..., ) ( ) ( )

m m k k k

F f g   

  x x x

If is a stationary point

  • f F, then,

10 20

( , , ..., )

m

   x

x

( ) f x

Joseph-Louis Lagrange

  • Jan. 25, 1736~Apr.10, 1813

Facial expression recognition Page 17

slide-18
SLIDE 18

Pre-requisite: Lagrange multiplier

  • Lagrange multiplier is a strategy for finding the local

extremum of a function subject to equality constraints

Problem: find stationary points for under m constraints

( ) 0, 1,2,...,

k

g k m   x

Solution:

1 1

( ; ,..., ) ( ) ( )

m m k k k

F f g   

  x x x

is a stationary point of F

10

( , ,..., )

m

  x

1 2 1 2

0, 0,..., 0, 0, 0,...,

n m

F F F F F F x x x                     

n + m equations! at that point

Facial expression recognition Page 18

slide-19
SLIDE 19

Pre-requisite: Lagrange multiplier

  • Example

Problem: for a given point p0 = (1, 0), among all the points lying on the line y=x, identify the one having the least distance to p0. y=x p0 ?

The distance is

2 2

( , ) ( 1) ( 0) f x y x y    

Now we want to find the stationary point

  • f f(x, y) under the constraint

( , ) g x y y x   

According to Lagrange multiplier method, construct another function

2 2

( , , ) ( ) ( ) ( 1) ( ) F x y f x g x x y y x          

Find the stationary point for

( , , ) F x y 

Facial expression recognition Page 19

slide-20
SLIDE 20

Pre-requisite: Lagrange multiplier

  • Example

Problem: for a given point p0 = (1, 0), among all the points lying on the line y=x, identify the one having the least distance to p0. y=x p0 ?

F x F y F                 2( 1) 2 x y x y               0.5 0.5 1 x y         

(0.5,0.5,1) is a stationary point of

( , , ) F x y 

(0.5,0.5)is a stationary point of f(x,y) under constraints

Facial expression recognition Page 20

slide-21
SLIDE 21

Pre-requisite: matrix differentiation

  • Function is a vector and the variable is a scalar

 

1 2

( ) ( ), ( ),..., ( )

T n

f t f t f t f t 

Definition

1 2

( ) ( ) ( ) , ,...,

T n

df t df t df t df dt dt dt dt       

Facial expression recognition Page 21

slide-22
SLIDE 22

Pre-requisite: matrix differentiation

  • Function is a matrix and the variable is a scalar

11 12 1 21 22 2 1 2

( ) ( ),..., ( ) ( ) ( ),..., ( ) ( ) ( ) ( ) ( ),..., ( )

m m ij n m n n nm

f t f t f t f t f t f t f t f t f t f t f t

                 

Definition

1 11 12 2 21 22 1 2

( ) ( ) ( ) ,..., ( ) ( ) ( ) ( ) ,..., ( ) ( ) ( ) ,...,

m m ij n m n n nm

df t df t df t dt dt dt df t df t df t df t df dt dt dt dt dt df t df t df t dt dt dt

                           

Facial expression recognition Page 22

slide-23
SLIDE 23

Pre-requisite: matrix differentiation

  • Function is a scalar and the variable is a vector

1 2

( ), ( , ,..., )T

n

f x x x  x x

Definition

1 2

, ,...,

T n

df f f f d x x x              x

In a similar way,

1 2

( ), ( , ,..., )

n

f x x x  x x

1 2

, ,...,

n

df f f f d x x x              x

Facial expression recognition Page 23

slide-24
SLIDE 24

Pre-requisite: matrix differentiation

  • Function is a vector and the variable is a vector

   

1 2 1 2

, ,..., , ( ), ( ),..., ( )

T T n m

x x x y y y   x y x x x

Definition

1 1 1 1 2 2 2 2 1 2 1 2

( ) ( ) ( ) , ,..., ( ) ( ) ( ) , ,..., ( ) ( ) ( ) , ,...,

n n T m m m n m n

y y y x x x y y y d x x x d y y y x x x

                                         x x x x x x y x x x x

Facial expression recognition Page 24

slide-25
SLIDE 25

Pre-requisite: matrix differentiation

  • Function is a vector and the variable is a vector

   

1 2 1 2

, ,..., , ( ), ( ),..., ( )

T T n m

x x x y y y   x y x x x

In a similar way,

1 2 1 1 1 1 2 2 2 2 1 2

( ) ( ) ( ) , ,..., ( ) ( ) ( ) , ,..., ( ) ( ) ( ) , ,...,

m m T m n n n n m

y y y x x x y y y d x x x d y y y x x x

                                         x x x x x x y x x x x

Facial expression recognition Page 25

slide-26
SLIDE 26

Pre-requisite: matrix differentiation

  • Function is a vector and the variable is a vector

Example:

1 1 2 2 2 1 1 2 2 3 2 2 3

( ) , , ( ) , ( ) 3 ( ) x y x y x x y x x y x                       x y x x x x

1 2 1 1 1 1 2 2 2 3 1 2 3 3

( ) ( ) 2 ( ) ( ) 1 3 2 ( ) ( )

T

y y x x x d y y d x x x y y x x                                            x x y x x x x x

Facial expression recognition Page 26

slide-27
SLIDE 27

Pre-requisite: matrix differentiation

  • Function is a scalar and the variable is a matrix

11 12 1 1 2

( )

n m m mn

f f f x x x df d f f f x x x                              X X

( ),

m n

f

 X X

Definition

Facial expression recognition Page 27

slide-28
SLIDE 28

Pre-requisite: matrix differentiation

  • Useful results

1

,

n

 x a ,

T T

d d d d   a x x a a a x x Then, How to prove? (1)

Facial expression recognition Page 28

slide-29
SLIDE 29

Pre-requisite: matrix differentiation

  • Useful results

(2) Then,

T

dA A d  x x (3) Then,

T T T

d A A d  x x (4) Then, ( )

T T

d A A A d   x x x x (5) Then,

T T

d d  a Xb ab X (6) Then,

T T T

d d  a X b ba X (7) Then, 2

T

d d  x x x x

Facial expression recognition Page 29

slide-30
SLIDE 30

Outline

  • Introduction
  • Facial expression recognition
  • Appearance-based vs. model-based
  • Active appearance model (AAM)
  • Pre-requisite
  • Principle component analysis
  • Procrustes analysis
  • ASM
  • Delaunay triangulation
  • AAM

Facial expression recognition Page 30

slide-31
SLIDE 31

Principal Component Analysis (PCA)

  • PCA: converts a set of observations of possibly

correlated variables into a set of values of linearly uncorrelated variables called principal components

  • The number of principal components is less than or

equal to the number of original variables

  • This transformation is defined in such a way that the

first principal component has the largest possible variance, and each succeeding component in turn has the highest variance possible under the constraint that it be orthogonal to (i.e., uncorrelated with) the preceding components

Facial expression recognition Page 31

slide-32
SLIDE 32

Principal Component Analysis (PCA)

  • Illustration

x , y

(2.5, 2.4) (0.5, 0.7) (2.2, 2.9) (1.9, 2.2) (3.1, 3.0) (2.3, 2.7) (2.0, 1.6) (1.0, 1.1) (1.5, 1.6) (1.1, 0.9)

Along which orientation the data points scatter most? How to find? De-correlation!

Facial expression recognition Page 32

slide-33
SLIDE 33

Principal Component Analysis (PCA)

  • Identify the orientation with largest variance

Suppose X contains n data points, and each data point is p- dimensional, that is

1

Now, we want to find such a unit vector ,

Facial expression recognition Page 33

slide-34
SLIDE 34

Principal Component Analysis (PCA)

  • Identify the orientation with largest variance

 

2 1 1

1 1 var ( ) ( )( ) 1 1

n n T T T T T i i i i i T

n n C          

 

       

 

X x x x

where

1

1 ( )( ) 1

n T i i i

C n  

     x x

and is the covariance matrix

1

1

n i i

n 

 x ( ) ( )

T T i i

       x x

(Note that: )

Facial expression recognition Page 34

slide-35
SLIDE 35

Principal Component Analysis (PCA)

  • Identify the orientation with largest variance

Since is unit,

 

 

argmax 1

T T

C

      

Based on Lagrange multiplier method, we need to,

 1

T

  

 

 

1 2 2

T T

d C C d              C  

is C’s eigen-vector

 

 

   

 

max var max max max

T T T

C          X

Since, Thus,

Facial expression recognition Page 35

slide-36
SLIDE 36

Principal Component Analysis (PCA)

  • Identify the orientation with largest variance

Thus, should be the eigen-vector of C corresponding to the largest eigen-value of C

1

What is another orientation , orthogonal to , and along which the data can have the second largest variation?

2

1

Answer: it is the eigen-vector associated to the second largest eigen-value of C and such a variance is

2

2

Facial expression recognition Page 36

slide-37
SLIDE 37

Principal Component Analysis (PCA)

  • Identify the orientation with largest variance

Results: the eigen-vectors of C forms a set of orthogonal basis and they are referred as Principal Components of the

  • riginal data X

You can consider PCs as a set of orthogonal coordinates. Under such a coordinate system, variables are not correlated.

Facial expression recognition Page 37

slide-38
SLIDE 38

Principal Component Analysis (PCA)

  • Express data in PCs

Suppose are PCs derived from X,

1 2

{ , ,..., }

p

  

p n 

 X

Then, a data point can be linearly represented by , and the representation coefficients are

1 p i 

 x

1 2

{ , ,..., }

p

  

1 2 T T i i T p

                  c x

Actually, ci is the coordinates of xiin the new coordinate system spanned by

1 2

{ , ,..., }

p

  

Facial expression recognition Page 38

slide-39
SLIDE 39

Principal Component Analysis (PCA)

  • Illustration

x , y

(2.5, 2.4) (0.5, 0.7) (2.2, 2.9) (1.9, 2.2) (3.1, 3.0) (2.3, 2.7) (2.0, 1.6) (1.0, 1.1) (1.5, 1.6) (1.1, 0.9)

2.5 0.5 2.2 1.9 3.1 2.3 2.0 1.0 1.5 1.1 2.4 0.7 2.9 2.2 3.0 2.7 1.6 1.1 1.6 0.9        X 5.549 5.539 cov( ) 5.539 6.449        X

Eigen-values = 11.5562,0.4418 Corresponding eigen-vectors:

1 2

0.6779 0.7352 0.7352 0.6779                 

Facial expression recognition Page 39

slide-40
SLIDE 40

Principal Component Analysis (PCA)

  • Illustration

Facial expression recognition Page 40

slide-41
SLIDE 41

Principal Component Analysis (PCA)

  • Illustration

1 2

0.6779 0.7352 0.7352 0.6779 3.459 0.854 3.623 2.905 4.307 3.544 2.532 1.487 2.193 1.407 0.211 0.107 0.348 0.094 0.245 0.139 0.386 0.011 0.018 0.199

T T

newC                               X X

Coordinates of the data points in the new coordinate system

Facial expression recognition Page 41

slide-42
SLIDE 42

Principal Component Analysis (PCA)

  • Illustration

Draw newC on the plot Coordinates of the data points in the new coordinate system In such a new system, two variables are linearly independent!

Facial expression recognition Page 42

slide-43
SLIDE 43

Principal Component Analysis (PCA)

  • Data dimension reduction with PCA

Suppose , are the PCs

1 1

{ } ,

n p i i i  

  X x x

1 1

{ } ,

p p i i i

 

 

If all of are used, is still p-dimensional

1

{ }p

i i

1 2 T T i i T p

                  c x

If only are used, will be m-dimensional

1

{ } ,

m i i

m p 

i

c

That is, the dimension of the data is reduced!

Facial expression recognition Page 43

slide-44
SLIDE 44

Principal Component Analysis (PCA)

  • Illustration

Coordinates of the data points in the new coordinate system

0.6779 0.7352 0.7352 0.6779 newC         X

If only the first PC (corresponds to the largest eigen-value) is remained

   

0.6779 0.7352 3.459 0.854 3.623 2.905 4.307 3.544 2.532 1.487 2.193 1.407 newC   X

Facial expression recognition Page 44

slide-45
SLIDE 45

Principal Component Analysis (PCA)

  • Illustration

All PCs are used Only 1 PC is used Dimension reduction!

Facial expression recognition Page 45

slide-46
SLIDE 46

Principal Component Analysis (PCA)

  • Illustration

If only the first PC (corresponds to the largest eigen-value) is remained

   

0.6779 0.7352 3.459 0.854 3.623 2.905 4.307 3.544 2.532 1.487 2.193 1.407 newC   X

How to recover newC to the original space? Easy

   

0.6779 0.7352 0.6779 3.459 0.854 3.623 2.905 4.307 3.544 2.532 1.487 2.1931.407 0.7352

T newC

      

Facial expression recognition Page 46

slide-47
SLIDE 47

Principal Component Analysis (PCA)

  • Illustration

Data recovered if only 1 PC used Original data

Facial expression recognition Page 47

slide-48
SLIDE 48

Outline

  • Introduction
  • Facial expression recognition
  • Appearance-based vs. model-based
  • Active appearance model (AAM)
  • Pre-requisite
  • Principle component analysis
  • Procrustes analysis
  • ASM
  • Delaunay triangulation
  • AAM

Facial expression recognition Page 48

slide-49
SLIDE 49

Procrustes analysis

  • Who is Procrustes?

Facial expression recognition Page 49

slide-50
SLIDE 50

Procrustes analysis

  • Problem:
  • Suppose we have two sets of point correspondence

pairs (m1, m2,…, mN) and (n1, n2,…, nN).

  • We want to find a scale factor s, an orthogonal

matrix R and a vector t so that: (1)

Facial expression recognition Page 50

 

2 2 1

( )

N i i i

m sR n T

   

slide-51
SLIDE 51

Procrustes analysis

  • In 2D space:

Facial expression recognition Page 51

slide-52
SLIDE 52

Procrustes analysis

  • How to compute R and T?
  • We assume that there is a similarity transform

between point sets and

  • Find s, R and T to minimize

(1)

  • Let
  • Note that

Facial expression recognition Page 52

 

1 N i i

m

 

1 N i i

n

 

2 2 2 1 1

( )

N N i i i i i

e m sR n T

 

    

 

' ' 1 1

1 1 , , ,

N N i i i i i i i i

m m n n m m m n n n N N

 

     

 

' ' 1 1

,

N N i i i i

m n

 

 

 

slide-53
SLIDE 53

Then:

 

' ' ' ' ' ' ' '

( ) ( ) ( ) ( ) ( ) ( ) ( )

i i i i i i i i i i i

e m sR n T m m sR n n T m m sR n sR n T m sR n T m sR n m sR n e                     

( ) e T m sR n   

(1) can be rewritten as:

     

2 2 2 2 ' ' ' ' ' ' 2 1 1 1 1 2 ' ' ' ' 2 1 1 1 2 ' ' 2 1

( ) ( ) 2 ( ) ( ) 2 2 ( ) ( )

N N N N i i i i i i i i i i i N N N i i i i i i i N i i i

e m sR n e m sR n e m sR n Ne m sR n e m e sR n Ne m sR n Ne

       

                    

       

Variables are separated and can be minimized separately.

2

( ) e T m sR n    

If we have s and R, T can be determined.

is independent from

' '

{ , }

i i

m n

Procrustes analysis

slide-54
SLIDE 54

Then the problem simplifies to: how to minimize

2 2 ' ' 1

( )

N i i i

m sR n

  

Consider its geometric meaning here.

We revise the error item as a symmetrical one:

2 2 2 2 ' ' ' ' ' ' 1 1 1 1 2 2 ' ' ' ' 1 1 1

1 1 1 ( ) 2 ( ) ( ) 1 2 ( )

N N N N i i i i i i i i i i N N N i i i i i i i

m sR n m m R n s R n s s s m m R n s n s

      

          

      

P

D

Q

2 2

1 1 1 2 2( ) P D sQ s Q P PQ D s s s              

Variables are separated.

Thus,

Procrustes analysis

slide-55
SLIDE 55

2 ' 2 1 2 ' 1

1

N i i N i i

m P s Q P s Q s n

 

          

 

Determined!. Then the problem simplifies to: how to maximize

' ' 1

( )

N i i i

D m R n

 

Note that: D is a real number.

   

 

' ' ' ' ' ' 1 1 1 N N N T T i i i i i i i i i

D m Rn m Rn trace Rn m trace RH

  

          

  

 

' ' 1 N T i i i

H n m



Now we are looking for an orthogonal matrix R to maximize the trace of RH.

Procrustes analysis

slide-56
SLIDE 56

Lemma For any positive semi-definite matrix C and any orthogonal matrix B:

   

trace C trace BC 

Let be the ith column of A. Then

i

a

   

 

T T T i i i

trace BAA trace A BA a Ba  

According to Schwarz inequality:

, x y x y   

 

  

T T T T T T i i i i i i i i i i

a Ba a Ba a a a B Ba a a   

Hence,

   

T T T i i i

trace BAA a a trace AA  

Proof:

,

T

A C AA  

From the positive definite property of C, where A is a non-singular matrix.

   

trace BC trace C 

that is,

Procrustes analysis

slide-57
SLIDE 57

Consider the SVD of T

H U V  

According to the property of SVD, U and V are orthogonal matrices, and Λ is a diagonal matrix with nonnegative elements. Now let

T

X VU 

Note that: X is orthogonal. We have

T T T

XH VU U V V V    

which is positive semi-definite. Thus, from the lemma, we know: for any orthogonal matrix B

( ) ( ) trace XH trace BXH 

( ) ( ) trace XH trace H  

for any orthogonal matrix Ψ It’s time to go back to our objective now… R should be X

 

' ' 1 N T i i i

H n m



Procrustes analysis

slide-58
SLIDE 58

Now, s, R and T are all determined.

 

' ' 1 N T T i i i

H n m U V

  

T

R VU 

2 ' 1 2 ' 1 N i i N i i

m s n

 

 

( ) T m sR n  

Procrustes analysis

slide-59
SLIDE 59

Procrustes analysis

  • Problem: Given two configuration matrices X and

Y with the same dimensions, find rotation and translation that would bring Y as close as possible to X.

1) Find the centroids (mean values of columns) of X and Y. Call them 𝐲 and 𝐳. 2) Remove from each column corresponding mean. Call the new matrices Xnew and Ynew 3) Find Ynew

  • TXnew. Find the SVD of this matrix Ynew

TXnew=

UDVT 4) Find the rotation matrix R = UVT. Find scale factor 5) Find the translation vector T = 𝐲- sR 𝐳.

Facial expression recognition Page 59

2 1 2 1 N new new i N i

s

 

 

X Y

slide-60
SLIDE 60

Some modifications

  • Sometimes it is necessary to weight some

variables down and others up. In these cases Procrustes analysis can be performed using weights. We want to minimize the function:

  • This modification can be taken into account

if we find SVD of YTWX instead of YTX

2

( ( )( ) )

T

M tr    W X AY X AY

Facial expression recognition Page 60

slide-61
SLIDE 61

Outline

  • Introduction
  • Facial expression recognition
  • Appearance-based vs. model-based
  • Active appearance model (AAM)
  • Pre-requisite
  • Principle component analysis
  • Procrustes analysis
  • ASM
  • Delaunay triangulation
  • AAM

Facial expression recognition Page 61

slide-62
SLIDE 62

Active shape model (ASM)

  • Collect training samples
  • 30 neutral faces
  • 30 smile faces

Facial expression recognition Page 62

slide-63
SLIDE 63

ASM

  • Add landmarks
  • 26 points each face
  • X = [x1 x2 … xN]; N = 60.

Facial expression recognition Page 63

slide-64
SLIDE 64

ASM

  • Align training faces together using Procrustes analysis

Transform xi to xj: Rotation (Ri), Scale (si), Transformation (Ti) Consider a weight matrix W:

Dkl represents the distance between the point k and l in one image and VDkl represents the variance of Dkl in different images m is the dimension of xi

Facial expression recognition Page 64

min *

T i i

Z Z

( * *( ) )

i j i

Z s R T    x x

1 1

( )

kl

N l k D

w V

 

 

1 m

w W w           

slide-65
SLIDE 65

ASM

  • We want to minimize

1) Find the centroids (mean values of columns) of xi and xj. 2) Remove from each column corresponding mean. 3) Find the SVD of this matrix xi_new*W*xj_new

T=

UDVT 4) Find the rotation matrix A = UVT. Find the scale factor and translation vector as shown in page 59.

Facial expression recognition Page 65

min * *

T i i i

E Z W Z 

slide-66
SLIDE 66

ASM

  • Align training faces using Procrustes analysis
  • Steps:
  • 1. Align the other faces with the first face
  • 2. Compute the mean face
  • 3. Align training faces with the mean face
  • 4. Repeat step 2 and 3 until the discrepancies

between training faces and the mean face won’t change

Facial expression recognition Page 66

1 N i i

  x x

slide-67
SLIDE 67

ASM

  • Faces after alignment

Facial expression recognition Page 67

slide-68
SLIDE 68

ASM

  • Construct models of faces
  • Compute mean face
  • Calculate covariance matrix
  • Find its eigenvalues (λ1, λ2, …, λm) and

eigenvectors P = (p1, p2, …, pm)

  • Choose the first t largest eigenvalues

Usually fv = 0.98

Facial expression recognition Page 68

1 N i i

  x x

1

1 ( )( )

i i T i N

S N

  

 x

x x x

1

,

i v T t t i T i

f V V  

 

 

Dimension reduction: 26*227

slide-69
SLIDE 69

ASM

  • We can approximate a training face x
  • bi is called the ith mode of the model
  • constraint:

Facial expression recognition Page 69

( )

T

    x Pb P x x b x

| | 3

i i

b  

slide-70
SLIDE 70

ASM

  • Effect of varying the first three shape

parameters in turn between ±3 s.d. from the mean value

Facial expression recognition Page 70

  • 3 s.d.
  • rigin

+3 s.d.

  • 3 s.d.
  • rigin

+3 s.d.

slide-71
SLIDE 71

ASM

  • Active Shape Model Algorithm
  • 1. Examine a region of the image around each

point xi to find the best nearby match for the point xi'

  • 2. Update the parameters (T, s, R, b) to best fit the

new found points x'

  • 3. Apply constraints to the parameters, b, to ensure

plausible shapes (e.g. limit so |bi| < 3 λ𝑗).

  • 4. Repeat until convergence.

Facial expression recognition Page 71

Q1: How to find corresponding points in a new image?

slide-72
SLIDE 72

ASM

  • Find the initial corresponding points
  • Detect face using Viola-Jones face detector
  • Estimate positions of eyes centers, nose center,

and mouse center

  • Align the corresponding positions on the mean

face to the estimated positions of eyes centers, nose center, and mouse center (sinit, Rinit, Tinit) on the new face

Facial expression recognition Page 72

* *

init init init init

s R T   x x

slide-73
SLIDE 73

ASM

  • Construct local features for each point in the

training samples

  • For a given point, we sample along a profile k

pixels either side of the model point in the ith training image.

  • Instead of sampling absolute grey-level values, we

sample derivatives and put them in a vector gi

  • Normalize the sample:

Facial expression recognition Page 73

point i point i-1 point i+1 2k+1 pixels

i i j ij

  g g g

slide-74
SLIDE 74

ASM

  • For each training image, we can get a set of

normalized samples {g1, g2,…, gN} for point i

  • We assume that these gi are distributed as a

multivariate Gaussian, and estimate their mean 𝒉𝒋 and covariance 𝑇𝑕𝑗.

  • This gives a statistical model for the grey-

level profile about the point i

  • Given a new sample gs, the distance of gs to

𝒉𝒋 can be computed using the Mahalanobis distance

Facial expression recognition Page 74

1

( , ) ( ( ) )

i

T s i s i g s i

d S     g g g g g g

slide-75
SLIDE 75

ASM

  • During search we sample a profile m pixels

from either side of each initial point (m > k )

  • n the new face.

Facial expression recognition Page 75

point i point i-1 point i+1 2m+1 pixels

1

min ( , ) ( ( ) )

i s

T s i s i g s i

d S    

g

g g g g g g

dxi

slide-76
SLIDE 76

ASM

  • Some constraints on dxi
  • |dxi| = 0

if |dbest| <= δ

  • |dxi| = 0.5dbest

if δ<= |dbest| <= dmax

  • |dxi| = 0.5dmax

if |dbest| > dmax

Facial expression recognition Page 76

slide-77
SLIDE 77

ASM

  • Apply one iteration of ASM algorithm
  • 1. Examine a region of the image around each

point xi to find the best nearby match for the point xi': xi' = xi + dxi

  • 2. Update the parameters (T, s, R, b) to best fit the

new found points x'

  • 3. Apply constraints to the parameters, b, to ensure

plausible shapes (e.g. limit so |bi| < 3 λ𝑗).

  • 4. Repeat until convergence.

Facial expression recognition Page 77

Q2: How to find T, s, R, and b for x'?

slide-78
SLIDE 78

ASM

  • Suppose we want to match a model x to a

new set of image points y

  • We wish to find (T, s, R, b) that can minimize

Facial expression recognition Page 78

2 2

min | * ( ) | min | * ( ) | s R T s R T       x Pb y x y

slide-79
SLIDE 79

ASM

  • A simple iterative approach to achieving the minimum
  • 1. Initialize the shape parameters, b, to zero (the mean shape).
  • 2. Generate the model point positions using x =

𝐲 + Pb

  • 3. Find the pose parameters (s, R, T) which best align the model

points x to the current found points y

  • 4. Project y into the model co-ordinate frame by inverting the

transformation :

  • 5. Project y into the tangent plane to

𝐲 by scaling: y'' = y'/(y'· 𝐲).

  • 6. Update the model parameters to match to y''
  • 7. If not converged, return to step 2.

Facial expression recognition Page 79

2

min | * ( ) | s R T   y x

1

' ( ) / R T s

  y y ( '' )

T

  b P y x

slide-80
SLIDE 80

ASM

  • Apply one iteration of ASM algorithm
  • 1. Examine a region of the image around each

point xi to find the best nearby match for the point xi': xi' = xi + dxi

  • 2. Update the parameters (T, s, R, b) to best fit the

new found points x' using the algorithm in page 79

  • 3. Apply constraints to the parameters, b, to ensure

plausible shapes (e.g. limit so |bi| < 3 λ𝑗).

  • 4. Repeat until convergence.

Facial expression recognition Page 80

slide-81
SLIDE 81

ASM

  • So now we have a vector of b for the new

face

  • Classify facial expression using b

Facial expression recognition Page 81

slide-82
SLIDE 82

Classification

  • Training
  • Compute b for each training faces
  • Training a classifier (e.g. SVM, Neural Network)

using {b1, b2,…, bN} and the corresponding labels

  • Test
  • Using the trained classifier to classify a new mode

vector bnew of a new face

Facial expression recognition Page 82

slide-83
SLIDE 83

Outline

  • Introduction
  • Facial expression recognition
  • Appearance-based vs. model-based
  • Active appearance model (AAM)
  • Pre-requisite
  • Principle component analysis
  • Procrustes analysis
  • ASM
  • Delaunay triangulation
  • AAM

Facial expression recognition Page 83

slide-84
SLIDE 84

Delaunay triangulation

  • Terrains by interpolation
  • To build a model of the terrain surface, we

can start with a number of sample points where we know the height.

Facial expression recognition Page 84

slide-85
SLIDE 85

Delaunay triangulation

  • How do we interpolate the height at other

points?

  • Height ƒ(p) defined at each point p in P
  • How can we most naturally approximate height of

points not in P?

Facial expression recognition Page 85

Does not look natural

Let ƒ(p) = height of nearest point for points not in A

slide-86
SLIDE 86

Delaunay triangulation

  • Better option: triangulation
  • Determine a triangulation of P in R2, then raise

points to desired height

  • Triangulation: planar subdivision whose bounded

faces are triangles with vertices from P

Facial expression recognition Page 86

slide-87
SLIDE 87

Delaunay triangulation

  • Formal definition
  • Let P = {p1,…,pn} be a point set.
  • Maximal planar subdivision: a

subdivision S such that no edge connecting two vertices can be added to S without destroying its planarity

  • A triangulation of P is a maximal

planar subdivision with vertex set P.

Facial expression recognition Page 87

slide-88
SLIDE 88

Delaunay triangulation

  • Triangulation is made of triangles
  • Outer polygon must be convex hull
  • Internal faces must be triangles, otherwise they

could be triangulated further

Facial expression recognition Page 88

slide-89
SLIDE 89

Delaunay triangulation

  • For P consisting of n points, all

triangulations contain

  • 2n-2-k triangles
  • 3n-3-k edges
  • n = number of points in P
  • k = number of points on convex hull of P

Facial expression recognition Page 89

slide-90
SLIDE 90

Delaunay triangulation

  • But which triangulation?

Facial expression recognition Page 90

slide-91
SLIDE 91

Delaunay triangulation

  • Some triangulations are “better” than
  • thers
  • Avoid skinny triangles, i.e. maximize

minimum angle of triangulation

Facial expression recognition Page 91

slide-92
SLIDE 92

Delaunay triangulation

  • Let 𝒰 be a triangulation of P with m triangles.

Its angle vector is A(𝒰) = (α1,…, α3m) where α1,…, α3m are the angles of 𝒰 sorted by increasing value.

Facial expression recognition Page 92

  • Let 𝒰′ be another

triangulation of P. A(𝒰) is larger then A(𝒰′) iff there exists an i such that j = 'j for all j < i and i > 'i

  • 𝒰 is angle optimal if A(𝒰) >

A(𝒰′) for all triangulations 𝒰′ of P

slide-93
SLIDE 93

Delaunay triangulation

  • If the two triangles form a convex quadrilateral, we

could have an alternative triangulation by performing an edge flip on their shared edge.

  • The edge 𝑓 = 𝑄𝑗𝑄

𝑘 is illegal if min 1≤𝑗≤6 𝛽𝑗 ≤ min 1≤𝑗≤6 𝛽′𝑗

  • Flipping an illegal edge increases the angle vector

Facial expression recognition Page 93

slide-94
SLIDE 94

Delaunay triangulation

  • If triangulation 𝒰 contains an illegal edge e,

we can make A(𝒰) larger by flipping e.

  • In this case, 𝒰 is an illegal triangulation.

Facial expression recognition Page 94

slide-95
SLIDE 95

Delaunay triangulation

  • We can use Thale’s Theorem to test

if an edge is legal without calculating angles Theorem: Let C be a circle, ℓ a line intersecting C in points a and b, and p, q, r, s points lying on the same side of ℓ. Suppose that p, q lie on C, r lies inside C, and s lies outside C. Then

Facial expression recognition Page 95

∡𝑏𝑠𝑐 > ∡𝑏𝑞𝑐 = ∡𝑏𝑟𝑐 > ∡𝑏𝑡𝑐

slide-96
SLIDE 96

Delaunay triangulation

  • If pi, pj, pk, pl form a convex quadrilateral

and do not lie on a common circle, exactly

  • ne of pipj and pkpl is an illegal edge.

Lemma: The edge 𝑄𝑗𝑄

𝑘 is illegal iff pl lies in

the interior of the circle C.

Facial expression recognition Page 96

slide-97
SLIDE 97

Delaunay triangulation

  • A legal triangulation is a triangulation that does not

contain any illegal edge.

  • Compute Legal Triangulations
  • 1. Compute a triangulation of input points P.
  • 2. Flip illegal edges of this triangulation until all edges are legal.
  • Algorithm terminates because there is a finite number of

triangulations.

  • Too slow to be interesting…

Facial expression recognition Page 97

slide-98
SLIDE 98

Delaunay triangulation

  • Before we can understand an interesting

solution to the terrain problem, we need to understand Delaunay Graphs.

  • Delaunay Graph of a set of points P is the

dual graph of the Voronoi diagram of P

Facial expression recognition Page 98

slide-99
SLIDE 99

Delaunay triangulation

Facial expression recognition Page 99

  • Voronoi Diagram and Delaunay Graph
  • Let P be a set of n points in the plane
  • The Voronoi diagram Vor(P) is the subdivision of

the plane into Voronoi cells 𝒲(𝑞) for all 𝑞 ∈ 𝑄

  • Let 𝒣 be the dual graph of Vor(P)
  • The Delaunay graph 𝒠𝒣(𝑄) is the straight line

embedding of 𝒣

slide-100
SLIDE 100

Delaunay triangulation

  • Voronoi Diagram and Delaunay Graph
  • Calculate Vor(P)
  • Place one vertex in each site of the Vor(P)

Facial expression recognition Page 100

slide-101
SLIDE 101

Delaunay triangulation

  • Voronoi Diagram and Delaunay Graph
  • If two sites si and sj share an edge (si and sj are

adjacent), create an arc between vi and vj, the vertices located in sites si and sj

Facial expression recognition Page 101

slide-102
SLIDE 102

Delaunay triangulation

  • Voronoi Diagram and Delaunay Graph
  • Finally, straighten the arcs into line segments. The

resultant graph is DG(P).

Facial expression recognition Page 102

slide-103
SLIDE 103

Delaunay triangulation

  • Properties of Delaunay Graphs
  • No two edges cross; DG(P) is a planar graph.

Facial expression recognition Page 103

slide-104
SLIDE 104

Delaunay triangulation

  • Some sets of more than 3 points of

Delaunay graph may lie on the same circle.

  • These points form empty convex polygons,

which can be triangulated.

  • Delaunay Triangulation is a triangulation
  • btained by adding 0 or more edges to the

Delaunay Graph.

Facial expression recognition Page 104

slide-105
SLIDE 105

Delaunay triangulation

  • From the properties of Voronoi Diagrams…
  • Three points pi, pj, pk  P are vertices of the same

face of the DG(P) iff the circle through pi, pj, pk contains no point of P on its interior.

Facial expression recognition Page 105

slide-106
SLIDE 106

Delaunay triangulation

  • From the properties of Voronoi Diagrams…
  • Two points pi, pj  P form an edge of DG(P) iff

there is a closed disc C that contains pi and pj on its boundary and does not contain any other point

  • f P.

Facial expression recognition Page 106

slide-107
SLIDE 107

Delaunay triangulation

  • From the previous two properties…
  • A triangulation T of P is a DT(P) iff the

circumcircle of any triangle of T does not contain a point of P in its interior.

Facial expression recognition Page 107

slide-108
SLIDE 108

Delaunay triangulation

  • A triangulation T of P is legal iff T is a DT(P).
  • DT  Legal: Empty circle property and Thale’s

Theorem implies that all DT are legal

  • Legal  DT
  • Let P be a set of points in the plane. Any

angle-optimal triangulation of P is a Delaunay triangulation of P.

  • Furthermore, any Delaunay triangulation of

P maximizes the minimum angle over all triangulations of P.

Facial expression recognition Page 108

slide-109
SLIDE 109

Delaunay triangulation

  • Therefore, the problem of finding a

triangulation that maximizes the minimum angle is reduced to the problem of finding a Delaunay Triangulation. So how do we find the Delaunay Triangulation?

Facial expression recognition Page 109

slide-110
SLIDE 110

Delaunay triangulation

  • How do we compute DT(P)?
  • We could compute Vor(P) then dualize into

DT(P).

  • Instead, we will compute DT(P) using a

randomized incremental method.

Facial expression recognition Page 110

slide-111
SLIDE 111

Delaunay triangulation

  • Incremental method
  • 1. Initialize triangulation T with a “big enough”

helper bounding triangle that contains all points P.

  • 2. Randomly choose a point pr from P.
  • 3. Find the triangle  that pr lies in.
  • 4. Subdivide  into smaller triangles that have pr as

a vertex.

  • 5. Flip edges until all edges are legal.
  • 6. Repeat steps 2-5 until all points have been added

to T.

Facial expression recognition Page 111

slide-112
SLIDE 112

Delaunay triangulation

  • In matlab, try delaunay(X,Y) function

Facial expression recognition Page 112

slide-113
SLIDE 113

Outline

  • Introduction
  • Facial expression recognition
  • Appearance-based vs. model-based
  • Active appearance model (AAM)
  • Pre-requisite
  • Principle component analysis
  • Procrustes analysis
  • ASM
  • Delaunay triangulation
  • AAM

Facial expression recognition Page 113

slide-114
SLIDE 114

AAM

  • Steps of constructing AAM
  • 1. Apply triangulation algorithm on the training

faces;

Facial expression recognition Page 114

slide-115
SLIDE 115

AAM

  • Steps of constructing AAM
  • 2. Warp the training face to the mean face by

matching the corresponding triangles

Facial expression recognition Page 115

slide-116
SLIDE 116

AAM

  • Steps of constructing AAM
  • 3. Sample the grey level information gim from the

shape-normalized image over the region covered by the mean face To minimize the effect of global lighting variation, normalize the faces 𝐡 = (𝐡𝑗𝑛 − 𝛾𝟐)/𝛽 𝛽 = 𝐡𝑗𝑛 ⋅ 𝐡, 𝛾 = (𝐡𝑗𝑛 ⋅ 𝟐)/𝑜

Facial expression recognition Page 116

slide-117
SLIDE 117

AAM

  • Steps of constructing AAM
  • 4. Apply PCA to the normalized data

𝐡 = 𝐡 + 𝐐

𝑕𝐜𝑕

Facial expression recognition Page 117

slide-118
SLIDE 118

AAM

  • Appearance vector:
  • Apply a further PCA
  • c is a vector of appearance parameters
  • We can express the face as functions of c

Facial expression recognition Page 118

( ) ( )

T s s s s T g g

                  W b W P x g P g x b b

 b Qc ,

s s s g g

    x W Q c g g P P Q x c

s g

       Q Q Q