-
Notifications
You must be signed in to change notification settings - Fork 1
/
denoiseanddeblurnonsym.m
201 lines (165 loc) · 6.98 KB
/
denoiseanddeblurnonsym.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
%% USING THE MATRIX FUNCTION ROUTINE TO DENOISE THE IMAGE:
clear; clc;
warning('off','all');
clear classes
cd('AIRToolsII/');
AIRToolsII_setup;
cd('..');
cd('IRtools/');
IRtools_setup;
cd('..');
warning('on','all');
FID = fopen('results_IRfun.dat','a');
fprintf(FID,'Experiment run on %s\n',datestr(now));
%% Launch iteration:
for imagename = {'phillips','gravity'} % ,
fprintf(FID,'TEST CASE %s \n',imagename{1});
%% Generate the blurred and noised signal:
[A,bl,x_true] = feval(imagename{1},4*2^8);
for NoiseLevel = [1e-3,1e-2,1e-1,3e-1,6e-1]
fprintf(FID,'%1.1e',NoiseLevel);
[b, NoiseInfo] = PRnoise(bl, 'gauss',NoiseLevel);
%% Apply the CGLS to restore the signal:
fprintf('CGLS Algorithm:\n');
try
options = IRcgls('defaults');
options.x_true = x_true;
options.NoiseLevel = NoiseLevel;
options.verbosity = 'off';
options.IterBar = 'off';
tic;
[Xcgls,infocgls] = IRcgls(A,b,options);
timecgls = toc;
options.NoStop = 'on';
[~,infocglsbest] = IRcgls(A,b,options);
fprintf(FID, ' & %d (%d) & %1.1e & %1.2f (%1.2f)',...
infocgls.StopReg.It,infocglsbest.BestReg.It,timecgls,...
psnr(reshape(infocgls.StopReg.X,size(x_true)),x_true),...
psnr(reshape(infocglsbest.BestReg.X,size(x_true)),x_true));
catch
fprintf(FID, ' & -- & -- & --');
end
%% Apply the Range-Restricted GMRES
fprintf('\nRangeRestricted GMRES Algorithm:\n');
try
options = IRrrgmres('defaults');
options.x_true = x_true;
options.NoiseLevel = NoiseLevel;
options.verbosity = 'off';
options.IterBar = 'off';
tic;
[Xrrgmres,inforrgmres] = IRrrgmres(A,b,options);
timerrgmres = toc;
options.NoStop = 'on';
[~,inforrgmresbest] = IRrrgmres(A,b,options);
fprintf(FID,' & %d (%d) & %1.1e & %1.2f (%1.2f)', ...
inforrgmres.StopReg.It,...
inforrgmresbest.BestReg.It,timerrgmres,...
psnr(reshape(inforrgmres.StopReg.X,size(x_true)),x_true),...
psnr(reshape(inforrgmresbest.BestReg.X,size(x_true)),x_true));
catch
fprintf(FID, ' & -- & -- & --');
end
%% CGLS for Tikhonov method
fprintf('\nTikhonov CGLS method:\n');
try
options = IRcgls('defaults');
options.x_true = x_true;
options.verbosity = 'off';
options.IterBar = 'off';
options.NoiseLevel = 'none';
tic;
options.RegParam = settikhonov(A,b);
[Xtikhonov,infotikhonov] = IRcgls(A,b,options);
timetikhonov = toc;
fprintf(FID,'& %1.2e & %d & %1.1e & %1.2f',...
options.RegParam,infotikhonov.StopReg.It,timetikhonov,...
psnr(reshape(infotikhonov.StopReg.X,size(x_true)),x_true));
catch
fprintf(FID, ' & -- & -- & --');
end
%% Apply the matrix-function denoiser:
fprintf('\nMatrix Function Regularizer:\n');
try
options = IRfun('defaults');
options.RegParam = NoiseLevel*1e-1;
options.x_true = x_true;
options.NoStop = 'off';
options.RegBeta = 1e+6;
options.verbosity = 0;
options.NoiseLevel = NoiseLevel;
options.MaxIter = 100;
options.IterBar = 'off';
options.Reorth = 'on';
options.eta = 1.01;
if norm(A-A') > 1e-6
options.RegType = 'arnoldi';
else
options.RegType = 'lanczos';
end
fprintf(FID,' & %1.1e',options.RegParam);
tic;
[X,infofun] = IRfun(A,b,options);
timefun = toc;
options.NoStop = 'on';
[~,infofunbest] = IRfun(A,b,options);
fprintf(FID,'& %d (%d) & %1.1e & %1.2f (%1.2f)',...
infofun.StopReg.It,infofunbest.BestReg.It,timefun,...
psnr(reshape(infofun.StopReg.X,size(x_true)),x_true),...
psnr(reshape(infofunbest.BestReg.X,size(x_true)),x_true));
catch
fprintf(FID, ' & -- & -- & --');
end
%% Apply Hybrid methods : Hybrid-GMRES
fprintf('\nHybrid GMRES method:\n');
options = IRhybrid_gmres('defaults');
options.x_true = x_true;
options.verbosity = 'off';
options.IterBar = 'off';
options.NoStop = 'off';
tic;
[Xhybridgmres,infohybridgmres] = IRhybrid_gmres(A,b,options);
timehybridgmres = toc;
options.NoStop = 'on';
[~,infohybridgmresbest] = IRhybrid_gmres(A,b,options);
fprintf(FID, ' & %d (%d) & %1.1e & %1.2f (%1.2f)',...
infohybridgmres.StopReg.It,infohybridgmresbest.BestReg.It,timehybridgmres,...
psnr(reshape(infohybridgmres.StopReg.X,size(x_true)),x_true),...
psnr(reshape(infohybridgmresbest.BestReg.X,size(x_true)),x_true));
%% Apply Hybrid methods : Hybrid-FGMRES
fprintf('\nHybrid fgmres method:\n');
options = IRhybrid_fgmres('defaults');
options.x_true = x_true;
options.verbosity = 'off';
options.IterBar = 'off';
options.NoStop = 'off';
tic;
[Xhybridfgmres,infohybridfgmres] = IRhybrid_fgmres(A,b,options);
timehybridfgmres = toc;
options.NoStop = 'on';
[~,infohybridfgmresbest] = IRhybrid_fgmres(A,b,options);
fprintf(FID, ' & %d (%d) & %1.1e & %1.2f (%1.2f)',...
infohybridfgmres.StopReg.It,infohybridfgmresbest.BestReg.It,timehybridfgmres,...
psnr(reshape(infohybridfgmres.StopReg.X,size(x_true)),x_true),...
psnr(reshape(infohybridfgmresbest.BestReg.X,size(x_true)),x_true));
%% Apply Hybrid methods : Hybrid-lsqr
fprintf('\nHybrid lsqr method:\n');
options = IRhybrid_lsqr('defaults');
options.x_true = x_true;
options.verbosity = 'off';
options.IterBar = 'off';
options.NoStop = 'off';
tic;
[Xhybridlsqr,infohybridlsqr] = IRhybrid_lsqr(A,b,options);
timehybridlsqr = toc;
options.NoStop = 'on';
[~,infohybridlsqrbest] = IRhybrid_lsqr(A,b,options);
fprintf(FID, ' & %d (%d) & %1.1e & %1.2f (%1.2f)',...
infohybridlsqr.StopReg.It,infohybridlsqrbest.BestReg.It,timehybridlsqr,...
psnr(reshape(infohybridlsqr.StopReg.X,size(x_true)),x_true),...
psnr(reshape(infohybridlsqrbest.BestReg.X,size(x_true)),x_true));
fprintf(FID,'\\\\\n');
end
end
fprintf(FID,'\n\n\n\n');
fclose(FID);