PCA需要先求数据的散布矩阵x*x’,再求其特征向量,那么随便一个400*450的图像,就是180000维,矩阵就是180000*180000,matlab无法容纳,那么通常的PCA对图像的降维,比如求eigenface是怎么实现的?难道都是很小的图像?修改举报添加评论 分享 • 邀请回答
0
吕祺,喜欢思考,爱美好的食物 修改话题经验
Suppose you store the images as column vectors of length NxN (the
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);