OMP.m 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. function [ x ] = OMP( y , D , k )
  2. % Author: Clément DORFFER
  3. % Date: 26/11/2018
  4. % @: clement.dorffer@ensta-bretagne.fr
  5. % Goal: perform a sparse approximation of a signal y using a weighted Orthogonal Matching Pursuit (OMP) technique
  6. % which was used in:
  7. %
  8. % C. Dorffer, M. Puigt, G. Delmaire, G. Roussel, Informed Nonnegative Matrix Factorization Methods for
  9. % Mobile Sensor Network Calibration, IEEE Transactions on Signal and Information Processing over Networks,
  10. % Volume 4, Issue 4, pp. 667-682, December 2018 ;
  11. %
  12. % and is inspired by the original OMP technique proposed in:
  13. %
  14. % Y. Pati, R. Rezaiifar, P. Krishnaprasad, Orthogonal Matching Pursuit: recursive function approximation
  15. % with application to wavelet decomposition, in Proc. IEEE ACSSC'93, 1993.
  16. %
  17. residual = y;
  18. Atoms_sel = zeros(k,1);
  19. D_select = zeros(size(D,1),k);
  20. x_OMP = zeros(k,1);
  21. for iter = 1 : k
  22. [ ~ , idx_max ] = max(abs(residual'*D));
  23. Atoms_sel(iter) = idx_max;
  24. D_select(:,iter) = D(:,Atoms_sel(iter));
  25. for j = 1 : iter-1
  26. D_select(:,iter) = D_select(:,iter)-real(D_select(:,iter)'*D_select(:,j))*D_select(:,j);
  27. end
  28. D_select(:,iter) = D_select(:,iter)/norm(D_select(:,iter));
  29. x_OMP(iter) = real(D_select(:,iter)'*residual);
  30. residual = residual-D_select(:,iter)*x_OMP(iter);
  31. end
  32. x = zeros(size(D,2),1);
  33. x(Atoms_sel) = real(D(:,Atoms_sel)\y);