# Hyperspectral Image Inpainting Based on Robust Spectral Dictionary Learning
## 3 Robust Spectral Dictionary Learning and Sparse Representation
### Robust Spectral Dictionary Learning
To prevent the dictionary atom in \(\mathbf{D}\) from tending toward infinity due to the effect of the \(l_{1}\) norm regularization term, we imposed a constraint \(\mathbf{D}\in C\), \(C=\left\{\mathbf{D}\in\mathbf{R}^{\mathrm{L}\times\mathbf{k}}:d_{j}^{T}d_{j}\leq 1,\,j=1, \,\ldots\,,k\right\}\), which may be viewed as a constraining convex set matrix. For the joint optimization problem of dictionary \(\mathbf{D}\) and sparse solution \(\mathbf{\widetilde{\alpha}}=[\mathbf{\widetilde{\alpha}}_{1},\,\ldots\,,\mathbf{ \widetilde{\alpha}}_{n_{c}}]\) for Equation (14), a more convenient solution is to alternately fix the values of \(\mathbf{D}\) and \(\mathbf{\widetilde{\alpha}}_{q}\) and subsequently solve for the minimum value of the other, i.e., to alternately solve and optimize \(\mathbf{D}\) and \(\mathbf{\widetilde{\alpha}}_{q}\). Because there is a non-smooth term in Equation (14), its solution is somewhat challenging. Due to the large size of the HSI data, the cost of optimizing \(\mathbf{\widetilde{\alpha}}=[\mathbf{\widetilde{\alpha}}_{1},\,\ldots\,,\mathbf{ \widetilde{\alpha}}_{n_{c}}]\) is very high. Therefore, we used the idea of an online method in which only one subset of a randomly selected pixel spectral vector set was trained in each iteration. For each new element in the subset, we first computed the robust sparse coding and subsequently performed a dictionary update. First, we solved the problem of the robust sparse coding in a given dictionary, i.e., for a given dictionary matrix \(\mathbf{D}\), we optimized each element \(\mathbf{\widetilde{\alpha}}_{q}\) in \(\mathbf{\widetilde{\alpha}}=[\mathbf{\widetilde{\alpha}}_{1},\,\ldots\,,\mathbf{ \widetilde{\alpha}}_{n_{c}}]\) and expressed it as follows:  
\[\mathbf{\widetilde{\alpha}}_{q}=\arg\min_{\mathbf{\widetilde{\alpha}}_{q}}\left|\bm {D}\mathbf{\widetilde{\alpha}}_{q}-\overline{y}_{c,q}\right|\right|_{1}^{1}+ \lambda\left|\mathbf{\widetilde{\alpha}}_{q}\right|_{1},\,q=1,\ldots,n_{c}. \tag{15}\]  
Equation (15) is a \(l_{1}\) norm metric and regularization convex optimization problem. We solved the optimization problem expressed by Equation (15) using the equivalent \(l_{1}\) approximation robust sparse coding scheme reported previously [27]. The specific details are discussed in the next subsection. When the robust sparse coding is assumed to be constant, the optimization solution of the dictionary matrix \(\mathbf{D}\) is equivalent to minimizing the following problem:  
\[\min_{\mathbf{D}\geq 0}\frac{1}{h}\left|\left|\overline{y}_{c}^{t}-\mathbf{D}\mathbf{ \widetilde{\alpha}}^{t}\right|\right|_{1}^{1}+\lambda\left|\mathbf{\widetilde{ \alpha}}^{t}\right|\right|_{1}, \tag{16}\]  
where \(t\) is the current number of iterations, \(h\) is the number of pixel spectral vectors used in each iteration, \(\overline{y}_{c}^{t}\) is the current training set consisting of \(h\) randomly chosen pixel spectral vectors from the complete observation pixel spectral vector set \(\overline{Y}_{c}=\left[\overline{y}_{c,1},\ldots,\overline{y}_{c,n_{c}}\right]\), and the current training set robust sparse coding matrix \(\mathbf{\widetilde{\alpha}}^{t}\) is obtained by solving Equation (15). Equation (16) is a standard \(l_{1}\) regression problem. Due to the lack of differentiability, it cannot be solved like an \(l_{2}\) regression problem. Therefore, we resorted to the iteratively re-weighted least squares method (IRLS) [28]. Each \(\mathbf{D}(j,:)\) can be estimated independently, and thus, without loss of generality, the \(j\)-th optimization function can be expressed as follows:  
\[\mathbf{D}(j,:)=\arg\min_{\mathbf{D}(j,:)}\frac{1}{h}\sum_{j=1}^{h}\left|\left| \overline{y}_{c,j}^{t}-\mathbf{D}(j,:)\mathbf{\widetilde{\alpha}}_{i}^{t}\right|\right|, \tag{17}\]where \(\mathbf{D}(j,:)\in\mathbf{\mathrm{R}}^{1\times\mathrm{k}}\), and \(\overline{y}_{c,ij}^{t}\) is the \(j\)-th element of \(\overline{y}_{c,i}^{t}\).