• 大小: 3KB
    文件类型: .m
    金币: 1
    下载: 0 次
    发布日期: 2021-05-14
  • 语言: Matlab
  • 标签: matlab  

资源简介

基于matlab的人脸识别算法,可以识别单个几多个人脸,希望对大家有用哈

资源截图

代码片段和文件信息

close all
clear all
clc

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%reading an image
tic
I = imread(‘E:\123.png‘);


[IxIyIz]=size(I);
if Ix>400&Iy>300
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %%%reducing the scale of image let the high is 400
    I=imresize(I[400Iy*400/Ix]‘nearest‘);
end
figure
imshow(I)
title(‘normal image‘)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%%%%skin detection 
I=double(I);             %converting the integer into decimal fraction
[huesv]=rgb2hsv(I);    %converting RGB space into HSV space
cb=0.148*I(::1)-0.291*I(::2)+0.439*I(::3)+128;%converting RGB space into YCrCb space
cr=0.439*I(::1)-0.368*I(::2)-0.071*I(::3)+128;  
[w h]=size(I(::1)); %size of the image 

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%% let the skin pels points in the YCrCb space as 1
for i=1:w
    for j=1:h 
        % segmenting the yellow skin colour areas      
        if  145<=cr(ij)&cr(ij)<=165&145<=cb(ij)&cb(ij)<=180&0.01<=hue(ij)&hue(ij)<=0.15      
            segment(ij)=1; %skin areas        
        else       
            segment(ij)=0;    
        end    
    end
end
figure
imshow(segment);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%% processing on the detected areas
skin=segment;
% removing small connected pixels
skin=bwareaopen(skinround(w*h/900));
%dilating
se=strel(‘disk‘5);
skin=imdilate(skinse);        

%%%%%%%%%

评论

共有 条评论