annotate util/SMALL_denoise.m @ 155:b14209313ba4 ivand_dev

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