在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
步骤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);
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论