annotate toolboxes/AudioInpaintingToolbox/Solvers/inpaintFrame_OMP.m @ 247:ecce33192fcc tip

Added tag ver_2.1 for changeset cef4500b936f
author luisf <luis.figueira@eecs.qmul.ac.uk>
date Wed, 31 Oct 2012 12:24:44 +0000
parents 56d719a5fd31
children
rev   line source
ivan@138 1 function y = inpaintFrame_OMP(problemData,param)
ivan@138 2 % Inpainting method based on OMP
ivan@138 3 %
ivan@138 4 % Usage: y = inpaintFrame_OMP(problemData,param)
ivan@138 5 %
ivan@138 6 %
ivan@138 7 % Inputs:
ivan@138 8 % - problemData.x: observed signal to be inpainted
ivan@138 9 % - problemData.Imiss: Indices of clean samples
ivan@138 10 % - param.D - the dictionary matrix (optional if param.D_fun is set)
ivan@138 11 % - param.D_fun - a function handle that generates the dictionary
ivan@138 12 % matrix param.D if param.D is not given. See, e.g., DCT_Dictionary.m and Gabor_Dictionary.m
ivan@138 13 % - param.wa - Analysis window
ivan@138 14 %
ivan@138 15 % Outputs:
ivan@138 16 % - y: estimated frame
ivan@138 17 %
ivan@138 18 %
ivan@138 19 % -------------------
ivan@138 20 %
ivan@138 21 % Audio Inpainting toolbox
ivan@138 22 % Date: June 28, 2011
ivan@138 23 % By Valentin Emiya, Amir Adler, Michael Elad, Maria Jafari
ivan@138 24 % This code is distributed under the terms of the GNU Public License version 3 (http://www.gnu.org/licenses/gpl.txt).
ivan@138 25 % ========================================================
ivan@138 26 % To do next: use a faster implementation of OMP
ivan@138 27
ivan@138 28 %% Load data and parameters
ivan@138 29
ivan@138 30 x = problemData.x;
ivan@138 31 IObs = find(~problemData.IMiss);
ivan@138 32 p.N = length(x);
ivan@138 33 E2 = param.OMPerr^2;
ivan@138 34 E2M=E2*length(IObs);
ivan@138 35
ivan@138 36 wa = param.wa(param.N);
ivan@138 37
ivan@138 38
ivan@138 39 %% Build and normalized dictionary
ivan@138 40 % build the dictionary matrix if only the dictionary generation function is given
ivan@138 41 if ~isfield(param,'D')
ivan@138 42 param.D = param.D_fun(param);
ivan@138 43 end
ivan@138 44 Dict=param.D(IObs,:);
ivan@138 45 W=1./sqrt(diag(Dict'*Dict));
ivan@138 46 Dict=Dict*diag(W);
ivan@138 47 xObs=x(IObs);
ivan@138 48
ivan@138 49 %% OMP iterations
ivan@138 50 residual=xObs;
ivan@138 51 maxNumCoef = param.sparsityDegree;
ivan@138 52 indx = [];
ivan@138 53 currResNorm2 = E2M*2; % set a value above the threshold in order to have/force at least one loop executed
ivan@138 54 j = 0;
ivan@138 55 while currResNorm2>E2M && j < maxNumCoef,
ivan@138 56 j = j+1;
ivan@138 57 proj=Dict'*residual;
ivan@138 58 [dum pos] = max(abs(proj));
ivan@138 59 indx(j)=pos;
ivan@138 60
ivan@138 61 a=pinv(Dict(:,indx(1:j)))*xObs;
ivan@138 62
ivan@138 63 residual=xObs-Dict(:,indx(1:j))*a;
ivan@138 64 currResNorm2=sum(residual.^2);
ivan@138 65 end
ivan@138 66
ivan@138 67 %% Frame Reconstruction
ivan@138 68 indx(length(a)+1:end) = [];
ivan@138 69
ivan@138 70 Coeff = sparse(size(param.D,2),1);
ivan@138 71 if (~isempty(indx))
ivan@138 72 Coeff(indx) = a;
ivan@138 73 Coeff = W.*Coeff;
ivan@138 74 end
ivan@138 75 y = param.D*Coeff;
ivan@138 76
ivan@138 77 return