annotate Problems/AudioDenoise_reconstruct.m @ 220:0d30f9074dd9

Merge
author luisf <luis.figueira@eecs.qmul.ac.uk>
date Wed, 11 Apr 2012 15:56:39 +0100
parents f42aa8bcb82f
children
rev   line source
ivan@161 1 function reconstructed=AudioDenoise_reconstruct(y, Problem)
ivan@161 2 %% Audio denoising Problem reconstruction function
ivan@161 3 %
ivan@161 4 % This reconstruction function is using sparse representation y
ivan@161 5 % in dictionary Problem.A to reconstruct denoised audio.
ivan@161 6 % The output structre has following fields:
ivan@161 7 % audio - denoised audio signal
ivan@161 8 % psnr - psnr of the reconstructed audio signal
ivan@161 9 %
ivan@161 10 % [1] I. Damnjanovic, M. E. P. Davies, and M. P. Plumbley "SMALLbox - an
ivan@161 11 % evaluation framework for sparse representations and dictionary
ivan@161 12 % learning algorithms," V. Vigneron et al. (Eds.): LVA/ICA 2010,
ivan@161 13 % Springer-Verlag, Berlin, Germany, LNCS 6365, pp. 418-425
ivan@161 14
ivan@161 15 %
ivan@161 16 % Centre for Digital Music, Queen Mary, University of London.
ivan@161 17 % This file copyright 2011 Ivan Damnjanovic.
ivan@161 18 %
ivan@161 19 % This program is free software; you can redistribute it and/or
ivan@161 20 % modify it under the terms of the GNU General Public License as
ivan@161 21 % published by the Free Software Foundation; either version 2 of the
ivan@161 22 % License, or (at your option) any later version. See the file
ivan@161 23 % COPYING included with this distribution for more information.
ivan@161 24 %%
ivan@161 25
ivan@161 26 windowSize = Problem.windowSize;
ivan@161 27 overlap = Problem.overlap;
ivan@161 28 ws = Problem.ws(windowSize);
ivan@161 29 wa = Problem.wa(windowSize);
ivan@161 30
ivan@161 31 A = Problem.A;
ivan@161 32
ivan@161 33 orig = Problem.Original;
ivan@161 34 noisy = Problem.Noisy;
ivan@161 35
ivan@161 36
ivan@161 37 % reconstruct audio frames
ivan@161 38
ivan@161 39 xFrames = diag(ws)*(A*y);
ivan@161 40 wNormFrames = (ws.*wa)'*ones(1,size(xFrames,2));
ivan@161 41
ivan@161 42 % overlap and add
ivan@161 43
ivan@161 44 rec = col2imstep(xFrames, size(noisy), [windowSize 1], [windowSize*overlap 1]);
ivan@161 45 wNorm = col2imstep(wNormFrames, size(noisy), [windowSize 1], [windowSize*overlap 1]);
ivan@161 46 wNorm(find(wNorm==0)) = 1;
ivan@161 47 recN = rec./wNorm;
ivan@161 48
ivan@161 49 %% output structure image+psnr %%
ivan@161 50 reconstructed.audio = recN;
ivan@161 51 reconstructed.psnr = 20*log10(sqrt(numel(orig)) / norm(orig - reconstructed.audio));
ivan@161 52
ivan@161 53 end