Machine Learning for Signal Processing
Eigenfaces and Eigenrepresentations
Class 6. 17 Sep 2013 Instructor: Bhiksha Raj
17 Sep 2013 11-755/18-797 1
Machine Learning for Signal Processing Eigenfaces and - - PowerPoint PPT Presentation
Machine Learning for Signal Processing Eigenfaces and Eigenrepresentations Class 6. 17 Sep 2013 Instructor: Bhiksha Raj 17 Sep 2013 11-755/18-797 1 Administrivia Project teams? By the end of the month.. Project proposals?
17 Sep 2013 11-755/18-797 1
– By the end of the month..
– Please send proposals to TAs, and cc me
17 Sep 2013 11-755/18-797 2
17 Sep 2013 11-755/18-797 3
17 Sep 2013 11-755/18-797 4
BW PROJECTION age B pinv W age BW Im ) ( Im
] [ . . ... Im
3 2 1 3 2 1 3 3 2 2 1 1
B B B B w w w W B w B w B w age
B1 B2 B3 B4 B5 B6 Getting closer at 625 bases!
– Orthogonal – But not “smooth”
17 Sep 2013 11-755/18-797 5
B1 B2 B3 B4 B5 B6
...
3 3 2 2 1 1
B w B w B w image
faces
17 Sep 2013 11-755/18-797 6
17 Sep 2013 11-755/18-797 7
N NB
w B w B w B w X ...
3 3 2 2 1 1 2 2 1 1
ˆ B w B w X
2
ˆ X X Error
17 Sep 2013 11-755/18-797 8
– Every face can be represented by a scaled version of a typical face – We will denote this face as V
– How? What is V?
17 Sep 2013 11-755/18-797 9
The typical face
– V2 is used to “correct” errors resulting from using only V1. So on average – V3 corrects errors remaining after correction with V2
– And so on.. – V = [V1 V2 V3]
– How? What is V?
17 Sep 2013 11-755/18-797 10
2 1 , 1 , 2 2 , 2 , 1 , 1 ,
) (
f f f f f f
V w f V w V w f
2 2 , 2 , 1 , 1 , 2 3 , 3 , 2 , 2 , 1 , 1 ,
) ( ) (
f f f f f f f f f f
V w V w f V w V w V w f
17 Sep 2013 11-755/18-797 11
M = N = S=Pinv(N) M
U =
M N pinv S M NS U ) (
17 Sep 2013 11-755/18-797 12
M = N =
S = U =
) ( S pinv M N M NS U
17 Sep 2013 11-755/18-797 13
Find the four notes and their score that generate the
M = N =
S = U =
– Such that the squared error between U and M is minimum
17 Sep 2013 11-755/18-797 14
M = U = Approximation W V Typical faces
17 Sep 2013 11-755/18-797 15
Pixel 1 Pixel 2
17 Sep 2013 11-755/18-797 16
Pixel 1 Pixel 2 V
17 Sep 2013 11-755/18-797 17
Pixel 1 Pixel 2 V f error
17 Sep 2013 11-755/18-797 18
Pixel 1 Pixel 2 V
Find the V for which the total projection error is minimum!
17 Sep 2013 11-755/18-797 19
Pixel 1 Pixel 2 V
Find the V for which the total projection error is minimum!
17 Sep 2013 11-755/18-797 20
Pixel 1 Pixel 2 V
Find the V for which the total projection error is minimum!
17 Sep 2013 11-755/18-797 21
Pixel 1 Pixel 2 V
Find the V for which the total projection error is minimum!
17 Sep 2013 11-755/18-797 22
Pixel 1 Pixel 2 V
Find the V for which the total projection error is minimum!
17 Sep 2013 11-755/18-797 23
Pixel 1 Pixel 2 V1
17 Sep 2013 11-755/18-797 24
x y v x Approximating: x = wv
17 Sep 2013 11-755/18-797 25
x y v x
T
T
T
vvTx x-vvTx
2
T
Approximating: x = wv
17 Sep 2013 11-755/18-797 26
x y v x vvTx x-vvTx
2
T
17 Sep 2013 11-755/18-797 27
x y v x vvTx x-vvTx
2
T
T T T T T T T
T T T T T T T T
17 Sep 2013 11-755/18-797 28
x y v x vvTx x-vvTx
T T T T T T T T
=1
T T T T T T T
2
T
17 Sep 2013 11-755/18-797 29
x y v x vvTx x-vvTx
T T T T T T T
T T T
T T T T T T T
2
T
17 Sep 2013 11-755/18-797 30
x y v x vvTx x-vvTx This is the very familiar pythogoras’ theorem!!
Length of projection
17 Sep 2013 11-755/18-797 31
T T T
x y v
i i T T i i T i i i
i i i T T i i T i
17 Sep 2013 11-755/18-797 32
x y v
T i i i T T i i T i
i i i T T i i T i
17 Sep 2013 11-755/18-797 33
T T T
T
17 Sep 2013 11-755/18-797 34
x y v
i T i i
T i i i T T i i T i
i T i i
17 Sep 2013 11-755/18-797 35
i T i i X = Data Matrix XT = Transposed Data Matrix Correlation
N
2 1
T i T i i
17 Sep 2013 11-755/18-797 36
x y v
17 Sep 2013 11-755/18-797 37
i i i T T i i T i
i i T i i T i T i
i T i T i i T i T i i T i T i
i i T i
i i T i i T i T i
17 Sep 2013 11-755/18-797 38
i i T i
– Arrange them in matrix X and compute R = XXT
– The Eigen vector with the largest Eigen value
17 Sep 2013 11-755/18-797 39
The typical face
– Such that the squared error between U and M is minimum
17 Sep 2013 11-755/18-797 40
M = U = Approximation W V Typical faces
Tvj = 0 if i != j
– We are trying to find the optimal K-dimensional subspace to project the data – Any set of vectors in this subspace will define the subspace – Constraining them to be orthogonal does not change this
– Pinv(V) = VT
17 Sep 2013 11-755/18-797 41
17 Sep 2013 11-755/18-797 42
T T T
T
T
x y V x VVTx x-VVTx Represents a K-dimensional subspace
17 Sep 2013 11-755/18-797 43
T T T
x y
i i i T T i i T i
V
17 Sep 2013 11-755/18-797 44
T i i i T T i i T i
i T i i
i K j j i T i
1
17 Sep 2013 11-755/18-797 45
17 Sep 2013 11-755/18-797 46
– In my example: 300 faces. So the matrix is 10000 x 300
– The correlation matrix is 10000x10000
17 Sep 2013 11-755/18-797 47
M = Data Matrix MT = Transposed Data Matrix Correlation
10000x300 300x10000 10000x10000
– Only 300 of the 10000 eigen values are non-zero
– Could use a higher threshold
17 Sep 2013 11-755/18-797 48
[U,S] = eig(correlation)
10000 2 1
. . . . . . . . . . . . . . . S U eigenface1 eigenface2
face.
17 Sep 2013 11-755/18-797 49
U eigenface1 eigenface2 eigenface1 eigenface2 eigenface3
17 Sep 2013 11-755/18-797 50
= w1 + w2 + w3 Representation = [w1 w2 w3 …. ]T
17 Sep 2013 11-755/18-797 51
1 1v
17 Sep 2013 11-755/18-797 52
1 1v
17 Sep 2013 11-755/18-797 53
10 10 2 2 1 1
17 Sep 2013 11-755/18-797 54
30 30 10 10 2 2 1 1
17 Sep 2013 11-755/18-797 55
60 60 30 30 10 10 2 2 1 1
17 Sep 2013 11-755/18-797 56
17 Sep 2013 11-755/18-797 57
eigenface1 eigenface2 eigenface3
17 Sep 2013 11-755/18-797 58
17 Sep 2013 11-755/18-797 59
1 1v
17 Sep 2013 11-755/18-797 60
10 10 2 2 1 1
17 Sep 2013 11-755/18-797 61
30 30 10 10 2 2 1 1
17 Sep 2013 11-755/18-797 62
100 100 30 30 10 10 2 2 1 1
17 Sep 2013 11-755/18-797 63
– Will take a very long time on your laptop
– Only need to perform “Thin” SVD. Very fast
– The columns of U are the eigen faces! – The Us corresponding to the “zero” eigen values are not computed
17 Sep 2013 11-755/18-797 64
M = Data Matrix 10000x300 U=10000x300 S=300x300 V=300x300
U eigenface1 eigenface2
17 Sep 2013 11-755/18-797 65
17 Sep 2013 11-755/18-797 66
Pixel 1 Pixel 2
17 Sep 2013 11-755/18-797 67
17 Sep 2013 11-755/18-797 68
17 Sep 2013 11-755/18-797 69
17 Sep 2013 11-755/18-797 70
17 Sep 2013 11-755/18-797 71
17 Sep 2013 11-755/18-797 72
17 Sep 2013 11-755/18-797 73
– Eliminate lighting/contrast variations – All pictures must have “similar” lighting
17 Sep 2013 11-755/18-797 74
– Maximize the contrast
greyscale
– Doing it for every image ensures that every image has the same constrast
– Which should be flat
17 Sep 2013 11-755/18-797 75
255
– New pixel value = f(old pixel value) – What is f()?
17 Sep 2013 11-755/18-797 76
– E.g. in the above image, the count of pixel value 180 is about 110
– CCF(X) = H(1) + H(2) + .. H(X)
17 Sep 2013 11-755/18-797 77
17 Sep 2013 11-755/18-797 78
– x = pixel value – f() is the function that converts the old pixel value to a new (normalized) pixel value – a = (total no. of pixels in image) / (total no. of pixel levels)
17 Sep 2013 11-755/18-797 79
Move x axis levels around until the plot to the left looks like the plot to the right
– Find the location on the red line that has the closet Y value to the observed CCF at x
17 Sep 2013 11-755/18-797 80
– Find the location on the red line that has the closet Y value to the observed CCF at x
17 Sep 2013 11-755/18-797 81
x1 x2 f(x1) = x2 x3 x4 f(x3) = x4 Etc.
– The pixel has a value x – Find the CCF at that pixel value CCF(x) – Find x’ such that CCF(x’) in the function to the right equals CCF(x)
– Modify the pixel value to x’
17 Sep 2013 11-755/18-797 82
Move x axis levels around until the plot to the left looks like the plot to the right
– The value of the CCF at the smallest observed pixel value
– 10000 for a 100x100 image
– 255 for 8-bit pixel representations
17 Sep 2013 11-755/18-797 83
value pixel Max CCF Npixels CCF x CCF round x f . . ) ( ) (
min min
17 Sep 2013 11-755/18-797 84
17 Sep 2013 11-755/18-797 85
17 Sep 2013 11-755/18-797 86
17 Sep 2013 11-755/18-797 87
– How do we find if a picture has faces in it – Where are the faces?
– Define a “typical face” – Find the “typical face” in the image
17 Sep 2013 11-755/18-797 88
17 Sep 2013 11-755/18-797 89
17 Sep 2013 11-755/18-797 90
17 Sep 2013 11-755/18-797 91
17 Sep 2013 11-755/18-797 92
17 Sep 2013 11-755/18-797 93
17 Sep 2013 11-755/18-797 94
17 Sep 2013 11-755/18-797 95
17 Sep 2013 11-755/18-797 96
17 Sep 2013 11-755/18-797 97
17 Sep 2013 11-755/18-797 98
17 Sep 2013 11-755/18-797 99
17 Sep 2013 11-755/18-797 100
– What is the match “score”
– Express the typical face as a vector – Express the region of the image being evaluated as a vector
– Just the section being evaluated, without considering the rest of the image
– Compute the dot product of the typical face vector and the “region” vector
17 Sep 2013 11-755/18-797 101
17 Sep 2013 11-755/18-797 102
– Redder is higher
– Likes George’s face most
– A false alarm
17 Sep 2013 11-755/18-797 103
– Not all faces are the same size – Some people have bigger faces – The size of the face on the image changes with perspective – Our “typical face” only represents
– The head need not always be upright!
17 Sep 2013 11-755/18-797 104
– One for each scaling factor – One for each rotation
– Kind of .. Not well enough at all – We need more sophisticated models
17 Sep 2013 11-755/18-797 105
– Use edge detectors and search for face like patterns – Find “feature” detectors (noses, ears..) and employ them in complex neural networks..
– Boosted cascaded classifiers
17 Sep 2013 11-755/18-797 106