Mercurial > hg > smallbox
comparison toolboxes/AudioInpaintingToolbox/Solvers/inpaintFrame_janssenInterpolation.m @ 138:56d719a5fd31 ivand_dev
Audio Inpaintin Toolbox
author | Ivan Damnjanovic lnx <ivan.damnjanovic@eecs.qmul.ac.uk> |
---|---|
date | Thu, 21 Jul 2011 14:27:47 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
137:9207d56c5547 | 138:56d719a5fd31 |
---|---|
1 function y = inpaintFrame_janssenInterpolation(problemData,param) | |
2 % Frame-level inpainting method based on the linear prediction by | |
3 % Janssen. | |
4 % | |
5 % Usage: xEst = inpaintFrame_janssenInterpolation(problemData,param) | |
6 % | |
7 % | |
8 % Inputs: | |
9 % - problemData.x - observed signal to be inpainted | |
10 % - problemData.Imiss - Indices of clean samples | |
11 % - param.p - Order of the autoregressive model used in | |
12 % for linear prediction | |
13 % | |
14 % Outputs: | |
15 % - y: estimated frame | |
16 % | |
17 % References: | |
18 % | |
19 % ------------------- | |
20 % | |
21 % Audio Inpainting toolbox | |
22 % Date: June 28, 2011 | |
23 % By Valentin Emiya, Amir Adler, Maria Jafari | |
24 % This code is distributed under the terms of the GNU Public License version 3 (http://www.gnu.org/licenses/gpl.txt). | |
25 | |
26 s = problemData.x; | |
27 N = length(s); | |
28 Im = find(problemData.IMiss); | |
29 IObs = find(~problemData.IMiss); | |
30 M = length(Im); | |
31 Im = sort(Im); Im = Im(:); % Im: indexes of missing samples | |
32 s(Im) = 0; | |
33 | |
34 if nargin<2 || ~isfield(param,'p') | |
35 p = min(3*M+2,round(N/3)); | |
36 else | |
37 p = param.p; | |
38 end | |
39 if nargin<2 || ~isfield(param,'GR') | |
40 param.GR = false; | |
41 end | |
42 if nargin<2 || ~isfield(param,'NIt') | |
43 NIt = 100; | |
44 else | |
45 NIt = param.NIt; | |
46 end | |
47 | |
48 | |
49 IAA = abs(Im*ones(1,N)-ones(M,1)*(1:N)); | |
50 IAA1 = IAA<=p; | |
51 AA = zeros(size(IAA)); | |
52 | |
53 if param.GR | |
54 figure; | |
55 hold on | |
56 end | |
57 for k=1:NIt | |
58 | |
59 % Re-estimation of LPC | |
60 aEst = lpc(s,p).'; | |
61 | |
62 % Re-estimation of the missing samples | |
63 b = aEst.'*hankel(aEst.',[aEst(end),zeros(1,p)]); | |
64 AA(IAA1) = b(IAA(IAA1)+1); | |
65 % xEst = -inv(AA(:,Im))*AA(:,IObs)*s(IObs); % use Chol to invert matrix | |
66 [R flagErr] = chol(AA(:,Im)); | |
67 if flagErr | |
68 % xEst = - AA(:,Im)\(AA(:,IObs)*s(IObs)); | |
69 xEst = -inv(AA(:,Im))*AA(:,IObs)*s(IObs); | |
70 else | |
71 xEst = -R\(R'\(AA(:,IObs)*s(IObs))); | |
72 end | |
73 s(Im) = xEst; | |
74 if param.GR | |
75 e = filter(aEst,1,s); | |
76 plot(k,10*log10(mean(e(p+1:end).^2)),'o') | |
77 end | |
78 end | |
79 | |
80 y = s; | |
81 | |
82 return |