-
Notifications
You must be signed in to change notification settings - Fork 9
/
compute_error.m
141 lines (122 loc) · 4.86 KB
/
compute_error.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
%%%%%% uncomment for the jointly trained 10 operator model with real-time parameter tuning module %%%%%%
% types = {'L0smooth','WLS','RTV','RGF','WMF','fast_LLFenhancement','fast_LLFenhancementgeneral','WLSenhancement','style','pencilColor'};
% totalPara = {{'000200', '000431', '002000', '009283', '020000'},
% {'010000', '021544', '100000', '464159', '1000000'},
% {'000200', '000447', '001000', '002236', '005000'},
% {'1.00000','3.25000','5.50000','7.75000','10.00000'},
% {'1.00000','3.25000','5.50000','7.75000','10.00000'},
% {'2','3','5','7','8'},
% {'1.00000'},
% {'1.00000'},
% {'1.00000'},
% {'1.00000'}};
%%%%%% uncomment for the jointly trained 10 operator model %%%%%%
% types = {'L0smooth','WLS','RTV','RGF','WMF','shock','deblock-y','rain','SR-y','noise-gray'};
% totalPara = {{'000200', '000431', '002000', '009283', '020000'},
% {'010000', '021544', '100000', '464159', '1000000'},
% {'000200', '000447', '001000', '002236', '005000'},
% {'1.00000','3.25000','5.50000','7.75000','10.00000'},
% {'1.00000','3.25000','5.50000','7.75000','10.00000'},
% {'1.00000'},
% {'10','20'},
% {'10'},
% {'2','3','4'},
% {'15','25','50'}
% };
%%%%%% uncomment for the jointly trained 6 filtering based operator model %%%%%%
% types = {'L0smooth','WLS','RTV','RGF','WMF','shock'};
% totalPara = {{'000200', '000431', '002000', '009283', '020000'},
% {'010000', '021544', '100000', '464159', '1000000'},
% {'000200', '000447', '001000', '002236', '005000'},
% {'1.00000','3.25000','5.50000','7.75000','10.00000'},
% {'1.00000','3.25000','5.50000','7.75000','10.00000'},
% {'1.00000'}};
%%%%%% uncomment for the jointly trained 4 restoration operator model %%%%%%
% types = {'deblock-y','rain','SR-y','noise-gray'};
% totalPara = {{'10','20'},
% {'10'},
% {'2','3','4'},
% {'15','25','50'}
% };
%%%%%% uncomment for the individually trained single operator model %%%%%%
% types = {'L0smooth'};
% totalPara = {{'000200', '000431', '002000', '009283', '020000'}};
% types = {'WLS'};
% totalPara = {{'010000', '021544', '100000', '464159', '1000000'}};
% types = {'RTV'};
% totalPara = {{'000200', '000447', '001000', '002236', '005000'}};
% types = {'RGF'};
% totalPara = {{'1.00000','3.25000','5.50000','7.75000','10.00000'}};
% types = {'WMF'};
% totalPara = {{'1.00000','3.25000','5.50000','7.75000','10.00000'}};
% types = {'shock'};
% totalPara = {{'1.00000'}};
% types = {'deblock-y'};
% totalPara = {{'10','20'}};
% types = {'rain'};
% totalPara = {{'10'}};
% types = {'SR-y'};
% totalPara = {{'2','3','4'}};
% types = {'noise-gray'};
% totalPara = {{'15','25','50'}};
inputDir = './results/';
for m = 1:length(totalPara)
para = totalPara{m};
disp(types{m});
totalPSNR_all = 0;
totalSSIM_all = 0;
totalMSE_all = 0;
count_all = 0;
for k = 1:length(para)
totalPSNR = 0;
totalSSIM = 0;
totalMSE = 0;
count = 0;
disp(para{k});
if length(para) ~=1
searchDir = sprintf('%s*-%s-%s-predict.png',inputDir,types{m},para{k});
else
searchDir = sprintf('%s*-%s-predict.png',inputDir,types{m});
end
if strcmp(types{m}, 'rain')
searchDir = sprintf('%s*_GT.png',inputDir);
end
if strcmp(types{m}, 'shock')
searchDir = sprintf('%s*-%s-%s-predict.png',inputDir,types{m},para{k});
end
s = dir(searchDir);
for n = 1:length(s)
inputName = [inputDir s(n,1).name];
targetName = strrep(inputName,'-predict','');
if strcmp(types{m}, 'rain')
targetName = strrep(inputName,'_GT','_predict');
end
if strcmp(types{m}, 'SR-y')
targetName = strrep(inputName,sprintf('SR-y-%s-predict',para{k}),sprintf('input-y-%s',para{k}));
end
if strcmp(types{m}, 'noise-gray')
targetName = strrep(inputName,sprintf('noise-gray-%s-predict',para{k}),'label-gray');
end
if strcmp(types{m}, 'deblock-y')
targetName = strrep(inputName,sprintf('deblock-y-%s-predict.png',para{k}),'label-y.png');
end
input = imread(inputName);
target = imread(targetName);
[height,width,channel] = size(input);
[peaksnr, snr] = psnr(input, target);
totalPSNR = totalPSNR + peaksnr;
input = rgb2gray(input);
target = rgb2gray(target);
[ssimval, ssimmap] = ssim(input, target);
totalSSIM = totalSSIM + ssimval;
count = count + 1;
end
totalPSNR = totalPSNR/count;
totalSSIM = totalSSIM/count;
disp(sprintf('psnr: %f, ssim: %f',totalPSNR,totalSSIM));
totalPSNR_all = totalPSNR_all + totalPSNR;
totalSSIM_all = totalSSIM_all + totalSSIM;
count_all = count_all + 1;
end
disp(sprintf('AVE psnr: %f, ssim: %f',totalPSNR_all/count_all,totalSSIM_all/count_all));
end