0、符号说明如下
1、ROMP重构算法流程
正则化正交匹配追踪算法流程与OMP的最大不同之处就在于从传感矩阵A中选择列向量的标准,OMP每次只选择与残差内积绝对值最大的那一列,而ROMP则是先选出内积绝对值最大的K列(若所有内积中不够K个非零值则将内积值非零的列全部选出),然后再从这K列中按正则化标准再选择一遍,即为本次迭代选出的列向量(一般并非只有一列)。正则化标准意思是选择各列向量与残差内积绝对值的最大值不能比最小值大两倍以上(comparable coordinates)且能量最大的一组(with the maximal energy),因为满足条件的子集并非只有一组。似乎用叙述语言描述不清楚,下面给出一种实现第(2)(3)步的算法流程图: 贴出文献[1]中的算法流程:
function[val,pos]=Regularize(product,Kin)
% Regularize Summary of this function goes here
% Detailed explanation goes here
% product = A'*r_n;%传感矩阵A各列与残差的内积
% K为稀疏度
% pos为选出的各列序号
% val为选出的各列与残差的内积值
% Reference:Needell D,Vershynin R. Uniform uncertainty principle and
% signal recovery via regularized orthogonal matching pursuit.
% Foundations of Computational Mathematics, 2009,9(3): 317-334.
productabs=abs(product);%取绝对值
[productdes,indexproductdes]=sort(productabs,'descend');%降序排列
for ii=length(productdes):-1:1
if productdes(ii)>1e-6%判断productdes中非零值个数
break;
end
end
%Identify:Choose a set J of the K biggest coordinates
if ii>=Kin
J=indexproductdes(1:Kin);%集合J
Jval=productdes(1:Kin);%集合J对应的序列值
K=Kin;
else%or all of its nonzero coordinates,whichever is smaller
J=indexproductdes(1:ii);%集合J
Jval=productdes(1:ii);%集合J对应的序列值
K=ii;
end
%Regularize:Among all subsets J0∈J with comparable coordinates
MaxE=-1;%循环过程中存储最大能量值
for kk=1:K
J0_tmp=zeros(1,K);iJ0=1;
J0_tmp(iJ0)=J(kk);%以J(kk)为本次寻找J0的基准(最大值)
Energy=Jval(kk)^2;%本次寻找J0的能量
for mm=kk+1:K
if Jval(kk)<2*Jval(mm)%找到符合|u(i)|<=2|u(j)|的
iJ0=iJ0+1;%J0自变量增1
J0_tmp(iJ0)=J(mm);%更新J0
Energy=Energy+Jval(mm)^2;%更新能量
else%不符合|u(i)|<=2|u(j)|的
break;%跳出本轮寻找,因为后面更小的值也不会符合要求
end
end
if Energy>MaxE%本次所得J0的能量大于前一组
J0=J0_tmp(1:iJ0);%更新J0
MaxE=Energy;%更新MaxE,为下次循环做准备
end
end
pos=J0;
val=productabs(J0);
end
第12行代码中用到了函数sort进行排序,采用的是降序方式,indexproductdes索引中保存的是排序后的内积值productdes在原来集合productabs中原来所在的位置。
第13-17行判断大于0的内积值的个数,并在第19到27行中进行选择,将内积值所对应的列序号形成集合J,并将所选择的内积值组成集合Jval。
第29行,首先初始化 MaxE为-1.
第30行,接下来是在第某次选择出的J中选择子集J0 ,总共迭代K次,K为原始信号非零元素的个数。


2、正则化正交匹配追踪(ROMP)MATLAB代码(CS_ROMP.m)
function [ theta ] = CS_ROMP( y,A,K )
%CS_ROMP Summary of this function goes here
%Version: 1.0 written by jbb0523 @2015-04-24
% Detailed explanation goes here
% y = Phi * x
% x = Psi * theta
% y = Phi*Psi * theta
% 令 A = Phi*Psi, 则y=A*theta
% 现在已知y和A,求theta
% Reference:Needell D,Vershynin R.Signal recovery from incomplete and
% inaccurate measurements via regularized orthogonal matching pursuit[J].
% IEEE Journal on Selected Topics in Signal Processing,2010,4(2):310—316.
[y_rows,y_columns] = size(y);
if y_rows<y_columns
y = y';%y should be a column vector
end
[M,N] = size(A);%传感矩阵A为M*N矩阵
theta = zeros(N,1);%用来存储恢复的theta(列向量)
At = zeros(M,3*K);%用来迭代过程中存储A被选择的列
Pos_theta = zeros(1,2*K);%用来迭代过程中存储A被选择的列序号
Index = 0;
r_n = y;%初始化残差(residual)为y
%Repeat the following steps K times(or until |I|>=2K)
for ii=1:K%迭代K次
product = A'*r_n;%传感矩阵A各列与残差的内积
%[val,pos] = max(abs(product));%找到最大内积绝对值,即与残差最相关的列
[val,pos] = Regularize(product,K);%按正则化规则选择原子
At(:,Index+1:Index+length(pos)) = A(:,pos);%存储这几列
Pos_theta(Index+1:Index+length(pos)) = pos;%存储这几列的序号
if Index+length(pos)<=M%At的行数大于列数,此为最小二乘的基础(列线性无关)
Index = Index+length(pos);%更新Index,为下次循环做准备
else%At的列数大于行数,列必为线性相关的,At(:,1:Index)'*At(:,1:Index)将不可逆
break;%跳出for循环
end
A(:,pos) = zeros(M,length(pos));%清零A的这几列(其实此行可以不要因为它们与残差正交)
%y=At(:,1:Index)*theta,以下求theta的最小二乘解(Least Square)
theta_ls = (At(:,1:Index)'*At(:,1:Index))^(-1)*At(:,1:Index)'*y;%最小二乘解
%At(:,1:Index)*theta_ls是y在At(:,1:Index)列空间上的正交投影
r_n = y - At(:,1:Index)*theta_ls;%更新残差
if norm(r_n)<1e-6%Repeat the steps until r=0
break;%跳出for循环
end
if Index>=2*K%or until |I|>=2K
break;%跳出for循环
end
end
theta(Pos_theta(1:Index))=theta_ls;%恢复出的theta
end
相比CS_OMP.m,ROMP所做的修改已用颜色标出。
首先解释下第19行和20行,博客中的解释是:
然后我还是没有太明白,但是传感矩阵满足2K阶RIP,满足2K阶RIP的矩阵任意2K列线性无关。可能跟这个有关系,以后再看看。

3、ROMP单次重构测试代码
%压缩感知重构算法测试
clear all;close all;clc;
M=128;%观测值个数
N=256;%信号x的长度
K=12;%信号x的稀疏度
Index_K=randperm(N);
x=zeros(N,1);
x(Index_K(1:K))=5*randn(K,1);%x为K稀疏的,且位置是随机的
Psi=eye(N);%x本身是稀疏的,定义稀疏矩阵为单位阵x=Psi*theta
Phi=randn(M,N);%测量矩阵为高斯矩阵
A=Phi*Psi;%传感矩阵
y=Phi*x;%得到观测向量y
%% 恢复重构信号x
tic
theta=CS_ROMP(y,A,K);
x_r=Psi*theta;% x=Psi * theta
toc
%% 绘图
figure;
plot(x_r,'k.-');%绘出x的恢复信号
hold on;
plot(x,'r');%绘出原信号x
hold off;
legend('Recovery','Original')
fprintf('\n恢复残差:');
norm(x_r-x)%恢复残差


4、测量数M与重构成功概率关系曲线绘制例程代码
clear all;close all;clc;
%% 参数配置初始化
CNT=1000;%对于每组(K,M,N),重复迭代次数
N=256;%信号x的长度
Psi=eye(N);%x本身是稀疏的,定义稀疏矩阵为单位阵x=Psi*theta
K_set=[4,12,20,28,36];%信号x的稀疏度集合
Percentage=zeros(length(K_set),N);%存储恢复成功概率
%% 主循环,遍历每组(K,M,N)
tic
forkk=1:length(K_set)
K=K_set(kk);%本次稀疏度
M_set=K:5:N;%M没必要全部遍历,每隔5测试一个就可以了
PercentageK=zeros(1,length(M_set));%存储此稀疏度K下不同M的恢复成功概率
kk
formm=1:length(M_set)
M=M_set(mm)%本次观测值个数
P=0;
forcnt=1:CNT%每个观测值个数均运行CNT次
Index_K=randperm(N);
x=zeros(N,1);
x(Index_K(1:K))=5*randn(K,1);%x为K稀疏的,且位置是随机的的
Phi=randn(M,N);%测量矩阵为高斯矩阵
A=Phi*Psi;%传感矩阵
y=Phi*x;%得到观测向量y
theta=CS_ROMP(y,A,K);%恢复重构信号theta
x_r=Psi*theta;% x=Psi * theta
ifnorm(x_r-x)<1e-6%如果残差小于1e-6则认为恢复成功
P=P+1;
end
end
PercentageK(mm)=P/CNT*100;%计算恢复概率
end
Percentage(kk,1:length(M_set))=PercentageK;
end
toc
save ROMPMtoPercentage1000%运行一次不容易,把变量全部存储下来
%% 绘图
S=['-ks';'-ko';'-kd';'-kv';'-k*'];
figure;
forkk=1:length(K_set)
K=K_set(kk);
M_set=K:5:N;
L_Mset=length(M_set);
plot(M_set,Percentage(kk,1:L_Mset),S(kk,:));%绘出x的恢复信号
hold on;
end
hold off;
xlim([0256]);
legend('K=4','K=12','K=20','K=28','K=36');
xlabel('Number of measurements(M)');
ylabel('Percentage recovered');
title('Percentage of input signals recovered correctly(N=256)(Gaussian)');
本程序运行结果: