annotate util/SMALL_denoise.m @ 8:33850553b702

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