显著性检测(saliency detection)评价指标之KL散度距离Matlab代码实现

Posted 酸罗卜不酸II

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了显著性检测(saliency detection)评价指标之KL散度距离Matlab代码实现相关的知识,希望对你有一定的参考价值。

步骤1:先定义KLdiv函数:

function score = KLdiv(saliencyMap, fixationMap)
% saliencyMap is the saliency map
% fixationMap is the human fixation map

map1 = im2double(imresize(saliencyMap, size(fixationMap)));
map2 = im2double(fixationMap);

% make sure map1 and map2 sum to 1
if any(map1(:))
    map1 = map1/sum(map1(:));
end

if any(map2(:))
    map2 = map2/sum(map2(:));
end

% compute KL-divergence
score = sum(sum(map2 .* log(eps + map2./(map1+eps))));

  步骤2:再写一个主函数调用它:

clear;
clc;
smap_path=‘E:\Dataset180303\final_data\smap_Result1\‘;
gmap_path=‘E:\Dataset180303\final_data\image_resize_gt\‘;
smap_file=dir(smap_path);

for j=3:length(smap_file)
    disp(j-2);
    gmap_name=strcat(gmap_path,num2str(j-2), ‘.jpg‘);
%     gmap_name=strcat(gmap_path,smap_file(j).name);
    smap_name=strcat(smap_path,num2str(j-2+ 0 ), ‘.jpg‘);
%     smap_name=strcat(smap_path,num2str(j-2+ 0 ), ‘_SaliencyMap‘, ‘.jpg‘);
    gmap=imresize(imread(gmap_name), [224, 224], ‘bicubic‘);
    smap=imresize(imread(smap_name), [224, 224], ‘bicubic‘);
    sal_map=mat2gray(smap);
    if gmap==0
        continue;
    end
    
    if size(gmap,3)==3
        gt_final_map=rgb2gray(gmap);
    else
        gt_final_map = gmap;
    end
    sal_map=imresize(sal_map,0.5);
    gt_final_map=imresize(gt_final_map,0.5);
    
    threshold_value = graythresh(gt_final_map);
    gt_final_map_bin = im2bw(gt_final_map, threshold_value);
    c = KLdiv(sal_map, gt_final_map);
    idx=find(isnan(c));
    c(idx)=0.5;
    c = abs(c);
    a(j-2,1)=mean(c);
end
% b(i-2,1)=mean(a);
% clear a;
% end
KLdiv = mean(a);

  

以上是关于显著性检测(saliency detection)评价指标之KL散度距离Matlab代码实现的主要内容,如果未能解决你的问题,请参考以下文章

显著性检测(saliency detection)评价指标之KL散度距离Matlab代码实现

视觉显著性简介 Saliency Detection

Saliency Detection: A Spectral Residual Approach

paper 27 :图像/视觉显著性检测技术发展情况梳理(Saliency DetectionVisual Attention)

论文阅读:Review of Visual Saliency Detection with Comprehensive Information

视频显著性检测-----Predicting Video Saliency using Object-to-Motion CNN and Two-layer Convolutional LSTM(示例