回覆列表
  • 1 # 最NEW資訊

    clcclear allclose allclear memorynump=40; %no_of_classesnots=5; %no_of_training_setD=pwd;cd([D, "\ORLDatabase"]);[face,MAP]=imread("face1.bmp");[a,b]=size(face);counter=0;for i=1:nump for j=1:nots file=["face" int2str((i-1)*10+j) ".bmp"]; [face,MAP]=imread(file); grayface=ind2gray(face,MAP); counter=counter+1; X(counter,:)=double(reshape(grayface,a*b,1)); endendcounter=0;for i=1:nump for j=nots+1:10 file=["face" int2str((i-1)*10+j) ".bmp"]; [face,MAP]=imread(file); grayface=ind2gray(face,MAP); counter=counter+1; Y(counter,:)=double(reshape(grayface,a*b,1)); endendcd(D)clear memoryclcAVERAGE=mean(x")";Average_Matrix=(ones(noc*nots,1)*AVERAGE")";clear memoryDifference=double(x)-double(Average_Matrix);[V,L]=eig(Difference"*Difference);clear memory[rr,cc]=size(L);maxL=min(min(L));for i=1:rr for j=1:cc if L(i,j)>maxL maxL=L(i,j); ii=i; jj=j; end endendv=V(:,jj);Lamda=max(max(L));clear memory counter=1;for i=1:nump for j=1:nots new_X(counter,:)=v(i,:)"*(x(:,counter))"; counter=counter+1; endendclear memorycounter=1;for i=1:nump for j=1:3-nots new_Y(counter,:)=v(i,:)"*(y(:,counter))"; counter=counter+1; endendclear memorycounter=0;holder=0;for i=1:nump*(3-nots) error=[]; for j=1:nump*nots temp=(new_X(j,:)-new_Y(i,:)); distance=sqrt(temp*temp"); error=[error distance]; end clear memory Minimum_Error=max(error); for k=1:nump*nots if error(k)<Minimum_Error Minimum_Error=error(k); holder=k; end end if ceil(holder/nots)==ceil(i/(3-nots)) counter=counter+1; end clear memoryendclear memoryclear new_Y new_X v x y error Minimum_ErrorLDA_Performance=(counter/(noc*(3-nots)))*100clear counter

  • 中秋節和大豐收的關聯?
  • HR的必備法律檔案有哪些?