-
Notifications
You must be signed in to change notification settings - Fork 10
/
runme.m
77 lines (61 loc) · 2.65 KB
/
runme.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
clc; clear; close all;
%% 1. addpath
addpath(genpath('matconvnet-1.0-beta19/matlab'));
addpath(genpath('func'));
%% 2. init fcn
global fcnnet;
fprintf('**********************************************************************\n');
fprintf('Load FCN model...\n');
tic;
fcnnet = dagnn.DagNN.loadobj(load('./matconvnet-1.0-beta19/Data/pascal-fcn32s-dag.mat')) ;
toc;
fprintf('Done!\n');
fprintf('**********************************************************************\n');
%% 3. config parameters for HCA
spnumber = [200; 170; 140];
params = HCA_config('spnumber',spnumber, 'use_prior', false);
fprintf('Config parameters for HCA.\n');
disp(params);
%% 4. setup path
imgRoot = './images/';% test image path
priorRoot = './priors/';
saldir = './saliencymaps/';
if ~exist(priorRoot, 'dir')
mkdir(priorRoot)
end
if ~exist(saldir, 'dir')
mkdir(saldir)
end
im_ext = 'jpg';
prior_ext = 'png';
sal_ext = 'png';
imnames = dir([ imgRoot '*' 'jpg']);
fprintf('Run HCA for %d images...\n', length(imnames));
fprintf('**********************************************************************\n');
%% 5. Saliency Map Calculation
for ii = 1:length(imnames)
fprintf('Processing image %d/%d ......\n', ii, length(imnames));
tTotalStart = tic;
imname = imnames(ii).name(1:end-4);
imPath = [ imgRoot imname '.' im_ext];
Image_info.path = imPath;
Image_info.name = imname;
Prior_info.fullpath = [priorRoot imname '.' prior_ext];
%%run a pre-processing to remove the image frame
Image_info = removeframe(Image_info);
%%extract fcn feature
FCNfeat = extract_fcn_im_feature(Image_info, params, fcnnet);
SCA_maps = zeros(Image_info.height, Image_info.width, length(params.spnumber));
fprintf(' 3. Compute SCA in %d scales...\n', length(params.spnumber));
for scale = 1 : length(params.spnumber)
%%-----------------Single-layer Cellular Automata---------------%%
SCA_maps(:,:,scale) = run_SCA(Image_info, FCNfeat, params, scale, Prior_info);
end
%%----------------Cubic MCA----------------
fprintf(' 4. Compute CCA, we have %d scales...\n', length(params.spnumber));
HCA_map = run_CCA(SCA_maps, params);
tTotal = toc(tTotalStart);
fprintf(' Total time for one image: %f seconds.\n\n', tTotal);
out_fullpath=[saldir Image_info.name '.' sal_ext];
imwrite(HCA_map, out_fullpath);
end