display mean, and fisher faces + image reconstruction
Hi all. So i added the code for displaying the mean, fisher faces and reconstruction of those fisher faces. I added it in webcam face recognition code. I have 3 sets of images for 3 persons.
2 things: 1. It display 1 image for mean (expected :-)) and 2 for fisher faces and fisher face reconstruction. I thought i would see 16 (well it does say up to, so what is it based on?), or 3 based on the amount of images i trained it with. 2. I'm doing a direct imshow after, but i don't see these outputs updated, they seem static to me. If that's normal, i guess all this is done on the trained model, not on the input the webcam is getting?
I guess i was looking for some cool picture that would be based on the input :-)
code:
// Here is how to get the eigenvalues of this Eigenfaces model:
Mat eigenvalues = model->getEigenValues();
// And we can do the same to display the Eigenvectors (read Eigenfaces):
Mat W = model->getEigenVectors();
// Get the sample mean from the training data
Mat mean = model->getMean();
imshow("mean", norm_0_255(mean.reshape(1, images[0].rows)));
// Display or save the first, at most 16 Fisherfaces:
for (int i = 0; i < min(16, W.cols); i++) {
string msg = format("Eigenvalue #%d = %.5f", i, eigenvalues.at<double>(i));
cout << msg << endl;
// get eigenvector #i
Mat ev = W.col(i).clone();
// Reshape to original size & normalize to [0...255] for imshow.
Mat grayscale = norm_0_255(ev.reshape(1, im_height));
// Show the image & apply a Bone colormap for better sensing.
Mat cgrayscale;
applyColorMap(grayscale, cgrayscale, COLORMAP_BONE);
// Display or save:
imshow(format("fisherface_%d", i), cgrayscale);}
// Display or save the image reconstruction at some predefined steps:
for(int num_component = 0; num_component < min(16, W.cols); num_component++) {
// Slice the Fisherface from the model:
Mat ev = W.col(num_component);
Mat projection = LDA::subspaceProject(ev, mean, images[0].reshape(1,1));
Mat reconstruction = LDA::subspaceReconstruct(ev, mean, projection);
// Normalize the result:
reconstruction = norm_0_255(reconstruction.reshape(1, images[0].rows));
// Display or save:
imshow(format("fisherface_reconstruction_%d", num_component), reconstruction);}
Alef