91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 2KB
    文件類型: .rar
    金幣: 2
    下載: 0 次
    發布日期: 2021-05-14
  • 語言: Matlab
  • 標簽: TwoDPCA??

資源簡介

用matlab實現的2dpca人臉識別程序,運行速度比傳統的pca方法快至少10倍, 識別率也比pca 高 -Using matlab to achieve 2dpca face recognition program, run faster than the traditional PCA method at least 10 times faster, than the PCA recognition rate is high

資源截圖

代碼片段和文件信息


function?[]=TwoDPCA

%%%%%%%%%%%%%特征臉顯示已正確,訓練與測試沒有分開。
%?Face?recognition?
clear?all
close?all
clc


M=200;%%%%
traincopy=5;%%%表示同一個人有幾張相片。
eignum=3;%%%選取的特征個數。

cel=cell(1M);
cellafter=cell(1M);

tt=clock;

S=[];???

ii=1;

????str=strcat(‘E:\三維人臉\2dfacedatabase\ORL\s1\1.pgm‘);
????img=imread(str);
????[ia?ib]=size(img);
????sum=zeros(iaib);
????B=zeros(iaib);
????
for?i=1:40
????for?j=1:5
??????str=strcat(‘E:\三維人臉\2dfacedatabase\ORL\s‘int2str(i)‘\‘int2str(j)‘.pgm‘);
????eval(‘img=imread(str);‘);
????sum=double(sum)+double(img);
????cel{1ii}=img;
????ii=ii+1;
????end
end

??meanA=sum/M;
??
??
??cov=zeros(ib);
??
??for?i=1:M
???img=cel{1i};
????B=double(img)-double(meanA);
????temp=B‘*B;
????cov=double(cov)+double(temp);
??end




[vv?dd]=eig(cov);
num2=size(vv);
%?Sort?and?eliminate?those?whose?eigenvalue?is?zero
v=[];
d=[];

for?i=1:size(vv2)
????if(dd(ii)>1e-4)
????????v=[v?vv(:i)];
????????d=[d?dd(ii)];
????end
end
num1=size(v2);

%sort??will?return?an?ascending?sequence
[B?index]=sort(d);
ind=zeros(size(index));
dtemp=zeros(size(index));
vtemp=zeros(size(v));
len=length(index);
for?i=1:len
????dtemp(i)=B(len+1-i);
????ind(i)=len+1-index(i);
????vtemp(:ind(i))=v(:i);
end
d=dtemp;
v=vtemp;


imgafter=[];
for?i=1:M
????for?j=1:eignum
????img=cel{1i};
????temp1=double(img)*double(v(:j));
????imgafter=[imgafter?temp1];
????end
????cellafter{1i}=imgafter;???
????imgafter=[];
????
end

timeconsume=etime(clocktt);


testimg=M/traincopy;
findimgnum=traincopy;

suc=0;
%?figure(5);
for?k=1:testimg
????InputImage?=imread(strcat(‘E:\三維人臉\2dfacedatabase\ORL\s‘int2str(k)‘\10.pgm‘));
????
????testafter=[];
????for?j=1:eignum
????????temp=double(InputImage)*double(v(:j));
????????testafter=[testafter?temp];
??
????end??????


????%?Find?Euclidean?distance
????e=[];
????
????for?i=1:M
????????tempA=double(testafter)-double(cellafter{1i});
????????total=0;
????????for?j=1:eignum
???????????aa=norm(tempA(:j));
???????????total=total+aa;
????????end
???????????e=[e?total];???????????
????end
????
????[C?index]=sort(e);
????min=index(1);
????
????
????
????%%%%%%%計算正確率
????testingroup=floor((min-1)/traincopy)+1;?%%計算要測試的圖像所在的組
????if?testingroup==k
????????suc=suc+1;
?????else?
????????fprintf(‘%d.jpg?fails?to?match!\n‘k);
????end????
????????
????

%?%%%%%%%%%%%%%%%%%%%顯示所有找到的與測試圖像為同一個人的圖片(可)。(顯示所有與測試圖片最小距離的那組,而不是比較出來的最小的5個)
%?????subplot(testimgfindimgnum+1(k-1)*(findimgnum+1)+1);%?subplot(行數,列數,放圖像位置的序數)
%?????imshow(InputImage);
%?
%?????for?i=1:findimgnum
%?????????temppos=(testingroup-1)*traincopy+i;
%?????????str=strcat(‘E:\三維人臉\testpic\orl\‘int2str(temppos)‘.pgm‘);????%concatenates?two?strings?that?form?the?name?of?the?image
%?????????eval(‘img1=imread(str);‘);
%?????????subplot(testimgfindimgnum+1(k-1)*(findimgnum+1)+i+1)
%?????????imshow(img1)??
%?????????drawnow;???????

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

?????文件???????3329??2008-03-13?22:22??TwoDPCA.m

-----------?---------??----------?-----??----

?????????????????3547????????????????????2


評論

共有 條評論

相關資源