# From Classic to Cutting-Edge: A Near-Perfect Global Thresholding Approach with Machine Learning
## 2 Materials and Methods
### Features
They use the following formula for fuzziness:  
\[\mathrm{E}(t)=\sum\limits_{i=1}^{I_{\mathrm{max}}}S(\mu_{t}(i))h(i), \tag{10}\]  
where \(h(i)\) represents how many times the ith intensity appears in the image,  
\[\mathrm{S}(\mu_{t}(i))=\mu_{t}(i)\mathrm{ln}\,\mu_{t}(i)-(1-\mu_{t}(i))\mathrm{ ln}(1-\mu_{t}(i)) \tag{11}\]  
is [PERSON]'s entropy, and the membership function is  
\[\mu_{t}(i)= \begin{cases}\left(1+\left|i-\mu_{0}\right|/C\right)^{-1},\text{ if i }\leq\mathrm{t}\\ \left(1+\left|i-\mu_{1}\right|/C\right)^{-1},\text{ otherwise}\end{cases}  \tag{12}\]  
where \(C\) is a constant value such that \(0.5\leq\mu_{t}(i)\leq 1\). [PERSON] et al. (2013) proposed an algorithm based on functional approximation of the histogram composed of recursive bilevel approximations that minimize an error function. They compare the results of two error functions:  
* The sum of the square errors: \[\mathrm{E}(t)=\sum\limits_{i=1}^{t}(i-\mu_{0})^{2}+\sum\limits_{i=t+1}^{I_{ \mathrm{max}}}(i-\mu_{1})^{2}\] (13)
* The sum of the variances of each class: \[\mathrm{E}(t)=\sigma_{0}^{2}+\sigma_{1}^{2}.\] (14)  
Their experimental results show that the latter error function produces better results than the former. [PERSON] and [PERSON] [25] proposed an algorithm based on minimizing the cross-entropy between the original image and the binarized image. The cross-entropy is computed for each possible threshold with the following formula:  
\[\mathrm{H}(t)=\sum\limits_{i=1}^{t-1}ih_{i}\mathrm{ln}\frac{i}{\mu_{0}(t)}+\sum \limits_{i=t}^{I_{max}}ih_{i}\mathrm{ln}\frac{i}{\mu_{1}(t)}, \tag{15}\]  
where \(h_{i}\) is the number of pixels with intensity \(i\) in the image, and \(I_{max}\) is the maximum intensity. [PERSON] and [PERSON] [26] proposed an iterative variation of this algorithm, boasting improved computational speed at the cost of accuracy. [PERSON] and [PERSON] [27] proposed a similar algorithm, but they compute the cross-entropy with the following formula:  
\[\mathrm{H}(t)=\sum\limits_{i=1}^{t}\mu_{0}(t)\mathrm{log}\frac{\mu_{0}(t)}{i} +\sum\limits_{i=t+1}^{I_{max}}\mu_{1}(t)\mathrm{log}\frac{\mu_{1}(t)}{i}. \tag{16}\]  
[PERSON] et al. [26] proposed an algorithm based on maximizing an evaluation function:  
\[\mathrm{f}(t)=\frac{\mathrm{H}(t)}{\mathrm{H}(I_{max})}\frac{\mathrm{ln}c(t)} {\mathrm{ln}\left(\mathrm{max}_{i-1}p(i)\right)}+\frac{1-H(t)}{H(I_{max})} \frac{\mathrm{ln}(1-c(t))}{\mathrm{ln}\left(\mathrm{max}_{i-t+1}^{I_{max}}p(i )\right)}, \tag{17}\]  
where they use the classic information entropy formula:  
\[\mathrm{H}(t)=-\sum\limits_{i=1}^{t}p(i)\mathrm{ln}\,p(i) \tag{18}\]  
and  
\[\mathrm{c}(t)=\sum\limits_{i=1}^{t}p(i) \tag{19}\]  
is the cumulative probability density function. [PERSON] et al. [26] proposed an algorithm based on maximizing the sum of [PERSON]'s entropies associated with each class:  
\[ \begin{split}& H_{0}^{\alpha}=(1-\alpha)^{-1}ln\sum\limits_{i=0}^{t }\left(\frac{p(i)}{W_{0}}\right)^{\alpha}\\ & H_{1}^{\alpha}=(1-\alpha)^{-1}ln\sum\limits_{i=t+1}^{I_{max}} \left(\frac{p(i)}{W_{1}}\right)^{\alpha}.\end{split}  \tag{20}\]  
They observed that there are three distinct thresholds \(t_{1},t_{2},t_{3}\) that maximize the sum depending on whether \(\alpha\) is lower than, equal to, or greater than 1, and use all three values to determine the optimal threshold:  
\[\mathrm{t}=t_{[1]}\left(p\left(t_{[1]}\right)+0.25\omega\beta_{1}\right)+0.25t _{[2]}\omega\beta_{2}+t_{[3]}\left(1-p\left(t_{[3]}\right)+0.25\omega\beta_{ 3}\right), \tag{21}\]  
where \(t_{[1]},t_{[2]},t_{[3]}\) are the order statistics of the thresholds \(t_{1},t_{2},t_{3}\), respectively;  
\[\omega=p\left(t_{[3]}\right)-p\left(t_{[1]}\right); \tag{22}\]  
and \(\beta_{1},\beta_{2},\beta_{3}\) take different values based on the distances between \(t_{[1]},t_{[2]},t_{[3]}\). [PERSON] [26] proposed a modified version of [PERSON]'s algorithm.