Face Detection Using PCA
Face Detection Using PCA
Objective
To do face detection using Principal Component Analysis (PCA).
Some important terms Standard Deviation -- a measure of how spread out the data is.
Variance -- is the square of standard deviation. These two measures are purely 1-dimensional.
Covariance is the measure of how much two random variables vary together. If the value is +ve then both dimensions increase together & if ve, they are inversely proportional.
Covariance Matrix
where S is the covariance matrix, sjk is the covariance of variables Xj and Xk when j k and the diagonal element sjjis the variance of variable Xj when j = k.
Method 1. Obtain the data in the form of a matrix. 2. Obtain the covariance matrix for the data. 3. Calculate the eigenvectors and eigenvalues of the covariance matrix. The eigenvector with the highest eigenvalue is the principle component of the data set. 4. Select the eigenvectors with the highest eigenvalues and form a matrix which is smaller in size compared to the data matrix.
PCA projects the data along the directions where the data varies the most.
Directions are determined by the eigenvectors of the covariance matrix corresponding to the largest eigenvalues
EIGENFACES
Set of eigenvectors Develpoed by Matthew Turk and Alex Pentland Eigenfaces can be extracted out of the image data by means of the mathematical tool called Principal Component Analysis (PCA)
Calculate the eigenfaces from the covariance matrix, keeping only the best M images with the highest eigenvalues. These M images define the face space.
Given an image, calculate a set of weights of the M eigenfaces by projecting it onto each of the eigenfaces
Determine if the image is a face at all by checking to see if the image is sufficiently close to the face space
Image Representation
A square, N by N image can be expressed as an N2 dimensional vector.
Say we have 20 images. Each image is N pixels high by N pixels wide. Write each image as an image vector and put all the images together in one big image-matrix like this:
x
Pixel 1 gray value
Training Set
Experiment
JAFFE image database 20 images(M) 256 x 256 (N x N) Each image converted into a column vector of N2 x 1 Column vectors stacked together to get a matrix (N2 x M) Covariance matrix needed (N2 x N2) over 4 billion entries Calculate eigenvectors of the covariance matrix
(BTB) y = e y => B(BTB) y = e (By) => (BBT)(By) = e (By) => By is the eigenvector of BBT
Eigenfaces
PCA extracts the Eigenfaces of the set of images
Gives a set of vectors v1,v2,v3 Each vector represents a dimension in the face space What do they look like?
a9v9
a10v10
Projections
Procedure
1. Process the image database (training set of images)
Run PCAcompute eigenfaces
3. Detect if x is a face
Detection Result
Result
Image name Images part of the training set KA.HA1.29 MK.NE3.115 3.0430e+012 1.4271e+012 Distance
Images not part of training set but belonging to people in the set YM.HA2.53 KA.NE2.27 4.4622e+012 1.3121e+012
Images with no relation to the training set Containing a face lena Not containing a face nens wheel grey 2356R CT_scan Lone 7.9097e+012 8.8347e+012 3.4745e+012 8.9020e+012 5.9903e+012 3.8256e+012 2.6338e+012
Threshold value
Threshold value = 3.4745e+12 (corresponding to image grey) fails to detect a face in the image -- YM.HA2.53. If the threshold value is increased to the distance corresponding to the image -- YM.HA2.53, then 100% detection takes place but accuracy goes down as the program will detect faces in images with no human face in them. Also, the image nens consists of a number of faces, but they are not detected.
Implementation
MATLAB
Imread Reshape Double Clear Eig Zeros Pdist Uint8
Conclusion
Project images onto a low-dimensional linear subspace face space, defined by eigenfaces.
The distance between an image and its projection in face space is compared to a threshold value determined experimentally.
This approach was tested on a number of images giving good detection results.
Advantage
Ease of implementation Simplicity of the maths behind the concept. No knowledge of geometry or specific feature of the face is required.
Limitation
Applicable only to front views
Input images should be of the same type(size, color, etc) as the images in the trainig set
Refrences 1.Eigenfaces for recognition, M. Turk and A. Pentland 2. Face recognition using eigenfaces, M. Turk and A. Pentland 3. Stellar Spectral Classification using Principal Component Analysis and artificial neural networks, Harinder P Singh, Ravi K Gulati and Ranjan Gupta 4. http://en.wikipedia.org/wiki/Eigenface 5. http://en.wikipedia.org/wiki/Principal_Component_Analysis 6. Advanced Engineering Mathematics by Erwin Kreyszig 7. JAFFE image database "Coding Facial Expressions with Gabor Wavelets, Michael J. Lyons, Shigeru Akamatsu, Miyuki Kamachi, Jiro Gyoba