显著性检测(saliency detection)评价指标之NSS的Matlab代码实现

calcNSSscore.m

function [ score ] = calcNSSscore( salMap, eyeMap )
%calcNSSscore Calculate NSS score of a salmap
%   Usage: [score] = calcNSSscore ( salmap, eyemap )
%
%   score     : an array of score of each eye fixation
%   salmap    : saliency map. will be resized nearest neighbour to eyemap
%   eyemap    : should be a binary map of eye fixation
% clear;clc;
% salMap=imread('spatial_temporal_smap.png');
% eyeMap=imread('SMB_src35_hrc00_035.png');
% eyeMap=rgb2gray(eyeMap);

%%% Resize and normalize saliency map
salMap = double(imresize(salMap,size(eyeMap),'bicubic'));
mapMean = mean2(salMap); mapStd = std2(salMap);
salMap = (salMap - mapMean) / mapStd; % Normalized map
%%% NSS calculation
[X Y] = find(eyeMap > 0);
NSSVector = zeros(1,size(X,1));
for p=1:size(X,1)
    NSSVector(p) = salMap(X(p),Y(p));
end
score = NSSVector;

% end

  main.m

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 i=3:length(vedio_file)
%     disp(i);
%     vedio_name=strcat(smap_path,vedio_file(i).name);%字符串
%     smap_file=dir(vedio_name);%文件夹
%     
%     vedio_name1=strcat(gmap_path,vedio_file(i).name);
%     gmap_file=dir(vedio_name1);
    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 ), '_SaliencyMap', '.jpg');
        smap_name=strcat(smap_path,num2str(j-2 +0), '.jpg');
        gmap=imresize(imread(gmap_name), [224, 224], 'bicubic');
        smap=imresize(imread(smap_name), [224, 224], 'bicubic');
        sal_map=mat2gray(smap);
        if size(gmap,3)==3
            gt_map=rgb2gray(gmap);
        else
            gt_map=gmap;
        end
        threshold_value = graythresh(gt_map);%使用最大类间方差法:找到图片的一个合适的阈值(threshold)。
%         threshold_value=0.01;
        gt_final_map = im2bw(gt_map, threshold_value);%make gt_map to boolean map也叫逻辑矩阵

        b=calcNSSscore(sal_map,gt_final_map);
        b = abs(b);
        a(j-2,1)=mean(b);
        disp(j-2);
    end
    idx=find(isnan(a));
    a(idx)=1.5;
    RGBD_NSS=mean(a);
%     clear a;
% end

nss = mean(RGBD_NSS);

  

转载于:https://www.cnblogs.com/Qsir/p/8687040.html

你可能感兴趣的:(显著性检测(saliency detection)评价指标之NSS的Matlab代码实现)