## 2 Materials and Methods
### Proposed Method
#### 2.3.2 Background Purification  
The improved trilateral filter can be helpful in the reconstruction of the background part. A large reconstruction error will be expected while using the neighborhood background atom to represent the abnormal part. Based on this principle, the preliminary abnormal information distribution can be obtained. When the central pixel is the background component, the weight coefficient for the similar background components will be large when reconstructing the representation, and the reconstruction error is small. However, when the central pixel is an abnormal pixel, the weight coefficient for the background component will be small, and that for the abnormal pixels will be large, resulting in a smaller reconstruction error. In this situation, the preliminary extraction of anomaly information cannot be obtained according to the above principles. Many studies were carried out to solve similar problems [7; 8; 9; 10; 11]. The internal and external double-window structure was introduced to restrict the selection of reconstructed atoms. As shown in Figure 4, the abnormal pixel occupies a small part of the hyperspectral image, and also has a certain degree of aggregation. Thus, the influence of the abnormal neighborhood pixels on the reconstruction results is greatly reduced by adding the inner frame limit area and selecting the corresponding pixels between the inner and outer windows for reconstruction.  
After adding the area limit, the size of the inner window may be set to \(W_{\text{in}}\), and the size of the outer window may be set to \(W_{\text{out}}\). Equation (16) can be updated to Equation (18):  
\[\mathbf{R}(x)=\frac{1}{k(x)}\left(\sum_{i=1}^{N}\mathbf{O}(\varepsilon_{i})SEDW (x,\varepsilon_{i})SVDW(x,\varepsilon_{i})LGD(x,\varepsilon_{i})\right) \tag{18}\]  
where \(O\) is the initial feature image, \(\mathbf{R}\) is the background image after filtering and reconstruction, \(x\) is the central pixel, \(\varepsilon_{i}\) represents the \(i\)-th pixel of the reconstructed selection region between the inner and outer windows, and \(k(x)\) is the corresponding regularization parameter, which can be updated to Equation (19).  
\[k(x)=\sum_{i=1}^{N}SEDW(x,\varepsilon_{i})SVDW(x,\varepsilon_{i})LGD(x, \varepsilon_{i}) \tag{19}\]  
where \(N\) is the number of reconstructed pixels between the inner and outer windows, and the calculation formula is expressed in Equation (20).  
\[N=W_{out}\times W_{out}-W_{in}\times W_{in} \tag{20}\]  
After the background reconstruction of the initial feature image is completed by sliding through the whole image with two windows, further operations are performed on the initial feature image and the filtered background image to obtain the reconstruction representation error. It is expressed in Equation (21).  
\[\mathbf{E}(x)=\mathbf{I}(x)-\mathbf{R}(x) \tag{21}\]when \(\text{E}(x)\) is greater than a certain threshold, the pixel can be considered as a possible abnormal point, and when it is lower than the threshold, the pixel can be considered the background point. After traversing the whole image, the coordinates of all possible abnormal points should be recorded. Then, the spectral curve at the corresponding coordinates of the possible abnormal points will be set to zero in the original hyperspectral image and replaced by the mean vector of all possible background pixels in the neighborhood. In order to ensure the effectiveness of the filling vector, the size of the filling neighborhood is consistent with the size of the previous internal window (\(W_{\text{in}}\)) to complete the background purification. Then, the purified background and the original image are used to complete the joint collaborative representation. The background parts between the two windows in the purified background image are used as dictionary atoms to reconstruct the central pixel. Finally, the final detection result is obtained according to the reconstruction error between the pixel to be measured and the reconstructed spectral curve.