PCA and Face Recognition - Eigen Face

PCA (Principal component analysis), just as its name shows, it computes the data set’s internal structure, its “principal components”.

Considering a set of 2 dimensional data, for one data point, it has 2 dimensions and . Now we get n such data points . What is the relationship between the first dimension and the second dimension ? We compute the so called covariance:

the covariance shows how strong is the relationship between and . Its logic is the same as Chebyshev’s sum inequality:

Which tells us a truth:

big with big, small with small can result big value;big with small, small with big can result small value.

So on the other way around, measures how the data points’ and are related to each other, let’s say data point , if is relatively big compared to the other and the same for , then will be big, which will be added to the final value, if and changes in the same direction, which means when gets big, also gets big, the value will be very big. The changing direction of both dimensions are more different to each other, the smaller is the final value.

We compute , and , obviously will be the same as . These 3 values will form a matrix, the so called covariance matrix:

eigen

the dots in the upper right chart means one data point

The C matrix is the covariance matrix, lower are its eigen vector and eigen value.

As we can see from the eigen vector’s visualization, if the point dots can form a ellipse, the eigen vectors will be its long and short axis. The corresponding eigen values are their lengths.

Use PCA to recognize faces

Our input:the image of a face

Our training set: face images of different people

Out output: who is this input face?

We consider a face image is a point in high-dimensional space.

The training set of face images will be our point set, just as one dot in the upper chart. Remember, this face image data set only contains the face images of one person.

Training:

The training process will be calculating this data set’s covariance matrix and its eigen vectors and eigen values.For this task we use SVD, assume that we have the data matrix X, after the SVD we get:

What we want is the eigenvalues and eigenvectors of X’s covariance matrix:

According to the properties of SVD, we get:

As we know that is an orthogonal matrix, which means , so we get:

Obviously, The vectors in U are the eigenvectors of and the square of the values in are its eigenvalues.

Practically:

For a image of 100x100, we get a data point in a 10000 dimensional space. Then we can calculate a 10000x10000 covariance matrix. From this matrix we get a 10000 dimensional eigen vector whose eigen value is the biggest of all eigen values.

This 10000 eigen vector is of course also a face image, it is the so called eigen face or basis face. Eigen face is the computed face image which contains the most important features of this person.

Matching/Recognition:

recognition

Wangxin

I am algorithm engineer focused in computer vision, I know it will be more elegant to shut up and show my code, but I simply can't stop myself learning and explaining new things ...