📄 facereco.m
字号:
function FaceReco( num1,num2 )%FACERECO Summary of this function goes here% Detailed explanation goes here% num1,num2 num1_num2.bmp is the name of the image load ORL;load train;load CreateFeature;% test=double(fea(testInIdx,:));% train=double(fea(trainIdx,:));%%%此段代码用于显示大图p=num2str(num1);q=num2str(num2);str=strcat('.\','ORL','\',p,'\',q,'.bmp');image=imread(str);figure;imshow(image);tit='this is the picture you chose.';title(tit);%%%显示32*32图的时候用此段代码% a=num1;% b=10*(a-1)+num2; %照片顺序数 1-400中某一个% Y=zeros(32);% for i=0:31% m=32*i+1;% n=32*i+32;% Y(:,i+1)=fea(b,m:n);% end% str='this is the picture you chose.';% figure(1) ;% imshow(Y,[0,255]);% % imagesc(Y);colormap(gray);% title(str);%% test=double(fea(testInIdx,:)); 因为已经load CreateFeature了所以不用再进行以下五行 % train=double(fea(trainIdx,:));% options=[];% options.ReducedDim=75;% [eigve,eigvl,mean,new]=Train(train,options);% %人脸匹配a=num1;b=10*(a-1)+num2; %照片顺序数 1-400中某一个[rle,rab]=Test(3,double(fea(b,:)),eigvector,meanData,new_data,750);result=[rle,rab];result;%%%根据索引显示大图x=trainIdx(result(1,1),1);%x,y,z为result在trainIdx中的行数,也就是对应在ORL中的行数y=trainIdx(result(1,2),1);z=trainIdx(result(1,3),1);train=[x y z];x1=ceil(10\x);x2=x-10*fix(10\x);%x1,x2分别为第x1个人的第x2幅图片,如果是第十副图片则做以下if处理if (x2==0) x1=x1-1;x2=10;end y1=ceil(10\y);y2=y-10*fix(10\y);if (y2==0) y1=y1-1;y2=10;end z1=ceil(10\z);z2=z-10*fix(10\z);if (z2==0) z1=z1-1;z2=10;end % a1=[x1 x2] %test the value of a1 a2 a3% a2=[y1 y2]% a3=[z1 z2]f1=num2str(x1);h1=num2str(x2);str1=strcat('.\','ORL','\',f1,'\',h1,'.bmp');image1=imread(str1);f2=num2str(y1);h2=num2str(y2);str2=strcat('.\','ORL','\',f2,'\',h2,'.bmp');image2=imread(str2);f3=num2str(z1);h3=num2str(z2);str3=strcat('.\','ORL','\',f3,'\',h3,'.bmp');image3=imread(str3);Images=zeros(3,10304);for i=1:92 m=112*i-111; n=112*i; Images(1,m:n)=image1(:,i);endfor i=1:92 m=112*i-111; n=112*i; Images(2,m:n)=image2(:,i);endfor i=1:92 m=112*i-111; n=112*i; Images(3,m:n)=image3(:,i);end% train(1,:)=% f2=num2str(x1);% h2=num2str(x2);% str2=strcat('.\','ORL','\',f2,'\',h2,'.bmp');% image2=imread(str2);figure;DispImage(Images,92,112,3,1);%%%直接显示小图% figure ;% DispImage(train(result,:),32,32,3,1);[m,n]=size(rle); if n==0 str='No face below threshold. And No.1,2,3 face above threshold.'; end if n==1 str='No.1 face below threshold.And No.2,3 face above threshold.'; end if n==2 str='No.1,2 face below threshold.And No.3 face above threshold.'; end if n==3 str='No.1,2,3 face below threshold.And No face above threshold.'; end title(str);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -