what is the exact differance between PCA and MPCA , and how to apply this to an image with N*N , wikipidea says PCA operates on image with 100*100 pixel , with 10,000*1, where as MPCA operates on same image with TWO mode as 100* 1, 100*1.

2 views (last 30 days)
wikipidea says PCA operates on image with 100*100 pixel with 10,000*1 in sigle mode , where as MPCA operates on same image with TWO mode as 100*1, 100*1.what it means , and how to implement this in MATLAB, i have tried to do this , please check this code, if any one have any code which will differentiate the PCA and MPCA for image, or any further reading pleas guide me.
i am attaching my code of MPCA here
if true
% 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);
% face space projection
[r c]=size(IVMean); Wt=zeros(c,FaceNo);
for i=1:c
Wt(i,:)=single(IVMean(:,i))'*eigVec;
end

Answers (0)

Categories

Find more on Dimensionality Reduction and Feature Extraction in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!