Question

I am implementing a face recognition mini-project using eigenfaces.

I have computer successfully and saved eigenfaces to a folder. Using:

  Matrix<-readInImagesAndLinearize()
  avg_face<-as.vector(colMeans(Matrix, na.rm = FALSE, dims = 1))
  A <- t(Matrix) - matrix(avg_face, ncol=dim(Matrix)[1], nrow=dim(Matrix)[2])
  L <- t(A) %*% A
  V <- eigen(L)

  eigenValues <<- V[['values']]
  eigenFaces <<- apply((A %*% V[['vectors']]), 2, function(x) {
  # normalize and scale to 1
  y <- x/sqrt(sum(x^2))
  y <- x - min(x)
  (1/max(y)) * y
  })  

And later save them to files.

What should be my next step ? How exactly do I reduce the dimensionality and later use it to recognise if a give face is similiar to another ?

Was it helpful?

Solution

You reduce dimensionality by removing the eigenvectors that correspond to the smallest eigenvalues. How many eigenvectors you retain is a decision you must make (e.g., you may decide to retain enough eigenvectors/eigenvalues such that the sum of the retained eigenvalues is at least 99% of the sum of all eigenvalues). When you receive a new image, you reduce its dimensionality by projecting it onto the retained eigenvectors (i.e., take the dot product of the image vector with each of the retained eigenvectors).

Recognizing if two faces are similar is another problem entirely. PCA only deals with the dimensionality reduction - it is not a classifier. You will still need to select a classification algorithm, which should be based on a number of considerations (size & characteristics of the images, are there multiple images of the same people, are there different viewing angles/distances, etc.)

OTHER TIPS

Given a new face image, you should represent it as a linear combination of the eigenfaces. The coefficients of the linear combination are your descriptors. That's how you reduce dimensionality.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top