A list,

Face detection is the premise of face recognition, human-computer interaction, intelligent visual monitoring and so on. In recent years, in the field of pattern recognition and computer vision, face detection has become a popular and active research direction. In this paper, an experimental system of face detection is constructed based on the combination of skin color segmentation, template matching and candidate face image block screening, and a series of experimental statistics are carried out in this system with a self-made face image database. This paper first introduces the background and current situation of face detection technology research, expounds the significance of the development of face detection technology, summarizes some commonly used detection algorithms, and then focuses on the face detection algorithm based on skin color segmentation and template matching verification. Skin color is an important feature of human face. After sampling statistics and clustering analysis, a skin color segmentation method based on Gaussian model in YCbCr space was established. Gaussian model of skin distribution was established in YCbCr color space to obtain skin probability likelihood image, and skin region segmentation was completed under the optimal dynamic threshold selection algorithm. Mathematical morphology and some prior knowledge were used for face feature screening of skin color regions, and non-skin color regions were removed step by step to reduce the number of candidate faces and simplify the processing of subsequent detection process. This article USES the average template matching method to confirm the candidate face to face usually has a certain Angle in the image rotation and size of uncertain problems, by calculating the deflection Angle and the candidate face image block area, and to adjust the template, optimize the template matching, improve the accuracy of the template matching, at the same time avoid using multi-scale template matching algorithm for many times, Improve algorithm efficiency. The candidate face image region and template centroid are used as the origin of registration to suppress the interference of face image noise. Finally, a face detection test system based on skin color segmentation and template verification is constructed, and the system is tested with self-made face image database. Experimental results show that the system algorithm is effective and has high detection performance and low misjudgment rate.

Ii. Source code

function varargout = untitled(varargin)
% UNTITLED MATLAB code for untitled.fig
%      UNTITLED, by itself, creates a new UNTITLED or raises the existing
%      singleton*.
%
%      H = UNTITLED returns the handle to a new UNTITLED or the handle to
%      the existing singleton*.
%
%      UNTITLED('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in UNTITLED.M with the given input arguments.
%
%      UNTITLED('Property','Value',...) creates a new UNTITLED or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before untitled_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to untitled_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
 
% Edit the above text to modify the response to help untitled
 
% Last Modified by GUIDE v2.5 19-May-2020 15:25:06
 
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
    'gui_Singleton',  gui_Singleton, ...
    'gui_OpeningFcn', @untitled_OutputFcn, ...
    'gui_OutputFcn',  @untitled_OutputFcn, ...
    'gui_LayoutFcn',  [] , ...
    'gui_Callback',   []);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end
 
if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
 
 
% --- Executes just before untitled is made visible.
function untitled_OutputFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to untitled (see VARARGIN)
 
% Choose default command line output for untitled
handles.output = hObject;
 
% Update handles structure
guidata(hObject, handles);
 
% UIWAIT makes untitled wait for user response (see UIRESUME)
% uiwait(handles.figure1);
 
 
% --- Outputs from this function are returned to the command line.
%-------------------------------------- pushbutton1_Callback(回调函数)
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
global im imycbcr skin1 skin2 lpf %----------------宣布为全域变量
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
if get (gcbo, 'Value' ) ==1;
    im=imread('10.jpg' ) ; %------------------------------读入彩色图像
    axes(handles.axes1)
    set(handles.axes1, 'XMinorTick' , 'on' ) %-------------嵌入Axes(1) 回调函数
    imshow(im) ; %------------------------------显示彩色图像
else
    imformats
end
% Hint: get(hObject, ' Value' ) returns push state of togglebutton1
%-------------------------------------- pushbutton2_Callback(回调函数)
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global im imycbcr skin1 skin2 lpf %------
    cr = filter2(lpf, cr) ;
    cr = reshape(cr, 1, prod(size(cr) ) ) ;
    bmean = mean(cb) ; %--------------------------------求平均值
    rmean = mean(cr) ;
    brcov = cov(cb, cr) ;
    skin1 = zeros(dim(1) , dim(2) ) ;
    for i = 1: dim(1)
        for j = 1: dim(2)
            cb = double(imycbcr(i, j, 2) ) ;
            cr = double(imycbcr(i, j, 3) ) ;
            x =[(cb-bmean);(cr-rmean)] ;
            skin1(i,j) = exp(-0.5*x'*inv(brcov)*x) ; %---------------------------------计算任意像素为皮肤的概率
      
    skin1 = skin1./max(max(skin1) ) ;
    axes(handles. axes3)
    set(handles. axes3, 'XMinorTick' , 'on' ) %-------------嵌入Axes(3) 回调函数
    imshow(skin1) ; %------------------------------显示皮肤概率图像
else
    imformats
end
% Hint: get(hObject, ' Value' ) returns push state of pushbutton3
%-------------------------------------- pushbutton4_Callback(回调函数)
% --- Executes on button press in pushbutton4.
function pushbutton4_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global im imycbcr skin1 skin2 lpf %----------------: 0.05
        skin2 = zeros(size(skin1,1),size(skin1,2)) ;
        skin2(find(skin1>threshold)) = 1;
        change = sum(sum(skin2 - previousSkin2) ) ;
        changelist = [changelist change] ;
        previousSkin2 = skin2;
    end
    %----------------------------------找出最佳门限值
    [C, I] = min(changelist) ;
    optimalThreshold = (7-I) *0.1;
    skin2 = ones(size(skin1,1),size(skin1,2)) ;
    skin2(find(skin1>optimalThreshold))= 0;
    skin2 = filter2(lpf, skin2) ; %------------------------中值滤波
    axes(handles.axes5)
    set(handles. axes5, 'XMinorTick','on' ) %-------------嵌入Axes(4) 回调函数
    imshow(skin2); %------------------------------显示皮肤二值化图像
else
    imformats
end
% Hint: get(hObject, ' Value' ) returns push state of pushbutton4
%-------------------------------------- pushbutton5_Callback(回调函数)
% --- Executes on button press in pushbutton5.
function pushbutton5_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global im imycbcr skin1 skin2 lpf %----------------宣布为全域变量
if get (gcbo, 'Value' ) ==1;
    sumarea = bwarea(skin2) ; %-----------计算对象的总面积, 为利用面积进行判别做准备
    [L,numobj] =bwlabel(skin2, 8) ;
    avearea = sumarea/numobj; %-----------计算出对象的平均面积
    A = zeros(4, numobj) ;%179
    n = 1;
   
        % ------------------------获得一副只包含该区域的图像, 让图像其他区域为黑色
        bwsegment = bwselect(skin2, y, x, 8) ;
        % --------------------- 计算出该区域内分割块的数目
        [L, numobjs] = bwlabel(bwsegment, 4) ;
        % ---------------------------------得到区域孔的数目
        numfeatures = bweuler(bwsegment, 4) ;
        numholes = 1 - numfeatures;
        % --------------------------------扫描得出区域坐标
        top = -1;
        buttom =-1;
        left = -1;
        right = -1;
        dim=size(bwsegment);
        for i=1:dim(1)
            for j=1:dim(2)
                if(bwsegment(i,j) ~= 0)
                    top=i;
                    break;
                end;
            end;
            if (top ~= -1) break; end;
        end;
Copy the code

3. Operation results

Fourth, note

Complete code or simulation consultation QQ1575304183