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