• 大小: 810KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-06-19
  • 语言: Matlab
  • 标签:

资源简介

该程序包中包含了传感压缩算法中的五个经典算法源码:COSAMP,GBP,IHT,IRLS,OMP,SP

资源截图

代码片段和文件信息

function Demo_CS_CoSaMP()
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% the DCT basis is selected as the sparse representation dictionary
% instead of seting the whole image as a vector I process the image in the
% fashion of column-by-column so as to reduce the complexity.

% Author: Chengfu Huo roy@mail.ustc.edu.cn http://home.ustc.edu.cn/~roy
% Reference: D. Deedell andJ. Tropp “COSAMP: Iterative Signal Recovery from
% Incomplete and Inaccurate Samples” 2008.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%------------ read in the image --------------
img=imread(‘lena.bmp‘);     % testing image
img=double(img);
[heightwidth]=size(img);


%------------ form the measurement matrix and base matrix ---------------
Phi=randn(floor(height/3)width);  % only keep one third of the original data  
Phi = Phi./repmat(sqrt(sum(Phi.^21))[floor(height/3)1]); % normalize each column


mat_dct_1d=zeros(256256);  % building the DCT basis (corresponding to each column)
for k=0:1:255 
    dct_1d=cos([0:1:255]‘*k*pi/256);
    if k>0
        dct_1d=dct_1d-mean(dct_1d); 
    end;
    mat_dct_1d(:k+1)=dct_1d/norm(dct_1d);
end


%--------- projection ---------
img_cs_1d=Phi*img;          % treat each column as a independent signal


%-------- recover using omp ------------
sparse_rec_1d=zeros(heightwidth);            
Theta_1d=Phi*mat_dct_1d;
for i=1:width
    column_rec=cs_cosamp(img_cs_1d(:i)Theta_1dheight);
    sparse_rec_1d(:i)=column_rec‘;           % sparse representation
end
img_rec_1d=mat_dct_1d*sparse_rec_1d;          % inverse transform


%------------ show the results --------------------
figure(1)
subplot(221)imagesc(img)title(‘original image‘)
subplot(222)imagesc(Phi)title(‘measurement mat‘)
subplot(223)imagesc(mat_dct_1d)title(‘1d dct mat‘)
psnr = 20*log10(255/sqrt(mean((img(:)-img_rec_1d(:)).^2)))
subplot(224)imagesc(img_rec_1d)title(strcat(‘1d rec img ‘num2str(psnr)‘dB‘))

disp(‘over‘)


%************************************************************************%
function hat_x=cs_cosamp(yT_Matm)
% y=T_Mat*x T_Mat is n-by-m
% y - measurements
% T_Mat - combination of random matrix and sparse representation basis
% m - size of the original signal
% the sparsity is length(y)/4

n=length(y);                           % length of measurements
s=floor(n/4);                                 % sparsity                  
r_n=y;                                 % initial residuals

sig_pos_lt=[];                         % significant pos for last time iteration

for times=1:s                          % number of iterations
    
    product=abs(T_Mat‘*r_n);
    [valpos]=sort(product‘descend‘);
    sig_pos_cr=pos(1:2*s);             % significant pos for curretn iteration
    
    sig_pos=union(sig_pos_crsig_pos_lt);
    
    Aug_t=T_Mat(:sig_pos);            % current selected entries 

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件     428181  2010-07-23 10:17  Matlab重构算法\CS Recovery Algorithms.pdf

     文件       3456  2010-07-16 14:45  Matlab重构算法\software\Demo_CS_CoSaMP.m

     文件       8278  2010-07-15 10:02  Matlab重构算法\software\Demo_CS_GBP.m

     文件       2904  2010-07-22 14:16  Matlab重构算法\software\Demo_CS_IHT.m

     文件       2903  2010-07-15 10:02  Matlab重构算法\software\Demo_CS_IRLS.m

     文件       3340  2010-07-16 14:47  Matlab重构算法\software\Demo_CS_OMP.m

     文件       3434  2010-07-15 10:03  Matlab重构算法\software\Demo_CS_SP.m

     文件      66614  2010-05-11 20:29  Matlab重构算法\software\lena.bmp

     文件       1135  2011-03-10 11:13  Matlab重构算法\SP算法\SP.m

     文件     466187  2012-01-04 16:49  Matlab重构算法\SP算法\SP.pdf

     目录          0  2012-01-08 12:32  Matlab重构算法\software

     目录          0  2012-01-08 12:32  Matlab重构算法\SP算法

     目录          0  2012-01-08 12:32  Matlab重构算法

----------- ---------  ---------- -----  ----

               986432                    13


评论

共有 条评论

相关资源