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