qq_33284740 2016-01-01 02:26 采纳率: 0%
浏览 1850

求大神告诉一下这个性别识别matlab程序是用什么神经网络训练的?可以的话帮我注释一下啊,感谢!

clear all;
for kk=1:14
%'Loading picture......'
p1=ones(16,16);
m=strcat('C:\Users\wj\Desktop\Gender\train_db\',int2str(kk),'.jpg');
x=imread(m,'jpg');
I=rgb2gray(x);
BW=im2bw(I,0.5);
%figure,imshow(BW)
%'Processing picture......'
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%% minimisation of background portion

[n1 n2]=size(BW);
r=floor(n1/10);
c=floor(n2/10);
x1=1;x2=r;
s=r*c;

for i=1:10
    y1=1;y2=c;
    for j=1:10
        if (y2<=c | y2>=9*c) | (x1==1 | x2==r*10)
            loc=find(BW(x1:x2, y1:y2)==0);
            [o p]=size(loc);
            pr=o*100/s;
            if pr<=100
                BW(x1:x2, y1:y2)=0;
                r1=x1;r2=x2;s1=y1;s2=y2;
                pr1=0;
            end
            %imshow(BW);
        end
            y1=y1+c;
            y2=y2+c;
    end

 x1=x1+r;
 x2=x2+r;
end
%figure,imshow(BW)

%'Locating face......'

% find how many connected object in the detection area
L = bwlabel(BW,8); 
BB  = regionprops(L, 'BoundingBox');
BB1=struct2cell(BB);
BB2=cell2mat(BB1);

[s1 s2]=size(BB2);
mx=0;
for k=3:4:s2-1
    p=BB2(1,k)*BB2(1,k+1);
    if p>mx & (BB2(1,k)/BB2(1,k+1))<1.8
        mx=p;
        j=k;
    end
end
%figure,imshow(I);
%hold on;
%rectangle('Position',[BB2(1,j-2),BB2(1,j-1),BB2(1,j),BB2(1,j+1)],'EdgeColor','r' )
fprintf('id = %d\n',kk);
%pause(3);
%'Traning ......'
%fprintf('(x,y,w,h)=(%f,%f,%f,%f)',BB2(1,j-2),BB2(1,j-1),BB2(1,j),BB2(1,j+1));
face = BW(round(BB2(1,j-1)):round((BB2(1,j-1)+BB2(1,j+1))),round(BB2(1,j-2)):round((BB2(1,j-2)+BB2(1,j))));
rate=16/max(size(face));
face=imresize(face,rate);
[i,j]=size(face);
i1=round((16-i)/2);
j1=round((16-j)/2);
p1(i1+1:i1+i,j1+1:j1+j)=face;
p1=-1.*p1+ones(16,16);
for m=0:15
    p(m*16+1:(m+1)*16,kk)=p1(1:16,m+1);
end

if kk < 8
    t(kk) = 1; % female
else
    t(kk) = 0 ; % male
end

end
save TMPDATA p t;

% training

  • 写回答

2条回答 默认 最新

报告相同问题?

悬赏问题

  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料