clc
clear all
NSamples =3;
NClasses =30;
counter =1;
S=[];
figure(1);
for i=1:NClasses
str = strcat('D:\eigenfaces\s\', int2str(i));
str = strcat(str, '.jpg');
eval('I=imread(str);');
I = rgb2gray(I);
I = imresize(I, [50,50]);
[m n]=size(I);
subplot(ceil(sqrt(NClasses)),ceil(sqrt(NClasses)),i)
if j==NSamples
title('TrainingDatasets','fontsize',18)
data( counter ,:)=I (:) ;
Y( counter ,1)=NClasses;
counter = counter +1;
end
drawnow;
end
NTrainingSamples =2;
counter =1;
Training =[]; Testing =[]; TrLabels =[]; TestLabels =[];
for i=1: NClasses
for j=1: NTrainingSamples
Training ( size ( Training ,1) +1 ,:)= data( counter ,:) ;
TrLabels ( size ( TrLabels ,1) +1 ,1)= Y( counter ,1) ;
counter = counter +1;
end
for j= NTrainingSamples +1: NSamples
Testing ( size ( Testing ,1) +1 ,:)= data( counter ,:);
TestLabels ( size ( TestLabels ,1) +1 ,:)= Y( counter ,1);
counter = counter +1;
end
end
clear data Y I;
tic