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

AUC_shuffled.m

function [score,tp,fp] = AUC_shuffled(saliencyMap, fixationMap, otherMap, Nsplits, stepSize, toPlot)
% saliencyMap is the saliency map
% fixationMap is the human fixation map (binary matrix)
% otherMap is a binary fixation map (like fixationMap) by taking the union of
% fixations from M other random images (Borji uses M=10)
% Nsplits is number of random splits
% stepSize is for sweeping through saliency map
% if toPlot=1, displays ROC curve

if nargin < 6, toPlot = 0; end
if nargin < 5, stepSize = .1; end
if nargin < 4, Nsplits = 100; end

score=nan;

% If there are no fixations to predict, return NaN
if ~any(fixationMap)
    disp('no fixationMap');
    return
end 

% make the saliencyMap the size of fixationMap
if size(saliencyMap, 1)~=size(fixationMap, 1) || size(saliencyMap, 2)~=size(fixationMap, 2)
    saliencyMap = imresize(saliencyMap, size(fixationMap));
end

% normalize saliency map
saliencyMap = (saliencyMap-min(saliencyMap(:)))/(max(saliencyMap(:))-min(saliencyMap(:)));

if sum(isnan(saliencyMap(:)))==length(saliencyMap(:))
    disp('NaN saliencyMap');
    return
end

S = saliencyMap(:);
F = fixationMap(:);
Oth = otherMap(:);

Sth = S(F>0); % sal map values at fixation locations
Nfixations = length(Sth);

% for each fixation, sample Nsplits values from the sal map at locations
% specified by otherMap

ind = find(Oth>0); % find fixation locations on other images

Nfixations_oth = min(Nfixations,length(ind));
randfix = nan(Nfixations_oth,Nsplits);

for i=1:Nsplits
    randind = ind(randperm(length(ind))); % randomize choice of fixation locations
    randfix(:,i) = S(randind(1:Nfixations_oth)); % sal map values at random fixation locations of other random images
end

% calculate AUC per random split (set of random locations)
auc = nan(1,Nsplits);
for s = 1:Nsplits
    
    curfix = randfix(:,s);
    
    allthreshes = fliplr([0:stepSize:double(max([Sth;curfix]))]);
    tp = zeros(length(allthreshes)+2,1);
    fp = zeros(length(allthreshes)+2,1);
    tp(1)=0; tp(end) = 1; 
    fp(1)=0; fp(end) = 1; 
    
    for i = 1:length(allthreshes)
        thresh = allthreshes(i);
        tp(i+1) = sum((Sth >= thresh))/Nfixations;
        fp(i+1) = sum((curfix >= thresh))/Nfixations_oth;
    end

    auc(s) = trapz(fp,tp);
end

score = mean(auc); % mean across random splits

if toPlot
    subplot(121); imshow(saliencyMap, []); title('SaliencyMap with fixations to be predicted');
    hold on;
    [y, x] = find(fixationMap);
    plot(x, y, '.r');
    subplot(122); plot(fp, tp, '.b-');   title(['Area under ROC curve: ', num2str(score)])
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 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=calcAUCscore(sal_map,gt_final_map);
% [score,tp,fp] = AUC_shuffled(saliencyMap, fixationMap, otherMap, Nsplits, stepSize, toPlot)
    [c,tp,fp]=AUC_shuffled(sal_map,gt_final_map_bin,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
sAUC = mean(a);

  

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

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
1. 显著点的检测 Itti的A Model of Saliency-Based Visual Attention for Rapid Scene Analysis (TPAMI 1999)论文是显著检测的鼻祖论文,检测出来的是用户关注的点。 2. 显著区域的检测 侯晓迪同学在2007年发表的一篇CVPR的论文,用很简单的方法检测显著区域,那之后显著检测主要以区域检测为主:Saliency detection: A spectral residual approach (CVPR 2007),虽然之后有人诟病这篇论文有不足之处,但该想法简单,推动了显著研究的普及。侯同学靠这一篇文章再加上投稿期间的趣事,就封神了。 3. 其他经典的显著检测方法 在那之后陆续又有一些经典的显著检测算法被提出:https://blog.csdn.net/touch_dream/article/details/78716507 可以看这个博文。 4. 基于深度学习的显著检测 再之后,显著检测领域就进入了Deep Learning时代, Deep Visual Attention Prediction TIP2018 (CODE)     https://github.com/wenguanwang/deepattention Predicting Human Eye Fixations via an LSTM-based Saliency Attentive Model (CODE)     https://github.com/marcellacornia/sam CVPR2016 Shallow and Deep Convolutional Networks for Saliency Prediction (CODE)     https://github.com/imatge-upc/saliency-2016-cvpr Saliency Detection with GAN (2017)     https://github.com/imatge-upc/saliency-salgan-2017  (CODE)     https://github.com/batsa003/salgan/ (PyTorch的版本) 5. 非自然图象的显著检测 例如,海报的显著检测,图表的显著检测,地理数据的显著检测等等。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值