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

资源简介

快速人脸定位matlab程序,准确的确定人脸,然后定位

资源截图

代码片段和文件信息

clear all
close all
clc
%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 读入待检测图像
x= imread(‘1.jpg‘);
xx=x;
figure
imshow(x);


fR=xx(::1);
fG=xx(::2);
fB=xx(::3);
f=1/9*ones(3);%低通滤波器,滤除高频噪声
filtered_fR=imfilter(fRf);
filtered_fG=imfilter(fGf);
filtered_fB=imfilter(fBf);
x_filtered=cat(3filtered_fRfiltered_fGfiltered_fB);
figure
imshow(x_filtered);


I=rgb2ycbcr(x);        %颜色空间转换 
gray=rgb2gray(x);
figure
imshow(gray);

[abc]=size(I); %得到图像的像素点个数
cb=double(I(::2));
cr=double(I(::3));
for i=1:a
    for j=1:b
        w=[cb(ij)cr(ij)];
        m=[117.4316 148.5599];
        n=[260.1301 12.1430;12.1430 150.4574];
        p(ij)=exp((-0.5)*(w-m)*inv(n)*(w-m)‘);%算某象素点的概率
        if (p(ij)<0.5) 
            p(ij)=0;
        else 
            p(ij)=1;
        end
    end
end 
fenge=p;
figure
imshow(fenge);

SE = strel(‘square‘3); 
imf=imopen(pSE);         %开运算(即先腐蚀再膨胀),消除杂散点 
xingtai=imf;
figure
imshow(xingtai);
%figureimshow(Ibwopen); 
%Ibwoc=imclose(IbwopenSE);      %闭运算,去掉由于开运算引入的许多缺口 
%figureimshow(Ibwoc); 
%imf=imfill(Ibwoc‘holes‘);      %填充孔洞 
%%%%%%%%%%%%%%%%%%%%%%%根据填充率去除手脚、胳膊等非人脸区域%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[Lnum]=bwlabel(imf8);     %连通区域标记 
B=zeros(size(imf));
for i=1:num
    Area(i)=bwarea(L==i);%计算每个皮肤区域的面积
end
for i=1:num
    [rc] = find(L==i) ;
    left(i)=min(c);
    right(i)=max(c);
    up(i)=min(r);
    down(i)=max(r);
end
for i=1:num 
    %计算各矩形区域面积
    Rect_Area(i)=(down(i)-up(i))*(right(i)-left(i));
end
%计算各区域的填充率
Ratio=Area./Rect_Area;
for i=1:n

评论

共有 条评论