## 2 Materials and Methods
### Selective Search
In general, two connected components can be considered the same when the minimum weight connecting the two components is less than the minimum internal difference for these two components. The minimum internal difference is defined as the minimum value of the largest weight of the minimum spanning tree of the two components. To make this criterion applicable to the case in which the two connected components are two single pixels, a threshold function \(\tau(C)=K/[C]\) is appended to control the degree of difference between two different components to be greater than their respective internal differences, in which \([C]\) represents the number of pixels in the component and \(K\) is a constant parameter that depends on the size of HSI and is preset to control the size of the formed components. Given that anomalies can occur at any location and in any shape, this over-segmentation method is opportunely applicable to hyperspectral anomaly detection, which is completely data-driven and can divide the image into a series of initial regions with freewill shape and size. Compared with some other over-segmentation algorithms, the graph-based over-segmentation method does not need control over the number of generated initial regions and the assignment for seed pixels of the regions, which is more convenient. After the initial segmentation [37] of HSIs is achieved, it is important to further coalesce the minor regions to ensure that adjacent regions with the similar spectral properties are not discrete. Therefore, the spectrum similarity computation between all neighboring regions is then implemented to judge whether the regions belong to the same class or object. The average spectrum of all pixels in each region is utilized to represent the spectral characteristics of regions, and thereby, to calculate the similarities of adjacent regions. The similarity is computed by the linear combination of the spectral angle \(sa\) and the correlation coefficient \(r\), given by:  
\[simi=\left(1-\frac{sa}{\pi}\right)+\frac{\left(1+r\right)}{2} \tag{5}\]Spectral angle (SA) mapper is a widely used criterion to evaluate the shape similarity of two spectral vectors by calculating the angle between two spectral vectors \(x_{i}\) and \(x_{j}\), and the angle can be calculated by:  
\[sa=\arccos\left(\frac{x_{i}\cdot x_{j}}{\|x_{i}\|\cdot\|x_{j}\|}\right) \tag{6}\]  
The two neighboring regions are more similar when the _simi_ is larger, meaning the sooner the two regions will be merged into one region. In detail, the smaller the \(sa\) and the closer \(r\) to 1 mean that the two spectra are more similar. Furthermore, \(1-sa/\pi\) is in the range [0, 1] and \(1+r\) is in the range [0, 2] (\(sa/\pi\) is in the range [0, 1] and \(r\) is in the range [\(-\)1, 1]). Therefore, we divide \(1+r\) by 2 to ensure equal weights for \(sa\) and \(r\). Any reasonable combination of similarity criteria is allowed, and the definition we proposed is one of the more effective solutions. The similarities of all pairs of initial neighboring regions are calculated and recorded in a similarity matrix. The greedy algorithm is used to iteratively merge the two adjacent regions with the highest similarity. By comparing the maximum of the spectral similarity of all adjacent regions with the pre-set threshold \(T\), two involved regions will be merged into the same region when the similarity maximum is greater than the threshold. The pre-set threshold \(T\) is used for constraining the degree of region, and its value is in the range of [0, 2], determined by the minimum and the maximum of the similarity matrix. The similarity values related to the two merged regions in the original similarity matrix are deleted. The similarity matrix is updated by computing the similarities between the new region and its neighboring regions. This process is looped until the similarity maximum is smaller than the threshold and the merging cannot be continued. Finally, the overall HSI is merged into a few regions.