comparison toolboxes/AudioInpaintingToolbox/Solvers/inpaintFrame_OMP_Gabor.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 , Coeff]= inpaintFrame_OMP_Gabor(problemData,param)
2 % Inpainting method based on OMP using the Gabor dictionary
3 % generated by Gabor_Dictionary.m. The method jointly selects
4 % cosine and sine atoms at the same frequency
5 %
6 % Usage: y = inpaintFrame_OMP_Gabor(problemData,param)
7 %
8 %
9 % Inputs:
10 % - problemData.x: observed signal to be inpainted
11 % - problemData.Imiss: Indices of clean samples
12 % - param.D - the dictionary matrix (optional if param.D_fun is set)
13 % - param.D_fun - a function handle that generates the dictionary
14 % matrix param.D if param.D is not given. See Gabor_Dictionary.m
15 % - param.wa - Analysis window
16 %
17 % Outputs:
18 % - y: estimated frame
19 %
20 %
21 % -------------------
22 %
23 % Audio Inpainting toolbox
24 % Date: June 28, 2011
25 % By Valentin Emiya, Amir Adler, Michael Elad, Maria Jafari
26 % This code is distributed under the terms of the GNU Public License version 3 (http://www.gnu.org/licenses/gpl.txt).
27 % ========================================================
28 % To do next: use a faster implementation of OMP
29
30
31 %% Load data and parameters
32
33
34 x = problemData.x;
35 IObs = find(~problemData.IMiss);
36 p.N = length(x);
37 E2 = param.OMPerr^2;
38 E2M=E2*length(IObs);
39 wa = param.wa(param.N);
40
41 %% Build and normalized dictionary
42 % build the dictionary matrix if only the dictionary generation function is given
43 if ~isfield(param,'D')
44 param.D = param.D_fun(param);
45 end
46 Dict=param.D(IObs,:);
47 W=1./sqrt(diag(Dict'*Dict));
48 Dict=Dict*diag(W);
49 Dict1 = Dict(:,1:end/2);
50 Dict2 = Dict(:,end/2+1:end);
51 Dict1Dict2 = sum(Dict1.*Dict2);
52 n12 = 1./(1-Dict1Dict2.^2);
53 xObs=x(IObs);
54
55 %% OMP iterations
56 residual=xObs;
57 maxNumCoef = param.sparsityDegree;
58 indx = [];
59 % currResNorm2 = sum(residual.^2);
60 currResNorm2 = E2M*2; % set a value above the threshold in order to have/force at least one loop executed
61 j = 0;
62 while currResNorm2>E2M && j < maxNumCoef,
63 j = j+1;
64 proj=residual'*Dict;
65 proj1 = proj(1:end/2);
66 proj2 = proj(end/2+1:end);
67
68 alpha_j = (proj1-Dict1Dict2.*proj2).*n12;
69 beta_j = (proj2-Dict1Dict2.*proj1).*n12;
70
71 err_j = sum(abs(repmat(residual,1,size(Dict1,2))-Dict1*sparse(diag(alpha_j))-Dict2*sparse(diag(beta_j))).^2);
72 [dum pos] = min(err_j);
73
74 indx(end+1)=pos;
75 indx(end+1)=pos+size(Dict1,2);
76 a=pinv(Dict(:,indx(1:2*j)))*xObs;
77 residual=xObs-Dict(:,indx(1:2*j))*a;
78 currResNorm2=sum(residual.^2);
79 end;
80
81 %% Frame Reconstruction
82 indx(length(a)+1:end) = [];
83
84 Coeff = sparse(size(param.D,2),1);
85 if (~isempty(indx))
86 Coeff(indx) = a;
87 Coeff = W.*Coeff;
88 end
89 y = param.D*Coeff;
90
91 return
92
93