├── Measurement matrixs
├── BernoulliMtx.m
├── CirculantMtx.m
├── PartFourierMtx.m
├── PartHadamardMtx.m
├── SparseRandomMtx.m
├── ToeplitzMtx.m
├── other simple matrixs.txt
└── 本文件夹中均为测量矩阵的实现.txt
├── README.md
├── Reconstruction algorithms
├── BP_linprog.m
├── CS_CoSaMP.m
├── CS_GBP.m
├── CS_IHT.m
├── CS_IRLS.m
├── CS_OMP.m
├── CS_ROMP.m
├── CS_SAMP.m
├── CS_SP.m
└── 本文件夹中均为重构算法的实现.txt
├── Refactoring articles
├── CS Recovery Algorithms.pdf
├── CoSaMP Iterative signal recovery from incomplete and inaccurate samples.pdf
├── Compressed sensing.pdf
├── IHT Iterative hard thresholding for compressed sensing.pdf
├── OMP Signal Recovery From Random Measurements Via Orthogonal Matching Pursuit.pdf
├── RIHT Robust iterative hard thresholding for compressed sensing.pdf
├── RIP The restricted isometry property and its implications for compressed sensing.pdf
├── ROMP Signal Recovery From Incomplete and Inaccurate Measurements Via Regularized Orthogonal Matching Pursuit.pdf
├── SAMP Sparsity Adaptive Matching Pursuit Algotithm For Practical Compressive Sensing.pdf
├── SP Subspace Pursuit for Compressive Sensing Signal Reconstruction.pdf
├── Signal Space CoSaMP for Sparse Recovery With Redundant Dictionaries With Redundant Dictionary.pdf
├── StOMP.pdf
└── 本文件夹中大多为重构相关文章.txt
├── Some examples
├── Demo_CS_BP.m
├── Demo_CS_CoSaMP.m
├── Demo_CS_CoSaMP_2.m
├── Demo_CS_GBP.m
├── Demo_CS_IHT.m
├── Demo_CS_IHT_2.m
├── Demo_CS_IRLS.m
├── Demo_CS_OMP.m
├── Demo_CS_OMP_2.m
├── Demo_CS_ROMP.m
├── Demo_CS_SAMP.m
├── Demo_CS_SP.m
├── Demo_CS_SP_2.m
├── lena.bmp
└── 一些一维和二维信号CS的Demo.txt
└── Sparse basis
├── DHartleyTmtx.m
├── DWT.m
├── DWangTmtx.m
├── other simple basis.txt
└── 本文件夹中是为稀疏基的实现.txt
/Measurement matrixs/BernoulliMtx.m:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tyl-stu/Compressed-sensing-code/00415dd00972e40f59eb122428c4ff2a14ce5261/Measurement matrixs/BernoulliMtx.m
--------------------------------------------------------------------------------
/Measurement matrixs/CirculantMtx.m:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tyl-stu/Compressed-sensing-code/00415dd00972e40f59eb122428c4ff2a14ce5261/Measurement matrixs/CirculantMtx.m
--------------------------------------------------------------------------------
/Measurement matrixs/PartFourierMtx.m:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tyl-stu/Compressed-sensing-code/00415dd00972e40f59eb122428c4ff2a14ce5261/Measurement matrixs/PartFourierMtx.m
--------------------------------------------------------------------------------
/Measurement matrixs/PartHadamardMtx.m:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tyl-stu/Compressed-sensing-code/00415dd00972e40f59eb122428c4ff2a14ce5261/Measurement matrixs/PartHadamardMtx.m
--------------------------------------------------------------------------------
/Measurement matrixs/SparseRandomMtx.m:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tyl-stu/Compressed-sensing-code/00415dd00972e40f59eb122428c4ff2a14ce5261/Measurement matrixs/SparseRandomMtx.m
--------------------------------------------------------------------------------
/Measurement matrixs/ToeplitzMtx.m:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tyl-stu/Compressed-sensing-code/00415dd00972e40f59eb122428c4ff2a14ce5261/Measurement matrixs/ToeplitzMtx.m
--------------------------------------------------------------------------------
/Measurement matrixs/other simple matrixs.txt:
--------------------------------------------------------------------------------
1 |
2 | %% 注:以下均是 matlab 程序,并产生的为压缩感知计算中的 测量矩阵
3 | %% 其中, N 、M 为测量矩阵的尺寸,N 的值为原信号长度
4 |
5 | 高斯矩阵
6 | Phi = randn(M,N);
--------------------------------------------------------------------------------
/Measurement matrixs/本文件夹中均为测量矩阵的实现.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tyl-stu/Compressed-sensing-code/00415dd00972e40f59eb122428c4ff2a14ce5261/Measurement matrixs/本文件夹中均为测量矩阵的实现.txt
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Compressed-sensing-code
2 |
3 | 此库中保存些许与压缩感知相关参数、重构的方法等代码,具体说明如下
4 |
5 | - Measurement matrixs :存有多种测量矩阵的实现代码
6 | - Reconstruction algorithms :存有多种重构算法的实现,包括最经典的 OMP、SAMP 等方法
7 | - Refactoring articles :保存了 CS 中多种重构算法的解释文件
8 | - Some examples :CS的实验案例
9 | - Sparse basis :保存了典型稀疏基的实现代码
10 |
11 | 注意:此中代码多为 `.m` 文件,且每个路径中都有相关的txt文件说明各自所实现的内容!
12 |
--------------------------------------------------------------------------------
/Reconstruction algorithms/BP_linprog.m:
--------------------------------------------------------------------------------
1 | function [ alpha ] = BP_linprog( s,Phi )
2 | %BP_linprog(Basis Pursuit with linprog) Summary of this function goes here
3 | %Version: 1.0 written by jbb0523 @2016-07-21
4 | %Reference:Chen S S, Donoho D L, Saunders M A. Atomic decomposition by
5 | %basis pursuit[J]. SIAM review, 2001, 43(1): 129-159.(Available at:
6 | %http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.37.4272&rep=rep1&type=pdf)
7 | % Detailed explanation goes here
8 | % s = Phi * alpha (alpha is a sparse vector)
9 | % Given s & Phi, try to derive alpha
10 | [s_rows,s_columns] = size(s);
11 | if s_rows epsilon,
114 | % run pinv_iter with epsilon=epsilon and c=1
115 | X = Psi_biortho';
116 | while Ierr > epsilon,
117 | X = X * (2*eye(size(AAplus)) - AAplus);
118 | AAplus = Psi*X;
119 | Ierr = max(max(abs(AAplus - eye(size(AAplus)))));
120 | %fprintf('... pinv: I error: %f\n', Ierr);
121 | end
122 | % pinv_iter complete
123 | Psi_biortho = X';
124 | alpha_list = (Psi_biortho*x')';
125 | end
126 |
127 | % Test if conv(Psi) contains extraneous atoms,
128 | % otherwise, continue wrapping
129 | while sum(alpha_list<=0)~=0,
130 | if OPT_VERBOSE_ON,
131 | fprintf('... Deleting atom. \n');
132 | end
133 | % Find an extraneous atom
134 | [alpha_j, j] = min(alpha_list);
135 | % Delete it
136 | psi_j_biortho = Psi_biortho(j,:);
137 | gamma = Psi_biortho*psi_j_biortho' / sum(psi_j_biortho.^2);
138 | Psi = Psi([1:j-1,j+1:n_atoms],:);
139 |
140 | Psi_biortho = Psi_biortho - gamma*psi_j_biortho;
141 | Psi_biortho = Psi_biortho([1:j-1,j+1:n_atoms],:);
142 |
143 | % Test biorthogonality
144 | AAplus = Psi*Psi_biortho';
145 | Ierr = max(max(abs(AAplus - eye(size(AAplus)))));
146 | if Ierr > epsilon,
147 | % run pinv_iter with epsilon=epsilon and c=1
148 | X = Psi_biortho';
149 | while Ierr > epsilon,
150 | X = X * (2*eye(size(AAplus)) - AAplus);
151 | AAplus = Psi*X;
152 | Ierr = max(max(abs(AAplus - eye(size(AAplus)))));
153 | %fprintf('... pinv: I error: %f\n', Ierr);
154 | end
155 | % pinv_iter complete
156 | Psi_biortho = X';
157 | alpha_list = (Psi_biortho*x')';
158 | else
159 | alpha_list = alpha_list - alpha_j*gamma';
160 | alpha_list = alpha_list([1:j-1,j+1:n_atoms]);
161 | end
162 |
163 | % Update the representation
164 | i_list = i_list([1:j-1,j+1:n_atoms]);
165 | n_atoms = length(i_list);
166 | end
167 |
168 | % Compute the new approximation
169 | xApprox = alpha_list * Psi;
170 | % Next hyperplane
171 | normal = (-D_n(i_Dsorted(1)))*v + (D_v(i_Dsorted(1)))*normal;
172 | normal = normal / sqrt(sum(normal.^2));
173 | d_H = dot(D(i_list(1),:), normal);
174 | xApprox_H = (d_H / dot(xApprox, normal))*xApprox;
175 | err_vec = x - xApprox;
176 | v = err_vec - dot(err_vec, normal)*normal;
177 | v = v / sqrt(sum(v.^2));
178 | end
179 |
180 | hat_x=zeros(1,size(D,1));
181 | hat_x(i_list)=alpha_list; % recovered sparse representation
182 | end
--------------------------------------------------------------------------------
/Reconstruction algorithms/CS_IHT.m:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tyl-stu/Compressed-sensing-code/00415dd00972e40f59eb122428c4ff2a14ce5261/Reconstruction algorithms/CS_IHT.m
--------------------------------------------------------------------------------
/Reconstruction algorithms/CS_IRLS.m:
--------------------------------------------------------------------------------
1 | function hat_x=CS_IRLS(y,T_Mat,m)
2 | % y=T_Mat*x, T_Mat is n-by-m
3 | % y - measurements
4 | % T_Mat - combination of random matrix and sparse representation basis
5 | % m - size of the original signal
6 | % the sparsity is length(y)/4
7 |
8 | %hat_x_tp=(T_Mat'*T_Mat)^(-1)*T_Mat'*y; % initialization, leading to warning
9 | hat_x_tp=T_Mat'*y;
10 |
11 | epsilong=1;
12 |
13 | p=1; % solution for l-norm p
14 | times=1;
15 | while (epsilong>10e-9) && (times