-
Notifications
You must be signed in to change notification settings - Fork 9
/
demo_mul.m
48 lines (40 loc) · 1.22 KB
/
demo_mul.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
close all;
clear;
%% parameter settings
addpath(genpath('./External'));
addpath(genpath('./SACS_code'));
imgpath = './images/multiple'; %put a group of images in this folder
mappath = './submaps/multiple'; % the sub saliency maps by other methods
imglist = dir([imgpath '/*.bmp']); % BMP imgs only
maplist = dir([mappath '/*.png']);
img_num = length(imglist);
%the map names used in this demo, correspoding to MR, HS, RC, SP and CO
map_names = {'_stage2.png','_res.png','_RC.png','_SP.png','_CO.png'};
map_num = length(map_names);
%% self-adaptively weight fusion
inames = cell(1,img_num);
for i=1:img_num,
inames{i} = strrep(imglist(i).name, '.bmp', '');
end;
Mset = cell(img_num, map_num);
for i=1:img_num,
for j=1:map_num,
Mset{i,j} = imread([mappath '/' inames{i} map_names{j}]);
end;
end;
w = sacs_calWeight(map_names, inames, Mset, imgpath);
saliency = cell(1,img_num);
for j=1:img_num,
saliency{j} = zeros(size(Mset{j,1}));
end;
for j = 1:img_num,
for q=1:map_num,
saliency{j} = saliency{j} + w(j,q)*double(Mset{j,q});
end;
end;
raws = saliency;
for j=1:img_num,
rs = raws{j};
rs = normalize(rs);
imwrite(rs, ['results/' strrep(imglist(j).name, 'bmp' , 'png')] , 'png');
end;