Orthogonal Matching Pursuit(OMP)正交匹配追踪算法

最近学习K-SVD算法的过程中,稀疏编码部分使用了OMP追踪算法,特作此总结。
求解问题:
其中D是过完备的字典,已经给定,Y是原始信号,X待求。
OMP算法的本质思想是:以贪婪迭代的方法选择D的列,使得在每次迭代的过程中所选择的列与当前冗余向量最大程度的相关,从原始信号向量中减去相关部分并反复迭代,只到迭代次数达到稀疏度K,停止迭代。
核心算法步骤如下:
相关Matlab代码如下:
function [A]=OMP(D,X,L); 
%=============================================
% Sparse coding of a group of signals based on a given 
% dictionary and specified number of atoms to use. 
% ||X-DA||
% input arguments: 
%       D - the dictionary (its columns MUST be normalized).
%       X - the signals to represent
%       L - the max. number of coefficients for each signal.
% output arguments: 
%       A - sparse coefficient matrix.
%=============================================
[n,P]=size(X);
[n,K]=size(D);
for k=1:1:P,
    a=[];
    x=X(:,k);                            %the kth signal sample
    residual=x;                        %initial the residual vector
    indx=zeros(L,1);                %initial the index vector

     %the jth iter
    for j=1:1:L,
        
        %compute the inner product
        proj=D'*residual;            
        
        %find the max value and its index
        [maxVal,pos]=max(abs(proj));

        %store the index
        pos=pos(1);
        indx(j)=pos;                    
        
        %solve the Least squares problem.
        a=pinv(D(:,indx(1:j)))*x;    

        %compute the residual in the new dictionary
        residual=x-D(:,indx(1:j))*a;    

        
%the precision is fill our demand.
%         if sum(residual.^2) < 1e-6
%             break;
%         end
    end;
    temp=zeros(K,1);
    temp(indx(1:j))=a;
    A(:,k)=sparse(temp);
end;
return;


http://blog.sciencenet.cn/blog-810210-653094.html 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值