annotate util/Pierre_reconstruct.m @ 38:84b7c44e54c4

(none)
author idamnjanovic
date Mon, 14 Mar 2011 15:33:18 +0000
parents fc395272d53e
children 0e2959c83824
rev   line source
idamnjanovic@8 1 function reconstructed=Pierre_reconstruct(y, Problem)
idamnjanovic@24 2 %%% Pierre Villars Example - reconstruction function
idamnjanovic@24 3 %
idamnjanovic@24 4 % Centre for Digital Music, Queen Mary, University of London.
idamnjanovic@24 5 % This file copyright 2009 Ivan Damnjanovic.
idamnjanovic@24 6 %
idamnjanovic@24 7 % This program is free software; you can redistribute it and/or
idamnjanovic@24 8 % modify it under the terms of the GNU General Public License as
idamnjanovic@24 9 % published by the Free Software Foundation; either version 2 of the
idamnjanovic@24 10 % License, or (at your option) any later version. See the file
idamnjanovic@24 11 % COPYING included with this distribution for more information.
idamnjanovic@24 12 %
idamnjanovic@8 13 % This example is based on the experiment suggested by Professor Pierre
idamnjanovic@8 14 % Vandergheynst on the SMALL meeting in Villars.
idamnjanovic@8 15
idamnjanovic@8 16 % using sparse representation y in dictionary Problem.A reconstruct the
idamnjanovic@8 17 % patches from the target image
idamnjanovic@8 18
idamnjanovic@8 19 imout=Problem.A*y;
idamnjanovic@8 20
idamnjanovic@8 21 % combine the patches into reconstructed image
idamnjanovic@8 22
idamnjanovic@8 23 im=col2im(imout,Problem.blocksize,size(Problem.imageTrg),'disctint');
idamnjanovic@8 24
idamnjanovic@8 25 % bound the pixel values to [0,255] range
idamnjanovic@8 26 im(im<0)=0;
idamnjanovic@8 27 im(im>255)=255;
idamnjanovic@8 28
idamnjanovic@8 29 %% output structure image+psnr %%
idamnjanovic@8 30 reconstructed.image=im;
idamnjanovic@8 31 reconstructed.psnr = 20*log10(Problem.maxval * sqrt(numel(Problem.imageTrg(:))) / norm(Problem.imageTrg(:)-im(:)));
idamnjanovic@8 32 end