-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathrun_script.m
116 lines (97 loc) · 3.01 KB
/
run_script.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
function run_script(scene_file)
%RUN_SCRIPT
% color spaces
color_spaces = {};
color_spaces{end + 1} = @(img) img;
color_spaces{end + 1} = @im_rgb2lab;
color_spaces{end + 1} = @im_rgb2upvpl;
color_spaces{end + 1} = @im_rgb2uvl;
color_spaces{end + 1} = @im_rgb2xyy;
color_spaces{end + 1} = @im_rgb2xyz;
color_spaces{end + 1} = @(img) select_channel(im_rgb2lab(img), 2:3);
color_spaces{end + 1} = @(img) select_channel(im_rgb2upvpl(img), 1:2);
color_spaces{end + 1} = @(img) select_channel(im_rgb2uvl(img), 1:2);
color_spaces{end + 1} = @(img) select_channel(im_rgb2xyz(img), [1 3]);
color_spaces{end + 1} = @(img) select_channel(im_rgb2xyy(img), [1 3]);
color_spaces{end + 1} = @(img) transform_channel(im_rgb2lab(img), 1, @(x) log(1+x));
color_spaces{end + 1} = @rgb2ycbcr;
color_spaces{end + 1} = @(img) select_channel(rgb2ycbcr(img), 2:3);
% load file
fname = sprintf('output/%s.mat', scene_file);
if exist(fname, 'file')
load(fname);
else
% build scene and target
if strcmp(scene_file(1:7), 'control')
[scene, target] = build_scene(scene_file, 0);
else
[scene, target] = build_scene(scene_file);
end
% save
save(['output/' scene_file '.mat'], 'scene', 'target');
end
fprintf('Scene %s...\n', scene_file);
% for each color space
for j = 1:length(color_spaces)
% get callback
color_cb = color_spaces{j};
% transform image
img = color_cb(scene);
fprintf('Color %d...\n', j);
% run four algorithms
% RX GLOBAL
fname = sprintf('output/%s-%d-rx.mat', scene_file, j);
if ~exist(fname, 'file')
img_rx = rxg(img);
save(fname, 'img_rx');
end
% RX LOCAL
fname = sprintf('output/%s-%d-rxl.mat', scene_file, j);
if ~exist(fname, 'file')
img_rxl = rxl(img);
save(fname, 'img_rxl');
end
% DWEST
fname = sprintf('output/%s-%d-dwest.mat', scene_file, j);
if ~exist(fname, 'file')
img_dwest = dwest(img);
save(fname, 'img_dwest');
end
% NSWTD
fname = sprintf('output/%s-%d-nswtd.mat', scene_file, j);
if ~exist(fname, 'file')
img_nswtd = nswtd(img);
save(fname, 'img_nswtd');
end
% MW-NSWTD
fname = sprintf('output/%s-%d-mwnswtd.mat', scene_file, j);
if ~exist(fname, 'file')
img_mwnswtd = mwnswtd(img);
save(fname, 'img_mwnswtd');
end
% PCAG
fname = sprintf('output/%s-%d-pcag.mat', scene_file, j);
if ~exist(fname, 'file')
img_pcag = pcag(img);
save(fname, 'img_pcag');
end
% MW-PCAG
fname = sprintf('output/%s-%d-mwpcag.mat', scene_file, j);
if ~exist(fname, 'file')
img_mwpcag = mwpcag(img);
save(fname, 'img_mwpcag');
end
% PCAD
fname = sprintf('output/%s-%d-pcad.mat', scene_file, j);
if ~exist(fname, 'file')
img_pcad = pcad(img);
save(fname, 'img_pcad');
end
% KNNA
fname = sprintf('output/%s-%d-knna.mat', scene_file, j);
if ~exist(fname, 'file')
img_knna = knna(img);
save(fname, 'img_knna');
end
end
end