资源简介

简单的人脸归一化,首先进行人眼定位,然后缩放和旋转

资源截图

代码片段和文件信息

clear all;
I1=imread(‘H:\新建文件夹\8_5.bmp‘);%读入图像
X1=double(I1);
[mn]=size(X1);
a=0;%垂直积分投影
f=0;d=0;PVD=0;
for j=1:n
    %for i=i0-(7-1)/2:i0+(7-1)/2
        %if i>=1&i<=512
    for i=1:m
     f=X1(ij);
    d=d+f;
    %end
      %end
    end
    a=a+1;
    PVD(a)=d;
    d=0;
end
% plot(PVD);
M=fix(n/2);%向最接近零取整
[h1h2]=min(PVD(18:M));
[h3h4]=min(PVD(1M+8:n));
h5=h4+M;

a=0;%水平积分投影
f=0;d=0;PVD=0;
for i=1:m
    for j=1:n
     f=X1(ij);
    d=d+f;
    end
    a=a+1;
    PVD(a)=d;
    d=0;
end
% % plot(PVD);
N=fix(m/2);

[w1w2]=max(PVD(11:N-10));%w1是最小数,w2是坐标
[w3w4]=max(PVD(1N+1:m));
w5=w4+N;
B=X1(w2:w5h2:h5);
D=uint8(B);
imshow(D);


J=imadjust(D[0.150.35][01]);%[0.20.3]对图像有影响, imadjust是线性灰度变换
BW=edge(J‘canny‘0.4);%0.5对图像有影响 canny必须是在uint之后
figureimshow(BW);

F=hough_3(BW);
a1=F(11);b1=F(12);
a2=F(21);b2=F(22);
BW(a1:)=1;BW(:b1)=1;
BW(a2:)=1;BW(:b2)=1;
% BW(a1b1-5:b1+5)=1;BW(a1-5:a1+5b1)=1;
% BW(a2b2-5:b2+5)=1;BW(a2-5:a2+5b2)=1;
figureimshow(BW);

% jiao=(a2-a1)/(b2-b1);
% theta=atan(jiao);%theta必须是角度,如38°
% %theta=(atan(jiao))*pi/180;%theta必须是角度,如38°
% T=[cos(theta)-sin(theta)0;sin(theta)cos(theta)0;001];
% tform=maketform(‘affine‘T);
% J2=imtransform(I1tform);
% figure;
% subplot(121)imshow(I1);
% subplot(122)imshow(J2);
% %imwrite(J2‘H:\facepicture\1\j2.bmp‘);

% A1=10;A2=10;B1=6;B2=44;  %标准图象双眼坐标
% dis1=sqrt((A1-A2).^2+(B1-B2).^2);
% dis2=sqrt((a1-a2).^2+(b1-b2).^2);
% r=dis1/dis2;g=r*112/92;

% T=[r00;0r0;001];     %进行缩放
% tform=maketform(‘affine‘T);
% J3=imtransform(J2tform);
% figureimshow(J3);
% % imwrite(J3‘H:\facepicture\1\j3.bmp‘);

% %s1=B1;s2=92-B2;u1=A1;u2=112-A1;    %进行尺寸裁减
% [AB]=size(J3);
% L1=A-112;x=fix(L1/2);y=L1/2;
% if y>x
%     s1=fix(L1/2)+2;s2=A-fix(L1/2);
% else
%     s1=fix(L1/2)+1;s2=A-fix(L1/2);
% end
% L2=B-92;m=fix(L2/2);k=L2/2;
% if k>m
%     u1=fix(L2/2)+2;u2=B-L2/2;
% else
%     u1=fix(L2/2)+1;u2=B-L2/2;
% end
% J4=J3(s1:s2u1:u2);
% %E1=14;E2=14;F1=12;F2=51;
% %J4=J3((E1-u1):(A-E1-u2)(F1-s1):(dis1+F1+s2));
% %J4=uint8(G);
% imshow(J4);
% % imwrite(J4‘H:\facepicture\1\j4.bmp‘);

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件      11382  2007-12-12 11:29  1\8_5.bmp

     文件       2304  2008-07-04 06:56  1\face_1.m

     文件        933  2008-02-15 15:49  1\hough_3.m

     文件      13454  2008-06-26 08:19  1\j2.bmp

     文件      13454  2008-06-26 08:19  1\j3.bmp

     文件      11382  2008-06-26 08:19  1\j4.bmp

    ..A.SH.     14336  2008-07-10 11:04  1\Thumbs.db

     目录          0  2008-09-12 19:29  1

----------- ---------  ---------- -----  ----

                67245                    8


评论

共有 条评论