## 2 Otsu Multi-Threshold Image Segmentation Principle  
Multi-threshold image segmentation is mainly to find several optimal thresholds that can accurately segment the image into different segments. The Otsu method takes the maximum variance function between classes as the objective function. It is the most commonly used method and has the advantages of simple application, simple calculation, and is easy to understand [14]. When solving the problem of image segmentation, this method eliminates the interference of contrast and brightness, thus realizing the effective separation of background and target information. With the inter-class variance between foreground and background becoming larger, the difference between the two parts also becomes larger. The threshold obtained by Otsu will be inclined to the type with a large variance when the difference between the inter-class variance of the two parts is large, some pixels with a large inter-class variance will be classified into those with small inter-class variance, resulting in incorrect segmentation. When the threshold value could maximize the inter-class variance function, then the probability of misclassification reaches the minimum. The basic principle of Otsu is as follows:  
Let \(f(x,y)\) be a grayscale image with a pixel grayscale value ranging from 0 to \(L-1\), where \(L\) represents the total number of gray levels, which represents the total number of pixels whose gray level value is equal to, then:  
\[N=\sum_{i=0}^{L-1}n_{i}. \tag{1}\]  
\(n_{i}\) represents the number of pixels with pixel value \(i\) in the image. \(N\) is the total number of pixels in the entire image. If \(p_{i}\) represents the probability of a pixel whose gray value is \(i\), it can be approximately expressed as a frequency, which is defined as:\[p_{i}=\frac{n_{i}}{N}. \tag{2}\]  
If \(T\) is used to represent the threshold, then for the problem of binary image segmentation, pixels can be divided into two different parts, labeled as \(C_{0}\) and \(C_{1}\), where \(C_{0}\) and \(C_{1}\) contain pixels with different characteristics respectively, Threshold \(T\) divides the gray values into two ranges, and their gray values are within the range [0, \(T\)] and [\(T+1\), \(L-1\)], respectively. For the definition of variance between classes, several data should be obtained first, namely \(\mu_{0}(T)\), \(\mu_{1}(T)\), \(\omega_{0}(T)\), \(\omega_{1}(T)\). The calculation formula for the above statistical data is as follows:  
\[\mu_{0}(T)=\ \frac{\sum_{i=0}^{T}ip_{i}}{\omega_{0}(T)} \tag{3}\]  
\[\omega_{0}(T)=\ \sum_{i=0}^{T}p_{i} \tag{4}\]  
\[\mu_{1}(T)=\ \frac{\sum_{i=T+1}^{L}ip_{i}}{\omega_{1}(T)} \tag{5}\]  
\[\omega_{1}(T)=\ \sum_{i=T+1}^{L}p_{i} \tag{6}\]  
\[\mu=\frac{\sum_{i=0}^{L}ip_{i}}{\sum_{i=0}^{L}p_{i}}=\ \sum_{i=0}^{L}ip_{i}=\ \omega_{0}(T)\cdot\mu_{0}(T)+\omega_{1}(T)\cdot\mu_{1}(T). \tag{7}\]  
In Formulas (3)-(7), \(\mu_{0}(T)\) and \(\mu_{1}(T)\) represent the gray value expectation of the background and foreground, respectively, \(\omega_{0}(T)\) and \(\omega_{1}(T)\) represent the sum of inter-class probability of background and foreground respectively. \(\mu\) is the average gray value of all pixels in the entire image. Based on the above definition, the between-class variance function can be expressed as:  
\[\sigma_{B}(T)=\omega_{0}(T)(\mu_{0}(T)-\mu)^{2}+\omega_{1}(T)(\mu_{1}(T)-\mu) ^{2}. \tag{8}\]  
The formula consists of two parts, corresponding to \(C_{0}\) and \(C_{1}\). In the Otsu method, when the between-class variance function obtains the maximum value with \(T^{*}\) as the threshold, \(T^{*}\) is used as the threshold. Therefore, the image segmentation problem can be transformed into an optimization problem, which can be described as:  
For the multi-threshold image segmentation problem, the weighted sum of variance between categories is calculated.