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