*3.2. Locally Adaptive Thresholding*

Using this group of algorithms, the threshold is calculated individually for each pixel depending on the local statistics of neighboring pixels. Such statistics can be, e.g., variance, range or surface-fitting parameters. Finally, the threshold value is a function dependent on the position of the pixel, i.e., *T(i,j)*, where: *i, j*—coordinates of the pixel [56]. This method is much more useful when assessing whether or not there is a crack in the analyzed, local area. Tang and Gu [57] used the locally adaptive thresholding on the histogram, which was initially smoothed with the Gaussian filter. They obtained a good quality image showing the cracking pattern on the surface of the concrete road pavement, however, it was contaminated with small objects with non-linear characteristics. They used morphology operators such as the dilation operator and erosion operator to remove them. Tong et al. [58] developed software for cracks inspections for concrete bridges using adaptive thresholding elements in their algorithm. Liu et al. [59] developed a multistage method for identifying cracks in concrete assets, without any focus on specific application. In order to solve the problem of low contrast between the cracks and background, they proposed an image enhancement algorithm that uses the multi-scale guided filters with gradient information. The result was a well-contrasted image that uses the adaptive threshold segmentation to create a binary image representing the cracking pattern. Tests carried out on various images showing the real surfaces of cement composites showed the high validity and robustness of this approach. An example of using the method is shown in Figure 3.

**Figure 3.** Example of the effect achieved by the locally adaptive thresholding: (**a**) original image; (**b**) after processing; based on [60].

### *3.3. Otsu Thresholding*

The Otsu method is a very popular method, valued for its simplicity and efficiency. The algorithm was published in 1979 [61]. The aim of the algorithm is to binaryize the image, i.e., to convert the grayscale image to a binary image. The method is based on the histogram analysis and consists in minimizing the sum of the weighted variance of two classes (background and foreground objects), which is the same as maximizing the interclass variance. The method is particularly well suited for cases where the number of background and foreground pixels is similar. The idea of this method is shown in Figure 4.

**Figure 4.** The Otsu method visualization.

Talab et al. [62] used the Otsu algorithm to detect major cracks on the surface of concrete structures. The original image was initially modified with a Sobel filter. The proposed method allowed for clear and accurate detection of cracks in images. Valenca et al. [63] developed an innovative method called the "MCRACK", which aimed at automatic identification of the cracking patterns on the surface of cement composites, using digital image processing techniques. The whole procedure consisted of 6 stages. In one of the stages it was necessary to create a binary image which reinforced the discontinuities on the surface of the material. For this purpose, several algorithms of image binearization were compared, including the Canny edge detector, the Otsu method and the manual threshold. Binearization with the Otsu algorithm proved to be the most stable and gave the most accurate results, so it was decided to implement it in the final method. Hoang [64] proposed a way to improve the Otsu method (Figure 5) by earlier implementation of an image enhancement algorithm called the Min-Max Grey Level Discrimination. The whole procedure allowed for positive identification of cracks on the surface

of cement composites, additionally analyzing the morphology of individual cracks, i.e., determining perimeter, area, width, length and orientation.

**Figure 5.** Extraction of cracks with Otsu thresholding: (**a**) original image; (**b**) after processing; based on [64].
