资源简介

稀疏度自适应匹配追踪算法,无需稀疏度,就可以重构原始信号。

资源截图

代码片段和文件信息

function SAMP()
clc;clear;
X=imread(‘lena256.bmp‘);
X=double(X);
[ab]=size(X);                %读图像数据

ww=DWT(a);                    %小波变换
X1=ww*sparse(X)*ww‘;
X1=full(X1);                  %稀疏信号

M=128;
Phi=randn(Ma);
Phi=orth(Phi‘)‘;              %测量矩阵归一化

y=Phi*X1;                     %测量信号值

X2=zeros(ab); 
tic
display(‘Running SAMP...‘);
for l=1:b
    rec=samp(y(:l)Phia);
    X2(:l)=rec;              %重构稀疏信号
end                         
ElapsedTime=toc;                                                             %计算CPU的运行时间
fprintf(‘Done... Elapsed Time=%f\n‘ ElapsedTime)
X3=ww‘*sparse(X2)*ww;         %小波变换
X3=full(X3);                  %近似信号

figure(1)
imshow(uint8(X));
title(‘原始图像‘);

figure(2)
imshow(uint8(X1));
title(‘小波稀疏基下的图像‘);

figure(3)
imshow(uint8(X3));
title(‘恢复图像‘);
errorx=sum(sum(abs(X3-X).^2))                                    %  MSE误差
psnr=10*log10(255*255/(errorx/a/b))                              %  峰值信噪比
Relative_error = sum(sum(abs(X3-X).^2))/sum(sum(abs(X).^2))     %  相对误差
SNR = 20*log10(norm(X)/norm(X-X3))                               %  信噪比
Mat_rate = 1 - norm(abs(X3)-abs(X))/norm(abs(X3)+abs(X))        %  匹配度


function hat_x=samp(yTN)

r_n=y;                                 %残差初始值y
hat_x=zeros(N1);                      %函数返回值
active_set = [];
s=10;                                   %步长s
j=1;                                   %步长索引j
L=s;                                   %挑出L个
while (norm(r_n)>1e-2)

    [~pos]=sort(abs(T‘*r_n)‘descend‘);
    candidate_set=union(active_set pos(1:L));
    
    [~pos]=sort(abs(pinv(T(:candidate_set))*y)‘descend‘);
    new_active_set=candidate_set(pos(1:L));
    
    r_cur= y-T(:new_active_set)*pinv(T(:new_active_set))*y;
     
    if (norm(r_cur) > norm(r_n)) 
       j=j+1;
       L=j*s;
    else
   r_n = r_cur;  
       active_set= new_active_set;
    end
end

xr_active_set= pinv(T(:active_set))*y;
hat_x(active_set)=xr_active_set;

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     文件        2118  2013-05-27 10:40  SAMP.m

评论

共有 条评论