-
Notifications
You must be signed in to change notification settings - Fork 0
/
Script_Saliency_images.m
68 lines (46 loc) · 1.66 KB
/
Script_Saliency_images.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
clc
clear all
close all
%% 1. This code is to compute Saliency in each frame of the video. This code assume that videos are already been saved as images.
%% To directly compute over the videos, use video reader to read video frames.
%%
All_Videos_Path = '../Data/DatasetName/Dataset_frames';
Result_Saliency_Path = '../Data/DatasetName/Dataset_Saliency';
if ~exist(Result_Saliency_Path,'dir')
mkdir(Result_Saliency_Path);
end
All_Videos=dir(All_Videos_Path);
All_Videos=All_Videos(3:end);
for ivideo =1:length(All_Videos)
Video_Path = [All_Videos_Path,'/',All_Videos(ivideo).name];
Result_Path = [Result_Saliency_Path,'/',All_Videos(ivideo).name];
ivideo
if exist( [Result_Path,'.mat'],'file')
continue;
end
% %
All_images=dir(Video_Path);
All_images=All_images(3:end);
%All_frames=min(length(All_images),150);
All_frames=length(All_images);
fname=cell(1,All_frames);
for iImage=1:1:All_frames
fname{iImage}=([Video_Path,'/',All_images(iImage).name]);
end
N = length(fname);
% compute the saliency maps for this sequence
% param = makeGBVSParams; % get default GBVS params
% param.channels = 'IF'; % but compute only 'I' instensity and 'F' flicker channels
% param.levels = 3; % reduce # of levels for speedup
%
% motinfo = []; % previous frame information, initialized to empty
Saliency_Map=cell(1,N);
for i = 1 : N
i
out = gbvs( fname{i});
Saliency_Map{i}=single(out.master_map_resized);
end
tic
save(Result_Path,'Saliency_Map');
toc
end