-
Notifications
You must be signed in to change notification settings - Fork 0
/
Run_benchmarks_dt2.m
413 lines (257 loc) · 10.2 KB
/
Run_benchmarks_dt2.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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
% TODO
% For each volume, we may reconstruct some frames. Save frames seperately.
%
%
% IMPORTANT NOTES:
%
%
% HINT: NOISE Estimation for "dt2"
%
% We have provided two functions for noise estimation on images from this
% dataset:
% estimate_noise_dt2_max
% estimate_noise_dt2_min
%
% Both of these methods cannot correctly estimate the noise level for this
% dataset. Therefore, researchers usually increase the estimated noise
% level by adding or multipling constants and experimentally and viauslly
% select an approporiate noise level.
%
clear
clc
addpath(genpath('./Methods'));
addpath('./Metrics/utils');
% ----------------------------------------------------------
% --- Indices of noisy volumes and frames to be denoised ---
% To evaluate on the whole dataset, use the followings:
load('./Metrics/dt2_random_images')
params.test_indices = 1:13; % indicates volumes to be denoised
params.frame_numbers = random_images; % each row indicates frame numbers for each volume
% To conduct a fast experiment, use these:
params.test_indices = [3]; % [3,5]
params.frame_numbers = ones(length(params.test_indices),1)*[10,60]; % [10, 60]
% ----------------------------------------------------------
% Number of frames to be denoised.
params.n_frames = 127; % >= 2 - Defualt: 5
params.valid_rows = 150:512 - 1; % 150:380 - 1
params.save_mat = true;
% Directly used by "benchmark_X_on_..." and "evaluate_metrics_..."
common_params = params;
%% Select a denoising method
% To run a method, set its corresponding variable to 1
KSVDS = 1;
KSVDS_log = 0;
WMF = 0;
WMF_log = 0;
VBM4D = 0;
VBM4D_log = 0;
TENSOR_DL = 0;
TENSOR_DL_log = 0;
BM4D_org = 0;
BM4D_org_log = 0;
BM4D_iid = 0;
BM4D_iid_log = 0;
MS_BM4D_dwt3 = 0;
MS_BM4D_dwt3_log = 0;
MS_BM4D_dualtree3 = 1;
MS_BM4D_dualtree3_log = 0;
%% Sparse K-SVD
if KSVDS == 1
params = common_params;
X = @run_ksvds;
params.get_params = @get_params_ksvds;
params.noise_estimator = @(y) estimate_noise_dt2_max(y)*2 - 1;
output_folder_name = 'benchmark_ksvds_dt2';
benchmark_X_on_dt2(output_folder_name,X,params)
evaluate_metrics_dt2(output_folder_name,params);
end
%% Sparse K-SVD in the logarithm domain
if KSVDS_log == 1
params = common_params;
X = @run_ksvds_log;
params.get_params = @get_params_ksvds;
params.noise_estimator = @(y) estimate_noise_dt2_max(y)*2 - 1;
output_folder_name = 'benchmark_ksvds_log_dt2';
benchmark_X_on_dt2(output_folder_name,X,params)
evaluate_metrics_dt2(output_folder_name,params);
end
%% WMF
% **NOTE: Parameters are not good for Topcon**
if WMF == 1
params = common_params;
X = @run_wmf;
params.get_params = @get_params_wmf_dt1; %%%%% Can we use better params?
output_folder_name = 'benchmark_wmf_dt2';
benchmark_X_on_dt2(output_folder_name,X,params)
params.preprocess = @make_size_even;
evaluate_metrics_dt2(output_folder_name,params);
end
%% WMF in the logarithm domain
% **NOTE: Parameters are not good for Topcon**
if WMF_log == 1
params = common_params;
output_folder_name = 'benchmark_wmf_log_dt2';
X = @run_wmf_log;
params.get_params = @get_params_wmf_dt1;
benchmark_X_on_dt2(output_folder_name,X,params)
params.preprocess = @make_size_even;
evaluate_metrics_dt2(output_folder_name,params);
end
%% V-BM4D
if VBM4D == 1
params = common_params;
X = @run_vbm4d;
% Profile parameter: 'np' or 'lc'
% 'lc' is fast and we have set it as default.
% params.method.profile = 'np';
params.noise_estimator = @(y) estimate_noise_dt2_max(y)*2 - 1;
output_folder_name = 'benchmark_vbm4d_dt2';
benchmark_X_on_dt2(output_folder_name,X,params)
evaluate_metrics_dt2(output_folder_name,params);
end
%% V-BM4D in the logarithm domain
if VBM4D_log == 1
params = common_params;
X = @run_vbm4d_log;
% Profile parameter: 'np' or 'lc'
% 'lc' is fast and we have set it as default.
% params.method.profile = 'np';
params.noise_estimator = @(y) estimate_noise_dt2_max(y)*2 - 1;
output_folder_name = 'benchmark_vbm4d_log_dt2';
benchmark_X_on_dt2(output_folder_name,X,params)
evaluate_metrics_dt2(output_folder_name,params);
end
%% Tensor DL
% NOTE: This method does not work on "dt2". I don't know why!. Even with
% bigger sigma_value it does not work.
% You may want to DELETE it for this dataset.
if TENSOR_DL == 1
params = common_params;
X = @run_tensor_dl;
params.noise_estimator = @(y) estimate_noise_dt2_max(y)*2 - 1;
output_folder_name = 'benchmark_tensor_dl_dt2';
benchmark_X_on_dt2(output_folder_name,X,params)
d = 4;
params.preprocess = @(x) crop_image(x,d);
evaluate_metrics_dt2(output_folder_name,params);
end
%% Tensor DL in the logarithm domain
% NOTE: This method does not work on "dt2". I don't know why!. Even with
% bigger sigma_value it does not work.
% You may want to DELETE it for this dataset.
if TENSOR_DL_log == 1
params = common_params;
X = @run_tensor_dl_log;
params.noise_estimator = @(y) estimate_noise_dt2_max(y)*2 - 1;
output_folder_name = 'benchmark_tensor_dl_log_dt2';
benchmark_X_on_dt2(output_folder_name,X,params)
d = 4;
params.preprocess = @(x) crop_image(x,d);
evaluate_metrics_dt2(output_folder_name,params);
end
%% Original BM4D: BM4D with voxel-wise noise estimation
if BM4D_org == 1
params = common_params;
X = @run_bm4d;
output_folder_name = 'benchmark_bm4d_dt2';
benchmark_X_on_dt2(output_folder_name,X,params)
evaluate_metrics_dt2(output_folder_name,params);
end
%% Original BM4D in the logarithm domain
if BM4D_org_log == 1
params = common_params;
X = @run_bm4d_log;
output_folder_name = 'benchmark_bm4d_log_dt2';
benchmark_X_on_dt2(output_folder_name,X,params)
evaluate_metrics_dt2(output_folder_name,params);
end
%% BM4D with iid noise assumption
if BM4D_iid == 1
params = common_params;
X = @run_bm4d_iidnoise;
params.noise_estimator = @(y) estimate_noise_dt2_max(y)*2 - 1;
output_folder_name = 'benchmark_bm4d_iidnoise_dt2';
benchmark_X_on_dt2(output_folder_name,X,params)
evaluate_metrics_dt2(output_folder_name,params);
end
%% BM4D with iid noise assumption in the logarithm domain
if BM4D_iid_log == 1
params = common_params;
X = @run_bm4d_iidnoise_log;
params.noise_estimator = @(y) estimate_noise_dt2_max(y)*2 - 1;
output_folder_name = 'benchmark_bm4d_iidnoise_log_dt2';
benchmark_X_on_dt2(output_folder_name,X,params)
evaluate_metrics_dt2(output_folder_name,params);
end
%% MS BM4D (dwt3)
% NOTE: wavelet name (wname), number of levels, and noise estimator should
% be tuned in such a way that the method can reasonably outperform KSVDS in
% terms of some metrics such as ENL, TP, and EP.
if MS_BM4D_dwt3 == 1
for n_levels = 3 % number of decomposition level
params = common_params;
X = @run_bm4d_mix;
params.method.n_levels = n_levels;
params.method.wname = 'sym4';
params.noise_estimator = @(y) estimate_noise_dt2_max(y)*2.3 - 1;
output_folder_name = sprintf('benchmark_bm4d_mix_dt2_%s_%d',...
params.method.wname, n_levels);
benchmark_X_on_dt2(output_folder_name,X,params)
evaluate_metrics_dt2(output_folder_name,params);
end
end
%% MS BM4D (dwt3) in the logarithm domain
% for this dataset, it seems that the log version is not better than the
% spatial domain.
%
if MS_BM4D_dwt3_log == 1
for n_levels = 3 % number of decomposition level
params = common_params;
X = @run_bm4d_mix_log;
params.method.n_levels = n_levels;
params.method.wname = 'sym4';
params.noise_estimator = @(y) estimate_noise_dt2_max(y)*2.3;
output_folder_name = sprintf('benchmark_bm4d_mix_log_dt2_%s_%d',...
params.method.wname, n_levels);
benchmark_X_on_dt2(output_folder_name,X,params)
evaluate_metrics_dt2(output_folder_name,params);
end
end
%% MS BM4D (dualtree3) *******
% Allowed filter banks are:
% ("nearsym5_7"), 'nearsym13_19', 'antonini', or 'legall'
% TODO:
% We can improve the result with the following command in less than one
% second:
% par.win = 4; par.nsig = 19; par.Beta = 1;
% im_out2 = averaging_nearby_slices_org(denoised_imgs,par);
%
if MS_BM4D_dualtree3 == 1
for n_levels = 3 % number of decomposition level
params = common_params;
X = @run_bm4d_mix_dualtree3;
params.method.n_levels = n_levels;
params.method.filter_bank = 'nearsym5_7'; % antonini legall
params.noise_estimator = @(y) estimate_noise_dt2_max(y)*2 - 1;
output_folder_name = sprintf('benchmark_bm4d_mix_dualtree3_dt2_%s_%d',...
params.method.filter_bank, n_levels);
benchmark_X_on_dt2(output_folder_name,X,params)
evaluate_metrics_dt2(output_folder_name,params);
end
end
%% MS BM4D (dualtree3) in the logarithm domain
% Allowed filter banks are:
% ("nearsym5_7"), 'nearsym13_19', 'antonini', or 'legall'
if MS_BM4D_dualtree3_log == 1
for n_levels = 3 % number of decomposition level
params = common_params;
X = @run_bm4d_mix_dualtree3_log;
params.method.n_levels = n_levels;
params.method.filter_bank = 'antonini';
params.noise_estimator = @(y) estimate_noise_dt2_max(y)*2.8;
output_folder_name = sprintf('benchmark_bm4d_mix_dualtree3_log_dt2_%s_%d',...
params.method.filter_bank, n_levels);
benchmark_X_on_dt2(output_folder_name,X,params)
evaluate_metrics_dt2(output_folder_name,params);
end
end