idamnjanovic@42
|
1 %% DICTIONARY LEARNING FOR IMAGE DENOISING
|
idamnjanovic@42
|
2 % This file contains an example of how SMALLbox can be used to test different
|
idamnjanovic@42
|
3 % dictionary learning techniques in Image Denoising problem.
|
idamnjanovic@42
|
4 % It calls generateImageDenoiseProblem that will let you to choose image,
|
idamnjanovic@42
|
5 % add noise and use noisy image to generate training set for dictionary
|
idamnjanovic@42
|
6 % learning.
|
maria@83
|
7 % Two dictionary learning techniques were compared:
|
idamnjanovic@42
|
8 % - KSVD - M. Elad, R. Rubinstein, and M. Zibulevsky, "Efficient
|
idamnjanovic@42
|
9 % Implementation of the K-SVD Algorithm using Batch Orthogonal
|
idamnjanovic@42
|
10 % Matching Pursuit", Technical Report - CS, Technion, April 2008.
|
maria@83
|
11 % - RLS-DLA - Skretting, K.; Engan, K.; , "Recursive Least Squares
|
maria@83
|
12 % Dictionary Learning Algorithm," Signal Processing, IEEE Transactions on,
|
maria@83
|
13 % vol.58, no.4, pp.2121-2130, April 2010
|
idamnjanovic@42
|
14 %
|
maria@83
|
15
|
maria@83
|
16
|
maria@83
|
17 % Centre for Digital Music, Queen Mary, University of London.
|
maria@83
|
18 % This file copyright 2011 Ivan Damnjanovic.
|
idamnjanovic@42
|
19 %
|
maria@83
|
20 % This program is free software; you can redistribute it and/or
|
maria@83
|
21 % modify it under the terms of the GNU General Public License as
|
maria@83
|
22 % published by the Free Software Foundation; either version 2 of the
|
maria@83
|
23 % License, or (at your option) any later version. See the file
|
maria@83
|
24 % COPYING included with this distribution for more information.
|
maria@83
|
25 %
|
idamnjanovic@42
|
26 %%
|
idamnjanovic@42
|
27
|
idamnjanovic@42
|
28
|
idamnjanovic@42
|
29
|
idamnjanovic@42
|
30 % If you want to load the image outside of generateImageDenoiseProblem
|
idamnjanovic@42
|
31 % function uncomment following lines. This can be useful if you want to
|
idamnjanovic@42
|
32 % denoise more then one image for example.
|
maria@83
|
33 % Here we are loading test_image.mat that contains structure with 5 images : lena,
|
maria@83
|
34 % barbara,boat, house and peppers.
|
idamnjanovic@42
|
35 clear;
|
idamnjanovic@42
|
36 TMPpath=pwd;
|
idamnjanovic@42
|
37 FS=filesep;
|
idamnjanovic@42
|
38 [pathstr1, name, ext, versn] = fileparts(which('SMALLboxSetup.m'));
|
idamnjanovic@42
|
39 cd([pathstr1,FS,'data',FS,'images']);
|
idamnjanovic@42
|
40 load('test_image.mat');
|
ivan@77
|
41 cd(TMPpath);
|
maria@83
|
42
|
maria@83
|
43 % Deffining the noise levels that we want to test
|
idamnjanovic@42
|
44
|
idamnjanovic@42
|
45 noise_level=[10 20 25 50 100];
|
maria@83
|
46
|
maria@83
|
47 % Here we loop through different noise levels and images
|
maria@83
|
48
|
maria@83
|
49 for noise_ind=2:2
|
maria@83
|
50 for im_num=1:1
|
maria@83
|
51
|
idamnjanovic@42
|
52 % Defining Image Denoising Problem as Dictionary Learning
|
idamnjanovic@42
|
53 % Problem. As an input we set the number of training patches.
|
maria@83
|
54
|
idamnjanovic@65
|
55 SMALL.Problem = generateImageDenoiseProblem(test_image(im_num).i, 40000, '',256, noise_level(noise_ind));
|
ivan@77
|
56 SMALL.Problem.name=int2str(im_num);
|
idamnjanovic@42
|
57
|
idamnjanovic@42
|
58 results(noise_ind,im_num).noisy_psnr=SMALL.Problem.noisy_psnr;
|
idamnjanovic@42
|
59
|
idamnjanovic@42
|
60 %%
|
idamnjanovic@42
|
61 % Use KSVD Dictionary Learning Algorithm to Learn overcomplete dictionary
|
idamnjanovic@42
|
62
|
idamnjanovic@42
|
63 % Initialising Dictionary structure
|
idamnjanovic@42
|
64 % Setting Dictionary structure fields (toolbox, name, param, D and time)
|
idamnjanovic@42
|
65 % to zero values
|
idamnjanovic@42
|
66
|
idamnjanovic@42
|
67 SMALL.DL(1)=SMALL_init_DL();
|
idamnjanovic@42
|
68
|
idamnjanovic@42
|
69 % Defining the parameters needed for dictionary learning
|
idamnjanovic@42
|
70
|
idamnjanovic@42
|
71 SMALL.DL(1).toolbox = 'KSVD';
|
idamnjanovic@42
|
72 SMALL.DL(1).name = 'ksvd';
|
idamnjanovic@42
|
73
|
idamnjanovic@42
|
74 % Defining the parameters for KSVD
|
idamnjanovic@42
|
75 % In this example we are learning 256 atoms in 20 iterations, so that
|
idamnjanovic@42
|
76 % every patch in the training set can be represented with target error in
|
idamnjanovic@42
|
77 % L2-norm (EData)
|
idamnjanovic@42
|
78 % Type help ksvd in MATLAB prompt for more options.
|
idamnjanovic@42
|
79
|
idamnjanovic@42
|
80 Edata=sqrt(prod(SMALL.Problem.blocksize)) * SMALL.Problem.sigma * SMALL.Problem.gain;
|
idamnjanovic@42
|
81 maxatoms = floor(prod(SMALL.Problem.blocksize)/2);
|
idamnjanovic@42
|
82 SMALL.DL(1).param=struct(...
|
idamnjanovic@42
|
83 'Edata', Edata,...
|
idamnjanovic@42
|
84 'initdict', SMALL.Problem.initdict,...
|
idamnjanovic@42
|
85 'dictsize', SMALL.Problem.p,...
|
idamnjanovic@42
|
86 'exact', 1, ...
|
idamnjanovic@42
|
87 'iternum', 20,...
|
idamnjanovic@42
|
88 'memusage', 'high');
|
idamnjanovic@42
|
89
|
idamnjanovic@42
|
90 % Learn the dictionary
|
idamnjanovic@42
|
91
|
idamnjanovic@42
|
92 SMALL.DL(1) = SMALL_learn(SMALL.Problem, SMALL.DL(1));
|
idamnjanovic@42
|
93
|
idamnjanovic@42
|
94 % Set SMALL.Problem.A dictionary
|
idamnjanovic@42
|
95 % (backward compatiblity with SPARCO: solver structure communicate
|
idamnjanovic@42
|
96 % only with Problem structure, ie no direct communication between DL and
|
idamnjanovic@42
|
97 % solver structures)
|
idamnjanovic@42
|
98
|
idamnjanovic@42
|
99 SMALL.Problem.A = SMALL.DL(1).D;
|
idamnjanovic@42
|
100 SMALL.Problem.reconstruct = @(x) ImgDenoise_reconstruct(x, SMALL.Problem);
|
idamnjanovic@42
|
101
|
idamnjanovic@42
|
102 %%
|
idamnjanovic@42
|
103 % Initialising solver structure
|
idamnjanovic@42
|
104 % Setting solver structure fields (toolbox, name, param, solution,
|
idamnjanovic@42
|
105 % reconstructed and time) to zero values
|
idamnjanovic@42
|
106
|
idamnjanovic@42
|
107 SMALL.solver(1)=SMALL_init_solver;
|
idamnjanovic@42
|
108
|
idamnjanovic@42
|
109 % Defining the parameters needed for image denoising
|
idamnjanovic@42
|
110
|
idamnjanovic@42
|
111 SMALL.solver(1).toolbox='ompbox';
|
idamnjanovic@42
|
112 SMALL.solver(1).name='omp2';
|
idamnjanovic@42
|
113 SMALL.solver(1).param=struct(...
|
idamnjanovic@42
|
114 'epsilon',Edata,...
|
idamnjanovic@42
|
115 'maxatoms', maxatoms);
|
idamnjanovic@42
|
116
|
idamnjanovic@42
|
117 % Denoising the image - SMALL_denoise function is similar to SMALL_solve,
|
idamnjanovic@42
|
118 % but backward compatible with KSVD definition of denoising
|
idamnjanovic@42
|
119
|
idamnjanovic@42
|
120 SMALL.solver(1)=SMALL_solve(SMALL.Problem, SMALL.solver(1));
|
idamnjanovic@42
|
121 SMALL.solver(1).reconstructed.psnr
|
idamnjanovic@42
|
122 %%
|
idamnjanovic@42
|
123 % Use KSVDS Dictionary Learning Algorithm to denoise image
|
idamnjanovic@42
|
124
|
idamnjanovic@42
|
125 % Initialising solver structure
|
idamnjanovic@42
|
126 % Setting solver structure fields (toolbox, name, param, solution,
|
idamnjanovic@42
|
127 % reconstructed and time) to zero values
|
idamnjanovic@42
|
128 %
|
idamnjanovic@42
|
129 % SMALL.DL(2)=SMALL_init_DL();
|
idamnjanovic@42
|
130 %
|
idamnjanovic@42
|
131 % % Defining the parameters needed for dictionary learning
|
idamnjanovic@42
|
132 %
|
idamnjanovic@42
|
133 % SMALL.DL(2).toolbox = 'KSVDS';
|
idamnjanovic@42
|
134 % SMALL.DL(2).name = 'ksvds';
|
idamnjanovic@42
|
135 %
|
idamnjanovic@42
|
136 % % Defining the parameters for KSVDS
|
idamnjanovic@42
|
137 % % In this example we are learning 256 atoms in 20 iterations, so that
|
idamnjanovic@42
|
138 % % every patch in the training set can be represented with target error in
|
idamnjanovic@42
|
139 % % L2-norm (EDataS). We also impose "double sparsity" - dictionary itself
|
idamnjanovic@42
|
140 % % has to be sparse in the given base dictionary (Tdict - number of
|
idamnjanovic@42
|
141 % % nonzero elements per atom).
|
idamnjanovic@42
|
142 % % Type help ksvds in MATLAB prompt for more options.
|
idamnjanovic@42
|
143 %
|
idamnjanovic@42
|
144 %
|
idamnjanovic@42
|
145 % SMALL.DL(2).param=struct(...
|
idamnjanovic@42
|
146 % 'Edata', Edata, ...
|
idamnjanovic@42
|
147 % 'Tdict', 6,...
|
idamnjanovic@42
|
148 % 'stepsize', 1,...
|
idamnjanovic@42
|
149 % 'dictsize', SMALL.Problem.p,...
|
idamnjanovic@42
|
150 % 'iternum', 20,...
|
idamnjanovic@42
|
151 % 'memusage', 'high');
|
idamnjanovic@42
|
152 % SMALL.DL(2).param.initA = speye(SMALL.Problem.p);
|
idamnjanovic@42
|
153 % SMALL.DL(2).param.basedict{1} = odctdict(8,16);
|
idamnjanovic@42
|
154 % SMALL.DL(2).param.basedict{2} = odctdict(8,16);
|
idamnjanovic@42
|
155 %
|
idamnjanovic@42
|
156 % % Learn the dictionary
|
idamnjanovic@42
|
157 %
|
idamnjanovic@42
|
158 % SMALL.DL(2) = SMALL_learn(SMALL.Problem, SMALL.DL(2));
|
idamnjanovic@42
|
159
|
idamnjanovic@42
|
160 % Set SMALL.Problem.A dictionary and SMALL.Problem.basedictionary
|
idamnjanovic@42
|
161 % (backward compatiblity with SPARCO: solver structure communicate
|
idamnjanovic@42
|
162 % only with Problem structure, ie no direct communication between DL and
|
idamnjanovic@42
|
163 % solver structures)
|
idamnjanovic@42
|
164
|
idamnjanovic@42
|
165 SMALL.Problem.A = SMALL.Problem.initdict;
|
idamnjanovic@42
|
166 % SMALL.Problem.basedict{1} = SMALL.DL(2).param.basedict{1};
|
idamnjanovic@42
|
167 % SMALL.Problem.basedict{2} = SMALL.DL(2).param.basedict{2};
|
idamnjanovic@42
|
168 SMALL.DL(2).D=SMALL.Problem.initdict;
|
idamnjanovic@42
|
169 SparseDict=0;
|
idamnjanovic@42
|
170 SMALL.Problem.reconstruct = @(x) ImgDenoise_reconstruct(x, SMALL.Problem, SparseDict);
|
idamnjanovic@42
|
171
|
idamnjanovic@42
|
172 %%
|
idamnjanovic@42
|
173 % Initialising solver structure
|
idamnjanovic@42
|
174 % Setting solver structure fields (toolbox, name, param, solution,
|
idamnjanovic@42
|
175 % reconstructed and time) to zero values
|
idamnjanovic@42
|
176
|
idamnjanovic@42
|
177 SMALL.solver(2)=SMALL_init_solver;
|
idamnjanovic@42
|
178
|
idamnjanovic@42
|
179 % Defining the parameters needed for image denoising
|
idamnjanovic@42
|
180
|
idamnjanovic@42
|
181 SMALL.solver(2).toolbox='ompbox';
|
idamnjanovic@42
|
182 SMALL.solver(2).name='omp2';
|
idamnjanovic@42
|
183 SMALL.solver(2).param=struct(...
|
idamnjanovic@42
|
184 'epsilon',Edata,...
|
idamnjanovic@42
|
185 'maxatoms', maxatoms);
|
idamnjanovic@42
|
186
|
idamnjanovic@42
|
187 % Denoising the image - SMALL_denoise function is similar to SMALL_solve,
|
idamnjanovic@42
|
188 % but backward compatible with KSVD definition of denoising
|
idamnjanovic@42
|
189 % Pay attention that since implicit base dictionary is used, denoising
|
idamnjanovic@42
|
190 % can be much faster then using explicit dictionary in KSVD example.
|
idamnjanovic@42
|
191
|
idamnjanovic@42
|
192 SMALL.solver(2)=SMALL_solve(SMALL.Problem, SMALL.solver(2));
|
idamnjanovic@42
|
193 %%
|
idamnjanovic@42
|
194
|
idamnjanovic@42
|
195 for i =1:1
|
idamnjanovic@42
|
196
|
idamnjanovic@42
|
197 X=SMALL.Problem.b1;
|
idamnjanovic@42
|
198 X_norm=sqrt(sum(X.^2, 1));
|
idamnjanovic@42
|
199 [X_norm_sort, p]=sort(X_norm);
|
idamnjanovic@42
|
200 p1=p(X_norm_sort>Edata);
|
maria@83
|
201 if size(p1,2)>40000
|
idamnjanovic@42
|
202 p2 = randperm(size(p1,2));
|
idamnjanovic@42
|
203 p2=sort(p2(1:40000));
|
idamnjanovic@42
|
204 size(p2,2)
|
idamnjanovic@42
|
205 SMALL.Problem.b=X(:,p1(p2));
|
idamnjanovic@42
|
206 else
|
idamnjanovic@42
|
207 size(p1,2)
|
idamnjanovic@42
|
208 SMALL.Problem.b=X(:,p1);
|
idamnjanovic@42
|
209
|
idamnjanovic@42
|
210 end
|
idamnjanovic@42
|
211
|
idamnjanovic@42
|
212 lambda=0.9998
|
idamnjanovic@42
|
213
|
idamnjanovic@42
|
214 % Use Recursive Least Squares
|
idamnjanovic@42
|
215 % to Learn overcomplete dictionary
|
idamnjanovic@42
|
216
|
idamnjanovic@42
|
217 % Initialising Dictionary structure
|
idamnjanovic@42
|
218 % Setting Dictionary structure fields (toolbox, name, param, D and time)
|
idamnjanovic@42
|
219 % to zero values
|
idamnjanovic@42
|
220
|
idamnjanovic@42
|
221 SMALL.DL(3)=SMALL_init_DL();
|
idamnjanovic@42
|
222
|
idamnjanovic@42
|
223 % Defining fields needed for dictionary learning
|
idamnjanovic@42
|
224
|
idamnjanovic@42
|
225 SMALL.DL(3).toolbox = 'SMALL';
|
idamnjanovic@42
|
226 SMALL.DL(3).name = 'SMALL_rlsdla';
|
idamnjanovic@42
|
227 SMALL.DL(3).param=struct(...
|
idamnjanovic@42
|
228 'Edata', Edata,...
|
idamnjanovic@42
|
229 'initdict', SMALL.Problem.initdict,...
|
idamnjanovic@42
|
230 'dictsize', SMALL.Problem.p,...
|
idamnjanovic@42
|
231 'forgettingMode', 'FIX',...
|
idamnjanovic@42
|
232 'forgettingFactor', lambda);
|
idamnjanovic@42
|
233
|
idamnjanovic@42
|
234 % % Type 'help mexTrainDL in MATLAB prompt for explanation of parameters.
|
idamnjanovic@42
|
235 %
|
idamnjanovic@42
|
236 % SMALL.DL(3).param=struct(...
|
idamnjanovic@42
|
237 % 'D', SMALL.Problem.initdict,...
|
idamnjanovic@42
|
238 % 'K', SMALL.Problem.p,...
|
idamnjanovic@42
|
239 % 'lambda', 2,...
|
idamnjanovic@42
|
240 % 'iter', 200,...
|
idamnjanovic@42
|
241 % 'mode', 3, ...
|
idamnjanovic@42
|
242 % 'modeD', 0);
|
idamnjanovic@42
|
243
|
idamnjanovic@42
|
244 % Learn the dictionary
|
idamnjanovic@42
|
245
|
idamnjanovic@42
|
246 SMALL.DL(3) = SMALL_learn(SMALL.Problem, SMALL.DL(3));
|
idamnjanovic@42
|
247 %SMALL.DL(3).D(:,1)=SMALL.DL(1).D(:,1);
|
idamnjanovic@42
|
248 %
|
idamnjanovic@42
|
249 % % Set SMALL.Problem.A dictionary
|
idamnjanovic@42
|
250 % % (backward compatiblity with SPARCO: solver structure communicate
|
idamnjanovic@42
|
251 % % only with Problem structure, ie no direct communication between DL and
|
idamnjanovic@42
|
252 % % solver structures)
|
idamnjanovic@42
|
253 %
|
idamnjanovic@42
|
254 %
|
idamnjanovic@42
|
255 %
|
idamnjanovic@42
|
256 % %%
|
idamnjanovic@42
|
257 % % Initialising solver structure
|
idamnjanovic@42
|
258 % % Setting solver structure fields (toolbox, name, param, solution,
|
idamnjanovic@42
|
259 % % reconstructed and time) to zero values
|
idamnjanovic@42
|
260 % SMALL.Problem.A = SMALL.DL(1).D;
|
idamnjanovic@42
|
261 % SMALL.Problem.reconstruct = @(x) ImgDenoise_reconstruct(x, SMALL.Problem);
|
idamnjanovic@42
|
262 % maxatoms=5;
|
idamnjanovic@42
|
263 % SMALL.solver(3)=SMALL_init_solver;
|
idamnjanovic@42
|
264 %
|
idamnjanovic@42
|
265 % % Defining the parameters needed for denoising
|
idamnjanovic@42
|
266 %
|
idamnjanovic@42
|
267 % % SMALL.solver(3).toolbox='SPAMS';
|
idamnjanovic@42
|
268 % % SMALL.solver(3).name='mexLasso';
|
idamnjanovic@42
|
269 % % SMALL.solver(3).param=struct(...
|
idamnjanovic@42
|
270 % % 'mode', 1, ...
|
idamnjanovic@42
|
271 % % 'lambda',Edata*Edata,...
|
idamnjanovic@42
|
272 % % 'L', maxatoms);
|
idamnjanovic@42
|
273 % % % Denoising the image - SMALL_denoise function is similar to SMALL_solve,
|
idamnjanovic@42
|
274 % % % but backward compatible with KSVD definition of denoising
|
idamnjanovic@42
|
275 % %
|
idamnjanovic@42
|
276 % % SMALL.solver(3)=SMALL_solve(SMALL.Problem, SMALL.solver(3));
|
idamnjanovic@42
|
277 % SMALL.solver(3).toolbox='SMALL';
|
idamnjanovic@42
|
278 % SMALL.solver(3).name='SMALL_cgp';
|
idamnjanovic@42
|
279 % SMALL.solver(3).param=sprintf('%d, %.2f', maxatoms, sqrt(Edata));
|
idamnjanovic@42
|
280 % % Denoising the image - SMALL_denoise function is similar to SMALL_solve,
|
idamnjanovic@42
|
281 % % but backward compatible with KSVD definition of denoising
|
idamnjanovic@42
|
282 %
|
idamnjanovic@42
|
283 % SMALL.solver(3)=SMALL_solve(SMALL.Problem, SMALL.solver(3));
|
idamnjanovic@42
|
284
|
idamnjanovic@42
|
285 % %%
|
idamnjanovic@42
|
286 % % Use RLS-DLA
|
idamnjanovic@42
|
287 %
|
idamnjanovic@42
|
288 % % Initialising Dictionary structure
|
idamnjanovic@42
|
289 % % Setting Dictionary structure fields (toolbox, name, param, D and time)
|
idamnjanovic@42
|
290 % % to zero values
|
idamnjanovic@42
|
291 %
|
idamnjanovic@42
|
292 % SMALL.DL(3)=SMALL_init_DL();
|
idamnjanovic@42
|
293 %
|
idamnjanovic@42
|
294 % % Defining fields needed for dictionary learning
|
idamnjanovic@42
|
295 %
|
idamnjanovic@42
|
296 % SMALL.DL(3).toolbox = 'mpv2';
|
idamnjanovic@42
|
297 % SMALL.DL(3).name = 'rlsdla';
|
idamnjanovic@42
|
298 %
|
idamnjanovic@42
|
299 % % Type 'help mexTrainDL in MATLAB prompt for explanation of parameters.
|
idamnjanovic@42
|
300 %
|
idamnjanovic@42
|
301 % SMALL.DL(3).param=struct(...
|
idamnjanovic@42
|
302 % 'D', SMALL.Problem.initdict,...
|
idamnjanovic@42
|
303 % 'K', SMALL.Problem.p,...
|
idamnjanovic@42
|
304 % 'abs', Edata*Edata,...
|
idamnjanovic@42
|
305 % 'lambda', 0.995,...
|
idamnjanovic@42
|
306 % 'iternum',1);
|
idamnjanovic@42
|
307 %
|
idamnjanovic@42
|
308 % % Learn the dictionary
|
idamnjanovic@42
|
309 %
|
idamnjanovic@42
|
310 % SMALL.DL(3) = SMALL_learn(SMALL.Problem, SMALL.DL(3));
|
idamnjanovic@42
|
311 %
|
idamnjanovic@42
|
312 % % Set SMALL.Problem.A dictionary
|
idamnjanovic@42
|
313 % % (backward compatiblity with SPARCO: solver structure communicate
|
idamnjanovic@42
|
314 % % only with Problem structure, ie no direct communication between DL and
|
idamnjanovic@42
|
315 % % solver structures)
|
idamnjanovic@42
|
316 %
|
idamnjanovic@42
|
317 %
|
idamnjanovic@42
|
318
|
idamnjanovic@42
|
319 %%
|
idamnjanovic@42
|
320 % Initialising solver structure
|
idamnjanovic@42
|
321 % Setting solver structure fields (toolbox, name, param, solution,
|
idamnjanovic@42
|
322 % reconstructed and time) to zero values
|
idamnjanovic@42
|
323 %SMALL.DL(3).D(:,225:256)=0;
|
idamnjanovic@42
|
324 SMALL.Problem.A = SMALL.DL(3).D;
|
idamnjanovic@42
|
325 SMALL.Problem.reconstruct = @(x) ImgDenoise_reconstruct(x, SMALL.Problem);
|
idamnjanovic@42
|
326 %maxatoms=32;
|
idamnjanovic@42
|
327 SMALL.solver(3)=SMALL_init_solver;
|
idamnjanovic@42
|
328
|
idamnjanovic@42
|
329 % Defining the parameters needed for denoising
|
idamnjanovic@42
|
330
|
idamnjanovic@42
|
331 % SMALL.solver(3).toolbox='SPAMS';
|
idamnjanovic@42
|
332 % SMALL.solver(3).name='mexLasso';
|
idamnjanovic@42
|
333 % SMALL.solver(3).param=struct(...
|
idamnjanovic@42
|
334 % 'mode', 1, ...
|
idamnjanovic@42
|
335 % 'lambda',Edata*Edata,...
|
idamnjanovic@42
|
336 % 'L', maxatoms);
|
idamnjanovic@42
|
337 % % Denoising the image - SMALL_denoise function is similar to SMALL_solve,
|
idamnjanovic@42
|
338 % % but backward compatible with KSVD definition of denoising
|
idamnjanovic@42
|
339 %
|
idamnjanovic@42
|
340 % SMALL.solver(3)=SMALL_solve(SMALL.Problem, SMALL.solver(3));
|
idamnjanovic@42
|
341
|
idamnjanovic@42
|
342 % Initialising solver structure
|
idamnjanovic@42
|
343 % Setting solver structure fields (toolbox, name, param, solution,
|
idamnjanovic@42
|
344 % reconstructed and time) to zero values
|
idamnjanovic@42
|
345
|
idamnjanovic@42
|
346 SMALL.solver(3)=SMALL_init_solver;
|
idamnjanovic@42
|
347
|
idamnjanovic@42
|
348 % Defining the parameters needed for image denoising
|
idamnjanovic@42
|
349
|
idamnjanovic@42
|
350 SMALL.solver(3).toolbox='ompbox';
|
idamnjanovic@42
|
351 SMALL.solver(3).name='omp2';
|
idamnjanovic@42
|
352 SMALL.solver(3).param=struct(...
|
idamnjanovic@42
|
353 'epsilon',Edata,...
|
idamnjanovic@42
|
354 'maxatoms', maxatoms);
|
idamnjanovic@42
|
355 % SMALL.solver(3).toolbox='SPAMS';
|
idamnjanovic@42
|
356 % SMALL.solver(3).name='mexLasso';
|
idamnjanovic@42
|
357 % SMALL.solver(3).param=struct(...
|
idamnjanovic@42
|
358 % 'mode', 2, ...
|
idamnjanovic@42
|
359 % 'lambda',40,...
|
idamnjanovic@42
|
360 % 'L', maxatoms);
|
idamnjanovic@42
|
361
|
idamnjanovic@42
|
362 % Denoising the image - SMALL_denoise function is similar to SMALL_solve,
|
idamnjanovic@42
|
363 % but backward compatible with KSVD definition of denoising
|
idamnjanovic@42
|
364
|
idamnjanovic@42
|
365 SMALL.solver(3)=SMALL_solve(SMALL.Problem, SMALL.solver(3));
|
idamnjanovic@42
|
366 % Plot results and save midi files
|
idamnjanovic@42
|
367 SMALL.solver(3).reconstructed.psnr
|
idamnjanovic@42
|
368 % show results %
|
idamnjanovic@42
|
369
|
idamnjanovic@42
|
370 SMALL_ImgDeNoiseResult(SMALL);
|
idamnjanovic@42
|
371 end
|
idamnjanovic@42
|
372 results(noise_ind,im_num).psnr.ksvd=SMALL.solver(1).reconstructed.psnr;
|
idamnjanovic@42
|
373 results(noise_ind,im_num).psnr.odct=SMALL.solver(2).reconstructed.psnr;
|
idamnjanovic@42
|
374 results(noise_ind,im_num).psnr.rlsdla=SMALL.solver(3).reconstructed.psnr;
|
idamnjanovic@42
|
375 results(noise_ind,im_num).vmrse.ksvd=SMALL.solver(1).reconstructed.vmrse;
|
idamnjanovic@42
|
376 results(noise_ind,im_num).vmrse.odct=SMALL.solver(2).reconstructed.vmrse;
|
idamnjanovic@42
|
377 results(noise_ind,im_num).vmrse.rlsdla=SMALL.solver(3).reconstructed.vmrse;
|
idamnjanovic@42
|
378 results(noise_ind,im_num).ssim.ksvd=SMALL.solver(1).reconstructed.ssim;
|
idamnjanovic@42
|
379 results(noise_ind,im_num).ssim.odct=SMALL.solver(2).reconstructed.ssim;
|
idamnjanovic@42
|
380 results(noise_ind,im_num).ssim.rlsdla=SMALL.solver(3).reconstructed.ssim;
|
idamnjanovic@42
|
381
|
idamnjanovic@42
|
382 results(noise_ind,im_num).time.ksvd=SMALL.solver(1).time+SMALL.DL(1).time;
|
idamnjanovic@42
|
383 results(noise_ind,im_num).time.rlsdla.time=SMALL.solver(3).time+SMALL.DL(3).time;
|
idamnjanovic@42
|
384 %clear SMALL;
|
idamnjanovic@42
|
385 end
|
idamnjanovic@42
|
386 end
|
idamnjanovic@42
|
387 save results.mat results
|