ivan@136
|
1 function reconstructed=AudioDeclipping_reconstruct(y, Problem, SparseDict)
|
ivan@136
|
2 %% Audio declipping Problem reconstruction function
|
ivan@136
|
3 %
|
ivan@136
|
4 % This reconstruction function is using sparse representation y
|
ivan@136
|
5 % in dictionary Problem.A to reconstruct the patches of the denoised
|
ivan@136
|
6 % image.
|
ivan@136
|
7
|
ivan@136
|
8 %
|
ivan@136
|
9 % Centre for Digital Music, Queen Mary, University of London.
|
ivan@136
|
10 % This file copyright 2009 Ivan Damnjanovic.
|
ivan@136
|
11 %
|
ivan@136
|
12 % This program is free software; you can redistribute it and/or
|
ivan@136
|
13 % modify it under the terms of the GNU General Public License as
|
ivan@136
|
14 % published by the Free Software Foundation; either version 2 of the
|
ivan@136
|
15 % License, or (at your option) any later version. See the file
|
ivan@136
|
16 % COPYING included with this distribution for more information.
|
ivan@136
|
17 %%
|
ivan@136
|
18
|
ivan@136
|
19 windowSize = Problem.windowSize;
|
ivan@136
|
20 overlap = Problem.overlap;
|
ivan@136
|
21 ws = Problem.ws(windowSize);
|
ivan@136
|
22 wa = Problem.wa(windowSize);
|
ivan@136
|
23 A = Problem.B;
|
ivan@136
|
24
|
ivan@136
|
25 orig = Problem.original;
|
ivan@136
|
26 clipped = Problem.clipped;
|
ivan@136
|
27 clipMask = Problem.clipMask;
|
ivan@136
|
28
|
ivan@136
|
29 % reconstruct audio frames
|
ivan@136
|
30
|
ivan@136
|
31 xFrames = diag(ws)*(A*y);
|
ivan@136
|
32 wNormFrames = (ws.*wa)'*ones(1,size(xFrames,2));
|
ivan@136
|
33
|
ivan@136
|
34 % overlap and add
|
ivan@136
|
35
|
ivan@136
|
36 rec = col2imstep(xFrames, size(clipped), [windowSize 1], [windowSize*overlap 1]);
|
ivan@136
|
37 wNorm = col2imstep(wNormFrames, size(clipped), [windowSize 1], [windowSize*overlap 1]);
|
ivan@136
|
38 wNorm(find(wNorm==0)) = 1;
|
ivan@136
|
39 recN = rec./wNorm;
|
ivan@136
|
40
|
ivan@136
|
41 % change only clipped samples
|
ivan@136
|
42
|
ivan@136
|
43 recSignal = orig.*double(~clipMask) + recN.*double(clipMask);
|
ivan@136
|
44
|
ivan@136
|
45 %% output structure image+psnr %%
|
ivan@136
|
46 reconstructed.audioAllSamples = recN;
|
ivan@136
|
47 reconstructed.audioOnlyClipped = recSignal;
|
ivan@136
|
48 [reconstructed.snrAll , reconstructed.snrMiss] = SNRInpaintingPerformance(orig, clipped, recSignal, clipMask, 1);
|
ivan@136
|
49
|
ivan@136
|
50 end |