⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 loadimages.m

📁 这个也是关于肤色人脸检测的程序
💻 M
字号:
% Version : 4.1
% Author  : Omid Bonakdar Sakhi

function IMGDB = loadimages
%{
This function will prepare faces and non-faces for the train set
这功能将会准备脸和非脸为那火车组
all data will be gathered in a large cell array . each colume represent
所有的数据将会是在大的细胞中聚集排列。 每 colume 表现
a window for the network , which could be a face or not.
为网络 ,可能是一个脸的一扇窗户。
rows are as follows :  排依下列各项 :

Row 1 ----> File Name  排 1----> 文件名字
Row 2 ----> Desired output of the net in responding to the vector
排 2----> 需要了输出那网在回应矢量方面
Row 3 ----> Prepaired vector for training phase 排 3----> Prepaired 矢量为训练状态

you can see for yourself this large database out of the program. 你能自个儿瞧瞧这个大的数据库从计画。
type  类型
    IMGDB = loadimages
in the command window . 在指令窗户中。

Also the function save the database to a file 'imgdb.mat' to save time
也功能救援数据库到一文件 'imgdb.mat' 对救援时间
so this function is a one time function except you want to change something
因此这功能是一一时间功能除你需要到变化某事
in the 'im2vec.m' . In that case you should build the database again.
在 'im 2 vec.m' 中 . 在情况,你应该再建立数据库。
%}

%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
face_folder = 'face\';      %location of faces for the train set    %脸的位置为火车组
non_face_folder = 'non-face\';      %location of non-faces  %非脸的位置
file_ext = '.png';
out_max = 0.9;      % desired output of the net for detecting a face    % 需要了输出那网为发现一脸
out_min = -0.9;     % desired output of the net for not detecting a face  % 需要了输出那网为不发现一脸
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
IMGDB = cell (3,[]);
fprintf ('Loading Faces ');
folder_content = dir ([face_folder,'*',file_ext]);
nface = size (folder_content,1);
for k=1:nface
    string = [face_folder,folder_content(k,1).name];
    image = imread(string);
    [m n] = size(image);
    if (m~=27 || n~=18)
        continue;
    end
    fprintf ('.');    
    % as you see , each face in the face folder becomes 10 vectors 
    % 当你见到 ,% 每个脸当面文件夹变成 10个矢量
    IM {1} = im2vec (image);    % the original face  % 最初的脸
    IM {2} = im2vec (fliplr(image));    % the mirror of the face which is a face  % 脸的镜子是一脸
    % for better response of the network , 1-pixel shifted face in any
      % 为网络的比较好的回应 , 单一图素的移转脸在任何的
    % direction is used to train network invariant to 1-pixel.
     % 方向对是无变化的火车网络被用到单一图素的。
    IM {3} = im2vec (circshift(image,1)); 
    IM {4} = im2vec (circshift(image,-1));
    IM {5} = im2vec (circshift(image,[0 1]));
    IM {6} = im2vec (circshift(image,[0 -1]));
    IM {7} = im2vec (circshift(fliplr(image),1));
    IM {8} = im2vec (circshift(fliplr(image),-1));
    IM {9} = im2vec (circshift(fliplr(image),[0 1]));
    IM {10} = im2vec (circshift(fliplr(image),[0 -1]));
    for i=1:10
        IMGDB {1,end+1}= string;
        IMGDB {2,end} = out_max;
        IMGDB (3,end) = {IM{i}};
    end    
end
fprintf ('\nLoading non-faces ');    
folder_content = dir ([non_face_folder,'*',file_ext]);
nnface = size (folder_content,1);
for k=1:nnface
    string = [non_face_folder,folder_content(k,1).name];
    image = imread(string);
    [m n] = size(image);
    if (m~=27 || n~=18)
        continue;
    end
    fprintf ('.');
    % here we need some examples to train the network with non-face vectors
    % 在这里我们需要一些例子到火车网络与非脸矢量
    % so now we do not have a face here . we can do what ever we want with
     % 因此现在我们做不有一脸在这里。 我们能做什么曾经我们需要与
    % the photo. strike it with a hammer ,... % 相片。 罢工它用一支槌 ,.。。
    % I have chosen only the fliped version of non-faces. flip left-right
    % 我有只有选择那用指头弹版本非脸。 突然转动左边-右边
    % and up-down   % 而且向上的-向下的
    IM {1} = im2vec (image);
    IM {2} = im2vec (fliplr(image));
    IM {3} = im2vec (flipud(image));
    IM {4} = im2vec (flipud(fliplr(image)));    
    for i=1:4
        IMGDB {1,end+1}= string;
        IMGDB {2,end} = out_min;
        IMGDB (3,end) = {IM{i}};
    end    
end
fprintf('\n');
save imgdb IMGDB

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -