深度好文!人眼中心定位(基于ACCURATE EYE CENTRE LOCALISATION BY MEANS OF GRADIENTS),含matlab实现










MeanOfWeightedSquaredDotProducts.M 脚本下载地址:
(https://download.csdn.net/download/ephemeroptera/11003123)
附上实现代码:

%% (1)get eye image
man = im2double(rgb2gray(imread('man.jpg')));
faceDetector = vision.CascadeObjectDetector('FrontalFaceCART');
LeftEyeDetector = vision.CascadeObjectDetector('ClassificationModel','LeftEyeCART','UseROI',true);
facebbox = faceDetector(man);
leftEyebbox = LeftEyeDetector(man,facebbox(1,:));
leftEye = imcrop(man,leftEyebbox(1,:));
figure(1),imshow(leftEye)

%% gaussian and invert
faceEdge = max(facebbox(1,3:4));
sigma = 0.005*faceEdge;
temp = fspecial('gaussian',[5,5],sigma);
leftEye2 = imfilter(leftEye,temp,'symmetric','corr');
Wc = 1 - leftEye2;

%% get eye image gradient
[px,py] = gradient(leftEye);
grad = abs(px)+abs(py);
% ignore smooth area
T = 0.3*std(grad(:))+mean(grad(:));
grad(grad<T) = 0;

%% in order to calculate each dot products with vector d and vector g ,we build a struct M
[x,y]= meshgrid(1:size(leftEye,1),1:size(leftEye,2));
M = cat(3,grad,x,y,px,py);

%% calculate each respond of c
C = zeros(size(leftEye));
for i = 1: size(leftEye,1)
    for j = 1: size(leftEye,2)
       C(i,j) = MeanOfWeightedSquaredDotProducts(M,Wc,i,j);
    end
end

%% post-processing
% remove extrem high values
%  C(C>0.9*max(C(:)))=0;
% remove border velues
C(1,:)=0;
C(end,:)=0;
C(:,1)=0;
C(:,end)=0;

%% get location of the maximum value as centre
MaxValue = max(C(:));
[centreY,centreX] = find(C==MaxValue);

%% show centre
eyeCentre = insertMarker(leftEye,[centreX,centreY]);
figure(2),imshow(eyeCentre);

评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值