# Hyperspectral Superpixel-Wise Glioblastoma Tumor Detection in Histological Samples
## 2 Materials and Methods
### Superpixel-Based Processing Framework
#### 2.3.1 Simple Linear Iterative Clustering (SLIC) Approach  
In this research, we used the simple linear iterative clustering (SLIC) superpixel segmentation method proposed by [PERSON] et al. [12]. This algorithm is a modification of the k-means clustering algorithm to work with superpixels. Given a fixed number of target superpixels (\(K\)), the SLIC algorithm first initializes the superpixels by dividing the input image (Figure 5A) in a regular grid (Figure 5B). The initial area of the superpixel is \(S\) pixels. Next, the initial centroids of each superpixel are assigned to a randomly selected pixel within the superpixel area. Then, for each superpixel centroid, the distance between the superpixel centroid and the pixels in an area of 2\(\cdot\)5 pixels is computed (Figure 5C). After computing this distance for all pixels in the images, each pixel is assigned to a superpixel. Finally, the superpixel centroid is updated (Figure 5D), and the process is repeated until the error in pixel assignment is minimized (Figure 5E).  
In the original paper, this approach was developed for conventional RGB images. The distance between a superpixel and a pixel in its neighborhood is calculated as the root mean squared of the color distance and the spatial distance. For each pixel, the color distance (\(d_{c}\)) is defined as the Euclidian distance between two color components in the CIELAB color space (a color space defined by the _International Commission on Illumination_ in 1976 [23]), and the spatial distance (\(d_{S}\)) is defined as the Euclidean distance between the spatial coordinates of the pixels. In order to compensate for the difference in range between \(d_{c}\) and \(d_{S}\), a hyperparameter \(m\) is defined (Equation (1)). This hyperparameter weighs the importance of each type of distance in the overall distance computation. Small values of \(m\) make the distance more sensitive to the color distance component, while a large \(m\) provides more importance to the spatial component.  
\[D_{SLIC}=\sqrt{d_{c}^{2}+\left(\frac{d_{S}}{S}\right)^{2}\cdot m^{2}} \tag{1}\]  
In a first attempt, we utilized the original SLIC algorithm with the HS data. However, in our experiments we found the use of the Euclidian distance for the spectral similarity was not suitable for spectral data. The superpixels generated when using the Euclidian distance were not able to successfully group spectrally similar materials, showing high spectral variations between pixels  
Figure 5: Block diagram of the different steps of the SLIC approach for superpixel classification.  
belonging to the same superpixel. For this reason, we propose some modifications to such distance metrics for adapting SLIC algorithm to HSI. First, we propose the use of the Spectral Angle (SA) as a distance metric for measuring the spectral similarity between two pixels \(p_{1}\) and \(p_{2}\) with \(N\) spectral bands (Equation (2)). The use of this type of distance is widely extended in the HSI research community [24]. For the spatial distance, we keep the Euclidian distance between two pixels. The SA distance (\(d_{SA}\)) is in the range [0,1]. For this reason, in order to compute the total distance (\(D_{proposed}\)), we propose to simply weight the influence of the spatial distance by multiplying it for a factor \(m\) (Equation (3)). This hyperparameter is used to weigh the importance of the spatial and the spectral distance in the superpixel assignment.  
\[d_{SA}=\frac{\sum_{i=1}^{N}p_{1i}\cdot p_{2i}}{\sqrt{\sum_{i=1}^{N}p_{1i}{}^{2} }+\sqrt{\sum_{i=1}^{N}p_{2i}{}^{2}}} \tag{2}\]  
\[D_{proposed}=d_{SA}+\left(\frac{d_{S}}{S}\right)\cdot m \tag{3}\]