I am doing face recognition using PCA and SVM. My training set has an array of 400 images on which i have performed PCA and mapped the data into the eigenspace. Now for testing i have only a single image whose principal components i need to extract to match with the previously extracted features. But any algorithm of PCA i use or even the inbuilt command (princomp) i am getting dimension error. Cause PCA requires forming the eigenspace and projecting data onto this space, how do i form the eigenspace for a single image?
One of the use cases of PCA is that it can be used for image compression — a technique that minimizes the size in bytes of an image while keeping as much of the quality of the image as possible. In this post, we will discuss that technique by using the MNIST dataset of handwritten digits.
Yes, it is possible. It is advisable to keep more PCs which explain the most variance (70-95%) to make the interpretation easier. More the PCs you include that explains most variation in the original data, better will be the PCA model.
coeff = pca( X ) returns the principal component coefficients, also known as loadings, for the n-by-p data matrix X . Rows of X correspond to observations and columns correspond to variables. The coefficient matrix is p-by-p.
PCA is an important method for feature extraction and image representation. In PCA, matrix transformation of the image takes place into high dimension vectors and its covariance matrix is obtained consuming high-dimension vector space.
You should use the same eigenspace obtained with the training data.
Here you have a tutorial that explains it very well. These are the main steps:
Training:
% step: 1: find the mean image
mean_face = mean(images, 2);
% step 3 : calculate the eigenvectors and eigenvalues
[evectors, score, evalues] = princomp(images');
Testing:
% calculate the feture vector
feature_vec = evectors' * (input_image(:) - mean_face);
As you can see evectors
and mean_face
were coputed during the training stage.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With