Implementing the Eigenfaces algorithm described in this paper by Matthew Turk and Alex Pentland, I made a basic face recognizer using MATLAB. I tested the algorithm first with a public face database, and then tested successfully on a less ideal set of images from my personal collections. When preparing my own images, I used the MATLAB Computer Vision toolbox (which uses the Viola-Jones algorithm for face detection) to produce constant size face images. As with many popular face databases, I ensured that there were an equal number of photos of each person in my collection, and that the face angles were varied enough to expand the range of recognizable images. The photos shown on this page are the results of the algorithm on my personal photo collections. The algorithm itself can be successfully applied to any well constructed face database.


Calculating the Eigenfaces of a collection involves simple matrix mathematics. The first step involves construction of the image matrix. In the image above, we see 2 representations of the same 4 images. The four 5x5 pixel squares represent different photos. However, in order to compute Eigenfaces, we need to transform these images into vectors, and these vectors become the columns or rows of our image matrix (as long as the inverse transformation is consistent, either should work).

Performing this transformation on an entire image database will create a very large image matrix. Take the average image vector across all images and subtract it from every image vector in the image matrix. Calculate the covariance matrix, and the eigenvectors for the largest eigenvalues of this covariance matrix are image vectors corresponding to our Eigenfaces. 

I chose to calculate 10 Eigenfaces throughout my testing (one set shown below), though that number can be increased or decreased depending on database size. While my Eigenface and matching functions performed on grayscale images, the input and results were mapped to their original colored versions. Grayscale images only have 1 color channel, which simplifies the amount of computation needed.


The Eigenfaces provide a basis for face space. Once they have been calculated, every image in the database can be represented as a weighted sum of all Eigenfaces. Matching is achieved by minimizing the Euclidean distance between a new (not in database) image's Eigenface components, and those from an image from the collection. The image(s) which result in the smallest distance are usually a correct face match. 


For a fairly basic recognizer the results were mostly accurate. However, some shortcomings I noticed with this less fancy approach included false detections due to similar physical features, facial angles, shadows and lighting, and errors due to the non-neutral expressions captured. While there are definitely more complex algorithms that exist to perform facial matching and recognition at a much higher accuracy, this project was a good introduction.