# Hyperspectral Image Inpainting Based on Robust Spectral Dictionary Learning
## 2 HSI Inpainting Model and Mechanism
### HSI Inpainting Mechanism  
In recent years, sparse representations have become a popular research topic for signal recovery and reconstruction [24]. The principle is that because a real image or signal has low rank attributes, it can be assumed that a pure defect-free image or signal is a linear combination of a few atoms in the dictionary. Based on the above assumptions, image inpainting can be considered to be a sparse signal reconstruction task supported by a dictionary. Because HSIs are sparse, a pure defect-free image can be expressed as follows:  
\[\mathbf{X}=\mathbf{D}\mathbf{\alpha}, \tag{2}\]  
where \(\mathbf{D}\in\mathbb{R}^{L\times k}\) is the spectral dictionary matrix, \(k\) is the number of atoms in the dictionary, \(\mathbf{\alpha}\in\mathbb{R}^{k\times n_{\mathrm{s}}}\) is the corresponding sparse coding matrix, and only a few elements in each column are non-zero. Substituting Equation (2) into Equation (1) yields the following:  
\[ \begin{array}{ll}\mathbf{y}&=\mathbf{M}\cdot\mathrm{vec}(\mathbf{D}\mathbf{\alpha})+\mathbf{n} \\ &=\mathbf{M}(I\otimes\mathbf{D})\cdot\mathrm{vec}(\mathbf{\alpha})+\mathbf{n}\end{array}  \tag{3}\]  
Here, \(\otimes\) is the Kronecker product operation. Therefore, the HSI inpainting problem can be expressed as follows:  
\[\min_{\mathrm{vec}(\mathbf{\alpha})}\frac{1}{2}\|\mathbf{M}(I\otimes\mathbf{D})\cdot \mathrm{vec}(\mathbf{\alpha})-\mathbf{y}\|_{2}^{2}+\lambda\cdot\phi(\mathrm{vec}(\mathbf{ \alpha})). \tag{4}\]  
We next address the problem of solving for the pixel spectral vector. Letting \(\mathbf{M}_{i}\) be a submatrix of \(\mathbf{M}\) acting on the pixel spectral vector \(i\),  
\[\mathbf{y}_{o,i}=\mathbf{M}_{i}\mathbf{x}_{i}+\mathbf{n}_{o,i}, \tag{5}\]  
where \(\mathbf{y}_{o,i}\in\mathbb{R}^{n_{i}}\) is the observation vector of the pixel spectral vector \(i\), and \(n_{i}\) represents the observable components in the pixel spectral vector, namely the number of spectra. Therefore, \(n_{i}\leq L\), \(x_{i}\) is the \(i\)-th column vector of the pixel spectral matrix \(\mathbf{X}\) with \(i=1,\ldots,n_{\mathrm{s}}\), and \(\mathbf{n}_{o,i}\in\mathbb{R}^{n_{i}}\) is the corresponding noise component. A pure defect-free pixel spectral vector can be expressed as follows:  
\[\mathbf{x}_{i}=\mathbf{D}\mathbf{\alpha}_{i}, \tag{6}\]  
where \(\mathbf{\alpha}_{i}\) is the \(i\)-th column vector of the sparse coding matrix \(\mathbf{\alpha}\), and \(i=1,\ldots,n_{\mathrm{s}}\). Substituting Equation (6) into Equation (5) yields the following:  
\[\mathbf{y}_{o,i}=\mathbf{M}_{i}\mathbf{D}\mathbf{\alpha}_{i}+\mathbf{n}_{o,i}. \tag{7}\]  
Letting \(\mathbf{\Psi}_{i}=\mathbf{M}_{i}\mathbf{D}\), Equation (7) can be expressed as follows:  
\[\mathbf{y}_{o,i}=\mathbf{\Psi}_{i}\mathbf{\alpha}_{i}+\mathbf{n}_{o,i}. \tag{8}\]  
Therefore, the optimization problem (4) can be rewritten as an objective function in the form of the least absolute shrinkage and selection operator (LASSO):  
\[\min_{\mathbf{\alpha}_{i}}\sum_{i}\frac{1}{2}\|\mathbf{\Psi}_{i}\mathbf{\alpha}_{i}-\mathbf{ y}_{o,i}\|_{2}^{2}+\lambda\|\mathbf{\alpha}_{i}\|_{1}. \tag{9}\]  
In Equation (9), the squared term is the data fitting term, the \(l_{1}\) norm term induces sparse coding, and the regularization parameter \(\lambda\) is the weight between the two terms in the objective function. In real images, the HSI data often contains noise and outliers, and the squared data fitting term used in Equation (9) is sensitive to noise and prone to large deviations.