idamnjanovic@8: function solver=SMALL_denoise(Problem, solver) idamnjanovic@8: idamnjanovic@8: %%% SMALL denoising idamnjanovic@8: % Ivan Damnjanovic 2009 idamnjanovic@8: % Function gets as input SMALL structure that contains SPARCO problem to idamnjanovic@8: % be solved, name of the toolbox and solver, and parameters file for idamnjanovic@8: % particular solver. idamnjanovic@8: % It is based on omp/omps denoising by Ron Rubenstein (KSVD toolbox) idamnjanovic@8: % idamnjanovic@8: % Outputs are denoised image, psnr, number of non-zero coeficients and idamnjanovic@8: % time spent idamnjanovic@8: %% idamnjanovic@8: idamnjanovic@8: %%%%% denoise the signal %%%%% idamnjanovic@8: fprintf('\nStarting %s... \n', solver.name); idamnjanovic@8: start=cputime; idamnjanovic@8: %% idamnjanovic@8: if strcmpi(solver.toolbox,'ompbox') idamnjanovic@8: if (~isfield(solver.param,'lambda')) idamnjanovic@8: solver.param.lambda = Problem.maxval/(10*Problem.sigma); idamnjanovic@8: end idamnjanovic@8: idamnjanovic@8: solver.param = Problem; idamnjanovic@8: %solver.param.memusage = 'high'; idamnjanovic@8: solver.param = rmfield(solver.param, {'Noisy' 'Original' 'b' 'm' 'n' 'p' 'initdict'}); idamnjanovic@8: solver.param.x = Problem.Noisy; idamnjanovic@8: solver.param.dict = Problem.A; idamnjanovic@8: p = Problem.signalDim; idamnjanovic@8: msgdelta=5; idamnjanovic@8: % call the appropriate ompdenoise function idamnjanovic@8: if (p==1) idamnjanovic@8: [y,nz] = ompdenoise1(solver.param,msgdelta); idamnjanovic@8: elseif (p==2) idamnjanovic@8: [y,nz] = ompdenoise2(solver.param,msgdelta); idamnjanovic@8: elseif (p==3) idamnjanovic@8: [y,nz] = ompdenoise3(solver.param,msgdelta); idamnjanovic@8: else idamnjanovic@8: [y,nz] = ompdenoise(solver.param,msgdelta); idamnjanovic@8: end idamnjanovic@8: elseif strcmpi(solver.toolbox,'ompsbox') idamnjanovic@8: if (~isfield(solver.param,'lambda')) idamnjanovic@8: solver.param.lambda = Problem.maxval/(10*Problem.sigma); idamnjanovic@8: end idamnjanovic@8: idamnjanovic@8: solver.param = Problem; idamnjanovic@8: %solver.param.memusage = 'high'; idamnjanovic@8: solver.param = rmfield(solver.param, {'Noisy' 'Original' 'b' 'm' 'n' 'p' 'initdict'}); idamnjanovic@8: solver.param.x = Problem.Noisy; idamnjanovic@8: if issparse(Problem.A) idamnjanovic@8: solver.param.A = Problem.A; idamnjanovic@8: else idamnjanovic@8: solver.param.A = sparse(Problem.A); idamnjanovic@8: end idamnjanovic@8: p = Problem.signalDim; idamnjanovic@8: msgdelta=5; idamnjanovic@8: % call the appropriate ompdenoise function idamnjanovic@8: if (p==1) idamnjanovic@8: [y,nz] = ompsdenoise1(solver.param,msgdelta); idamnjanovic@8: elseif (p==2) idamnjanovic@8: [y,nz] = ompsdenoise2(solver.param,msgdelta); idamnjanovic@8: elseif (p==3) idamnjanovic@8: [y,nz] = ompsdenoise3(solver.param,msgdelta); idamnjanovic@8: else idamnjanovic@8: [y,nz] = ompsdenoise(solver.param,msgdelta); idamnjanovic@8: end idamnjanovic@8: else idamnjanovic@8: printf('\nToolbox has not been registered. Please change SMALL_learn file.\n'); idamnjanovic@8: return idamnjanovic@8: end idamnjanovic@8: %% idamnjanovic@8: solver.time = cputime - start; idamnjanovic@8: fprintf('\n%s finished task in %2f seconds. \n', solver.name, solver.time); idamnjanovic@8: solver.reconstructed.Image=y; idamnjanovic@8: solver.reconstructed.psnr=20*log10(Problem.maxval * sqrt(numel(Problem.Original)) / norm(Problem.Original(:)-solver.reconstructed.Image(:))); idamnjanovic@8: solver.reconstructed.nz=nz; idamnjanovic@8: idamnjanovic@8: end