A surface crack detection method based on image processing

CN117974627BActive Publication Date: 2026-10-09HEFEI UNIV OF TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410250273.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-03-05
Publication Date
2026-10-09
Estimated Expiration
2044-03-05

AI Technical Summary

Technical Problem

但是传统算法大多针对特定背景的裂缝进行检测,不能很好的泛化到其他裂缝图像

Benefits of technology

[0039]1. This invention automatically calculates the segmentation threshold by combining the local and global statistical features of the image during image segmentation. This method overcomes the problem of insufficient applicability caused by the need to manually set a fixed threshold in traditional algorithms. It can adaptively calculate the optimal threshold according to different backgrounds, has good generalization ability, good crack detection effect, and high degree of automation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117974627B_ABST
    Figure CN117974627B_ABST
Patent Text Reader

Abstract

The application discloses a surface crack detection method based on image processing, which comprises the following steps: 1, using a collecting device to collect images on a surface with cracks; 2, performing pretreatment of the collected images, such as gray scale transformation, image filtering and image enhancement; 3, performing image segmentation on the pretreated images to obtain a crack segmentation image; 4, performing binary image processing on the segmented image to remove noise and obtain a fine segmentation image; and 5, performing skeletonization processing on the crack area, calculating crack length information by using pixel statistics, and calculating the maximum width and average width of the crack by using an orthogonal skeleton line method. The application can improve the recognition accuracy of complex cracks, thereby being favorable for accurately evaluating the surface damage degree.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of crack detection technology, specifically to a surface crack detection method based on image processing. Background Technology

[0002] The structural safety of bridges, buildings, and other structures is crucial to the safety of people's lives and property. However, due to prolonged use and various factors (such as earthquakes, natural aging, and foundation settlement), various defects and problems can appear on the surface of buildings, seriously affecting their structural safety and service life. Timely and effective detection in the early stages of these defects can not only greatly reduce the risk of accidents but also significantly extend the lifespan of buildings.

[0003] Cracks are the most common surface defects in building structures. Cracks not only affect the aesthetics of a building and cause surface leaks, but can also impact its strength, stability, and durability. Failure to detect and repair cracks in a timely manner can lead to incalculable damage. Manual inspection is a very common method for crack detection; however, it relies on human judgment, and the results are affected by the variability of both the inspector and the equipment used, potentially leading to missed detections or misjudgments, resulting in inaccurate and inconsistent measurement results. Therefore, manual crack detection methods cannot meet the needs of practical engineering applications.

[0004] With the development of digital image processing technology, crack detection using image processing techniques has become a faster, more accurate, and reliable method. Surface crack images acquired using acquisition devices are processed through crack segmentation and extraction, feature analysis, and other methods to obtain quantitative information such as crack width and length, thus achieving crack detection. However, traditional algorithms are mostly designed for cracks in specific backgrounds and cannot be well generalized to other crack images. Furthermore, current crack width calculations are based on binary image processing, making them easily affected by image binarization, which reduces detection accuracy. Summary of the Invention

[0005] The present invention addresses the shortcomings of existing algorithms by providing an image processing-based surface crack detection method, which aims to improve the identification accuracy of complex cracks and thus facilitate accurate assessment of the degree of surface damage.

[0006] To achieve the above-mentioned objectives, the present invention adopts the following solution:

[0007] The surface crack detection method based on image processing of this invention is characterized by the following steps:

[0008] Step 1: Acquire the image of the crack area and convert it into a grayscale image. Perform bilateral filtering on the grayscale image to remove background noise and obtain the filtered image. Then, use Gamma transformation to enhance the filtered image and obtain the preprocessed image.

[0009] Step 2: Use an adaptive thresholding segmentation algorithm to perform preliminary crack region segmentation on the preprocessed image to obtain a binary crack image;

[0010] Step 3: Use morphological operations to remove noise and smooth the contours in the binary crack image to obtain a denoised binary crack image. Obtain the feature components of all connected components in the denoised binary crack image, and use connected component analysis to remove connected components that do not meet the threshold conditions, thereby obtaining a fine segmentation image.

[0011] Step 4: Perform feature parameter analysis on the crack region in the finely segmented image, including: using the improved Zhang parallel thinning algorithm to thin the finely segmented image to obtain crack skeleton lines with a single pixel width; calculating the number of crack skeleton line pixels in the crack region and obtaining the crack length information; and using the orthogonal skeleton line method to obtain the maximum width and average width of the crack.

[0012] The surface crack detection method based on image processing described in this invention is also characterized in that step 2 includes:

[0013] Step 2.1: Obtain a neighborhood of size B×B around any pixel in the i-th row and j-th column of the preprocessed image, and calculate the Gaussian weighted average of all pixels in the neighborhood;

[0014] Step 2.2: Determine the correction constant C for the segmentation threshold:

[0015] Step 2.2.1: Preset a fixed threshold correction constant C. b And calculate the mean m and standard deviation s of the grayscale image;

[0016] Step 2.2.2: Determine a correction constant C for a dynamic threshold based on the mean m and standard deviation s. d :

[0017] Based on the mean distribution of all crack images, n-1 mean intervals (μ1, μ2], (μ2, μ3], ..., (μ1, μ2] are set. p ,μ p+1 ]…,(μ n-1 ,μ n ], where (μ p ,μ p+1 ] represents the p-th mean interval;

[0018] Determine the mean interval to which the mean m of the grayscale image belongs. And at p m Within each mean interval, n-1 standard deviation intervals are set. in, express The q-th standard deviation interval within;

[0019] Determine the standard deviation interval to which the standard deviation s belongs. Therefore, use equation (1) to calculate The correction constant C of the dynamic threshold within d :

[0020]

[0021] In formula (1); and Indicates the qth m interval of standard deviation The two scaling factors within;

[0022] Step 2.2.3: Use equation (2) to obtain the correction constant C for the segmentation threshold:

[0023] C = C b +C d (2)

[0024] Step 2.3: Subtract C from the Gaussian weighted average value of the neighborhood of the pixel in the i-th row and j-th column to obtain the segmentation threshold T for the pixel in the i-th row and j-th column. ij If the grayscale value of the pixel in the i-th row and j-th column is greater than T ij If the gray value of the pixel in the i-th row and j-th column is 0, then the gray value of the pixel in the i-th row and j-th column is set to 255; otherwise, the gray value of the pixel in the i-th row and j-th column is set to 255; thus, each pixel in the preprocessed image is processed to obtain a binary crack image.

[0025] The feature components in step 3 include: the area ratio of connected components, the aspect ratio of the minimum bounding rectangle of the connected components, and the rectangularity of the connected components. Connected components that do not meet the threshold conditions of any feature component are removed.

[0026] In step 4, the maximum and average widths of the cracks are calculated as follows:

[0027] Step 4.1: Calculate the normal vector of each point on the crack skeleton line using the local pixel point line fitting method;

[0028] Step 4.2: Taking each point on the crack skeleton line as the starting point, sample the grayscale image along its respective normal vector and its opposite direction, and fit the grayscale values ​​of all sampled points using a Gaussian function to obtain the fitting curve;

[0029] Step 4.3: Calculate the mean and standard deviation of the fitted curve, and use the difference between the mean and standard deviation as the preliminary determination of the left edge point of the crack, and use the sum of the mean and standard deviation as the preliminary determination of the right edge point of the crack.

[0030] Step 4.4: Accurately determine the final left and right edge points of the crack using the grayscale thresholding method:

[0031] Step 4.4.1: Obtain the minimum gray value among all sampling points, and then sum the gray values ​​of all sampling points and calculate the average.

[0032] Step 4.4.2: Starting from the left edge point; initialize c = 1;

[0033] Step 4.4.3: Take any c-th sampling point in the neighborhood of the starting point as the current sampling point;

[0034] Step 4.4.4: Compare the grayscale value of the current sampling point with the mean and minimum value respectively. If the grayscale value of the current sampling point is greater than the mean and the difference between the grayscale value and the minimum value is greater than the set threshold, then the current sampling point is considered background, and the (c-1)th sampling point is the final left edge point of the crack (x). l ,y l If the current sampling point belongs to the crack region, then execute step 4.5; otherwise, it indicates that the current sampling point belongs to the crack region, and after assigning c+1 to c, return to step 4.4.3.

[0035] Step 4.5: Starting from the right edge point and initializing c=1, obtain the final right edge point (x) of the crack following steps 4.4.3-4.4.4. r ,y r ).

[0036] The present invention provides an electronic device, including a memory and a processor, wherein the memory is used to store a program that supports the processor in executing the surface crack detection method, and the processor is configured to execute the program stored in the memory.

[0037] The present invention discloses a computer-readable storage medium on which a computer program is stored, wherein the computer program is executed by a processor to perform the steps of the surface crack detection method.

[0038] Compared with existing algorithms, the advantages of this invention are:

[0039] 1. This invention automatically calculates the segmentation threshold by combining the local and global statistical features of the image during image segmentation. This method overcomes the problem of insufficient applicability caused by the need to manually set a fixed threshold in traditional algorithms. It can adaptively calculate the optimal threshold according to different backgrounds, has good generalization ability, good crack detection effect, and high degree of automation.

[0040] 2. This invention addresses the problems of missing binary image information and susceptibility to image binarization in traditional width calculation based on binary images. It proposes a crack width calculation based on grayscale images. Grayscale images retain the brightness information of each pixel, providing rich details and edge information. The width calculation results are not affected by the threshold segmentation results, enabling more accurate crack width calculation.

[0041] 3. This invention proposes a crack width measurement method that combines curve fitting and grayscale thresholding. Curve fitting can effectively reduce the influence of noise and interference in the image, improving the robustness and accuracy of the measurement. Grayscale thresholding can effectively distinguish between cracks and background, reducing the impact of uneven illumination on the measurement results and improving the measurement accuracy. Attached Figure Description

[0042] Figure 1 This is a flowchart of an image processing-based surface crack detection method according to the present invention;

[0043] Figure 2 This is a schematic diagram of the grayscale transformation of the crack image according to the present invention;

[0044] Figure 3 This is a schematic diagram of filtering and denoising the crack image according to the present invention;

[0045] Figure 4 This is a schematic diagram of image enhancement for crack images according to the present invention;

[0046] Figure 5 This is a schematic diagram of image segmentation for the crack image of the present invention;

[0047] Figure 6 This is a schematic diagram of binary image processing for crack images according to the present invention;

[0048] Figure 7 This is a schematic diagram of the length measurement of the crack image according to the present invention;

[0049] Figure 8 This is a schematic diagram illustrating the measurement of the width of the crack image according to the present invention. Detailed Implementation

[0050] In this embodiment, an image processing-based surface crack detection method is proposed to obtain feature information such as crack length and width. The specific process is as follows: Figure 1As shown, the procedure is as follows:

[0051] Step 1: Acquire the image of the crack area and convert it into a grayscale image. Perform bilateral filtering on the grayscale image to remove background noise, obtaining the filtered image. Then, use Gamma transform to enhance the filtered image, obtaining the preprocessed image. The specific steps are as follows:

[0052] Step 1.1: Convert the color crack image to a grayscale image. The conversion formula is shown in equation (1):

[0053] Gray(i,j)=WR(i,j)+VG(i,j)+UB(i,j) (1)

[0054] In equation (1), R(i,j), G(i,j), and B(i,j) represent the red, green, and blue channel component values ​​of the pixel at position (i,j) in the image, respectively; W, V, and U represent the weights of R(i,j), G(i,j), and B(i,j), respectively; and Gray(i,j) represents the grayscale value of the pixel. Since the human eye is most sensitive to green and least sensitive to blue, a relatively reasonable grayscale image can be obtained by weighting the RGB components according to W = 0.299, V = 0.587, and U = 0.114. Figure 2 This is a schematic diagram of grayscale transformation of a crack image.

[0055] Step 1.2: When using an image acquisition device to acquire images, there will be a lot of noise in the images, so it is necessary to denoise the grayscale images. Although the classic mean filtering and median filtering can achieve good denoising, they will inevitably cause blurring of the crack edges, which will have an adverse effect on subsequent crack identification. Therefore, the bilateral filtering method is selected to denoise the grayscale images. Bilateral filtering can effectively preserve the crack edge information while eliminating noise. The bilateral filtering process can be expressed as Equation (2):

[0056]

[0057] In equation (2), σ d and σ r These are smoothing parameters, where I(i,j) and I(k,l) are the pixel intensities at (i,j) and (k,l) respectively. After obtaining the weights and standardizing them, they can be expressed as Equation (3):

[0058]

[0059] In equation (3), I D It is the pixel intensity at (i,j) after filtering. Figure 3This is a schematic diagram of crack image filtering and denoising. Bilateral filtering removes a large amount of interference information in the image and protects the crack edges.

[0060] Step 1.3: Generally, the crack area is darker while the background area is brighter. Gamma transformation is used to enhance the filtered image. By adjusting the contrast between the crack area and the background area, the crack area can be further highlighted and made more easily identifiable. Figure 4 This is a schematic diagram of image enhancement for a crack image, resulting in the preprocessed image.

[0061] Step 2: Use an adaptive thresholding segmentation algorithm to perform preliminary crack region segmentation on the preprocessed image to obtain a binary crack image. The specific steps are as follows:

[0062] Step 2.1: Obtain a neighborhood of size B×B around any pixel in the i-th row and j-th column of the preprocessed image, and calculate the Gaussian weighted average of all pixels in the neighborhood.

[0063] Step 2.2: Determine the correction constant C for the segmentation threshold:

[0064] Step 2.2.1: Preset a fixed threshold correction constant C. b And calculate the mean m and standard deviation s of the grayscale image;

[0065] Step 2.2.2: Determine a correction constant C for a dynamic threshold based on the mean m and standard deviation s. d :

[0066] Based on the mean distribution of all crack images, n-1 mean intervals (μ1, μ2], (μ2, μ3], ..., (μ1, μ2] are set. p ,μ p+1 ]…,(μ n-1 ,μ n ], where (μ p ,μ p+1 ] represents the p-th mean interval;

[0067] Determine the mean interval to which the mean m of the grayscale image belongs. And at p m Within each mean interval, n-1 standard deviation intervals are set. in, express The qth standard deviation interval within.

[0068] Determine the standard deviation interval to which the standard deviation s belongs. Therefore, equation (4) is used to calculate The correction constant C of the dynamic threshold within d :

[0069]

[0070] In equation (4); and Indicates the qth m interval of standard deviation The two scaling factors within.

[0071] Step 2.2.3: Use equation (5) to obtain the correction constant C for the segmentation threshold:

[0072] C = C b +C d (5)

[0073] Step 2.3: Subtract C from the Gaussian weighted average value of the neighborhood of the pixel in the i-th row and j-th column to obtain the segmentation threshold T for the pixel in the i-th row and j-th column. ij If the grayscale value of the pixel in the i-th row and j-th column is greater than T ij If the gray value of the pixel in the i-th row and j-th column is 0, then the gray value of the pixel in the i-th row and j-th column is set to 255; otherwise, the gray value of the pixel in the i-th row and j-th column is set to 255; thus, each pixel in the preprocessed image is processed to obtain a binary crack image.

[0074] In this embodiment, the mean of the grayscale image represents the average level of pixel grayscale values ​​in the entire image, i.e., the overall brightness of the image, while the standard deviation represents the distribution of grayscale values ​​in the image. Two thresholds, 150 and 200, are set based on the mean distribution of the surface crack image, dividing it into three levels: bright, medium brightness, and dim. Then, C is calculated based on the standard deviation. d The specific calculation method is as follows:

[0075] When m≤150:

[0076]

[0077] When 150 < m ≤ 200:

[0078]

[0079] When m > 200:

[0080]

[0081] When the neighborhood B is 65, the basic threshold correction constant C b The adaptive segmentation result of the crack image is as follows: (The value is 12) Figure 5 As shown.

[0082] Step 3: Step 2 initially generated a binary crack image using an adaptive threshold segmentation algorithm. However, due to the presence of a large amount of isolated noise in the binary image, such as stains and background depressions, post-processing is required. First, morphological operations are used to remove noise and smooth the contours of the binary crack image. Specifically, opening operations are used to eliminate noise points, making the cracks clearer and more accurate. Then, dilation operations are used to connect potentially broken crack regions. Finally, closing operations are used to make the cracks more continuous and complete, and to smooth the crack boundaries. The denoised binary crack image is obtained through morphological operations. Morphological operations can remove small noise regions in the binary image, but for larger noise regions, including large stains and localized background depressions, morphological operations alone cannot completely eliminate them. For large noise regions in the binary image, the feature components of all connected components in the denoised binary crack image can be obtained, and connected component analysis can be used to remove connected components that do not meet the threshold conditions, thus obtaining a finely segmented image. The connected component features used include: the area ratio of the connected components, the aspect ratio of the minimum bounding rectangle of the connected components, and the rectangularity of the connected components. Connected components that do not meet the threshold conditions of any feature component are removed. The specific implementation is as follows:

[0083] The area of ​​a connected component in a binary image can be obtained by calculating the number of pixels within that component. Generally, the area of ​​the connected component belonging to the crack varies in different crack images, making it difficult to choose a suitable value to remove noise and retain the true crack region. However, the area of ​​the connected component belonging to the crack is generally the largest among all connected components in the binary image. Therefore, the ratio of connected component areas can be used as a criterion to retain connected components that meet the criterion. The area S of each connected component is then obtained. c The area of ​​the largest connected component is S. max This is because the crack region size varies in different crack images, therefore S max It is a variable elastic value. The ratio of connected region areas can be expressed as equation (9):

[0084]

[0085] Given a connected component area ratio threshold T s , will ρ s Less than T s Connected component removal.

[0086] The aspect ratio of the minimum bounding rectangle of a crack typically varies considerably and can represent the extent of connected components; this feature can be used to extract cracks. To obtain the minimum bounding rectangle of each connected component, let's assume L... max and L min Let the long side and the short side of the minimum bounding rectangle of the connected component be represented respectively. Then the aspect ratio of the minimum bounding rectangle of the connected component can be expressed as Equation (10):

[0087]

[0088] Given a threshold T for the aspect ratio of the minimum bounding rectangle of a connected component. l , will ρ l Less than T l Connected component removal.

[0089] The rectangularity of a connected component can be used to represent the degree of similarity between the shape of the connected component and the shape of its circumscribed rectangle. Rectangularity can be measured by the ratio of the area of ​​the connected component to the area of ​​its smallest circumscribed rectangle. Rectangularity can be expressed as equation (11):

[0090]

[0091] Obtain the rectangularity threshold T of the minimum bounding rectangle of a given connected component. R , will ρ R Greater than T R Connected components are removed. The process involves traversing all connected components in the binary image and applying the aforementioned conditional checks to each component to obtain a finely segmented image. Figure 6 It is a threshold set to T after morphological operations and connected component analysis. s =0.01, T l =3, T R The result after setting the value to 0.25.

[0092] Step 4: Perform feature parameter analysis on the crack region in the finely segmented image, including: using the improved Zhang parallel thinning algorithm to thin the finely segmented image and obtain crack skeleton lines with a single pixel width; calculating the number of crack skeleton line pixels in the crack region and obtaining the crack length information; and using the orthogonal skeleton line method to obtain the maximum width and average width of the crack. The specific steps are as follows:

[0093] Step 4.1: Use the improved Zhang parallel thinning algorithm to obtain the crack skeleton line with a width of one pixel.

[0094] Step 4.2, as follows Figure 7 The crack length is calculated by counting the number of pixels on the skeleton line. In the binary image, pixels with a gray value of 255 belong to the crack region, while pixels with a gray value of 0 belong to the background region. When a pixel with a gray value of 255 is scanned in the binary image, it is marked as 1; otherwise, it is marked as 0. The crack length is obtained by scanning the thinned binary image line by line and counting the total number of pixels marked as 1. The specific calculation formula is shown in equation (12):

[0095]

[0096] Step 4.3: The maximum and average width of the crack are calculated as follows:

[0097] Step 4.3.1: Calculate the normal vector of each point on the crack skeleton line using a local pixel-based line fitting method. The crack skeleton line is usually continuous and relatively smooth, approximating a straight line in local regions. Therefore, a local pixel-based line fitting method can be used to estimate the normal vector. First, for a pixel on the skeleton line, select neighboring points within a certain range to obtain a local point set. Use the least squares method as the fitting method for the local line and Euclidean distance as the fitting error metric to perform line fitting based on the local point set. The direction vector of the fitted line can be calculated based on its parameters. Rotating the direction vector by 90 degrees yields the normal vector at that point.

[0098] Step 4.3.2: After obtaining the normal vector, take each point on the crack skeleton line as the starting point, and sample the grayscale image along their respective normal vectors and their opposite directions to obtain a set of sampling points. Then, use the Gaussian function to fit the grayscale values ​​of all sampling points to obtain the fitting curve.

[0099] Step 4.3.3: Calculate the mean and standard deviation of the fitted curve, and use the difference between the mean and the standard deviation as the preliminary determination of the left edge point of the crack, and use the sum of the mean and the standard deviation as the preliminary determination of the right edge point of the crack.

[0100] Step 4.3.4: Accurately determine the final left and right edge points of the crack using the grayscale thresholding method. The specific steps are as follows:

[0101] Step 4.3.4.1: Obtain the minimum gray value among all sampling points, and then sum the gray values ​​of all sampling points and calculate the average.

[0102] Step 4.3.4.2: Starting from the left edge point; initialize c = 1;

[0103] Step 4.3.4.3: Take any c-th sampling point in the neighborhood of the starting point as the current sampling point;

[0104] Step 4.3.4.4: Compare the grayscale value of the current sampling point with the mean and minimum value respectively. If the grayscale value of the current sampling point is greater than the mean and the difference between the grayscale value and the minimum value is greater than the set threshold, then the current sampling point is considered background, and the (c-1)th sampling point is the final left edge point of the crack (x). l ,y l If the current sampling point belongs to the crack region, then execute step 4.3.5; otherwise, it indicates that the current sampling point belongs to the crack region, and after assigning c+1 to c, return to step 4.3.4.3.

[0105] Step 4.3.5: Starting from the right edge point and initializing c=1, obtain the final right edge point (x) of the crack according to steps 4.3.4.3-4.3.4.4. r ,y r ).

[0106] Generally, the gray values ​​of pixels belonging to the crack area are lower than those of background pixels. Therefore, pixels outside the crack area can be eliminated by taking the average of the gray values ​​of all sampling points. However, due to uneven lighting, the gray values ​​of pixels in the crack area fluctuate. If only the average method is used, pixels with higher gray values ​​in the crack area may be mistakenly identified as background pixels. Therefore, the minimum gray value among all sampling points is obtained and a threshold is set. The gray value of the current sampling point is compared with the minimum value. If the difference between the two gray values ​​is greater than the threshold, it is considered a background pixel; otherwise, it belongs to the crack area. After obtaining the left and right edge points of the crack, the crack width is calculated as shown in the following formula (13):

[0107]

[0108] In equation (13), w represents the crack width at the skeleton point.

[0109] Calculate the crack width at all points on the crack skeleton line. The maximum and average crack widths are obtained by equations (14) and (15):

[0110] w max =max(w k (14)

[0111]

[0112] In equations (14) and (15), w max w represents the maximum width of the crack. mean represents the average width of the crack, and N represents the number of pixels on the skeleton line. Figure 8 This is a schematic diagram for measuring the width of a crack image.

[0113] In this embodiment, an electronic device includes a memory and a processor. The memory stores a program that supports the processor in executing the above-described method, and the processor is configured to execute the program stored in the memory.

[0114] In this embodiment, a computer-readable storage medium stores a computer program, which is executed by a processor to perform the steps of the above method.

Claims

1. A surface crack detection method based on image processing, characterized in that, The procedure is as follows: Step 1: Acquire the image of the crack area and convert it into a grayscale image. Perform bilateral filtering on the grayscale image to remove background noise and obtain the filtered image. Then, use Gamma transformation to enhance the filtered image and obtain the preprocessed image. Step 2: Use an adaptive thresholding segmentation algorithm to perform preliminary crack region segmentation on the preprocessed image to obtain a binary crack image; Step 3: Use morphological operations to remove noise and smooth the contours in the binary crack image to obtain a denoised binary crack image. Obtain the feature components of all connected components in the denoised binary crack image, and use connected component analysis to remove connected components that do not meet the threshold conditions, thereby obtaining a fine segmentation image. Step 4: Perform feature parameter analysis on the crack region in the finely segmented image, including: using the improved Zhang parallel thinning algorithm to thin the finely segmented image and obtain crack skeleton lines with a single pixel width; calculate the number of crack skeleton line pixels in the crack region and obtain the crack length information; and use the orthogonal skeleton line method to obtain the maximum width and average width of the crack. Step 4.1: Calculate the normal vector of each point on the crack skeleton line using the local pixel point line fitting method; Step 4.2: Taking each point on the crack skeleton line as the starting point, sample the grayscale image along its respective normal vector and its opposite direction, and fit the grayscale values ​​of all sampled points using a Gaussian function to obtain the fitting curve; Step 4.3: Calculate the mean and standard deviation of the fitted curve, and use the difference between the mean and standard deviation as the preliminary determination of the left edge point of the crack, and use the sum of the mean and standard deviation as the preliminary determination of the right edge point of the crack. Step 4.4: Accurately determine the final left and right edge points of the crack using the grayscale thresholding method: Step 4.4.1: Obtain the minimum gray value among all sampling points, and then sum the gray values ​​of all sampling points and calculate the average. Step 4.4.2: Starting from the left edge point; initialize c=1; Step 4.4.3: Take any c-th sampling point in the neighborhood of the starting point as the current sampling point; Step 4.4.4: Compare the grayscale value of the current sampling point with the mean and minimum value respectively. If the grayscale value of the current sampling point is greater than the mean and the difference between the grayscale value and the minimum value is greater than the set threshold, then the current sampling point is the background, and the (c-1)th sampling point is the final left edge point of the crack. If the current sampling point belongs to the crack region, then execute step 4.5; otherwise, assign c+1 to c and return to step 4.4.

3. Step 4.5: Starting from the right edge point and initializing c=1, obtain the final right edge point of the crack following steps 4.4.3-4.4.

4. .

2. The surface crack detection method based on image processing according to claim 1, characterized in that, Step 2 includes: Step 2.1: Obtain a neighborhood of size B×B around any pixel in the i-th row and j-th column of the preprocessed image, and calculate the Gaussian weighted average of all pixels in the neighborhood; Step 2.2: Determine the correction constant C for the segmentation threshold: Step 2.2.1: Preset a fixed threshold correction constant. And calculate the mean m and standard deviation s of the grayscale image; Step 2.2.2: Determine a correction constant for a dynamic threshold based on the mean m and standard deviation s. : Based on the mean distribution of all crack images, set n-1 mean intervals. , ,… …, ,in, This represents the p-th interval of the mean. Determine the mean interval to which the mean m of the grayscale image belongs. and in the Within each mean interval, n-1 standard deviation intervals are set. , ,… ,… ,in, express The q-th standard deviation interval within; Determine the standard deviation interval to which the standard deviation s belongs. Therefore, use equation (1) to calculate Correction constant for dynamic threshold within : (1) In formula (1); and Indicates the first interval of standard deviation The two scaling factors within; Step 2.2.3: Use equation (2) to obtain the correction constant C for the segmentation threshold: (2) Step 2.3: Subtract C from the Gaussian weighted average value of the neighborhood of the pixel in the i-th row and j-th column to obtain the segmentation threshold T for the pixel in the i-th row and j-th column. ij If the grayscale value of the pixel in the i-th row and j-th column is greater than T ij If the gray value of the pixel in the i-th row and j-th column is 0, then the gray value of the pixel in the i-th row and j-th column is set to 255; otherwise, the gray value of the pixel in the i-th row and j-th column is set to 255; thus, each pixel in the preprocessed image is processed to obtain a binary crack image.

3. The surface crack detection method based on image processing according to claim 1, characterized in that, The feature components in step 3 include: the area ratio of connected components, the aspect ratio of the minimum bounding rectangle of the connected components, and the rectangularity of the connected components. Connected components that do not meet the threshold conditions of any feature component are removed.

4. An electronic device, comprising a memory and a processor, characterized in that, The memory is used to store programs that support the processor in executing the surface crack detection method according to any one of claims 1-3, and the processor is configured to execute the programs stored in the memory.

5. A computer-readable storage medium storing a computer program thereon, characterized in that, The computer program, when run by a processor, performs the steps of the surface crack detection method according to any one of claims 1-3.