Eigenfaces: Turning Face Recognition into Projection onto a Low-Dimensional Basis

Recognising a face looks like a problem about images. The eigenface method turns it into a problem about vectors in a high-dimensional space, and once that translation is made, the entire solution is linear algebra you already know: subtract a mean, find an orthonormal basis that captures most of the variation, project, and compare.

Step 1: images become vectors

Read a grayscale image row by row and stack the pixel values into a single column. An image with hh rows and ww columns becomes a vector in Rd\mathbb{R}^{d} with d=hwd = hw. A modest 100×100100 \times 100 image already gives d=10,000d = 10{,}000. Two images are close in this space when their pixel values agree closely, position by position.


Collect MM training images as the columns of a d×Md \times M matrix. Because dd is enormous and MM is usually small by comparison, the data occupy a very thin sliver of Rd\mathbb{R}^{d}: almost no vector in that space looks anything like a face.

Step 2: subtract the mean face

Compute the average vector ψ=1M∑ixi\psi = \frac{1}{M}\sum_i x_i, the mean face, and form the mean-centred vectors φi=xi−ψ\varphi_i = x_i - \psi.


This step is not cosmetic. Every face image shares an enormous common component, a bright oval on a darker background, eyes roughly here, mouth roughly there.


If you skip the centring, the analysis measures second moments about the origin rather than variation about the average, and its largest direction can be dominated by that common offset.


For registered face images, where the shared component carries most of the energy, this is the usual outcome, and such a direction tells you little about which face you are looking at.


It is not guaranteed for every data set, since strong enough variation in another direction could come first. Covariance is defined about the mean precisely so that the analysed directions describe variation between faces, whatever the data.


The centred vectors also carry a built-in linear dependence: by construction


∑i=1Mφi=∑ixi−Mψ=0,\sum_{i=1}^{M}\varphi_i = \sum_i x_i - M\psi = 0,


so they always sum to the zero vector, whatever the images were. Any one of them is therefore determined by the others.

Step 3: principal components, computed the practical way

Let AA be the d×Md \times M matrix whose columns are the φi\varphi_i. The covariance matrix is C=1MAATC = \frac{1}{M}AA^{\mathsf T}, of size d×dd \times d. For d=10,000d = 10{,}000 that is 10810^{8} entries, which is impractical to diagonalise directly.


The standard trick uses the much smaller M×MM \times M matrix ATAA^{\mathsf T}A. If ATAv=λvA^{\mathsf T}A v=\lambda v with λ>0\lambda>0, then Av≠0Av\ne0 and AAT(Av)=λ(Av)AA^{\mathsf T}(Av)=\lambda(Av), so the non-zero eigensystem maps to image space. Zero-eigenvalue vectors for which Av=0Av=0 do not produce eigenvectors and are discarded.


Solve the small problem, map the eigenvectors across, normalise them, and you have the principal components without ever forming CC. Note the rank bound this rests on: rank⁡(A)≤min⁡(d,M)\operatorname{rank}(A) \le \min(d, M), so when M≪dM \ll d only a small number of directions can carry any variance at all.


The resulting orthonormal vectors u1,u2,…u_1, u_2, \ldots, ordered by decreasing eigenvalue, are the eigenfaces. Each is a vector in Rd\mathbb{R}^{d}, so each can be folded back into an h×wh \times w array and displayed; they look like ghostly face-shaped patterns because they are directions of variation, not faces.

Step 4: project

Keep the top kk eigenfaces and represent any face by its coordinates in that basis:


ωj=ujT(x−ψ),Ω=(ω1,…,ωk)T.\omega_j = u_j^{\mathsf T}(x - \psi), \qquad \Omega = (\omega_1,\ldots,\omega_k)^{\mathsf T}.


A face that lived in R10,000\mathbb{R}^{10{,}000} is now a short list of kk numbers. Because the uju_j are orthonormal, the reconstruction is x^=ψ+∑jωjuj\hat{x} = \psi + \sum_j \omega_j u_j, and Pythagoras gives the squared reconstruction error directly as ∥x−ψ∥2−∑jωj2\|x-\psi\|^2 - \sum_j \omega_j^2.

Worked example

Take three images in a four-pixel space: x1=(9,7,3,1)x_1 = (9,7,3,1), x2=(3,1,9,7)x_2 = (3,1,9,7), x3=(6,4,6,4)x_3 = (6,4,6,4). The mean face is


ψ=13[(9,7,3,1)+(3,1,9,7)+(6,4,6,4)]=13(18,12,18,12)=(6,4,6,4).\psi = \tfrac{1}{3}\big[(9,7,3,1)+(3,1,9,7)+(6,4,6,4)\big] = \tfrac{1}{3}(18,12,18,12) = (6,4,6,4).


Centring gives φ1=(3,3,−3,−3)\varphi_1 = (3,3,-3,-3), φ2=(−3,−3,3,3)\varphi_2 = (-3,-3,3,3) and φ3=(0,0,0,0)\varphi_3 = (0,0,0,0), which do indeed sum to zero. All three lie along a single direction, so take the unit vector u=12(1,1,−1,−1)u = \tfrac{1}{2}(1,1,-1,-1) and project:


ω(x1)=uTφ1=3+3+3+32=6,ω(x2)=−6,ω(x3)=0.\omega(x_1) = u^{\mathsf T}\varphi_1 = \tfrac{3+3+3+3}{2} = 6, \qquad \omega(x_2) = -6, \qquad \omega(x_3) = 0.


Reconstructing the first image: ψ+6u=(6,4,6,4)+(3,3,−3,−3)=(9,7,3,1)=x1\psi + 6u = (6,4,6,4) + (3,3,-3,-3) = (9,7,3,1) = x_1 exactly. Here a single number per image replaces four, with no loss at all, because the centred data happen to occupy a one-dimensional subspace. Real face data are not one-dimensional, but they are far lower-dimensional than the pixel count, and that gap is what the method exploits.

Step 5: match

Store a weight vector for each enrolled person. To identify a probe image, centre it, project it, and find the nearest stored weight vector in Euclidean distance. Two checks add information beyond that ranking.


  • Distance in weight space. How far is the probe from the nearest enrolled person? If it exceeds a calibrated threshold, the system may reject it as a poor match to the enrolled gallery; this does not establish that the probe is a face.
  • Distance from face space. How large is the reconstruction residual ∥(x−ψ)−∑jωjuj∥\|(x-\psi) - \sum_j \omega_j u_j\|? A photograph of a chair projects to some weight vector, which may land close to an enrolled person by accident. A large residual indicates that the input is poorly represented by the retained face space; it may be a non-face or a face affected by pose, lighting, or other variation. A residual threshold calibrated on suitable data may support rejection, but a residual neither proves that the input is a non-face nor catches every non-face: a non-face can lie in the retained subspace.


Omitting the second check removes a useful measure of fit to the retained face space. Neither the nearest-person distance nor the residual alone establishes identity or whether the image depicts a face.

What the method does not solve

Because the representation works on raw pixel values, it is sensitive to anything that changes those values globally. Illumination, head pose, scale and alignment all shift a face substantially in Rd\mathbb{R}^{d}, often by more than the difference between two different people under matched conditions.


Registration and photometric normalisation are commonly used to reduce sensitivity to alignment and illumination, depending on capture conditions. A small Euclidean distance between weight vectors is evidence about image similarity rather than proof of identity.

A face recognition system is built by vectorising a set of training images, subtracting the mean face, and computing the principal components of the resulting data.

What is an eigenface?

Choose an answer

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

Before computing principal components, the eigenface pipeline subtracts the mean face ψ=1M∑ixi\psi = \frac{1}{M}\sum_i x_i from every training image.

Why is this step necessary?

Choose an answer

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

A training set contains M=200M = 200 grayscale face images, each 60×5060 \times 50 pixels. The images are vectorised, the mean face is subtracted, and the covariance matrix C=1MAATC = \frac{1}{M}AA^{\mathsf T} of the mean-centred data is formed, where AA is the d×Md \times M matrix of centred vectors.

At most how many non-zero eigenvalues can CC have?

Choose an answer

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors