# Improved Image Denoising Algorithm Based on Superpixel Clustering and Sparse Representation
## 3 Proposed SC-SR Algorithm
### Superpixels Clustering  
the outset, SLIC is used to generate \(M\) superpixels, and a superpixel is described as a column vector \(u\) with several features. Each image pixel within a superpixel can be represented by a seven-dimensional feature vector \(\mathbf{f}\):  
\[\mathbf{f}=\left[g,\ I_{X}\,\ I_{Y},\ I_{XX},\ I_{YY},\ \beta\times x,\ \beta\times y \right]^{T}, \tag{9}\]where \(g\) is the gray value of the pixel; \(I_{X},~{}I_{Y},~{}I_{XX},~{}I_{YY}\) are the corresponding first or second order derivatives of image intensities in both \(X\) and \(Y\) axes; and \(x\), \(y\) are the coordinates of the pixel in an image. The parameter \(\beta\) aims to make a balance among image gray, gradient, and spatial features. If we use equal weight (\(\beta=1\)) for the spatial feature, similarities between pairs of patches with large spatial distances may be lost. Thus, we empirically chose \(\beta=0.5\) to alleviate this problem [15]. In addition, the image spatial, gray and gradient values were normalized. For a given superpixel, we computed the mean vector \(u\) of all pixels within it as its feature vector:  
\[\mathbf{u}=\frac{1}{\Gamma}\sum\
olimits_{j=1}^{\Gamma}\mathbf{f}_{j}, \tag{10}\]  
where \(\Gamma\) is the size of the superpixel and \(\mathbf{f}_{j}\) indicates a vector of a pixel within the superpixel. We considered these \(N_{\mathrm{s}}\) superpixels as a collection of data points drawn from a union of \(K\) independent affine subspaces. The sparse subspace clustering method was adopted to cluster the collection of data points into \(K\) groups. After transforming every superpixel into a column vector, the collection of data points \(\mathbf{U}=\{\mathbf{u}_{i}\}_{i=1}^{M}\) for clustering was obtained. For each superpixel, its covariance matrix \(\mathbf{Mc}\) was calculated by:  
\[\mathbf{Mc}=\left[ \begin{array}{ccc}\delta_{11}&\cdots&\delta_{17}\\ \vdots&\ddots&\vdots\\ \delta_{71}&\cdots&\delta_{77}\end{array} \right], \tag{11}\]  
\[\delta_{ij}=\frac{1}{\Gamma-1}\times\left(\sum\
olimits_{k=1}^{\Gamma}\left( \mathbf{f}_{i}^{k}-\mathbf{u}_{i}\right)\times\left(\mathbf{f}_{j}^{k}-\mathbf{u}_{j}\right) \right), \tag{12}\]  
where \(\mathbf{f}_{i}^{k}\) indicates the \(i\)-th feature of the \(k\)-th pixel of the current superpixel and \(\mathbf{u}_{i}\) indicates the \(i\)-th element of the feature vector of the superpixel. For two superpixels, their similarity can be computed based on the corresponding covariance matrices, \(\mathbf{[PERSON]_{1}}\) and \(\mathbf{[PERSON]_{2}}\):  
\[W(\mathbf{[PERSON]_{1}},\mathbf{[PERSON]_{2}})=e^{-\rho d(\mathbf{[PERSON]_{1}},\mathbf{[PERSON]_{2}})}, \tag{13}\]  
\[d(\mathbf{[PERSON]_{1}},\mathbf{Mc_{2}})=\sqrt{\sum\
olimits_{i=1}^{7}}ln^{2}(\lambda_{i}( \mathbf{[PERSON]_{1}},\mathbf{Mc_{2}})), \tag{14}\]  
where \(WM(\mathbf{c_{1}},\mathbf{Mc_{2}})\) is the similarity of the two superpixels; \(\lambda_{i}(\mathbf{[PERSON]_{1}},\mathbf{Mc_{2}})\) is the generalized eigenvalues from \(|\lambda\mathbf{[PERSON]_{1}}-\mathbf{Mc_{2}}|=0\); and \(\rho\) is a small constant (we experimentally set \(\rho\) to 0.5 in our experiment) [15]. To better characterize the relationship between the superpixels and alleviate the sensitivity of sparse coding to noise, a Laplacian regularization term [15] based on the similarity matrix \(W\) was introduced into Equation (6) to ensure the similarity of sparse coefficients among similar superpixels.