吕祺,喜欢思考,爱美好的食物 修改话题经验
number of pixels in each image) and that you have M images, you'll end
up with a matrix G (N^2 x M) :
1
CovMat = -------- G G^T
M - 1
this is what you are trying to find the eigenvalues/eigenvectors for,
right?
There is a trick widely used when doing PCA on sets of images, it is
based on the fact that the (M x M) matrix:
1
lmCovMat = -------- G^T G
M - 1
has the same non-zero eigenvalues of CovMat. So what you do is to
compute the eigenvalues and eigenvectors of this low memory covariance
matrix and then, for the eigenvectors, compute:
E = G lmE
where E is a matrix containing the wanted eigenvectors and lmE is the
matrix of the eigenvectors compouted from the lmCovMat.
This is implemented already in the OpenCV libraries.
Hope it helps.
clear
[x]=load_imgs('training');
x=x(1:100,:);
a1=x*x';
b=x'*x;
[va,p]=eig(a1/27);
[vb,q]=eig(b/27);
%b/27*vb(:,1)==q(1)*vb(:,1);