# Table 1 Summary of the K-cluster-valued CoSaMP algorithm

- Input: Measurement matrix Φ, measurement vector y, sparsity level S, and intensity cluster number K.
- Output: S-sparse approximation $\stackrel{^}{\mathbit{x}}$ of target image x.
- Initialization: ${\stackrel{^}{\mathbit{x}}}^{0}=0$, r= y and i = 1.
While halting criterion = true
1 zΦ*r{Compute the proxy of residual}
2 Ω ← supp(z2K) {Identify the largest 2K components of the proxy}
3 $\mathbit{T}←\mathbf{\Omega }\cup supp\left({\stackrel{^}{\mathbit{x}}}^{\left(i-1\right)}\right)$ {Merge supports}
4 $\mathbit{b}{|}_{\mathbit{T}}←{\mathbf{\Phi }}_{\mathbit{T}}^{†}\mathbit{y}$ and $\mathbit{b}{|}_{{\mathbit{T}}^{C}}←0${Estimate the image by least-squares solution}
5 ${\stackrel{^}{\mathbit{x}}}^{i}←{\mathbit{b}}_{K}$ {Prune to obtain the image approximation for the next iteration or output}
While ${\sum }_{n=1}^{N}{\sum }_{k=1}^{K}{r}_{nk}\parallel {\stackrel{^}{x}}_{n}^{i}-{\mu }_{k}^{i}{\parallel }_{2}
6 For each n = 1, 2,..., N, {Assign intensity values of each pixel to the closest intensity cluster}
${r}_{nk}^{i}=\left\{\begin{array}{cc}\hfill 1\hfill & \hfill if\phantom{\rule{2.77695pt}{0ex}}k=arg{min}_{j}\parallel {\stackrel{^}{x}}_{n}^{i}-{\mu }_{k}^{i}{\parallel }_{2}\phantom{\rule{1em}{0ex}}and\phantom{\rule{2.77695pt}{0ex}}\phantom{\rule{2.77695pt}{0ex}}{\stackrel{^}{x}}_{n}^{i}\ne 0\hfill \\ \hfill 0\hfill & \hfill otherwise\hfill \end{array}\right\$
7 For each $n=1,2,\phantom{\rule{2.77695pt}{0ex}}\dots ,\phantom{\rule{2.77695pt}{0ex}}N,\phantom{\rule{2.77695pt}{0ex}}{\mu }_{k}^{i}=\frac{{\Sigma }_{n=1}^{N}{r}_{nk}^{i}{\stackrel{^}{x}}_{n}^{i}}{{\Sigma }_{n=1}^{N}{r}_{nk}^{i}}$. {Obtain the K cluster centres}
End
8 For n = 1, 2,..., N, if r nk = 1, then ${\stackrel{^}{x}}_{n}^{i}={\mu }_{k}^{i}$ {Optimize the estimated image with K-cluster intensities}
9 $\mathbit{r}=\mathbit{y}-\mathbf{\Phi }{\stackrel{^}{\mathbit{x}}}^{i}$ {Update the measurement residual for the next iteration}
10 i = i + 1 {Update the iteration number}
End
return $\stackrel{^}{\mathbit{x}}$${\stackrel{^}{\mathbit{x}}}^{i}$