## 2 Materials and Methods
### Features  
As features, we used the results of ten thresholding algorithms that can be computed globally, using convolution (i.e., Gaussian blur), or per pixel in constant time, using summed area tables. Three thresholds were elementary, and seven were from the scientific literature. The elementary local thresholds are the average pixel value of the window, the average of the maximum and minimum pixel values of the window, and the Gaussian blur value, computed using the following formula:  
\[T=\sum_{x=-w}^{w}\sum_{y=-h}^{h}e^{-\frac{1}{2}((\frac{x}{g_{x}})^{2}+(\frac{y }{g_{y}})^{2})}I(x,y), \tag{3}\]  
where \(w\) is the half-width of the window, \(h\) is the half-height of the window, and \(\sigma_{x}=0.3(w-1)+0.8\) and \(\sigma_{y}=0.3(h-1)+0.8\) are the variances of the Gaussian kernel. The formulas for the standard deviations were taken from the Gaussian kernel generator function defined in OpenCV 4.13. [PERSON] [20] proposed an algorithm based on the range of pixel values within a window. In their method, to reduce the number of misclassified pixels in the very dark or very bright windows, the difference between the maximum and minimum values within the window is compared with a contrast threshold. If the difference is lower than this threshold, then the binarization threshold is the average of the maximum and minimum possible pixel values. Otherwise, the result is the average of the maximum and minimum pixel values in the window. [PERSON] and [PERSON] [21] proposed a dynamic threshold algorithm comprising a two-dimensional running average, \(z(x)\), and a bias function, \(h(x,z(x))\), between \(z(x)\) and the pixel being compared, \(x\). Without this bias function, noise fluctuations would heavily influence the threshold selection in areas with low variance. [PERSON]'s method [22] uses the local mean \(\mu\) and standard deviation \(\sigma\) to compute a local threshold \(T=\mu+k\sigma\), where \(k\) is an adjustable parameter with a negative value. The author recommends \(k=-0.2\). [PERSON] et al. [23] proposed the NICK algorithm, which is a modified version of [PERSON]'s method that shifts the binarization threshold down to improve the results for \"white- and light-page\" images. The formula for the NICK algorithm is \(T=\mu+k\sqrt{(\sum p_{i}^{2}-\mu^{2})/N}\), where \(k\) is an adjustable parameter, \(p_{i}\) are the gray-level values of the pixels within the local window, and \(N\) is the number of pixels within the local window. The authors recommend \(k=-0.2\). [PERSON] and [PERSON] [24] modified [PERSON]'s method by introducing a new term \(R\), which is the dynamic range of the standard deviations of every sliding window in the entire image. The formula for [PERSON]'s threshold is \(T=\mu(1+k(\sigma/R-1))\), where \(k\) is an adjustable parameter that gets positive values. The authors recommend a value of 0.5 for \(k\). [PERSON] and [PERSON] [25] modified [PERSON]'s method, shifting the binarization condition from gray levels towards contrast by introducing M, which is the minimum value of the gray levels of the whole image. The formula for [PERSON]'s method is \(T=(1-k)\mu+kM+k(\mu-M)\sigma/R\), where \(k\) is an adjustable parameter that controls the incertitude around the mean value. The authors recommend a value of 0.5 for \(k\). [PERSON] et al. [26] modified [PERSON]'s method to improve the performance in low-contrast dark regions without significantly affecting the performance in high-contrast light regions. The formula for [PERSON]'s method is \(T=\mu(1+pe^{-q\mu}+k(\sigma/R-1))\), where \(k\), \(p\), and \(q\) are adjustable parameters. The authors recommend \(k=0.25\), \(p=3,q=10\). We also used image statistics as features, including average, standard deviation, skewness, kurtosis, Sarle's Bimodality Coefficient (BC) [27], minimum, and maximum. Allthese statistics were computed both on the whole image and on each window, resulting in a global and local set of image statistics for each pixel. The last feature was a global normalized histogram computed using five bins.