91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 666KB
    文件類型: .rar
    金幣: 2
    下載: 0 次
    發布日期: 2024-02-06
  • 語言: Matlab
  • 標簽: matlab??

資源簡介

人臉識別中檢測人臉眼睛的狀態,基于matlab的,簡單易懂

資源截圖

代碼片段和文件信息

clc;
clear?all;
%------------------讀入待識別的人臉圖像------------------------
[filename?pathname]?=?uigetfile(?...
{‘*.bmp;*.jpg;*.png;*.jpeg‘?‘Image?Files?(*.bmp*.jpg*.png*.jpeg)‘;?...
‘*.*‘?‘All?Files?(*.*)‘}?...
‘Pick?an?image‘);
if?isequal(filename0)||isequal(pathname0)
????return;
end;
fpath=[pathname?filename];
RGB=imread(fpath);
YCbCr=rgb2ycbcr(RGB);%將rgb圖像轉為YCbCr圖像
[HW]=size(rgb2gray(RGB));

%------------------利用膚色來提取人臉區--------------------------
M=[117.4361;156.5599];
C=[160.130112.1430;12.1430299.4574];??%見文獻
P=zeros(HW);
PM=0;
x=zeros(21);??%x=[CbCr]‘轉置
for?i=1:H
????for?j=1:W
????????x(1)=YCbCr(ij2);
????????x(2)=YCbCr(ij3);
????????P(ij)=exp(-0.5*(x-M)‘/C*(x-M));%相似度計算
????????if?P(ij)>PM
????????????PM=P(ij);
????????end
????end
end
P=P/PM;??%歸一化

%---------------圖像二值化---------------------------
thr=0.6:-0.05:0.10;
len=length(thr);
nch=zeros(len-11);
num=zeros(len);
for?k=1:len
????thresh=thr(k);?%設定可能的閾值
????num(k)=sum(sum(P>thresh));
????if?k>1
????????nch(k-1)=num(k)-num(k-1);
????end
end
[minnchindex]=min(nch);
thresh=thr(index+1);%確定閾值
I=P>thresh;?%二值化處理???????????????
subplot(221)imshow(I)%I為二值化后的圖像


%-------------------直方圖,即投影積分--------------------------
shp=sum(I2);%人臉水平投影,即橫向,來確定人臉的高度
shp=shp‘;
len=length(shp);
y=1:len;
hold?on
subplot(221)
chz=sum(I);??%人臉垂直投影,即豎直方向來確定人臉的寬度
%subplot(222)
plot(shpy);
%subplot(222)
plot(chz);
subplot(222)
plot(shpy);
subplot(222)
plot(chz);
%%%%利用chz確定左右邊界,左邊界是峰值的0.2倍,右邊界是峰值的0.3倍
[max_chzindex]=max(chz);
i=index;
while?i>0
????i=i-1;
????if?chz(i)<0.2*max_chz;
????????L=i;
????????break;
????end
end
j=index;
while?j????j=j+1;
????if?chz(j)<0.3*max_chz;
????????R=j;
????????break;
????end
end
%%%%%%%%達到人臉寬度一半的起始位置確定為人臉框的上邊界
newpface=I(:L:R);
newshp=sum(newpface2);
i=0;
while?i????i=i+1;
????if?newshp(i)>0.5*(R-L);
????????T=i;???%%%上邊界
????????break;
????end
end

B=T+1.4*(R-L);??%下邊界1.5
if?B>H
????B=H;
else
????B=floor(B);
end;
subplot(224)imshow(RGB)
hold?on;
subplot(224);
plot([L?L][T?B]‘Linewidth‘2‘color‘‘red‘);
plot([R?R][T?B]‘Linewidth‘2‘color‘‘red‘);
plot([L?R][B?B]‘Linewidth‘2‘color‘‘red‘);
plot([L?R][T?T]‘Linewidth‘2‘color‘‘red‘);
face=RGB(T:BL:R:);
figure(2);
imshow(face);

%------------------確定眼睛y軸位置----------------------------
faceb=I(T:BL:R);%臉部的二值化圖像,該二值化圖像是以膚色為閾值的
figure(3)
subplot(221)imshow(faceb);
shp=sum(faceb2);%人臉水平投影,即橫向,來確定人臉的高度
shp=shp‘;
len=length(shp);
y=1:len;
chz=sum(faceb);??%人臉垂直投影,即豎直方向來確定人臉的寬度
hold?on
%subplot(222)
shp=smooth(shp30‘loess‘);%對數據進行平滑處理
chz=smooth(chz30‘loess‘);
plot(shpy);
%subplot(223)
plot(chz);
subplot(222)
plot(shpy);
subplot(223)
plot(chz);
indexmin=find(diff(sign(diff(shp)))==2)+1;???%求極小值對應位置
midface=len/2-5;%人臉的水平中心位置
nummin=length(indexmin);%極小值個數
indexpf=find(indexmineye=indexmin(indexpf(end));

eyebr

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

?????文件???????6380??2013-05-20?17:26??客戶\ycbcr.m

?????文件???????5651??2013-05-20?13:34??客戶\za.fig

?????文件???????9844??2013-05-20?13:48??客戶\za.m

?????文件???????3584??2013-05-20?13:34??客戶\za_activex1

?????文件???????3584??2013-05-20?13:34??客戶\za_activex2

?????文件?????710656??2013-05-20?19:17??客戶\項目驗收程序說明.doc

?????目錄??????????0??2013-05-21?21:45??客戶

-----------?---------??----------?-----??----

???????????????739699????????????????????7


評論

共有 條評論