ML  Face Recognition Using Eigenfaces (PCA Algorithm)
In 1991, Turk and Pentland suggested an approach to face recognition that uses dimensionality reduction and linear algebra concepts to recognize faces. This approach is computationally less expensive and easy to implement and thus used in various applications at that time such as handwritten recognition, lipreading, medical image analysis, etc.
PCA (Principal Component Analysis) is a dimensionality reduction technique that was proposed by Pearson in 1901. It uses Eigenvalues and EigenVectors to reduce dimensionality and project a training sample/data on small feature space. Let’s look at the algorithm in more detail (in a face recognition perspective).
Training Algorithm:

Let’s Consider a set of m images of dimension N*N (training images).

We first convert these images into vectors of size N^{2} such that:

Now we calculate the average of all these face vectors and subtract it from each vector

Now we take all face vectors so that we get a matrix of size of N^{2} * M.

Now, we find Covariance matrix by multiplying A with A^{T}. A has dimensions N^{2} * M, thus A^{T} has dimenions M * N^{2}. When we multiplied this gives us matrix of N^{2} * N^{2}, which gives us N^{2} eigenvectors of N^{2} size which is not computationally efficient to calculate. So we calculate our covariance matrix by multiplying A^{T} and A. This gives us M * M matrix which has M (assuming M << N^{2}) eigenvectors of size M.
In this step we calculate eigen values and eigenvectos of above covariance matrix using the formula below.
where,
andFrom the above statement It can be concluded that and C have same eigenvalues and their eigenvectors are related by the equation . Thus, the M eigenvalues (and eigenvectors) of covariance matrix gives the M largest eigenvalues(and eigenvectors) of
 Now we calculate Eigenvector and Eigenvalues of this reduced covariance matrix and map them into the by using the formula .
 Now we select the K eigenvectors of corresponding to the K largest eigenvalues (where K < M). These eigenvectors has size N^{2}.

In this step we used the eigenvectors that we got in previous step. We take the normalized training faces (face – average face) and represent each face vectors in the linear of combination of the best K eigenvectors (as shown in the diagram below).
These are called EigenFaces.

In this step, we take the coefficient of eigenfaces and represent the training faces in the form of a vector of those coefficients.
Testing/Detection Algorithm :
 Given an unknown face y, we need to first preprocess the face to make it centered in the image and have the same dimensions as the training face

Now, we subtract the face from the average face .

Now, we project the normalized vector into eigenspace to obtain the linear combination of eigenfaces.

From the above projection, we generate the vector of the coefficient such that
 We take the vector generated in the above step and subtract it from the training image to get the minimum distance between the training vectors and testing vectors
 If this is below tolerance level T_{r}, then it is recognised with l face from training image else the face is not matched from any faces in training set.
Advantages:
 Easy to implement and computationally less expensive.
 No knowledge (such as facial feature) of the image required (except id).
Limitations :
 Proper centered face is required for training/testing.
 The algorithm is sensitive to lightining, shadows and also scale of face in the image .
 Front view of the face is required for this algorithm to work properly.
Reference :
Recommended Posts:
 Deep Face Recognition
 ML  Face Recognition Using PCA Implementation
 Python  Face recognition using GUI
 ML  Implement Face recognition using kNN with scikitlearn
 Python  Multiple Face Recognition using dlib
 OpenCV C++ Program for Face Detection
 ML  Unsupervised Face Clustering Pipeline
 Opencv Python program for Face Detection
 Image Processing in Java  Set 9 ( Face Detection )
 Face Detection using Python and OpenCV with webcam
 Pattern Recognition  Introduction
 Applications of Pattern Recognition
 FaceNet  Using Facial Recognition System
 Project Idea  ( Character Recognition from Image )
 Pattern Recognition  Basics and Design Principles
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.