Can any one explain what is the exact difference between PCA and MPCA, and how to apply the MPCA ON face images

3 views (last 30 days)
wikipidea defines the differance bet PCA and MPCA in single line "PCA Opertares on image of 100*100 in to 10,000*1, where MPCA opertares on same image in two mode as 100*1 and 100*1" what it means , and how to implenet this with the matlab. if any one has code or tutorial about the step of MPCA, please help me out.

Accepted Answer

Ahmet Cecen
Ahmet Cecen on 20 Nov 2014
The very same page you copy pasted that explanation from has 2 decent references of a code and example.
In short it means PCA would assume a 100x100 image is actually a single 10000 dimensional vector, treating each pixel as a dimension. In contrast MPCA first assumes that the same 100x100 image is actually 100 separate row vectors each having 100 dimensions (treating every column as a dimension). Then it does the inverse (second mode) and assume the image is 100 separate column vectors each having 100 dimensions (treating each row as a dimension). Its and iterative projection problem. Also check out one of the references in particular:
which has pretty good definitions and theory in my opinion.
  1 Comment
dhiraj dabi
dhiraj dabi on 20 Nov 2014
Thanks for prompt answer to my question , as per the documents you have mentioned herehttp://www.comm.toronto.edu/~kostas/Publications2008/pub/102.pdf i have tried to devloped one matlab code for MPCA which is as below plese correct me if i am wrong somewhere
clear all;
close all;
clc;
[f p]=uigetfile('*.*','');
path=[p f];
Img=imread(path);
Img=rgb2gray(Img);
figure;
imshow(Img) title('Input Image') %% FaceNo=4;
IMat=[];
for i=1:FaceNo
s=num2str(i);
s=[ s '.jpg'];
imr=imread(s);
t = imresize(imr,[500 500]);
% t=imread(s);
t=rgb2gray(t);
figure,imshow(t);
IMat(:,:,i)=t;
end
IMat=uint8(IMat);
% image vector
[rw cl]=size(IMat(:,:,1));
for i=1:FaceNo
IVect(:,i)=reshape(IMat(:,:,i),rw*cl,1);
end
% mean image
IMean=mean(IVect,2);
IMean=uint8(IMean);
% substract mean image from image vector
mn=[];
for i=1:FaceNo
mn=[mn IMean];
end
IVMean=IVect-mn;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% calculate covariance matrix
CVMat=double(IVMean)'*double(IVMean);
% calculate eigen values and eigen vectors
[eigVal eigVec]=eig(CVMat); eigVec=single(IVMean)*eigVec;
eigFace=eigVec(:,end:-1:1);
figure;
for i=1:4
t=eigVec(:,i);
t=reshape(t,rw,cl);
t=uint8(t);
end
% face space projection
[r c]=size(IVMean);
Wt=zeros(c,FaceNo);
for i=1:c
Wt(i,:)=single(IVMean(:,i))'*eigVec;
end
please correct me if i have wring in any of the above step, if you have any code which has used the same algorithm, , them please send me the link , ii will be very helpful for me to compare with my code
end

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!