annotate util/SMALL_denoise.m @ 40:6416fc12f2b8

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