Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can i find PCA of a single image? - MATLAB

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?

like image 416
Sid Avatar asked Jan 28 '14 08:01

Sid


People also ask

Can you do PCA on images?

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.

Can you do PCA on one variable?

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.

How do I get PCA in Matlab?

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.

How PCA works in image feature extraction?

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.


1 Answers

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 evectorsand mean_face were coputed during the training stage.

like image 143
phyrox Avatar answered Oct 10 '22 19:10

phyrox