pca analysis in scilab

173 views
Skip to first unread message

tckb

unread,
Jan 1, 2009, 1:51:23 PM1/1/09
to Face Recognition Research Community
hi,
am tryng to develop a face recogintion system in scilab, ive choosen
the face recogntion using the eigen faces by pca anlysis. ive been
trying to do it but unfortunately i wasnt able to generate the eigen
face. ive read a lots of ieee papers and other kind of e-matrials
regaring the eigen faces . even the paper by mattew and pentland and
here is where i am

// eigf.sce
clear all
nofim=85 // no of images that am reading
for i=1:nofim
img=imread('/home/tckb/imdb/1-'+string(i)+'.jpg'); // just the path
to images
images(:,i)=double(img(:)); // saves the image vector in the image
matrix
imshow(img);
end;
mat=[];
for j=1:nofim,
mat=mat+images(:,i);
end;
mat_avg=mat/nofim; // change to '10' if in doubts

for k=1:nofim,
diffr_mat(:,k)=images(:,k)-mat_avg;
end

C=diffr_mat'*diffr_mat; // covariance matrix

[evect,evals_diag]=mtlb_eig(C);

evals=diag(evals_diag); // make diagonal evals to vector

eigen_faces=[];
eigen_faces=diffr_mat*evect; // this was given in some material is
this correct ?
// i want to display the eigen face

// am struct here!
----------------------
please go through the code and tell me if i did anything wrong please
correct me if possible you post some code snippets on how to generate
the eigen face from the eigen vectors of the covariance matrix


-tckb




hulijo

unread,
Jan 3, 2009, 6:28:57 AM1/3/09
to Face Recognition Research Community
The code looks fine. I actually don't see what your problem is? If you
would like to display your eigenfaces you just have to reshape your
eigenfaces back to the original size (from vector to matrix) and
dislpay them as an image (scaled to the 8bit interval for example). In
matlab you would do something like this:

[a,b]=size(img);
eigenface_one = reshape(eigen_faces(:,1),[a,b]);
imshow(eigenface_one,[])

However, this is just necessary for visualization purposes. For
computing the PCA features you don't have to do that. You just use
youreigenfaces as a projection matrix:

PCA_coeff = diffr_mat'*eigen_faces;

Hope this helps.
Reply all
Reply to author
Forward
0 new messages