淺談壓縮感知(二十六):壓縮感知重構算法之分段弱正交匹配追蹤(SWOMP)

主要內容:算法

  1. SWOMP的算法流程
  2. SWOMP的MATLAB實現
  3. 一維信號的實驗與結果
  4. 門限參數a、測量數M與重構成功機率關係的實驗與結果
  5. SWOMP與StOMP性能比較

1、SWOMP的算法流程

分段弱正交匹配追蹤(Stagewise Weak OMP)能夠說是StOMP的一種修改算法,它們的惟一不一樣是選擇原子時的門限設置,這能夠下降對測量矩陣的要求。咱們稱這裏的原子選擇方式爲"弱選擇"(Weak Selection),StOMP的門限設置由殘差決定,這對測量矩陣(原子選擇)提出了要求,而SWOMP的門限設置則對測量矩陣要求較低(原子選擇相對簡單、粗糙)。性能

SWOMP的算法流程:測試

2、SWOMP的MATLAB實現(CS_SWOMP.m)

function [ theta ] = CS_SWOMP( y,A,S,alpha )
%   CS_SWOMP
%   Detailed explanation goes here
%   y = Phi * x
%   x = Psi * theta
%    y = Phi*Psi * theta
%   令 A = Phi*Psi, 則y=A*theta
%   S is the maximum number of SWOMP iterations to perform
%   alpha is the threshold parameter
%   如今已知y和A,求theta
%   Reference:Thomas Blumensath,Mike E. Davies.Stagewise weak gradient
%   pursuits[J].IEEE Transactions on Signal Processing,200957(11):4333-4346if nargin < 4
        alpha = 0.5; %alpha範圍(0,1),默認值爲0.5
    end
    if nargin < 3
        S = 10; %S默認值爲10
    end
    [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(列向量)
    Pos_theta = []; %用來迭代過程當中存儲A被選擇的列序號
    r_n = y; %初始化殘差(residual)爲y
    for ss=1:S %最多迭代S次
        product = A'*r_n; %傳感矩陣A各列與殘差的內積
        sigma = max(abs(product));
        Js = find(abs(product)>=alpha*sigma); %選出大於閾值的列
        Is = union(Pos_theta,Js); %Pos_theta與Js並集
        if length(Pos_theta) == length(Is)
            if ss==1
                theta_ls = 0; %防止第1次就跳出致使theta_ls無定義
            end
            break; %若是沒有新的列被選中則跳出循環
        end
        %At的行數要大於列數,此爲最小二乘的基礎(列線性無關)
        if length(Is)<=M
            Pos_theta = Is; %更新列序號集合
            At = A(:,Pos_theta); %將A的這幾列組成矩陣At
        else%At的列數大於行數,列必爲線性相關的,At'*At將不可逆
            if ss==1
                theta_ls = 0; %防止第1次就跳出致使theta_ls無定義
            end
            break; %跳出for循環
        end
        %y=At*theta,如下求theta的最小二乘解(Least Square)
        theta_ls = (At'*At)^(-1)*At'*y; %最小二乘解
        %At*theta_ls是y在At列空間上的正交投影
        r_n = y - At*theta_ls; %更新殘差
        if norm(r_n)<1e-6 %Repeat the steps until r=0
            break; %跳出for循環
        end
    end
    theta(Pos_theta)=theta_ls;%恢復出的theta
end

3、一維信號的實驗與結果

%壓縮感知重構算法測試
clear all;close all;clc;
M = 128; %觀測值個數
N = 256; %信號x的長度
K = 30; %信號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)/sqrt(M); %測量矩陣爲高斯矩陣
A = Phi * Psi; %傳感矩陣
y = Phi * x; %獲得觀測向量y

%% 恢復重構信號x
tic
theta = CS_SWOMP( y,A);
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、門限參數a、測量數M與重構成功機率關係的實驗與結果

一、門限參數a分別爲0.1-1.0時,不一樣稀疏信號下,測量值M與重構成功機率的關係:ui

clear all;close all;clc;

%% 參數配置初始化
CNT = 1000; %對於每組(K,M,N),重複迭代次數
N = 256; %信號x的長度
Psi = eye(N); %x自己是稀疏的,定義稀疏矩陣爲單位陣x=Psi*theta
alpha_set = 0.1:0.1:1;
K_set = [4,12,20,28,36]; %信號x的稀疏度集合
Percentage = zeros(N,length(K_set),length(alpha_set)); %存儲恢復成功機率

%% 主循環,遍歷每組(alpha,K,M,N)
tic
for tt = 1:length(alpha_set)
    alpha = alpha_set(tt);
    for kk = 1:length(K_set)
        K = K_set(kk); %本次稀疏度
        %M不必所有遍歷,每隔5測試一個就能夠了
        M_set=2*K:5:N;
        PercentageK = zeros(1,length(M_set)); %存儲此稀疏度K下不一樣M的恢復成功機率
        for mm = 1:length(M_set)
           M = M_set(mm); %本次觀測值個數
           fprintf('alpha=%f,K=%d,M=%d\n',alpha,K,M);
           P = 0;
           for cnt = 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)/sqrt(M); %測量矩陣爲高斯矩陣
                A = Phi * Psi; %傳感矩陣
                y = Phi * x; %獲得觀測向量y
                theta = CS_SWOMP(y,A,10,alpha); %恢復重構信號theta
                x_r = Psi * theta; % x=Psi * theta
                if norm(x_r-x)<1e-6 %若是殘差小於1e-6則認爲恢復成功
                    P = P + 1;
                end
           end
           PercentageK(mm) = P/CNT*100; %計算恢復機率
        end
        Percentage(1:length(M_set),kk,tt) = PercentageK;
    end
end
toc
save SWOMPMtoPercentage1000 %運行一次不容易,把變量所有存儲下來

%% 繪圖
for tt = 1:length(alpha_set)
    S = ['-ks';'-ko';'-kd';'-kv';'-k*'];
    figure;
    for kk = 1:length(K_set)
        K = K_set(kk);
        M_set=2*K:5:N;
        L_Mset = length(M_set);
        plot(M_set,Percentage(1:L_Mset,kk,tt),S(kk,:));%繪出x的恢復信號
        hold on;
    end
    hold off;
    xlim([0 256]);
    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,alpha=',...
        num2str(alpha_set(tt)),')(Gaussian)']);
end
for kk = 1:length(K_set)
    K = K_set(kk);
    M_set=2*K:5:N;
    L_Mset = length(M_set);
    S = ['-ks';'-ko';'-kd';'-k*';'-k+';'-kx';'-kv';'-k^';'-k<';'-k>'];
    figure;
    for tt = 1:length(alpha_set)
        plot(M_set,Percentage(1:L_Mset,kk,tt),S(tt,:));%繪出x的恢復信號
        hold on;
    end
    hold off;
    xlim([0 256]);
    legend('alpha=0.1','alpha=0.2','alpha=0.3','alpha=0.4','alpha=0.5',...
        'alpha=0.6','alpha=0.7','alpha=0.8','alpha=0.9','alpha=1.0');
    xlabel('Number of measurements(M)');
    ylabel('Percentage recovered');
    title(['Percentage of input signals recovered correctly(N=256,K=',...
        num2str(K),')(Gaussian)']);    
end

  

  

二、稀疏度爲4,12,20,28,36時,不一樣門限參數a下,測量值M與重構成功機率的關係:spa

clear all;close all;clc;
load StOMPMtoPercentage1000;
PercentageStOMP = Percentage;
S = ['-ks';'-ko';'-kd';'-kv';'-k*'];
figure;
for kk = 1:length(K_set)
    K = K_set(kk);
    M_set=2*K:5:N;
    L_Mset = length(M_set);
    %ts_set = 2:0.2:3;第3個爲2.4
    plot(M_set,Percentage(1:L_Mset,kk,3),S(kk,:));%繪出x的恢復信號
    hold on;
end
load SWOMPMtoPercentage1000;
PercentageSWOMP = Percentage;
S = ['-rs';'-ro';'-rd';'-rv';'-r*'];
for kk = 1:length(K_set)
    K = K_set(kk);
    M_set=2*K:5:N;
    L_Mset = length(M_set);
    %alpha_set = 0.1:0.1:1;第6個爲0.6
    plot(M_set,Percentage(1:L_Mset,kk,6),S(kk,:));%繪出x的恢復信號
    hold on;
end
hold off;
xlim([0 256]);
legend('StK=4','StK=12','StK=20','StK=28','StK=36',...
    'SWK=4','SWK=12','SWK=20','SWK=28','SWK=36');
xlabel('Number of measurements(M)');
ylabel('Percentage recovered');
title(['Percentage of input signals recovered correctly(N=256,ts=2.4,\alpha=0.5)(Gaussian)']);

 

   

結論:.net

經過對比能夠看出,整體上講a=0.6時效果較好。3d

5、SWOMP與StOMP性能比較

對比StOMP中ts=2.4與SWOMP中α=0.6的狀況:StOMP要略好於SWOMP。code

6、參考文章

http://blog.csdn.net/jbb0523/article/details/45441601orm

相關文章
相關標籤/搜索