Detect concrete cracks based on OTSU algorithm with differential image

: Aiming at the detection of concrete surface cracks, based on digital image processing technology, OTSU algorithm is processed based on differential image. First, the Gaussian filter is acted on the original image to obtain the smoothed image. Then the smoothed image is subtracted by the original image, the differential image is obtained. According to the OTSU algorithm, the optimal threshold on the differential image was calculated. As the characteristic cracks are a few pixels and with lower grey values, the pixels whose grey values are less than the mean value of the whole image to get the best threshold value were only calculated. Finally, remove the background noise based on the morphologic noise reduction to obtain the binary image of the crack. The experimental results show that the cracks can be discerned in complex backgrounds.


Introduction
The concrete crack is a kind of disease characteristic of building structure, it affects the safety of the structure seriously. The detection of crack is an important link in the inspection and safety evaluation of concrete [1][2][3]. Especially for large concrete structures, it is difficult to use close-range or point-type detection instruments. With the development of computer technology and image sensors, digital image processing technology has been widely used in various fields. Using digital image processing technology for identification has the advantages of non-contact, non-destructive, and high measurement speed [4][5][6]. It can be applied to hydropower dams [7], bridges [8], roads [9], and tunnels [10], as well as geological structures [11] and other cracks detection.
In the process of digital image processing, binarisation of the image is very critical in order to identify and measure the cracks correctly. Due to the influence of external light and air disturbance during the image capturing process, the image light is uneven or partially blurred. The background area of the acquired image is also very complicated, which causes great difficulties in the binarisation of the image. In the proposed automatic image threshold selection method, the representative methods are histogram trough method, OTSU, maximum entropy method, moment hold method, gradient statistics method etc. [12] The thresholding method was originally proposed by OTSU and is known as the OTSU algorithm [13]. It is a widely used image segmentation method. It uses each pixel in the image which belongs to the target or to the background area and then obtain the corresponding binarised image. In the early proposed threshold segmentation algorithm, the basic method is to obtain the objective function, and then the maximum value of the objective function is obtained, and the corresponding threshold is the optimal threshold. This algorithm solves the problem of selecting the image segmentation threshold, it is superior to the commonly used greydifference histogram method, differential histogram method etc. However, due to the lack of self-adaptation, noise interference and over-segmentation phenomenon will be generated [14]. The research by Lee et al. shows that when the area of the target is >30% of the whole image, the segmentation performance of the traditional algorithm is close to the optimal value. When the relative area of the target is reduced, the performance of these methods is rapidly reduced [15].
In the image of the concrete surface, the noise of the background is large, the grey scale is not uniform, and the area occupied by the crack area is small. It is difficult to recognise using the OTSU algorithm. This paper proposes OTSU algorithm based on differential image to solve the problem. First, the original image is filtered to obtain a smooth image, and then the original image and the smooth image are subtracted to obtain a differential image. For the part below the mean grey value of the differential image, the maximum variance between clusters is used to obtain the best threshold for segmentation. Morphological denoising is used to further reduce the background noise [16], and the binary image of the crack is identified.

Methodology
Digital image processing technology obtains the target image, digitises the image, and digitally process the image information through the computer. In modern architectural engineering, concrete is the most widely used building material, cracks are the most important defect in concrete structures. Many concrete surfaces have large variations in grayscale values and difficult to distinguish from cracks. However, the obtained image due to uneven illumination and surface erosion will also increase the complexity of the image structure. It is difficult to identify concrete cracks by using image method. Fig. 1 is a grayscale image of several concrete surfaces that containing crack defects. The image resolution is 2448 × 2048. Fig. 1a is a painted concrete wall surface, Fig. 1b is a concrete structure surface, and Fig. 1c is an asphalt concrete road surface.
The images in Fig. 1 represent common concrete surface materials and crack defects. The global binarisation methods used for the above crack images cannot fully extract the crack defects and using the OTSU method cannot obtain good results. Using local binarisation or adaptive binarisation method can get good results, but the parameters lack objectivity, and the automatic recognition ability is poor.
The method proposed in this paper aims at the automatic extraction of cracks for images under complex background and lighting conditions. In order to implement the method, first, the illumination and the background need to be homogenised, the grey difference of the background pixel is reduced, and the noise point is reduced. This is achieved by using Gaussian filtering.
The Gaussian kernel can produce multi-scale space. Suppose the original image I(x, y) is an 8-bit grayscale image, the image scale space L(x, y, σ) is the convolution operation of the original image I(x, y) and the variable scale two-dimensional Gaussian function G(x, y, σ).
The two-dimensional space Gaussian function is Scale space is According to formula (2), smooth the original image and subtract the grey value of the pixel corresponding to the original image to obtain a differential image: The differential image obtained by formula (3) is a 16-bit signed number, the pixels with grey values may be below 0. The grayscale image is an unsigned number of 0-255 grayscale values. Therefore, to obtain the minimum grey value of the differential image deform formula (3) to The range of the grayscale value of the differential image calculated by formula (4) is 0-255, and the effects of uneven illumination and background noise can be eliminated better.
Considering the crack defect is less distributed on the surface of the building, the total area is generally not >30% of the whole image. The grey value of the crack area is relatively small and the ideal segmentation result cannot be obtained directly for the differential image processing. Therefore, to calculate the grey average value I′′(x, y) of the differential image with formula (4), the Otsu method with maximal variance between two classes is performed only for the portion below the grey average value.
Using OTSU method for image segmentation, the threshold value should be selected to satisfy the target and background with the largest grey difference and the smallest error probability. For example, using {0, 1, 2, …, L − 1} to represent L different grey levels of an image, n i indicates the number of pixels whose grey level is i. The total number of pixels of the image is N = ∑ i = 0 L − 1 n i . The probability of each grey level appearing is p i = n i /N . Suppose we select T(k) (0 < k < L − 1) as the threshold, the probability that the target area A and the background area B appear are The average grey value of target area A and background area B are The grayscale of the whole image is Therefore, the variance of the target area A and the background area B can be obtained as: When σ 2 (k) obtains the maximum value, the corresponding threshold T(k) is the optimal threshold. OTSU threshold segmentation is performed for the part below the mean grey value of the differential image. The ideal segmentation result is automatically obtained and parameter adjustment is not required.
There are still some noises in the image obtained after threshold segmentation. Morphological denoising can be performed on binary images, to remove image background noise. The morphological denoising is based on the morphological structure element, extracts and manipulates the graphics. It can remove the irrelevant structures while maintaining the shape features of the target image. This paper uses morphological closing operation to process the image. Morphological closing operation is the expansion and corrosion of the image.
Suppose two-dimensional space Z 2 , A is a connected set, B is a structural element, use B to expand A: Use B to corrode A: where A c is a complement set of A, and ∅ is an empty set.
In this paper, the 3 × 3 structural element is used for performing morphological closing operation on crack binary images. Which can not only fill in the cracks but also eliminate the small noises and burrs and make the crack feature smooth and prominent.

Results
According to the previous method, this paper uses the Microsoft Visual Studio2005 development environment, loads the OpenCV library, and performs experimental verification.
First, the Gaussian smoothing filter is performed on each image in Fig. 1, and the obtained results are shown in Fig. 2.
It can be seen from Fig. 2 that after smoothing, the crack defects in the image become blurred, and the background becomes smooth.
Differential processing by Fig. 1 and Fig. 2, the results are shown in Fig. 3. After the difference, the background of the image is uniform, which eliminates the influence of uneven illumination and background noise and facilitates subsequent image processing.
The differential image is processed by using the maximum variance between clusters. Fig. 4 shows the results of processing the entire grey interval of the differential image.  Fig. 4, the maximum difference between clusters method is used to process the differential image. When the best threshold value is selected within the entire grey range of the differential image, the background and cracks cannot distinguish sufficiently, which is not conducive to denoising. Fig. 5 shows the results of processing the part below the mean value of the differential image.
From Fig. 5, when the best threshold value is selected by using the maximum variance between clusters method for the portion below the average grey value of the differential image, the result can effectively split the background and cracks. The noise area of the background area is small, which is conducive to subsequent processing.
Morphological denoising is performed based on the results of Fig. 5 and the final results obtained are shown in Fig. 6.
From the results shown in Fig. 6, after the morphological denoising operation, for the three kinds of original images in Fig. 1, the crack binary image information can be fully extracted, and the crack features are clear. In Fig. 6c, there are still some noise in the result, but the fracture features are well preserved and clearly distinguishable from the background noise.
The algorithm in this paper can automatically identify the binary image of cracks on the concrete surface without adjusting the parameters. This method can effectively identify crack images on different concrete surfaces.

Conclusion
In order to identify cracks on the concrete surface effectively, the OTSU method based on differential image is used to extract the binary images of cracks. First, the crack image is smoothed using Gaussian filter and compared with the original image to obtain a differential image. Then, the maximum difference between clusters method is applied to automatically select a threshold value for the part below the average grey value of the differential image, thereby extracting the binary image of the crack. The results show that this method can automatically identify cracks on different concrete surfaces and complex backgrounds.
Next step, the connected domain denoising algorithm will be introduced to further eliminate the residual noise in the crack binary image.