资源简介
提取Gabor特征,用2DPCA进行人脸识别。在Yale数据库上测试,识别率较高,速度很快。
代码片段和文件信息
clear;
clear all;
facesz = [25 25]; % face size
sampleRate = 6; % Gabor降采样率
gAngle = 0:1:7; % 4个Gabor核参数
gScale = 0:4;
gShape = 1.8*pi;
gWinLen = 0; % Gabor核的长宽,0表示自行计算
N_Class=15;
N_face=1;
a=[];
W=25*5
H=25*8
img_per=[];
img_class=[];
img_vector=[];
img_face=[];
MT=zeros(WH);
temp=zeros(WH);
A=zeros(WW);
L=[];
T=[];
K=[];
right=0;
err=0;
I=[];
img1_face=[];
dd=70;
M=N_Class*N_face;
[g gWinLen] = genGaborKernel(gAnglegScalegShapegWinLen);
for i=1:N_Class
S=zeros(WH);
for j=1:N_face
gabor_image=[];
img_per=[];
D1=[];
a=[‘C:\Users\john archie\Desktop\52920923Gabor_face\Gabor_face\Yalefaces\‘ num2str(i) ‘\s‘ num2str(j) ‘.bmp‘]
% a=[‘C:\Documents and Settings\Administrator\桌面\Gabor_face\ATfaces\‘ num2str(i) ‘\‘ num2str(j) ‘.bmp‘]
%a=[‘C:\Documents and Settings\Administrator\桌面\hmm_matlab\hmm_matlab\face\s‘ num2str(i) ‘\‘ num2str(j) ‘.jpg‘];
I=imread(a);
I1=imresize( I [25 25] ‘bilinear‘ );
tic
[ GgWinLen ] = genGaborKernelF( ggWinLen facesz );
gabor_image = gaborConvF(double(I1)GgWinLen)
%size(gabor_image);
toc
D1=cell2mat((gabor_image));
imshow(uint8(D1));
% for k=1:W
% p=I(k:);
% img_per=[img_perp];
% end
%img_per=reshape(IW*H1);
img_per=D1;
T=[T img_per];
MT=MT+1/M*(img_per);
S=1/N_face*(img_per)+S;
end
K=[K S];
end
size(MT)
size(K)
size(T)
for n=1:N_Class*N_face
temp=(T(:H*(n-1)+1:H*n))-MT;
A=1/M*temp*temp‘+A;
end
L=A;
size(L)
[S V]=eig(L);
L_eig_vec = [];
for i = 1 : size(S2)
if( V(ii)>1 )
L_eig_vec = [L_eig_vec S(:i)];
end
end
%L_eig_vec;
[u1s1v1]=svd(L);
u1
s1
size(v1)
figure(2);
imshow(v1)
C=[];
C=v1(:1:dd);
figure(3);
size(C)
imshow(C)
Y=[];
B=[];
X=[];
for n=1:N_Class*N_face
X=(T(:H*(n-1)+1:H*n));
B=X‘*C;
Y=[Y B];
end
size(B)
size(Y)
%B
%Y
B1=[];
X1=[];
S1=[];
for n=1:N_Class
X1=(K(:H*(n
- 上一篇:SVPWM模型的simuli
nk仿真 - 下一篇:KPCA实现。。。。
评论
共有 条评论