comparison toolboxes/AudioInpaintingToolbox/Solvers/inpaintFrame_OMP.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_OMP(problemData,param)
2 % Inpainting method based on OMP
3 %
4 % Usage: y = inpaintFrame_OMP(problemData,param)
5 %
6 %
7 % Inputs:
8 % - problemData.x: observed signal to be inpainted
9 % - problemData.Imiss: Indices of clean samples
10 % - param.D - the dictionary matrix (optional if param.D_fun is set)
11 % - param.D_fun - a function handle that generates the dictionary
12 % matrix param.D if param.D is not given. See, e.g., DCT_Dictionary.m and Gabor_Dictionary.m
13 % - param.wa - Analysis window
14 %
15 % Outputs:
16 % - y: estimated frame
17 %
18 %
19 % -------------------
20 %
21 % Audio Inpainting toolbox
22 % Date: June 28, 2011
23 % By Valentin Emiya, Amir Adler, Michael Elad, 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 % To do next: use a faster implementation of OMP
27
28 %% Load data and parameters
29
30 x = problemData.x;
31 IObs = find(~problemData.IMiss);
32 p.N = length(x);
33 E2 = param.OMPerr^2;
34 E2M=E2*length(IObs);
35
36 wa = param.wa(param.N);
37
38
39 %% Build and normalized dictionary
40 % build the dictionary matrix if only the dictionary generation function is given
41 if ~isfield(param,'D')
42 param.D = param.D_fun(param);
43 end
44 Dict=param.D(IObs,:);
45 W=1./sqrt(diag(Dict'*Dict));
46 Dict=Dict*diag(W);
47 xObs=x(IObs);
48
49 %% OMP iterations
50 residual=xObs;
51 maxNumCoef = param.sparsityDegree;
52 indx = [];
53 currResNorm2 = E2M*2; % set a value above the threshold in order to have/force at least one loop executed
54 j = 0;
55 while currResNorm2>E2M && j < maxNumCoef,
56 j = j+1;
57 proj=Dict'*residual;
58 [dum pos] = max(abs(proj));
59 indx(j)=pos;
60
61 a=pinv(Dict(:,indx(1:j)))*xObs;
62
63 residual=xObs-Dict(:,indx(1:j))*a;
64 currResNorm2=sum(residual.^2);
65 end
66
67 %% Frame Reconstruction
68 indx(length(a)+1:end) = [];
69
70 Coeff = sparse(size(param.D,2),1);
71 if (~isempty(indx))
72 Coeff(indx) = a;
73 Coeff = W.*Coeff;
74 end
75 y = param.D*Coeff;
76
77 return