A crack size measurement method based on image connectivity and skeleton analysis

By employing image connectivity and skeleton analysis, the problems of accuracy and efficiency in crack identification and measurement were solved, enabling rapid and accurate measurement of crack size in complex backgrounds.

CN115578343BActive Publication Date: 2026-01-02CHINACCS INFORMATION IND
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202211223265.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-10-08
Publication Date
2026-01-02
Estimated Expiration
2042-10-08

AI Technical Summary

Technical Problem

Existing technologies for crack identification and measurement suffer from insufficient accuracy, difficulty in adapting to complex scenarios, and high computational cost and time consumption. In particular, it is difficult to accurately measure the length, width, and other dimensions of cracks in complex environments.

Method used

A method based on image connectivity and skeleton analysis is adopted. Through image preprocessing, crack segmentation, skeleton extraction and Euclidean distance transformation, the minimum width, average width, maximum width and location information of the crack are calculated, combined with the measurement of crack length and area.

Benefits of technology

It enables rapid and accurate measurement of cracks in various scenarios, and has wide adaptability, low computing power consumption and high efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115578343B_ABST
    Figure CN115578343B_ABST
Patent Text Reader

Abstract

The application discloses a crack size measurement method based on image connectivity and skeleton analysis, and specifically comprises the following steps: image preprocessing and crack segmentation are performed on an original image, the connectivity graph of each crack is detected, the area of the connectivity graph is calculated by summing up the number of all pixel points in the connectivity graph, then the skeleton of the image is extracted, the Euclidean distance transformation is performed on all pixel points in the connectivity graph, and the distance transformation value of the pixel points on the skeleton is extracted from the distance transformation matrix of the calculated connectivity graph; the skeleton, the maximum crack width and the maximum crack position information are calculated, the skeleton line is drawn on the original image, the crack number and the width value are marked, and the image file is saved after the image crack visualization marking is completed. The application has the advantages that the application can be used for crack size measurement in various scenes, has the characteristics of wide application range, strong adaptability, accurate measurement, small calculation power consumption and high operation efficiency, and the like.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of image analysis processing, and in particular to a crack size measurement method based on image connectivity and skeleton analysis. BACKGROUND

[0002] The crack described in the present application refers to a long and narrow gap formed on the surface of an object, which is commonly found in geological structures, industrial products, roads, buildings, river embankments, etc. In many cases, cracks are a kind of defect and have potential hidden dangers, so people hope to find them as soon as possible in order to take appropriate measures in time. There are many methods for finding, identifying and measuring cracks, such as human eye observation method, field measurement method, instrument measurement method, electron beam scanning analysis method, image analysis method, etc.

[0003] In recent years, computer vision technology has developed rapidly, and more and more researchers have begun to use digital image processing and analysis technology to study the detection and identification of cracks, and even to calculate the length, width and other sizes of cracks. Since the digital image analysis method has universal adaptability and relatively low cost, it is widely used at present. By applying this technology, part of the manual work can be replaced, the production efficiency can be improved, and the cost can be reduced. It can be used for crack defect detection of industrial products, roads, buildings, river embankments, dams, etc., and has quite wide application.

[0004] However, due to the different shapes of cracks, no fixed rules, and different environmental backgrounds, as well as the influence of light, shooting angle and other factors, there are many interference factors, so it is often difficult to accurately identify cracks in a complex background, not to mention accurately measuring the sizes of cracks.

[0005] Through the study of papers in the past two years, it is found that the common methods for measuring crack width based on image processing and analysis technology at present can be divided into the following categories: ① solving the average width value of the crack based on the corresponding relationship between the perimeter and the area of the crack; ② calculating the maximum width of the crack by calculating the set of maximum inscribed circles corresponding to each pixel point in the crack; ③ detecting the edge contour and calculating the distance from each pixel point in the image to the edge contour to solve the maximum width of the crack.

[0006] We analyze the above three methods one by one. The first method is obviously an approximate solution method, and it can only solve the average width value and cannot guarantee the accuracy; the second method is an effective method, but it can only solve the maximum width, and the operation amount is huge, which is very time-consuming and not suitable for real-time applications; the third method is also a good method with the help of contour detection method, but the problem is that the contour is not completely equivalent to the crack, and when there are multiple cracks intersecting, the same crack will be identified as multiple contours, which will cause misidentification and directly lead to incorrect solution, so this method has certain limitations.

[0007] Through research and analysis of the prior art, it is found that some methods are not accurate enough, some methods have poor performance, some methods are difficult to adapt to complex crack scenes, and the size properties that can be measured are limited, which is difficult to meet the requirements of actual business.

[0008] The focus of the present application is to study a general crack size measurement method for different crack scenes, based on image processing and analysis theory, using image connectivity and skeleton analysis technology to quickly extract each crack from an image containing cracks, and solve the length, area, minimum width, maximum width, position, average width and other attribute values of the crack. SUMMARY

[0009] In view of the problems of the prior art, such as inaccurate recognition, poor performance, and difficulty in adapting to complex crack scenes, the present application provides a crack size measurement method based on image connectivity and skeleton analysis.

[0010] The present application is realized by the following technical scheme: a crack size measurement method based on image connectivity and skeleton analysis, the measurement method is:

[0011] Step S1: load a scene color image img_src containing cracks, pre-process the color image img_src, crack segmentation, and detect the crack connectivity graph in the color image img_src and the number of crack connectivity graphs graph_count;

[0012] Step S2: traverse each crack connectivity graph, set the loop variable i to 0, calculate the crack area of the i-th crack connectivity graph, and filter out the crack connectivity graph with small crack area;

[0013] Step S3: create a new graph curt_graph with the same rectangular shape and size as the pre-processed color image img_src, and identify the new graph curt_graph according to the crack connectivity graph, with background pixel value 0 and crack pixel value 1;

[0014] Step S4: extract the skeleton skel based on the identified curt_graph;

[0015] Step S5: perform Euclidean distance transformation on all pixel points in the identified curt_graph to form a distance transformation matrix dist with the same matrix shape and size as the skeleton skel and data type float;

[0016] Step S6: create a matrix skel_dist with the same matrix shape size, the same data type as the distance transformation matrix dist, and all data being 0; traverse each element in the skeleton skel, and extract the distance transformation value of the corresponding position of the distance transformation matrix dist whose element value is True, and assign it to the corresponding position of the matrix skel_dist;

[0017] Step S7: take the matrix skel_dist after assignment as the data basis, and calculate the minimum crack width, the average crack width, the maximum crack width, and the position information of the maximum crack width through the set operation of the matrix data;

[0018] Step S8: calculate the crack length and the crack area by summing up the number of all pixel points on the skeleton skel;

[0019] Step S9: according to the obtained crack skeleton, the maximum crack width, and the position information of the maximum crack width, draw the skeleton line on the color image img_src, draw the maximum inscribed circle at the position of the maximum crack width, and label the crack number and the width value at the position adjacent to the inscribed circle;

[0020] Step S10: the loop variable i is incremented by 1, and if i < graph_count, the step S2 is executed in a loop until i >= graph_count, and the loop is ended;

[0021] Step S11: after the above loop is ended, the image crack visualization marking is completed, and the image file is saved.

[0022] In the step S1, the method of pre-processing and crack segmentation is specifically:

[0023] Step S101: perform gray processing on the color image img_src to obtain a gray image img_gray;

[0024] Step S102: use a square structural element with an aperture size ksize of 7 as a mask to perform fuzzy processing on the gray image img_gray using a median filter algorithm to obtain an image img_medianblur; here, the median filter algorithm is used to perform fuzzy processing on the gray image img_gray to make the image background smoother and more integrated, increase the contrast between the crack and the background, and facilitate subsequent binarization processing;

[0025] Step S103: determine the optimal threshold value by using a triangle algorithm on the image img_medianblur, and perform image binarization to obtain a binarized image img_bin;

[0026] Step S104: foreground and background correction is performed on the binary image img_bin, white is crack, black is background, and the proportion of pixel values of the entire binary image img_bin is counted. If white pixels are more, the binary image img_bin is inverted;

[0027] Step S105: a square structural element with a side length of 3 is used as a mask, and the center of the square is used as an anchor point. Morphological closing operation is performed on the binary image img_bin to eliminate small black hole noise points in the crack. After processing, the image img_close is obtained;

[0028] Step S107: a square structural element with a side length of 3 is used as a mask, and the center of the square is used as an anchor point. Morphological opening operation is performed on the binary image img_close to eliminate small white spot noise points outside the crack. After processing, the image img_open is obtained;

[0029] Step S108: all crack connected graphs are detected from the binary image img_open, each crack connected graph is labeled differently, and the pixel values in the same crack connected graph are the same label value. The area of the crack connected graph is calculated by summing all pixel points in each crack connected graph, and the number of crack connected graphs graph_count is counted.

[0030] Further, in step S108, the method for detecting crack connected graphs from the binary image img_open is specifically:

[0031] S1081: prepare to traverse each pixel point of the binary image img_open, set the loop variable j to 0, and set the crack connected graph label k to 1;

[0032] S1082: if the jth pixel value is not 255, execute S1083, otherwise, mark the jth pixel value as k, judge its 8-neighborhood pixel value, if it is 255, mark it as k, continue to judge the 8-neighborhood pixel value of the pixel with value k in the 8-neighborhood, if it is 255, mark it as k; and so on, until all neighborhood values are not equal to 255, then a connected graph traversal is completed, and the crack connected graph label k is incremented by 1;

[0033] S1083: the loop variable j is incremented by 1, and the value of k is judged. If the value of k is less than the total number of pixels PT of the binary image img_open, the loop of S1082 is executed, until the value of j is greater than or equal to PT, the loop is ended.

[0034] The step S2 is specifically:

[0035] Step S201: prepare to traverse each crack connected graph and measure crack size, set loop variable i to 0, set minimum connected graph area MIN AREA, set actual size value per pixel MM PERPIXEL;

[0036] Step S202: read information of the i-th crack connected graph;

[0037] Step S203: calculate the area of the i-th crack connected graph, if less than the minimum connected graph area MIN AREA, then loop variable i is incremented by 1, and step S202 is executed.

[0038] The step S4 is specifically:

[0039] The skeleton skel is extracted from the identified curt graph by using a thinning digital pattern algorithm, the skeleton skel is a matrix, has the same matrix shape size as the curt graph, and has a data type of bool; wherein, if each pixel point position in the skeleton skel is a skeleton, the value of the pixel point is True, otherwise the value of the pixel point is False.

[0040] The step S5 is specifically:

[0041] All pixel points in the current crack connected graph are traversed, the minimum distance from the pixel point to the background is calculated, and the numerical value of the distance is recorded to the pixel point; after the traversal is completed, a distance transformation matrix dist is formed, which has the same matrix shape size as the skeleton skel and has a data type of float.

[0042] The step S7 is specifically:

[0043] The minimum distance, the average distance, the maximum distance and the position index are calculated by set operation on the matrix data based on the assigned matrix skel_dist; the minimum width of the crack is twice the minimum distance, the average width is twice the average distance, and the maximum width is twice the maximum distance. All of the above are pixel sizes, which need to be multiplied by the actual size of each pixel MM PERPIXEL to convert into the actual size of the crack.

[0044] The step S8 is specifically:

[0045] The crack length is calculated by summing the number of all pixel points on the skeleton skel, and multiplied by MM PERPIXEL to convert into the actual length of the crack; the crack area corresponds to the area of the crack connected graph, and the area is multiplied by the square of the actual size of each pixel MM PERPIXEL to convert into the actual area of the crack.

[0046] The application can be used for crack size measurement in various scenes, has the characteristics of wide application range, strong adaptability, accurate measurement, small calculation power consumption, high running efficiency and the like. BRIEF DESCRIPTION OF DRAWINGS

[0047] Figure 1 The flow chart of the crack size measurement method of the embodiments 1 and 2 of the application.

[0048] Figure 2 The color image containing cracks in the embodiment 2 of the application is shown.

[0049] Figure 3 The gray scale image in the embodiment 2 of the application is shown.

[0050] Figure 4 The image after median filtering in the embodiment 2 of the application is shown.

[0051] Figure 5 The binary image in the embodiment 2 of the application is shown.

[0052] Figure 6 The binary image after background correction in the embodiment 2 of the application is shown.

[0053] Figure 7 The image after morphological closing operation in the embodiment 2 of the application is shown.

[0054] Figure 8 The image after morphological opening operation in the embodiment 2 of the application is shown.

[0055] Figure 9 The crack connected graph in the embodiment 2 of the application is shown.

[0056] Figure 10 The crack connected graph after screening larger cracks in the embodiment 2 of the application is shown.

[0057] Figure 11 The crack skeleton graph in the embodiment 2 of the application is shown.

[0058] Figure 12 The numbering and position relationship of the center pixel point and its eight neighborhood in the embodiment 2 of the application is shown.

[0059] Figure 13 The three special pixel points that cannot be deleted in the embodiment 2 of the application are shown.

[0060] Figure 14 The eight situations of the eight neighborhood of the center pixel point changing from 0 to 1 in the embodiment 2 of the application are shown.

[0061] Figure 15 The crack connected graph matrix transformation in the embodiment 2 of the application is shown.

[0062] Figure 16A fracture connection graph for Example 2 of the present invention.

[0063] Figure 17 A fracture marking graph for Example 2 of the present invention.

[0064] Figure 18 A fracture marking graph for asphalt pavement in a verification test of the present invention.

[0065] Figure 19 A fracture marking graph for asphalt pavement in a verification test of the present invention.

[0066] Figure 20 A fracture marking graph for a cement floor in a verification test of the present invention.

[0067] Figure 21 A fracture marking graph for a cement floor in a verification test of the present invention.

[0068] Figure 22 A fracture marking graph for a floor in a verification test of the present invention.

[0069] Figure 23 A fracture marking graph for a cement pavement in a verification test of the present invention.

[0070] Figure 24 A fracture marking graph for quartz stone in a verification test of the present invention.

[0071] Figure 25 A fracture marking graph for artificial stone in a verification test of the present invention.

[0072] Figure 26 A fracture marking graph for land in a verification test of the present invention.

[0073] Figure 27 A fracture marking graph for concrete in a verification test of the present invention. DETAILED DESCRIPTION

[0074] The present application adopts median filter blur and smooths image background by carrying out gray scale processing on the original image, adopts a triangular algorithm to determine the optimal threshold and carries out image binarization, and the binary image takes white as the crack and black as the background. Then, the binary image is subjected to morphological close operation to eliminate small black hole noise points in the crack, and then subjected to morphological open operation to eliminate small white spot noise points outside the crack. Thus, the image preprocessing and crack segmentation are completed. Then, each crack connected graph is detected, each crack is marked, and the area of the connected graph is calculated by summing all pixel points in the connected graph. Each crack connected graph is traversed, and the connected graph with a small area is filtered out. A connected graph is extracted, the background pixel is marked as 0, and the crack pixel is marked as 1. A kind of algorithm for extracting the skeleton of a digital pattern is adopted to carry out Euclidean distance transformation on all pixel points in the connected graph. The distance transformation value of the pixel point on the skeleton is extracted from the distance transformation matrix of the connected graph. Based on the skeleton distance transformation value as the basic data, the minimum distance, the average distance, the maximum distance and the position index are calculated. The length of the crack is calculated by summing all pixel points on the skeleton. The area of the connected graph is the crack area. According to the skeleton, the maximum crack width and the maximum crack position information obtained, the skeleton line is drawn on the original image, the maximum inscribed circle is drawn at the position of the maximum crack width, and the crack number and width value are marked at the adjacent position of the inscribed circle. After the image crack visualization marking is completed, the image file is saved.

[0075] To clearly illustrate the technical features of the present scheme, the present scheme will be described below through a specific implementation.

[0076] Example 1

[0077] Referring to Figure 1 The present application provides a crack size measurement method based on image connectivity and skeleton analysis, which is specifically as follows:

[0078] Step S1: load a scene color image img_src containing a crack, and perform preprocessing and crack segmentation on the color image img_src to detect the crack connected graph in the color image img_src and the number of crack connected graphs graph_count;

[0079] Step S2: traverse each crack connected graph, set the loop variable i to 0, calculate the crack area of the ith crack connected graph, and filter out the crack connected graph with a small crack area;

[0080] Step S3: create a new graph curt_graph with the same rectangular shape and size as the preprocessed color image img_src, and mark the new graph curt_graph according to the crack connected graph, with the background pixel value being 0 and the crack pixel value being 1;

[0081] Step S4: Extract the skeleton skel based on the identified curt_graph;

[0082] Step S5: Perform Euclidean distance transformation on all pixel points in the identified curt_graph to form a distance transformation matrix dist with the same matrix shape size as the skeleton skel and a data type of float;

[0083] Step S6: Create a matrix skel_dist with the same matrix shape size, same data type, and all data being 0 as the distance transformation matrix dist; traverse each element in the skeleton skel, extract the distance transformation value of the corresponding position in the distance transformation matrix dist with the element value True, and assign it to the corresponding position in the matrix skel_dist;

[0084] Step S7: Take the assigned matrix skel_dist as the data basis, and calculate the minimum crack width, average crack width, maximum crack width, and position information of the maximum crack width through set operation on matrix data;

[0085] Step S8: Calculate the crack length and crack area by summing the number of all pixel points on the skeleton skel;

[0086] Step S9: According to the obtained crack skeleton, maximum crack width, and position information of the maximum crack width, draw the skeleton line on the color image img_src, draw the maximum inscribed circle at the position of the maximum crack width, and label the crack number and width value at the adjacent position of the inscribed circle;

[0087] Step S10: Loop variable i is incremented by 1, and if i < graph_count, execute step S2 in the loop until i ≥ graph_count, then end the loop;

[0088] Step S11: After the above loop is completed, the image crack visualization marking is completed, and the image file is saved.

[0089] In step S1, the method of pre-processing and crack segmentation is as follows:

[0090] Step S101: Perform grayscale processing on the color image img_src to obtain a grayscale image img_gray;

[0091] Step S102: using a square structural element with an aperture size ksize of 7 as a mask, the median filter algorithm is used to blur the gray-scale image img_gray, and the image img_medianblur is obtained; here, the median filter algorithm is used to blur the gray-scale image img_gray, so that the image background is smoother and more integrated, the contrast between the crack and the background is increased, and the subsequent binaryzation processing is facilitated;

[0092] Step S103: using the triangle algorithm to determine the best threshold for the image img_medianblur, and performing image binaryzation to obtain the binaryzation image img_bin;

[0093] Step S104: foreground and background correction is performed on the binary image img_bin, taking white as the crack and black as the background, and the pixel value proportion of the entire binary image img_bin is counted; if the white pixels are more, the binary image img_bin is inverted;

[0094] Step S105: using a square structural element with a side length of 3 as a mask and the center of the square as an anchor point, morphological closing operation is performed on the binary image img_bin to eliminate small black hole noise points in the crack, and the image img_close is obtained after processing;

[0095] Step S107: using a square structural element with a side length of 3 as a mask and the center of the square as an anchor point, morphological opening operation is performed on the binary image img_close to eliminate small white spot noise points outside the crack, and the image img_open is obtained after processing;

[0096] Step S108: all crack connected graphs are detected from the binary image img_open, each crack connected graph is labeled differently, and the pixel values in the same crack connected graph are the same label value; the area of the crack connected graph is calculated by summing all the pixel points in each crack connected graph, and the number of crack connected graphs graph_count is counted.

[0097] Further, in step S108, the method for detecting the crack connected graph from the binary image img_open is specifically:

[0098] S1081: prepare to traverse each pixel point of the binary image img_open, set the loop variable j to 0, and set the crack connected graph label k to 1;

[0099] S1082: if the jth pixel value is not 255, then execute S1083, otherwise, mark the jth pixel value as k, judge its 8-neighborhood pixel value, if it is 255, mark it as k, continue to judge the pixel value of the 8-neighborhood of the pixel with value k in the 8-neighborhood, if it is 255, mark it as k; and so on, until all the neighborhood values are not equal to 255, then a connected graph traversal ends, the crack connected graph label k is incremented by 1;

[0100] S1083: the loop variable j is incremented by 1, and the value of k is judged, if it is less than the total number of pixels PT of the binary image img_open, then the loop of S1082 is executed until the value of j is greater than or equal to PT, and the loop ends.

[0101] The step S2 is specifically:

[0102] Step S201: prepare to traverse each crack connected graph and measure the crack size, set the loop variable i to 0, set the minimum connected graph area MIN AREA, and set the actual size value MM PERPIXEL per pixel;

[0103] Step S202: read the information of the ith crack connected graph;

[0104] Step S203: calculate the area of the ith crack connected graph, if it is less than the minimum connected graph area MIN AREA, then the loop variable i is incremented by 1, and step S202 is executed.

[0105] The step S4 is specifically:

[0106] The skeleton skel is extracted from the identified curt_graph by using the thinning digital pattern algorithm, the skeleton skel is a matrix, has the same matrix shape size as the curt_graph, and the data type is bool type; wherein, if each pixel point position in the skeleton skel is a skeleton, the value of the pixel point is True, otherwise the value of the pixel point is False.

[0107] The step S5 is specifically:

[0108] All pixel points in the current crack connected graph are traversed, the minimum distance from the pixel point to the background is calculated, and the distance value is recorded to the pixel point; after the traversal is completed, a distance transformation matrix dist with the same matrix shape size as the skeleton skel and the data type of float is formed.

[0109] The step S7 is specifically:

[0110] With the assigned matrix skel_dist as data basis, the minimum distance, average distance, maximum distance and position index are calculated through the set operation of matrix data; the minimum width of the crack is twice the minimum distance, the average width is twice the average distance, and the maximum width is twice the maximum distance. The above are pixel sizes, which need to be multiplied by the actual size of each pixel MM_PERPIXEL to convert into the actual size of the crack.

[0111] The step S8 is specifically:

[0112] The length of the crack is calculated by summing up the number of all pixel points on the skeleton skel, and multiplied by MM_PERPIXEL to convert into the actual length of the crack; the area of the crack corresponds to the area of the crack connectivity graph, and the area is multiplied by the square of the actual size of each pixel MM_PERPIXEL to convert into the actual area of the crack.

[0113] Embodiment two

[0114] Referring to Figures 1-27 , the embodiment of the present application provides a crack size measurement method based on image connectivity and skeleton analysis, comprising the following steps:

[0115] S1: loading a color image img_src containing a crack (see Figure 2 ) :

[0116] S2: performing gray scale processing on the image img_src to obtain a gray scale image img_gray (see Figure 3 ) ;

[0117] S3: taking a square structural element with an aperture size ksize of 7 as a mask, and adopting a median filter algorithm to perform blur processing on the gray scale image img_gray, so that the image background is smoother and more integrated, the contrast between the crack and the background is increased, and the subsequent binarization processing is facilitated; after the median filter processing, an image img_medianblur is obtained (see Figure 4 ) ;

[0118] S4: determining the optimal threshold value by using a triangle algorithm on the median filter image img_medianblur, and performing image binarization to obtain a binarized image img_bin (see Figure 5 ) ;

[0119] S5, foreground and background correction is carried out on the binary image img_bin, specifically: in order to ensure that the subsequent image processing process is correctly carried out, we need to unify the definition of crack and background in the binary image, set white as crack and black as background. We assume that an image is usually mostly background pixels, based on this principle, the proportion of pixel values of the entire binary image is counted, if it is found that the white pixels are mostly, then the binary image is inverted (see Figure 6 );

[0120] S6: a square structural element with a side length of 3 is used as a mask, and the center of the square is used as an anchor point, morphological closing operation is performed on the binary image img_bin to eliminate small black hole noise points in the crack, and the processed image img_close is obtained (see Figure 7 );

[0121] S7: a square structural element with a side length of 3 is used as a mask, and the center of the square is used as an anchor point, morphological opening operation is performed on the binary image img_close to eliminate small white spot noise points outside the crack, and the processed image img_open is obtained (see Figure 8 );

[0122] S8: all crack connected graphs are detected from the binary image img_open, each crack connected graph is labeled differently, and the pixel values in the same crack connected graph are the same label value. The area of the connected graph is calculated by summing the number of all pixel points in each crack connected graph. The number of crack connected graphs graph_count is detected. In order to facilitate observation (not required by the algorithm), the crack connected graph is marked with color, and the colored crack connected graph is obtained (see Figure 9 );

[0123] Further, the crack connected graph detection algorithm described in S8 is as follows:

[0124] S81: prepare to traverse each pixel point of the binary image, set the loop variable j to 0, and set the connected graph label k to 1.

[0125] S82: if the jth pixel value is not 255, execute S83, otherwise, mark the jth pixel value as k, judge its 8-neighborhood pixel value, if it is 255, mark it as k, continue to judge the 8-neighborhood pixel value of the pixel with value k in the 8-neighborhood, if it is 255, mark it as k. In this way, until all neighborhood values are not equal to 255, a connected graph traversal is completed, and the connected graph label k is incremented by 1;

[0126] S83: the loop variable j is incremented by 1, and the value of k is judged, if it is less than the total number of pixels PT of the binary image img_open, the loop executes S82, until the value of j is greater than or equal to PT, the loop ends;

[0127] S9: Prepare to traverse each crack connected graph to measure crack size, set loop variable i to 0, set the minimum connected graph area MIN AREA, set the actual size value of each pixel (unit: millimeter) MM PERPIXEL, which can be determined according to the specific shooting scene, shooting a reference object of known size, and then dividing the actual length value of the reference object by the number of pixels in the same direction of the reference object in the image;

[0128] S10: Read the information of the ith crack connected graph;

[0129] S11: Filter out the connected graph with small area (see Figure 10 ), specifically: judge whether the area of the ith crack connected graph is smaller than the minimum connected graph area MIN AREA, if smaller than MIN AREA, then loop variable i is incremented by 1, and S10 is executed;

[0130] S12: Extract the ith crack connected graph, create a new graph curt_graph with the same matrix shape size as the binary image img_bin, and mark the background pixel value as 0 and the current crack pixel value as 1;

[0131] S13: Extract the skeleton skel of the marked curt_graph using a thinning digital pattern algorithm (see Figure 11 ). The skeleton is a matrix with the same matrix shape size as the binary graph curt_graph, and the data type is bool. For each pixel position of the skeleton skel, if it is a skeleton, the value of the pixel point is True, otherwise the value of the pixel point is False;

[0132] Further, the thinning digital pattern algorithm described in S13 is a parallel thinning algorithm based on image eight-neighborhood, which removes the target pixel that meets the condition by judging the logical condition of the target pixel and its eight-neighborhood, and iterates repeatedly until there is no pixel that can be deleted. Finally, the image is thinned to a skeleton with a pixel width while preserving the original connected graph shape.

[0133] Further, whether a pixel point can be removed from the foreground is judged based on the various connected relationships of the center point and its eight-neighborhood, and the numbering and position relationship of the eight-neighborhood is shown in Figure 12 (wherein, Figure 12 (a) is the numbering of the center pixel P1 and its eight-neighborhood, Figure 12(b) is the position relationship of the 8-neighborhood and the center pixel point). This operation of removing the foreground pixel point needs to be repeated for the pixel point with the pixel value of 1, one cycle needs to be performed twice, and the removal operation is performed after each iteration. The conditions for judging the removal of the pixel point are different in the two iterations, and the specific conditions are as follows:

[0134] The judgment condition of iteration one is that P1 is set to 0 when the following five conditions are met:

[0135] (1) the pixel value of P1 is 1;

[0136] (2) the center point is not a single point, an end point, or an inner point (see Figure 13 , wherein Figure 13 (a) is a single point, Figure 13 (b) is an end point, Figure 13 (c) is an inner point), that is, the sum of the pixels of the 8-neighborhood cannot be less than 2, nor can it be greater than 6, and the logical expression is:

[0137]

[0138] (3) the number of times that the pixel changes from 0 to 1 in one clockwise change of the 8-neighborhood is 1 (see Figure 14 )

[0139] (4) at least one of P2, P4, and P6 in the 8-neighborhood is zero, and the logical expression is:

[0140] P2×P4×P6=0

[0141] (5) at least one of P4, P6, and P8 in the 8-neighborhood is zero, and the logical expression is:

[0142] P4×P6×P8=0

[0143] The judgment condition of iteration two is that P1 is set to 0 when the following five conditions are met:

[0144] (1) the pixel value of P1 is 1;

[0145] (2) the center point is not a single point, an end point, or an inner point (see Figure 13 ), that is, the sum of the pixels of the 8-neighborhood cannot be less than 2, nor can it be greater than 6, and the logical expression is:

[0146]

[0147] (3) the number of times that the pixel changes from 0 to 1 in one clockwise change of the 8-neighborhood is 1 (see Figure 14 )

[0148] (4) At least one of P2, P4, P8 in the eight-neighborhood is zero, the logical expression is:

[0149] P2 x P4 x P8 = 0

[0150] (5) At least one of P2, P6, P8 in the eight-neighborhood is zero, the logical expression is:

[0151] P2 x P6 x P8 = 0

[0152] Further, the complete image thinning algorithm is as follows:

[0153] S131: Copy a copy of curt_graph to skel, extract all foreground pixel coordinates with value 1 from skel and save them to list_foreground, the purpose is to only traverse the foreground pixels with value 1 to improve speed. Create empty list objects list_iter1 and list_iter2 for caching pixel coordinates to be removed in the iteration process;

[0154] S132: Loop to remove unnecessary foreground pixels. Specifically: empty the list objects list_iter1 and list_iter2. Perform the first iteration, traverse the list list_foreground, extract each foreground pixel coordinate with value 1, and perform logical judgment according to the judgment condition of iteration one. For the pixel point that meets the removal condition, temporarily store its coordinate in the list object list_iter1, and remove the corresponding pixel coordinate from the list list_foreground. After the first iteration is completed, traverse the list object list_iter1, extract each pixel coordinate to be removed, and set the value of the corresponding pixel position in the graph skel to 0. If the list object list_iter1 is empty, there is no more removable pixels, exit the loop, otherwise perform the second iteration, traverse the list list_foreground, extract each foreground pixel coordinate with value 1, and perform logical judgment according to the judgment condition of iteration two. For the pixel point that meets the removal condition, temporarily store its coordinate in the list object list_iter2, and remove the corresponding pixel coordinate from the list list_foreground. After the second iteration is completed, traverse the list object list_iter2, extract each pixel coordinate to be removed, and set the value of the corresponding pixel position in the graph skel to 0. If the list object list_iter2 is empty, there is no more removable pixels, exit the loop, otherwise loop S132.

[0155] S133: Convert the data type of skel to bool type, where 0 is converted to False and 1 is converted to True.

[0156] S14: Euclidean distance transformation is performed on all pixel points in the identified curt_graph, specifically, all pixel points in the current connected graph are traversed, the minimum distance of the pixel point to the background is calculated, and the value of the distance is recorded to the pixel point. After traversal, a distance transformation matrix dist with the same matrix shape size as the binary graph skel and the data type of float is formed. In order to facilitate observation, dist is normalized to a value between 0 and 255, generating a matrix transformation graph, in which the high brightness represents the center axis of the crack;(see Figure 15 )

[0157] Further, the minimum distance calculation formula of the pixel point to the background is described as follows: assuming that the coordinates of the p point in the connected graph are (x1, y1), the coordinates of the background q point closest to the p point are (y1, y2), and the Euclidean distance d of the p point and the q point is calculated as follows:

[0158]

[0159] S15: The distance transformation value of the pixel point on the crack skeleton is extracted from the distance transformation matrix dist of the current crack connected graph, specifically, a matrix skel_dist with the same matrix shape size as the distance transformation matrix dist, the same data type, and all data being zero is created. Each element in the skeleton skel is traversed, and the value of the distance transformation matrix dist corresponding to the position where the element value is True is extracted and assigned to the corresponding position of the matrix skel_dist;(see Figure 16 )

[0160] S16: Based on the skeleton distance transformation matrix skel_dist, the minimum width of the crack, the average width of the crack, the maximum width of the crack, and the position information of the maximum width of the crack are calculated through the set operation of the matrix data. The minimum width of the crack is twice the minimum distance, the average width is twice the average distance, and the maximum width is twice the maximum distance. The above are pixel sizes, which need to be multiplied by the actual size of each pixel MM_PERPIXEL to convert into the actual size of the crack;

[0161] S17: The length of the crack is calculated by summing the number of all pixel points on the skeleton skel, and multiplied by MM_PERPIXEL to convert into the actual length of the crack. The area of the crack corresponds to the area of the crack connected graph, which is multiplied by the square of the actual size of each pixel MM_PERPIXEL to convert into the actual area of the crack;

[0162] S18: According to the obtained crack skeleton, the maximum crack width, and the position information of the maximum crack width, draw the skeleton line on the original image img_src, draw the maximum inscribed circle at the position of the maximum crack width, and mark the crack number and width value at the position adjacent to the inscribed circle to obtain a crack marked image (see Figure 17 );

[0163] S19: The value of the loop variable i is increased by 1, and if the value of i is less than the number of crack connected graphs graph_count, the loop is executed S10 until the value of i is greater than or equal to graph_count, and the loop is ended;

[0164] S20: After the above loop is ended, the size of all cracks is measured (see Table 1), the image crack visualization marking is completed, and the image file is saved.

[0165] Table 1: Crack size table (corresponding to Figure 17 )

[0166]

[0167] Verification test and analysis

[0168] The purpose of the experiment is to evaluate the performance of the algorithm in the present application. The algorithm is implemented by Python 3.9, and the running environment is: processor (Inter(R) core (TM) i7-4500U 1.8GHz), memory (8GB RAM), and operating system (Windows 10 64-bit).

[0169] All the images used are collected from the Internet. A total of 10 representative images are selected, covering cracks in asphalt pavement, cement, floor, stone, concrete, land and other scenes. The crack size measurement method of the present application is used, and 10 crack marked images are obtained by operation ( Figures 18-27 ). By observing the crack marking, the crack skeleton is clearly marked, the blue maximum inscribed circle is drawn at the widest part of the crack, and each crack is marked with a number and a maximum diameter. The detailed size of the crack is presented in a table (see Tables 2-11). The actual processing speed is 0.5s per image in the above CPU environment.

[0170] The following Tables 2-11 are the crack size tables of the 10 images:

[0171] Table 2: Crack size table (corresponding to Figure 18 )

[0172]

[0173] Table 3: Crack size table (corresponding to Figure 19 )

[0174]

[0175]

[0176] Table 4 Fracture size table (corresponding to Figure 20 )

[0177]

[0178] Table 5 Fracture size table (corresponding to Figure 21 )

[0179]

[0180] Table 6 Fracture size table (corresponding to Figure 22 )

[0181]

[0182] Table 7 Fracture size table (corresponding to Figure 23 )

[0183]

[0184] Table 8 Fracture size table (corresponding to Figure 24 )

[0185]

[0186] Table 9 Fracture size table (corresponding to Figure 25 )

[0187]

[0188] Table 10 Fracture size table (corresponding to Figure 26 )

[0189]

[0190] Table 11 Fracture size table (corresponding to Figure 27 )

[0191]

[0192] In the description of the invention, the foregoing detailed description has set forth various embodiments of the devices and / or processes via the use of block diagrams, flowcharts, and / or examples. Insofar as such block diagrams, flowcharts, and / or examples contain one or more functions and / or operations, it will be understood by those within the art that each function and / or operation within such block diagrams, flowcharts, or examples can be implemented, individually and / or collectively, by a wide range of

[0193] There is little distinction between the design choice of hardware or software implementing aspects of systems; the use of hardware and software is generally (but not always, in that in certain contexts the choice between hardware and software can become significant) a design choice representing cost vs. efficiency tradeoffs. There are various vehicles by which processes and / or systems and / or other technologies described herein can be implemented (e.g., hardware, software, and / or firmware) and that the preferred vehicle will vary with the context in which the processes and / or systems and / or other technologies are deployed. For example, if an implementer determines that speed and accuracy are paramount, the implementer can opt for mostly hardware and / or firmware implementations; if flexibility is paramount, the implementer can opt for software implementations; or, yet again alternatively, the implementer can opt for some combination of hardware, software, and / or firmware.

[0194] The terms "first", "second", etc. are used only for descriptive purposes and do not connote or imply relative importance or an ordering between or among the indicated technical features. Thus, a feature defined with "first", "second", etc. can include one or more of the features implicitly or explicitly. In the description of the present invention, the meaning of "a plurality" is two or more, unless otherwise specified.

[0195] The technical features of the present invention not described herein can be implemented by or with the prior art, which will not be described herein again. Of course, the above description is not a limitation on the present invention, and the present invention is not limited to the above examples. Changes, modifications, additions, or substitutions made by those skilled in the art within the spirit and principle of the present invention shall fall within the scope of the present invention.

[0196] In the description of the present invention, it should be noted that unless otherwise explicitly specified and limited, the terms "mounting", "connecting", "connecting", "arranging" should be understood broadly, for example, it can be fixedly connected, or detachably connected, or integrally connected; it can be mechanically connected, or electrically connected; it can be directly connected, or indirectly connected through an intermediate medium, or it can be the communication between two elements. For those skilled in the art, the specific meaning of the above terms in the present invention can be understood according to the specific circumstances.

[0197] The above description is only the preferred embodiment of the present invention, and is not intended to limit the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall fall within the scope of protection of the present invention.

Claims

1. A crack size measurement method based on image connectivity and skeleton analysis, characterized in that, The measurement method is as follows: Step S1: Load a scene color image img_src containing cracks, preprocess the color image img_src, segment the cracks, and detect the crack connectivity graph and the number of crack connectivity graphs graph_count in the color image img_src. Step S2: Traverse each crack connected graph, set the loop variable i to 0, calculate the crack area of ​​the i-th crack connected graph, and filter out crack connected graphs whose crack area is less than the area of ​​the minimum connected graph. Step S3: Create a new graph curt_graph with the same rectangular shape and size as the preprocessed color image img_src, and mark the new graph curt_graph according to the crack connectivity graph, with background pixel value of 0 and crack pixel value of 1; Step S4: Extract the skeleton skel based on the identified curt_graph; Step S5: Perform Euclidean distance transformation on all pixels in the identified curt_graph to form a distance transformation matrix dist with the same shape and size as the skeleton skel and a data type of float; Step S6: Create a matrix skel_dist with the same shape and size as the distance transformation matrix dist, and with all data set to 0. Iterate through each element in the skeleton skel, extract the distance transformation value of the distance transformation matrix dist corresponding to the position where the element value is True, and assign it to the matrix skel_dist at the corresponding position. Step S7: Using the assigned matrix skel_dist as the data basis, calculate the minimum crack width, average crack width, maximum crack width, and location information of the maximum crack width through set operations on the matrix data; Step S8: Calculate the crack length and crack area by summing the number of all pixels on the skeleton skel; Step S9: Based on the obtained crack skeleton, maximum crack width, and location information of the maximum crack width, draw the skeleton lines on the color image img_src, draw the maximum inscribed circle at the location of the maximum crack width, and mark the crack number and width value at the location near the inscribed circle. Step S10: Increment the loop variable i by 1. If i < graph_count, then repeat step S2 until i ≥ graph_count, then end the loop. Step S11: After the above loop is completed, complete the image crack visualization marking and save the image file; Specifically, step S8 is as follows: The crack length is calculated by summing the number of all pixels on the skeleton skel, and then multiplied by MM_PERPIXEL to convert it into the actual crack length. The crack area corresponds to the area of ​​the crack connected graph, and this area is multiplied by the square of the actual size of each pixel MM_PERPIXEL to convert it into the actual crack area.

2. The method according to claim 1, characterized in that, The preprocessing and crack segmentation methods in step S1 are as follows: Step S101: Perform grayscale processing on the color image img_src to obtain a grayscale image img_gray; Step S102: Using a square structuring element with an aperture size of 7 as a mask, the grayscale image img_gray is blurred using a median filtering algorithm to obtain the image img_medianblur; Step S103: Use the triangulation algorithm to determine the optimal threshold for the image img_medianblur, and perform image binarization to obtain the binarized image img_bin; Step S104: Perform foreground and background correction on the binary image img_bin, using white as the crack and black as the background, and count the pixel value ratio of the entire binary image img_bin. If white pixels are more numerous, then invert the binary image img_bin. Step S105: Using a square structuring element with a side length of 3 as a mask and the center of the square as the anchor point, perform a morphological closing operation on the binary image img_bin to eliminate small black hole noise in the cracks, and obtain the image img_close after processing; Step S107: Using a square structuring element with a side length of 3 as a mask and the center of the square as the anchor point, perform a morphological opening operation on the binary image img_close to eliminate small white noise outside the crack, and obtain the image img_open after processing; Step S108: Detect all the crack connected graphs from the binary image img_open, assign different labels to each crack connected graph, and the pixel values ​​in the same crack connected graph have the same label value; calculate the area of ​​the crack connected graph by summing the number of all pixels in each crack connected graph, and count the number of crack connected graphs graph_count.

3. The method according to claim 2, characterized in that, In step S108, the method for detecting the crack connectivity graph from the binary image img_open is as follows: S1081: Prepare to traverse each pixel of the binary image img_open, set the loop variable j to 0, and set the crack connectivity icon k to 1; S1082: If the value of the j-th pixel is not 255, then execute S1083; otherwise, mark the j-th pixel value as k, and check if its 8-neighbor pixel value is 255. If it is, mark it as k. Continue to check the pixel values ​​of the 8-neighbors of the pixel with value k in the 8-neighbors. If they are 255, mark them as k. Continue in this way until none of the neighboring values ​​are equal to 255. Then the traversal of a connected graph ends, and the crack connection icon number k is incremented by 1. S1083: Increment the loop variable j by 1. If the value of k is less than the total number of pixels PT of the binary image img_open, then execute S1082 repeatedly until the value of j is greater than or equal to PT and the loop ends.

4. The method according to claim 1, characterized in that, Step S2 specifically involves: Step S201: Prepare to traverse each crack connected graph and measure the crack size, set the loop variable i to 0, set the minimum connected graph area MIN_AREA, and set the actual size value per pixel MM_PERPIXEL; Step S202: Read the information of the connected graph of the i-th crack; Step S203: Calculate the area of ​​the connected graph of the i-th crack. If it is less than the area of ​​the minimum connected graph MIN_AREA, increment the loop variable i by 1 and execute step S202.

5. The method according to claim 1, characterized in that, Step S4 specifically involves: A refined digital pattern algorithm is used to extract the skeleton skel from the labeled curt_graph. The skeleton skel is a matrix with the same shape and size as the curt_graph and is of type bool. In the skeleton skel, if each pixel is part of the skeleton, the value of the pixel is True; otherwise, the value of the pixel is False.

6. The method according to claim 1, characterized in that, Step S5 specifically involves: Traverse all pixels in the current crack connected graph, calculate the minimum distance from each pixel to the background, and record the value of the distance to the pixel. After traversal, form a distance transformation matrix dist with the same matrix shape and size as the skeleton skel and with data type float.

7. The method according to claim 1, characterized in that, Step S7 specifically involves: Using the assigned matrix skel_dist as the data basis, the minimum distance, average distance, maximum distance, and position index are calculated through set operations on the matrix data. The minimum crack width is twice the minimum distance, the average width is twice the average distance, and the maximum width is twice the maximum distance. All of these are pixel dimensions, which need to be multiplied by the actual size of each pixel MM_PERPIXEL to convert them into the actual crack size.