annotate Problems/ImgDenoise_reconstruct.m @ 139:4bd6856a7128 ivand_dev

ompGabor mex version debuged and tested
author Ivan <ivan.damnjanovic@eecs.qmul.ac.uk>
date Thu, 21 Jul 2011 16:37:14 +0100
parents 8e660fd14774
children
rev   line source
idamnjanovic@45 1 function reconstructed=ImgDenoise_reconstruct(y, Problem, SparseDict)
ivan@128 2 %% Image Denoising Problem reconstruction function
ivan@128 3 %
ivan@128 4 % This reconstruction function is using sparse representation y
ivan@128 5 % in dictionary Problem.A to reconstruct the patches of the denoised
ivan@128 6 % image.
ivan@128 7
idamnjanovic@45 8 %
idamnjanovic@45 9 % Centre for Digital Music, Queen Mary, University of London.
idamnjanovic@45 10 % This file copyright 2009 Ivan Damnjanovic.
idamnjanovic@45 11 %
idamnjanovic@45 12 % This program is free software; you can redistribute it and/or
idamnjanovic@45 13 % modify it under the terms of the GNU General Public License as
idamnjanovic@45 14 % published by the Free Software Foundation; either version 2 of the
idamnjanovic@45 15 % License, or (at your option) any later version. See the file
idamnjanovic@45 16 % COPYING included with this distribution for more information.
ivan@128 17 %%
idamnjanovic@45 18
idamnjanovic@45 19
idamnjanovic@45 20 % stepsize %
idamnjanovic@45 21 if (isfield(Problem,'stepsize'))
idamnjanovic@45 22 stepsize = Problem.stepsize;
idamnjanovic@45 23 if (numel(stepsize)==1)
idamnjanovic@45 24 stepsize = ones(1,2)*stepsize;
idamnjanovic@45 25 end
idamnjanovic@45 26 else
idamnjanovic@45 27 stepsize = ones(1,2);
idamnjanovic@45 28 end
idamnjanovic@45 29 if (any(stepsize<1))
idamnjanovic@45 30 error('Invalid step size.');
idamnjanovic@45 31 end
idamnjanovic@45 32
idamnjanovic@45 33 % lambda %
idamnjanovic@45 34 if (isfield(Problem,'lambda'))
idamnjanovic@45 35 lambda = Problem.lambda;
idamnjanovic@45 36 else
idamnjanovic@45 37 lambda = Problem.maxval/(10*Problem.sigma);
idamnjanovic@45 38 end
idamnjanovic@45 39 if exist('SparseDict','var')&&(SparseDict==1)
idamnjanovic@45 40 if issparse(Problem.A)
idamnjanovic@45 41 A = Problem.A;
idamnjanovic@45 42 else
idamnjanovic@45 43 A = sparse(Problem.A);
idamnjanovic@45 44 end
idamnjanovic@45 45 cl_samp=add_dc(dictsep(Problem.basedict,A,y), Problem.b1dc,'columns');
idamnjanovic@45 46 else
idamnjanovic@45 47 cl_samp=add_dc(Problem.A*y, Problem.b1dc,'columns');
idamnjanovic@45 48 end
idamnjanovic@45 49 % combine the patches into reconstructed image
idamnjanovic@45 50 cl_im=col2imstep(cl_samp, size(Problem.Noisy), Problem.blocksize);
idamnjanovic@45 51
idamnjanovic@45 52 cnt = countcover(size(Problem.Noisy),Problem.blocksize,stepsize);
idamnjanovic@45 53
idamnjanovic@45 54 im = (cl_im+lambda*Problem.Noisy)./(cnt + lambda);
idamnjanovic@45 55 % y(y~=0)=1;
idamnjanovic@45 56 % numD=sum(y,2);
idamnjanovic@45 57 % nnzy=sum(y,1);
idamnjanovic@45 58 % figure(200);plot(sort(numD));
idamnjanovic@45 59 % figure(201);plot(sort(nnzy));
ivan@116 60 [v.RMSErn, v.RMSEcd, v.rn_im, v.cd_im]=SMALL_vmrse_type2(Problem.Original, Problem.Noisy, im);
idamnjanovic@45 61 %% output structure image+psnr %%
idamnjanovic@45 62 reconstructed.Image=im;
idamnjanovic@45 63 reconstructed.psnr = 20*log10(Problem.maxval * sqrt(numel(Problem.Original(:))) / norm(Problem.Original(:)-im(:)));
idamnjanovic@45 64 reconstructed.vmrse=v;
ivan@116 65 reconstructed.ssim=SMALL_ssim_index(Problem.Original, im);
idamnjanovic@45 66 end