資源簡介
該算法是對IHT算法的完整實現,使用者可改變圖片后直接使用
代碼片段和文件信息
%%二維迭代硬閾值法(IHT)
%?function?Demo_CS_IHT()
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%?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:?T.?Blumensath?and?M.?Davies?“Iterative?Hard?Thresholding?for
%?Compressed?Sensing”?2008.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
?
%------------?讀入圖像?--------------
load?C:\Users\zkdn\Desktop\MATLABdata\I1\I1.mat
X=I1;
background=imopen(Xstrel(‘disk‘15));%獲取背景信息
X=imsubtract(Xbackground);%利用函數去除背景
X=double(X);
[heightwidth]=size(X);
?
?
%------------?形成測量矩陣和基本矩陣---------------
Phi=randn(floor(height/2)width);??%?only?keep?one?third?of?the?original?data?
Phi?=?Phi./repmat(sqrt(sum(Phi.^21))[floor(height/2)1]);?%?normalize?each?column
?
mat_dct_1d=zeros(512512);??%?building?the?DCT?basis?(corresponding?to?each?column)
for?k=0:1:511
????dct_1d=cos([0:1:511]‘*k*pi/512);
????if?k>0
????????dct_1d=dct_1d-mean(dct_1d);
????end;
????mat_dct_1d(:k+1)=dct_1d/norm(dct_1d);
end
?
?
%---------?投影?---------
X_cs_1d=Phi*X;??????????%?treat?each?column?as?a?independent?signal
?
?
%--------?恢復使用iht?------------
sparse_rec_1d=zeros(heightwidth);???????????
Theta_1d=Phi*mat_dct_1d;
s_ratio?=?0.2;
for?i=1:width
????column_rec=cs_iht(X_cs_1
評論
共有 條評論