## 2 Materials and Methods
### Image Segmentation Techniques  
#### 2.2.1 Thresholding Technique  
Thresholding is a simple technique for separating objects from the background by introducing a threshold. Pixels are assigned to the foreground if their intensity is lower than the threshold; otherwise, they are set as background. There are about 40 thresholding algorithms, as investigated in [39]. In this work, we evaluated 9 thresholding algorithms: Otsu, Multi-Otsu, Yen, Isodata, Li, Local, Minimum, Mean, and Triangle. Short explanations of the algorithms are described in the following. The cumulative distribution function (\(F\)) is defined as:  
\[F(g)=\sum_{i=0}^{g}p(i), \tag{1}\]  
where \(p(g)\) is the probability mass function, and \(g\) is the intensity value in the image (\(g\) = 0,..., 255). The mean of foreground and background can be expressed as a function of threshold level \(T\) as:  
\[m_{f}(T)=\sum_{g=0}^{T}gp(g), \tag{2}\]  
\[m_{b}(T)=\sum_{g=T+1}^{255}gp(g). \tag{3}\]  
The variance of foreground and background can be expressed as a function of threshold level \(T\):  
\[\sigma_{f}^{2}(T)=\sum_{g=0}^{T}\left(g-m_{f}(T)\right)^{2}p(g), \tag{4}\]  
\[\sigma_{b}^{2}(T)=\sum_{g=T+1}^{255}(g-m_{b}(T))^{2}p(g). \tag{5}\]  
Figure 4: Sample images from thermal camera: (**a**) original image; (**b**) transformed image. Otsu thresholding [40] finds an optimal threshold \(T_{opt}\) by maximizing the between-class variance of foreground and background, and is given as [39]:  
\[T_{opt}=\text{argmax}\Bigg{\{}\frac{F(T)(1-F(T))\Big{(}m_{f}(T)-m_{b}(T)\Big{)}^{ 2}}{F(T)\sigma_{f}^{2}(T)+(1-F(T))\sigma_{b}^{2}(T)}\Bigg{\}}. \tag{6}\]  
Multi-level Otsu (Multi-Otsu) thresholding [41, 42] is an extension of Otsu thresholding, where \(M\)-1 optimal thresholds (_Topt_1_,..., _Topt_M-1_) are calculated for multi-class (\(M\) classes) separation. Yen thresholding [43] finds an optimal threshold \(T_{opt}\) by maximizing the entropic correlation, and is given as [39]:  
\[T_{opt}=\text{argmax}\Big{\{}C_{b}(T)+C_{f}(T)\Big{\}}, \tag{7}\]  
where  
\[C_{b}(T)=-\log\Bigg{\{}\sum_{g=0}^{T}\biggl{(}\frac{p(g)}{F(T)}\biggr{)}^{2} \Bigg{\}}, \tag{8}\]  
\[C_{f}(T)=-\log\Bigg{\{}\sum_{g=T+1}^{255}\biggl{(}\frac{p(g)}{1-F(T)}\biggr{)}^ {2}\Bigg{\}}. \tag{9}\]  
Isodata thresholding [44] finds an optimal threshold \(T_{opt}\), which is defined as [39]:  
\[m_{f}(T)=\sum_{g=0}^{T}gp(g), \tag{2}\]0  
Li thresholding [45, 46] finds an optimal threshold \(T_{opt}\), by minimizing the information theoretic distance, which is given as [39]:  
\[m_{f}(T)=\sum_{g=0}^{T}gp(g), \tag{2}\]1  
where  
\[m_{f}(T)=\sum_{g=0}^{T}gp(g), \tag{2}\]2  
In Local thresholding [47], an optimal threshold is calculated for each pixel by considering the mean value of its neighbors. The optimal threshold at pixel-(\(x\),\(y\)) \(T_{opt}\)(\(x\),\(y\)) is defined as:  
\[m_{f}(T)=\sum_{g=0}^{T}gp(g), \tag{2}\]3  
where \(m_{wxw}\)(\(x\),\(y\)) is the local mean value over a window size \(w\) at the neighbors of pixel-(\(x\),\(y\)), and \(C\) is a constant. Minimum thresholding [48] finds an optimal threshold \(T_{opt}\) as the valley between two maxima of the histogram, which is defined such that the following formula is satisfied:  
\[m_{f}(T)=\sum_{g=0}^{T}gp(g), \tag{2}\]4  
where \(y_{g}\) is the number of pixels with intensity value \(g\). Mean thresholding [48] finds an optimal threshold \(T_{opt}\) as the mean of the intensity value, which is calculated as the integer part of the following:  
\[ \begin{array}{l}\frac{\sum\limits_{g=0}^{255}gy_{g}}{255}.\\ \sum\limits_{g=0}^{\infty}y_{g}\end{array}  \tag{15}\]  
Triangle thresholding [49] finds an optimal threshold \(T_{opt}\) in the histogram based on the Triangle method, as illustrated in Figure 5. The algorithm locates a point \(A\) by maximizing the distance between the triangle line and the histogram, then the optimal threshold \(T_{opt}\) is defined by adding a fixed offset \(Of\)s to \(A\).