许可优化
许可优化
产品
产品
解决方案
解决方案
服务支持
服务支持
关于
关于
软件库
当前位置:服务支持 >  软件文章 >  为人脸关键点生成高斯热图(produce gaussian heatmap for landmarks)

为人脸关键点生成高斯热图(produce gaussian heatmap for landmarks)

阅读数 8
点赞 0
article_banner
% 28 * 28 for conv3
% 14 * 14 for conv4
% 7 * 7 for conv5
close all;
datas = load('datas5224_pure3.mat');
datas = datas.datas;

f = @(x,meanx,nSigma) exp(-1/2*(x-meanx)'*nSigma*(x-meanx));

for i = 1:length(datas)
    landmark  = datas(i).after_landmark;
    
    imgpath2 = datas(i).imgpath2;
    %imgpath = strrep(imgpath,'flickr','flickr224');
    img = imread(imgpath2);
    subplot(141);
    imshow(img);
    hold on;
    for j = 1:size(landmark,1)
        plot(landmark(j,1),landmark(j,2),'.r','markersize',15);
        text(landmark(j,1),landmark(j,2),num2str(j),'color','w');
    end
    
    subplot(142);
    heatmap = compute_heatmap([28,28],imgSize,[landmark(8,:);landmark(12,:);landmark(15,:)]);
    imshow(heatmap,[]);
    
    subplot(143);
    heatmap = compute_heatmap([14,14],imgSize,[landmark(8,:);landmark(12,:);landmark(15,:)]);
    imshow(heatmap,[]);
    
    subplot(144);
    heatmap = compute_heatmap([7,7],imgSize,[landmark(8,:);landmark(12,:);landmark(15,:)]);
    imshow(heatmap,[]);
    
    break;
end
function heatmap = compute_heatmap(imgsize,imgSize,landmarks)
% imgsize: the heatmap size for dst
% imgSize: the heatmap size for src, examples: 224 * 224 for CNN
% landmarks

landmarks = round(landmarks .* (imgsize ./ imgSize));
%tau = max((imgSize ./ imgsize)) * 0.1;
tau = min((imgsize ./ imgSize)) * 20; % change those values
Sigma = [tau^2 0 ; 0 tau^2]; % not use
nSigma = [1.0/(tau^2) 0;0 1.0/(tau^2)]; % inverse of Sigma
% note that: x and meanx's shape: [2,1], not [1,2]
f = @(x,meanx,nSigma) exp(-1/2*(x-meanx)'*nSigma*(x-meanx));
heatmap = zeros(imgsize(1),imgsize(2));

for i = 1:size(landmarks,1) % nlandmark
    landmark = landmarks(i,:); % x,y
    for j = 1:imgsize(2) % x: w
        for k = 1:imgsize(1) % y: h
            seat = [j,k]; % (x,y)
            heatmap(k,j) = heatmap(k,j) + f(seat',landmark',nSigma);
        end
    end
end
activation_type = 'softmax';
if strcmp(activation_type,'sigmoid')
    % pass Sigmoid activation funcion
    heatmap = 1 ./ (1+exp(-heatmap));
elseif strcmp(activation_type,'softmax')
    % pass softmax function
    heatmap = exp(heatmap);
    heatmap = heatmap ./ sum(heatmap(:));
end
end

在这里插入图片描述


免责声明:本文系网络转载或改编,未找到原创作者,版权归原作者所有。如涉及版权,请联系删


相关文章
QR Code
微信扫一扫,欢迎咨询~
customer

online

联系我们
武汉格发信息技术有限公司
湖北省武汉市经开区科技园西路6号103孵化器
电话:155-2731-8020 座机:027-59821821
邮件:tanzw@gofarlic.com
Copyright © 2023 Gofarsoft Co.,Ltd. 保留所有权利
遇到许可问题?该如何解决!?
评估许可证实际采购量? 
不清楚软件许可证使用数据? 
收到软件厂商律师函!?  
想要少购买点许可证,节省费用? 
收到软件厂商侵权通告!?  
有正版license,但许可证不够用,需要新购? 
联系方式 board-phone 155-2731-8020
close1
预留信息,一起解决您的问题
* 姓名:
* 手机:

* 公司名称:

姓名不为空

姓名不为空

姓名不为空
手机不正确

手机不正确

手机不正确
公司不为空

公司不为空

公司不为空