# Hyperspectral Image Inpainting Based on Robust Spectral Dictionary Learning
## 3 Robust Spectral Dictionary Learning and Sparse Representation  
### Robust Spectral Dictionary Learning  
The spectral dictionary \(\mathbf{D}\) used to solve the sparse coding \(\hat{\mathbf{\alpha}}_{i}\) and the final inpainted HSI in this work were obtained by adaptive training, i.e., by a learning method. Given the large volume of HSI data, dictionary-based learning methods, such as batch processing, result in computational intensiveness, and a low learning efficiency. Therefore, we adopted an online learning method to train the dictionary. This method used only one element or a subset of the data set per iteration. Because dictionary \(\mathbf{D}\) was regarded as a combination of the statistical parameters \(\mathbf{X}\) of the observation data during the training process, an update of \(\mathbf{D}\) did not require complete historical information. Thus, it was not necessary to record each iteration and process all the elements during the online processing. The online dictionary learning method is suitable for large-scale and dynamic data processing, which can greatly improve the computational efficiency and reduce memory overhead. In addition, to enhance the robustness against noise and outliers, a robust function as a data fitting term of the objective function was introduced for online updating in the dictionary learning process. Due to the special structure of the HSI data, it was necessary to adjust and improve the existing online dictionary learning algorithm. To make full use of the correlation between the spectral bands of the HSIs, the pixel spectrum vector of the completely observed portion of the HSI was used instead of the image block as the training data for the dictionary learning. The training process of the dictionary aimed to find the coding base of the information in the HSI to be inpainted. Thus, for a better inpainting effect, it was necessary to ensure that the coding of the information contained in each pixel spectral vector of the image carried a high degree of sparseness. Therefore, the spectral dictionary obtained through the learning was an over-complete dictionary, i.e., \(k>>L\). For a pixel spectral vector with a complete observation in the HSI to be inpainted, the following equation must be applied:  
\[\overline{\mathbf{y}}_{c,q}=\mathbf{M}_{c,q}\mathbf{D}\overline{\mathbf{\alpha}}_{q}+ \overline{\mathbf{n}}_{c,q}, \tag{12}\]  
where \(\overline{\mathbf{y}}_{c,q}\in\mathbb{R}^{L}\) is a pixel spectral vector \(q\) that can be observed completely, \(\overline{\mathbf{\alpha}}_{q}\) is the corresponding sparse coding, \(\overline{\mathbf{n}}_{c,q}\in\mathbb{R}^{L}\) is the corresponding noise component, \(q=1,\ldots,n_{c}\) and \(n_{c}\) is the number of pixel spectral vectors with complete observations in the image to be processed. Because \(\overline{\mathbf{y}}_{c,q}\) was observed completely, \(\mathbf{M}_{c,q}=\mathbf{I}\) and Equation (12) was simplified as follows:  
\[\overline{\mathbf{y}}_{c,q}=\mathbf{D}\overline{\mathbf{\alpha}}_{q}+\overline{\mathbf{n}}_{c,q}. \tag{13}\]For a set of completely observed pixel spectral vectors in a given HSI, the robust dictionary learning problem was expressed under the frame of regularization:  
\[\min_{\mathbf{D}\in C,\mathbf{\widetilde{\alpha}}_{1},\,\ldots\,\,\mathbf{\widetilde{\alpha}} _{n_{c}}}\sum_{q=1}^{n_{c}}\left|\left|\overline{y}_{c,q}-\mathbf{D}\mathbf{\widetilde{ \alpha}}_{q}\right|\right|_{1}^{1}+\lambda\left|\mathbf{\widetilde{\alpha}}_{q} \right|\right|_{1}. \tag{14}\]  
Equation (14) is an optimization problem. The objective function is constructed from a \(l_{1}\) norm fitting error and a sparsity-inducing term. The weight between the two is determined by the regularization parameter \(\lambda(>0)\), and \(n_{c}\) is the number of pixels in the training set.