comparison util/SMALL_denoise.m @ 8:33850553b702

(none)
author idamnjanovic
date Mon, 22 Mar 2010 10:56:54 +0000
parents
children fc395272d53e
comparison
equal deleted inserted replaced
7:0151f1ea080d 8:33850553b702
1 function solver=SMALL_denoise(Problem, solver)
2
3 %%% SMALL denoising
4 % Ivan Damnjanovic 2009
5 % Function gets as input SMALL structure that contains SPARCO problem to
6 % be solved, name of the toolbox and solver, and parameters file for
7 % particular solver.
8 % It is based on omp/omps denoising by Ron Rubenstein (KSVD toolbox)
9 %
10 % Outputs are denoised image, psnr, number of non-zero coeficients and
11 % time spent
12 %%
13
14 %%%%% denoise the signal %%%%%
15 fprintf('\nStarting %s... \n', solver.name);
16 start=cputime;
17 %%
18 if strcmpi(solver.toolbox,'ompbox')
19 if (~isfield(solver.param,'lambda'))
20 solver.param.lambda = Problem.maxval/(10*Problem.sigma);
21 end
22
23 solver.param = Problem;
24 %solver.param.memusage = 'high';
25 solver.param = rmfield(solver.param, {'Noisy' 'Original' 'b' 'm' 'n' 'p' 'initdict'});
26 solver.param.x = Problem.Noisy;
27 solver.param.dict = Problem.A;
28 p = Problem.signalDim;
29 msgdelta=5;
30 % call the appropriate ompdenoise function
31 if (p==1)
32 [y,nz] = ompdenoise1(solver.param,msgdelta);
33 elseif (p==2)
34 [y,nz] = ompdenoise2(solver.param,msgdelta);
35 elseif (p==3)
36 [y,nz] = ompdenoise3(solver.param,msgdelta);
37 else
38 [y,nz] = ompdenoise(solver.param,msgdelta);
39 end
40 elseif strcmpi(solver.toolbox,'ompsbox')
41 if (~isfield(solver.param,'lambda'))
42 solver.param.lambda = Problem.maxval/(10*Problem.sigma);
43 end
44
45 solver.param = Problem;
46 %solver.param.memusage = 'high';
47 solver.param = rmfield(solver.param, {'Noisy' 'Original' 'b' 'm' 'n' 'p' 'initdict'});
48 solver.param.x = Problem.Noisy;
49 if issparse(Problem.A)
50 solver.param.A = Problem.A;
51 else
52 solver.param.A = sparse(Problem.A);
53 end
54 p = Problem.signalDim;
55 msgdelta=5;
56 % call the appropriate ompdenoise function
57 if (p==1)
58 [y,nz] = ompsdenoise1(solver.param,msgdelta);
59 elseif (p==2)
60 [y,nz] = ompsdenoise2(solver.param,msgdelta);
61 elseif (p==3)
62 [y,nz] = ompsdenoise3(solver.param,msgdelta);
63 else
64 [y,nz] = ompsdenoise(solver.param,msgdelta);
65 end
66 else
67 printf('\nToolbox has not been registered. Please change SMALL_learn file.\n');
68 return
69 end
70 %%
71 solver.time = cputime - start;
72 fprintf('\n%s finished task in %2f seconds. \n', solver.name, solver.time);
73 solver.reconstructed.Image=y;
74 solver.reconstructed.psnr=20*log10(Problem.maxval * sqrt(numel(Problem.Original)) / norm(Problem.Original(:)-solver.reconstructed.Image(:)));
75 solver.reconstructed.nz=nz;
76
77 end