-
Notifications
You must be signed in to change notification settings - Fork 0
/
mW_metrics.m
executable file
·131 lines (98 loc) · 2.83 KB
/
mW_metrics.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
function [W, E, psnrs, ssims, mses, brisques, niqes, piqes] = mW_metrics(F, y, xref, options)
% modified Wiener iterations
% Keep track of metrics
% default value for 'a' from the image noise variance
if (size(y,3) ~= 1)
ybw = rgb2gray(y);
nsr = estimate_noise(ybw)^2 / var(ybw(:));
else
nsr = estimate_noise(y)^2 / var(y(:));
end
a_def = nsr;
options.null = 0;
maxiter = getoptions(options, 'maxiter', 100);
a = getoptions(options, 'a', a_def);
show_denoised = getoptions(options, 'show_denoised', 0);
W = y;
FW = F(W);
H = fft2(FW)./(fft2(W)+eps);
E = [];
e = img_norm(y - FW);
E = [E; e];
if show_denoised == 1
Wd = denoise(W);
psnrs = [];
curr_psnr = psnr(Wd, xref);
psnrs = [psnrs; curr_psnr];
ssims = [];
curr_ssim = ssim(Wd, xref);
ssims = [ssims; curr_ssim];
mses = [];
curr_mse = immse(Wd, xref);
mses = [mses; curr_mse];
brisques = [];
curr_brisque = brisque(Wd);
brisques = [brisques; curr_brisque];
niqes = [];
curr_niqe = niqe(Wd);
niqes = [niqes; curr_niqe];
piqes = [];
curr_piqe = piqe(Wd);
piqes = [piqes; curr_piqe];
else
psnrs = [];
curr_psnr = psnr(W, xref);
psnrs = [psnrs; curr_psnr];
ssims = [];
curr_ssim = ssim(W, xref);
ssims = [ssims; curr_ssim];
mses = [];
curr_mse = immse(W, xref);
mses = [mses; curr_mse];
brisques = [];
curr_brisque = brisque(W);
brisques = [brisques; curr_brisque];
niqes = [];
curr_niqe = niqe(W);
niqes = [niqes; curr_niqe];
piqes = [];
curr_piqe = piqe(W);
piqes = [piqes; curr_piqe];
end
for i=1:maxiter
H = H*(i-1)/i + fft2(FW)./(fft2(W)+eps)/i;
Hconj = conj(H);
W = real(ifft2((Hconj./(Hconj.*H+a)).*fft2(y)));
FW = F(W);
e = img_norm(y - FW);
E = [E; e];
if show_denoised == 1
Wd = denoise(W);
curr_psnr = psnr(Wd, xref);
psnrs = [psnrs; curr_psnr];
curr_ssim = ssim(Wd, xref);
ssims = [ssims; curr_ssim];
curr_mse = immse(Wd, xref);
mses = [mses; curr_mse];
curr_brisque = brisque(Wd);
brisques = [brisques; curr_brisque];
curr_niqe = niqe(Wd);
niqes = [niqes; curr_niqe];
curr_piqe = piqe(Wd);
piqes = [piqes; curr_piqe];
else
curr_psnr = psnr(W, xref);
psnrs = [psnrs; curr_psnr];
curr_ssim = ssim(W, xref);
ssims = [ssims; curr_ssim];
curr_mse = immse(W, xref);
mses = [mses; curr_mse];
curr_brisque = brisque(W);
brisques = [brisques; curr_brisque];
curr_niqe = niqe(W);
niqes = [niqes; curr_niqe];
curr_piqe = piqe(W);
piqes = [piqes; curr_piqe];
end
end
end