A crack extraction method under complex background
Through the structural line-guided crack extraction method, the accuracy and generalization of crack extraction in complex backgrounds are solved, and accurate identification and continuous and complete crack extraction effects are achieved in complex backgrounds.
Patent Information
- Application Number
- CN202211313293.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-10-25
- Publication Date
- 2025-08-12
- Estimated Expiration
- 2042-10-25
AI Technical Summary
In the complex context, it is difficult for the prior art to extract cracks accurately and completely, the binarization results of traditional methods are inaccurate due to interference, and the deep learning methods are poorly generalized, making it difficult to adapt to changeable engineering application scenarios.
The crack extraction method guided by structural line is adopted, including crack measurement calculation, skeleton map generation, key point extraction, structural line connection, length screening and grading merger, and other steps. The skeleton is refined through crack measurement definition, Hilditch algorithm, the grayscale consistency judgment of Levene and t-test, and the Freud algorithm grading, and finally the false crack is eliminated.
In a complex context, the cracks are accurately identified, with strong resistance to differences and generalization, and are suitable for different scenarios, with clear parameters and easy to apply, and the identification results are continuous and complete.
Smart Images

Figure CN115797649B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to a photogrammetry image processing method, and in particular relates to a crack extraction method under a complex background. Background Art
[0002] Crack detection is a crucial task in engineering maintenance. However, using visual methods for crack detection often results in incomplete and accurate crack extraction due to the complex background of the crack image. Therefore, research on crack extraction methods in complex backgrounds is crucial.
[0003] With the rapid development of computer vision, image processing, and other related fields, a growing number of crack detection methods have been proposed. These methods can be roughly divided into two categories: traditional methods and deep learning methods. For traditional methods, a key step is to binarize the image. This involves retaining possible crack regions and assigning the remaining pixels a grayscale value of 0. This process often involves using threshold segmentation or edge extraction algorithms for binarization. Threshold segmentation methods often use too low a threshold because the grayscale of interfering objects is lower than that of the cracks, resulting in the inclusion of interfering objects and discontinuity in the binarization result. Edge extraction algorithms can cause inconsistencies between the two crack edges due to varying crack widths, leading to ambiguity. This results in inaccurate binarization results from traditional methods. After obtaining the binary image, cracks need to be identified. Different methods use different approaches, resulting in varying effectiveness. Due to the influence of interfering objects, many false positives remain in the binary image. Therefore, in subsequent processing, it is necessary to consider removing these false positives from the binarization result. Deep learning methods, however, have poor generalization capabilities and are highly dependent on the training set. They struggle to detect cracks in images with textures that do not conform to the training set. However, in actual situations, the image background is complex and changeable, and it is difficult to find a training set that can represent all situations. Therefore, deep learning methods are difficult to adapt to complex and changeable engineering application scenarios.
[0004] In summary, crack extraction technology in complex scenes still requires further research. The challenges posed by detection methods primarily include the following three points: 1. A robust image binarization method is needed; 2. Strong robustness is required; and 3. Strong generalization is required to enable application to diverse image backgrounds. To address these challenges, this paper proposes a crack extraction method guided by structural lines, enabling crack extraction in complex backgrounds. Summary of the Invention
[0005] The present invention proposes a crack extraction method under complex background to solve the problem of crack extraction in images under complex background. The present invention mainly includes the following steps:
[0006] Step 1: First, the crack image is binarized and the crack measure of each pixel is calculated. For pixels with a crack measure greater than 0, a straight line is drawn along the width direction with the pixel as the midpoint and the width of the crack measure as the length. The pixels on the straight line are assigned a value of "1" and the remaining unassigned pixels are assigned a value of "0" to generate a binary crack map.
[0007] Step 2: Refine the crack map into a crack skeleton map with a width of 1 pixel;
[0008] Step 3: extract the key points of the crack skeleton diagram, including intersection points and endpoints, and connect the key points with structural lines according to the original connectivity to generate a crack structure line diagram;
[0009] Step 4: Search for the key points belonging to another crack near the end points of all cracks, and find the key points with a distance less than d thr pixels, and the angle τ between the line connecting the endpoints and the structure line where the endpoints are located is less than π-τ thr The key point is tested with the endpoint, and the grayscale distribution of the pixels around them is consistent.
[0010] Step 5: Eliminate the skeleton length after connection that is less than L thr cracks;
[0011] Step 6: Calculate the shortest path between the key points of each individual crack using the structural line as the path; Under the shortest path condition, the path length of each level structural line is the longest and the angle τ between adjacent structural lines is less than π-τ hhr For the classification conditions, the structural line of each individual crack is graded;
[0012] Step 7: Perform hypothesis testing at the intersection of each hierarchical structure line, and merge two structure lines of different levels with the same intersection that have true test results;
[0013] Step 8: Extract the crack pixels corresponding to each level of structural line, which are called graded cracks. Screen them according to the area ratio of the graded cracks to their circumscribed rectangles and the aspect ratio of the circumscribed rectangles, and eliminate those with an area ratio greater than S. thr And the aspect ratio is less than A thr cracks and obtain the final crack extraction results.
[0014] Furthermore, the detailed definition of the crack measurement in step 1 is as follows,
[0015] Let the Gaussian function and its first and second derivatives be:
[0016]
[0017] Among them, the normalized form of the Gaussian derivative is expressed as:
[0018]
[0019] From this, two two-dimensional bases can be defined:
[0020]
[0021]
[0022] Where x and y are pixel coordinates, based on the above two bases, two symmetric molecules can be defined:
[0023]
[0024]
[0025] in,
[0026]
[0027] t=[x,y] T , t0=[x0,y0] T is the coordinate offset, b = 0.0001 is the coordinate scaling factor, j is the scale factor, θ is the angle of the symmetric molecule, a and ρ are the parameters to be set; let the function be
[0028] f e (x) = G e (a j x), (8) set up is the function f e (x) The distance between the two zero points when j = 0, and w0 is called the width of the crack measurement when j = 0; let w j =w0×a -j is the width of the crack measurement corresponding to different j values in formula (26); let Grayscale image I and symmetrical molecule The j and θ corresponding to the maximum convolution value, where J is the set of j and θ is the set of angles θ; at the same time, define a j Changing the threshold parameter for:
[0029]
[0030] in, is j=j * The value of the width w when , the crack measure can be defined as:
[0031]
[0032] Among them, j ois the offset of the scale parameter j, β is the soft threshold, and the greater the contrast between the crack and the background, the larger β is.
[0033] Furthermore, in step 2, the crack map is thinned into a crack skeleton with a width of 1 pixel using the Hilditch algorithm or other thinning methods. Except for the skeleton, the remaining pixels are assigned a value of 0.
[0034] Furthermore, in step 2, the key points in the skeleton graph are connected according to their original topological relationships to generate a crack structure line graph. The lines connecting the key points are called structure lines, and the graph composed of the structure lines is called a crack structure line graph. Among them, the key points are divided into endpoints and intersections. The endpoints are points with only one non-zero value among the adjacent pixels on the skeleton, and the intersections are points with more than two non-zero values among the adjacent pixels on the skeleton. When both adjacent pixels meet the intersection condition, the point with the largest "01" pattern is taken as the intersection. The "01" pattern represents the number of times the value of the adjacent pixels of a certain pixel changes from 0 to 1 in a clockwise direction.
[0035] Furthermore, in step 4, two judgment functions are established to determine whether the cracks are connected. The detailed definition is: Let p0 and p1 be two key points on the same structural line of a crack, where p1 is the endpoint and the direction of the structural line is Let p2 be another crack with a distance from p1 less than d thr The key point of pixels, the direction of the line connecting it to p1 is The following function can be defined:
[0036]
[0037] in,, thr is the angle threshold,
[0038]
[0039] Let P cm (C j ) is the pixel set of a crack with a serial number j in the crack map, P cls (C j ,p,n)∈P cm (C j ) is P cm (c j ) is a set of n pixels closest to p pixels. A hypothesis test function can be defined to verify the two pixel sets and Is the grayscale distribution of pixels consistent?
[0040]
[0041] Among them, the significance level α = 0.05, the hypothesis test function includes two steps: first, the consistency of the variance of the two samples is tested using the Levene test, and then, taking into account the variance consistency, the consistency of the grayscale distribution of the two samples is tested using the t test; for each endpoint, the surrounding distance is less than d thr The key point of the other crack of the pixel is found, and the direction consistency is checked using formula (30); then the consistency of the grayscale of the pixels around the two points is checked using formula (31). If the results of both functions are true, the two cracks are connected.
[0042] Furthermore, the length screening function and usage in step 5 are as follows. Let P s (C j ) is crack C j The pixel set of the skeleton can be defined as:
[0043]
[0044] Among them, L thr is the length threshold, and function (32) is executed for each individual crack, and only cracks with true results are retained.
[0045] Furthermore, in step 6, the shortest path between all key points is calculated using the structure line as the path using the Floyd algorithm or other shortest path algorithms.
[0046] Then the structural lines are classified, which is characterized by: the classification process is as follows, let X = {χ0,χ1,χ2,…,χ n} is the shortest path set between all key points of a crack in descending order of path length, where χ n Refers to the nth structural line path; let the judgment path χ i and χ j The function to determine whether there are repeated line segments is:
[0047] bool=f re (χ i ,χ j ); (15)
[0048] And suppose Φ={φ0,φ1,φ2,…,φ m} is the set of currently graded structural line paths, where φ m Refers to the path with sequence number m; all structural lines of the crack can be graded by performing the following steps:
[0049] 1. Traverse X and access each shortest path χ n ;
[0050] 2. For χ nFor each point except the two end points, use formula (29) to judge the angle between the two connected structural lines;
[0051] 3. If the two structural lines connecting all points satisfy equation (29), then traverse Φ and use equation (33) to execute f re (χ,φ), to judge χ n and the path φ in Φ m Whether there are repeated segments;
[0052] 4. If n There is no repeated segment with all paths in Φ, then χ n Deposit Φ;
[0053] 5. After the X traversal is completed, the obtained Φ is the crack classification result;
[0054] After grading, the structural line of each crack will be divided into a primary result line and several secondary structural lines. The crack pixels corresponding to each structural line of different levels are regarded as different cracks, which are called graded cracks.
[0055] Furthermore, in step 7, whether to merge the structural lines is determined based on the grayscale distribution of the crack pixels belonging to the two structural lines of different levels near the intersection point;
[0056] Set line segment and The primary structure line AOC and line segments The secondary structure lines BO have a common intersection point p O , let p O′ To follow the skeleton from p O Move to p B The moving point, set O′ For p O′ The diameter of a circle with the length of OO' as its center increases with the increase of p O′ increases with the movement of O′ When both ends of the diameter touch the "0" pixel in the crack map at the same time, p O′ Stop moving, take the length of OO' as the diameter, and p O Draw a circle with the center O , and extract n “1” pixels on the crack map from the two circles respectively, where n is the number of “1” pixels contained in the circle with fewer “1” pixels in the two circles, and use formula (31) to perform T(P cls (⊙ O ,p O ,n),P cls (⊙ O′ ,p O′ ,n)), if the result is true, BO and AOC are merged and regarded as the same structural line.
[0057] Furthermore, using the circle in step 7, we move from one end point of the skeleton corresponding to the structural line to the other end point, extract the "1" pixels in the crack map, and then remove the duplicate pixels to obtain the classified crack pixels; let Is graded crack C j The bounding rectangle of is a rectangle aspect ratio; is the area ratio of the crack to the circumscribed rectangle; then the following two functions can be defined:
[0058]
[0059]
[0060] For each graded crack, equations (34) and (35) are calculated. If the results of both equations are false, the crack is considered a false crack and is removed. By merging the remaining pixels with the original image, the crack extraction result image can be obtained.
[0061] Furthermore, the method also includes step 9, which uses a public dataset to test the final crack extraction results and compares the crack extraction results with existing methods. The performance comparison indicators include:
[0062]
[0063] TP is the correctly identified pixel, FP is the incorrectly identified pixel, and FN is the correct pixel that has not been identified.
[0064] Compared with the prior art, the advantages and beneficial effects of the present invention are as follows:
[0065] 1. The present invention has strong anti-error capability and can accurately identify cracks in complex image backgrounds, meeting actual engineering needs.
[0066] 2. The present invention is a traditional method that does not rely on a training set and has strong generalization ability. It can be used to identify cracks of different objects in different scenarios.
[0067] 3. The present invention requires fewer parameters to be adjusted, and the meaning of each parameter is clear, so it can be easily applied by different groups of people. BRIEF DESCRIPTION OF THE DRAWINGS
[0068] Figure 1 A flow chart of the invention method;
[0069] Figure 2 Schematic diagram of w0 in an embodiment of the present invention;
[0070] Figure 3 The three-dimensional cracks in the embodiment of the present invention, And the crack measurement diagram; where (a) is a sub-segment of a three-dimensional crack, (b) is Schematic diagram of (c), which is the superposition of (a) and (b). When it is the maximum value, the corresponding j * Symmetric molecules The basis ψ e Width is equal to the crack width, and the angle θ * make Align cracks; since crack measurements are made at pixel p m Therefore, the actual crack pixel is calculated as p m As the midpoint, is the length, θ * The pixels on the straight line with the direction .
[0071] Figure 4 Schematic diagram of the structural lines in an embodiment of the present invention; in Figure (a), the gray grid is the skeleton diagram, the blank grid is the crack mapping diagram, p1, p4, p7 and p8 are key points, among which p3, p4 and p5 all satisfy that the number of non-zero values of adjacent pixels in the skeleton diagram is greater than 2, and their "01" patterns are the same as (b), (c) and (d), which are equal to 2, 3 and 2 (the number of black arrows), respectively. Therefore, p4 is considered to be an intersection point. By connecting the three structural lines p1-p4, p7-p4 and p8-p4, the structural line diagram (black straight line) of Figure (a) can be generated.
[0072] Figure 5 Schematic diagram of hierarchical structure line merging in an embodiment of the present invention; in the figure, AOC is a primary structure line, BO is a secondary structure line, and the two structure lines have a common intersection point p O , because the crack map is in p O Continuous, unable to distinguish p O To which structure line the nearby pixels belong, two circles with diameters equal to OO′ are defined. O′ and O Extract crack pixels of different levels for hypothesis testing.
[0073] Figure 6 : These are the crack extraction effect diagrams in an embodiment of the present invention; (a) is the original image; (b) is the extracted cracks; (c) is the superimposed image of (a) and (b).
[0074] Figure 7 This is a comparison chart of crack recognition effects in an embodiment of the present invention. DETAILED DESCRIPTION
[0075] In order to facilitate those skilled in the art to understand and implement the present invention, each step of the present invention is described in detail with reference to the accompanying drawings and implementation examples. Figure 1 The embodiments described herein are only used to illustrate and explain the present invention and are not intended to limit the present invention.
[0076] The present invention proposes a method for extracting cracks in a complex background, which mainly includes the following steps:
[0077] Step 1: Binarize the image. Calculate the crack measure for each pixel. For pixels with a crack measure greater than 0, draw a straight line with the pixel as the midpoint and the width of the crack measure as the length. Assign the value of "1" to the pixels on the line. Assign the value of "0" to the remaining unassigned pixels to generate a binary crack map.
[0078] Step 2: Skeleton extraction: The crack map is refined into a crack skeleton map with a width of 1 pixel.
[0079] Step 3: Structural line extraction: Extract the key points (intersections and endpoints) of the crack skeleton diagram and connect them with straight lines (called structural lines) based on the original connectivity to generate a crack structural line diagram.
[0080] Step 4: Crack connection. Search for key points belonging to another crack near the end points of all cracks, and connect the key points with a distance less than d thr pixels, and the angle τ between the line connecting the endpoints and the structure line where the endpoints are located is less than π-τ thr The key point of the endpoint is tested for the hypothesis of the distribution of surrounding pixels. If the grayscale distribution of the surrounding pixels of the two points is consistent, they are connected (when τ<π, take τ=2π-τ).
[0081] Step 5: Length screening. Eliminate the skeleton length after connection that is less than L thr cracks.
[0082] Step 6: Crack classification. Using the structural line as the path, calculate the shortest path between all key points in each individual crack; under the shortest path condition, the path length of each structural line is the longest and the angle τ between adjacent structural lines is less than π-τ. thr As the classification condition, the structural line of each individual crack is classified (when τ<π, τ=2π-τ);
[0083] Step 7: Merge structural lines. Perform hypothesis tests at the intersections of each hierarchical structural line, and merge two structural lines of different levels with the same intersections that have true test results.
[0084] Step 8: Crack screening. Extract the crack pixels corresponding to each level of structural line, which are called graded cracks. Screen according to the area ratio of the graded cracks to their circumscribed rectangles and the aspect ratio of the circumscribed rectangles, and eliminate those with an area ratio greater than S.thr And the aspect ratio is less than A thr cracks and obtain the final crack extraction results.
[0085] In step 1, the crack measure of each pixel needs to be calculated. The detailed definition of the crack measure is as follows. Let the Gaussian function and its first and second derivatives be:
[0086]
[0087] Among them, G0(x) is a Gaussian function, G o (x) is the first derivative of the Gaussian function, G e (x) is the second derivative of the Gaussian function. G o (x) and G e The normalized form of (x) is expressed as:
[0088]
[0089] From this, two two-dimensional bases can be defined:
[0090]
[0091]
[0092] Where x and y are pixel coordinates, based on the above two bases, two symmetric molecules can be defined (see Figure 3 ):
[0093]
[0094]
[0095] in,
[0096]
[0097] t=[x,y] T , t0=[x0,y0] T is the coordinate offset, b = 0.0001 is the coordinate scaling factor, j is the scale factor, θ is the angle of the symmetric molecule, and a and ρ are the parameters to be set. Let the function be
[0098] f e (x) = G e (a j x), (26)
[0099] Co-located is the function f e (x) The distance between the two zero points when j = 0, and w0 is called the width of the crack measurement when j = 0 (see Figure 2 ); let wj =w0×a -j is the width of the crack measurement corresponding to different j values in formula (26); let Grayscale image I and symmetrical molecule The j and θ corresponding to the maximum convolution value, where J is the set of j and θ is the set of angles θ. At the same time, define a j Changing the threshold parameter for:
[0100]
[0101] in, is j=j * The crack measure can be defined by the value of the width w when Figure 3 )for:
[0102]
[0103] Among them, j o is the offset of the scale parameter j, β is the soft threshold, and the greater the contrast between the crack and the background, the larger β is.
[0104] In practical application, ρ=1,Θ=[0:π:32](divide π into 32 parts), j o =1, J = [16,17,18,19,20,21,22,23,24,25,26] or any other set of integers between 16 and 26.
[0105] When calculating the crack measure of each pixel, and θ * Will be calculated at the same time, on the pixels where the crack measure is greater than 0, with the pixel as the midpoint and the length Direction θ * Draw a straight line and mark the pixels on the line as "1" (see Figure 3 ). Finally, the remaining unlabeled pixels are marked as “0” to generate the crack map.
[0106] In step 2, the crack map is refined using the Hilditch algorithm to obtain a crack skeleton map with a width of 1 pixel. In the skeleton map, all pixels except the skeleton are assigned a value of 0.
[0107] In step 3, the pixel point with only one non-zero value among the surrounding adjacent pixels in the skeleton image is defined as the endpoint, and the point with more than two non-zero values is defined as the intersection. When two adjacent pixels meet the intersection condition, let the "01" pattern represent the number of times the value of the adjacent pixels of a certain pixel changes from 0 to 1 in a clockwise direction, and select the point with the largest "01" pattern among the two pixels as the intersection point. According to the original topological connectivity relationship of the skeleton, the key points are connected to extract the structural line and generate the crack structure line map (see Figure 4 ).
[0108] In step 4, two judgment functions are established to determine whether the cracks are connected. Let p0 and p1 be two key points on the same structural line of a crack, where p1 is the endpoint and the direction of its structural line is Let p2 be the distance from p1 to another crack less than d thr (Under normal conditions, take 5) pixel key points, and the direction of the line connecting them to p1 is The following function can be defined:
[0109]
[0110] Among them, τ thr is the angle threshold,
[0111]
[0112] Let P cm (C j ) is the pixel set of the j-th crack in the crack map, P cls (C j ,p,n)∈P cm (C j ) is P cm (C j ) is the set of n pixels closest to pixel P. A hypothesis test function can be defined to verify the two pixel sets and Is the pixel grayscale distribution consistent?
[0113]
[0114] The significance level is α = 0.05. Formula (31) includes two steps: first, the consistency of the variance of the two samples is tested using the Levene test; then, taking into account the consistency of the variance, the consistency of the grayscale distribution of the two samples is tested using the t test. For each endpoint, search for the surrounding distance less than d tht The key point of the other crack of the pixel is found, and the direction consistency is checked using formula (30); then the consistency of the grayscale of the pixels around the two points is checked using formula (31). If the results of both functions are true, the two cracks are connected.
[0115] In step 5, the length of the skeleton of the connected crack graph is screened, and P s (C j ) is crack C j The pixel set of the skeleton can be defined as:
[0116]
[0117] Among them, L thr is the length threshold. Execute Equation (32) for each individual crack and only keep the cracks with true results.
[0118] In step 6, the shortest path between each point is calculated using the structural line of the crack map after length screening using the Floyd shortest path algorithm. Let χ(a,b)=[p a ,p1,p2,…p b ]∈X is p a to p b The shortest path, in χ, except for the two endpoints p a and p b In addition, each point is connected to two structural lines; let X = {χ0,χ1,χ2,…,χ n} is the shortest path set between all key points of a crack in descending order of path length, where χ n Refers to the nth structural line path; let the judgment path χ i and χ j The function to determine whether there are repeated line segments is:
[0119] bool=f re (χ i ,χ j ); (33)
[0120] And suppose Φ={φ0,φ1,φ2,…,φ m} is the set of currently graded structural line paths, where φ m Refers to the path with sequence number m; all structural lines of the crack can be graded by performing the following steps:
[0121] 1. Traverse X and access each shortest path χ n ;
[0122] 2. For χ n For each point except the two end points, use formula (29) to judge the angle of the two connected structural lines;
[0123] 3. If the two structural lines connecting all points satisfy equation (29), then traverse Φ and use equation (33) to execute f re (χ,φ), to judge χ n and the path φ in Φm Whether there are repeated segments;
[0124] 4. If n There is no repeated segment with all paths in Φ, then χ n Deposit Φ;
[0125] 5. After the traversal of X is completed, the obtained Φ is the crack classification result.
[0126] After grading, the structural line of each crack is divided into a primary result line and several secondary structural lines. The crack pixels corresponding to each structural line of different levels (including the structural lines merged in step 7) are considered to be different cracks, which are called graded cracks.
[0127] In step 7, if Figure 5 As shown by the line segment and The primary structure line AOC and line segments The secondary structure lines BO have a common intersection point p O , perform hypothesis test on the pixels near the intersection of the cracks belonging to the two structural lines to determine whether to merge the two structural lines. Let p O′ To follow the skeleton from p O Move to p B The moving point; set O′ For p O′ The diameter of a circle with the length of OO' as its center increases with the increase of p O′ When O′ When both ends of the diameter (EF) touch the "0" pixel in the crack map at the same time, p O′ Stop moving. Take the length of OO' as the diameter and p as the O Draw a circle with the center O , and extract n “1” pixels on the crack map from the two circles respectively, where n is the number of “1” pixels contained in the circle with fewer “1” pixels. Use formula (31) to execute T(P cls (⊙ O ,p O ,n),P cls (⊙ O′ ,p O′ ,n)), if the result is true, BO and AOC are merged and regarded as the same structural line.
[0128] In step 8, the two end points of each graded and merged graded structure line correspond to the two end points of a crack skeleton. Figure 5 The two ends of the circle touch the "0" pixel ⊙ O′, moving from one end point to another, extracting the "1" pixels in the crack map and removing the repeated pixels, we can obtain the classified crack pixels. Is graded crack C j The bounding rectangle of is a rectangle aspect ratio; is the area ratio of the crack to the circumscribed rectangle; then the following two functions can be defined:
[0129]
[0130]
[0131] For each graded crack, calculate equations (34) and (35). If the results of both equations are false, the crack is considered a false crack and is removed. By merging the remaining pixels with the original image, the crack extraction result image can be obtained (see Figure 6 ).
[0132] In the whole invention, the following six main parameters are included, namely β, L thr , A thr , S thr , τ thr and J. This paper named the proposed crack extraction method CDSL, tested CDSL using a public dataset, and compared the crack extraction effects with three different methods. The three methods are CrackForest, FCN, and TPTN. CrackForest is a traditional method, and FCN is a deep learning method. These two methods are often used for method comparison; TPTN is a new method proposed in 2022. The test dataset is the FCN-set crack dataset provided by the FCN method. In the comparative test, the parameters in CDSL are set to: β = 15, L thr =15, A thr =4, S thr =0.25, τ thr =π / 4, J = [16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26]; the performance comparison indicators are:
[0133]
[0134] TP is the pixel that is correctly identified, FP is the pixel that is incorrectly identified, and FN is the correct pixel that is not identified. The comparison results are shown in Table 1, and the effect comparison diagram is shown in Figure 7 .
[0135] Table 1 Comparison of performance indicators of various methods
[0136]
[0137] As shown in Table 1, the comprehensive performance of CDSL is better than the other three methods. Its comprehensive performance index F1 score is the highest and its recall rate is the highest. While TPTN has a higher accuracy than CDSL, it cannot identify the change of crack width, which will affect the final crack image interpretation. Figure 7 It can also be seen intuitively that the recognition results of CDSL are more continuous, more complete and have fewer errors than those of the other three methods.
[0138] In practical applications, the parameters can be set according to actual needs. When the contrast between the crack and the background is large, β can be appropriately increased, and vice versa. The parameter J is composed of a set of integers j, which affects the width range of cracks that CDSL can identify. The smaller the value, the larger the corresponding crack width. When j = 0 and b = 0.0001, Then by w j =w0×a -j The corresponding w when j is 16 to 26 can be calculated j , and w j This corresponds to the width of the cracks that can be identified by CDSL, as shown in Table 2:
[0139] Table 2. The corresponding w for different j j (Unit: pixel)
[0140]
[0141] When the crack width varies significantly, a wide range of J can be selected, such as J = [16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26]. When the crack width is relatively consistent, appropriate j can be selected according to Table 2 to form J, which can further improve the accuracy of crack identification. For example, when it is observed that the width of the crack in the acquired data varies roughly from 2 to 10 pixels, the w 21 =10,w 26 =2, so J=[21,22,23,24,25,26] can be selected to identify cracks.
[0142] Any portion not fully described in this specification is an existing mature technology. The description of the use cases in this specification does not limit the scope of protection of the patent of this invention; at the same time, any replacement or modification of the patent of this invention by those skilled in the art within the scope of protection claimed by the patent of this invention shall fall within the scope of protection of the patent of this invention, and the scope of protection claimed by the patent of this invention shall be based on the appended claims.
Claims
1. A crack extraction method under complex background, characterized in that: The following steps are involved: Step 1: First, the crack image is binarized and the crack measure of each pixel is calculated. For pixels with a crack measure greater than 0, a straight line is drawn along the width direction with the pixel as the midpoint and the width of the crack measure as the length. The pixels on the straight line are assigned a value of "1" and the remaining unassigned pixels are assigned a value of "0" to generate a binary crack map. The detailed definition of the crack measurement in step 1 is as follows: Let the Gaussian function and its first and second derivatives be: Among them, the normalized form of the Gaussian derivative is expressed as: From this, two two-dimensional bases can be defined: Where x and y are pixel coordinates, based on the above two bases, two symmetric molecules can be defined: in, t=[x,y] T , t0=[x0,y0] T is the coordinate offset, b = 0.0001 is the coordinate scaling factor, j is the scale factor, θ is the angle of the symmetric molecule, α and ρ are the parameters to be set; let the function be f e (x)=G e (a j x), (8) set up is the function f e (x) The distance between the two zero points when j = 0, and w0 is called the width of the crack measurement when j = 0; let w j =w0×a -j is the width of the crack measurement corresponding to different j values in formula (8); Grayscale image I and symmetrical molecule The j and θ corresponding to the maximum convolution value, where J is the set of j and θ is the set of angles θ; at the same time, define a j Changing the threshold parameter for: in, is j=j * The value of the width w when , the crack measure can be defined as: Among them, j o is the offset of the scale parameter j, β is the soft threshold, the greater the contrast between the crack and the background, the larger β is; Step 2: Refine the crack map into a crack skeleton map with a width of 1 pixel; Step 3: extract the key points of the crack skeleton diagram, including intersection points and endpoints, and connect the key points with structural lines according to the original connectivity to generate a crack structure line diagram; Step 4: Search for the key points belonging to another crack near the end points of all cracks, and find the key points with a distance less than d thr pixels, and the angle τ between the line connecting the endpoints and the structure line where the endpoints are located is less than π-τ thr The key point is tested with the endpoint, and the grayscale distribution of the pixels around them is consistent. Step 5: Eliminate the skeleton length after connection that is less than L thr cracks; Step 6: Using the structural line as the path, calculate the shortest path between the key points of each individual crack; under the shortest path condition, the path length of each level of structural line is the longest and the angle τ between adjacent structural lines is less than π-τ thr For the classification conditions, the structural line of each individual crack is graded; Step 7: Perform hypothesis testing at the intersection of each hierarchical structure line, and merge two structure lines of different levels with the same intersection that have true test results; Step 8: Extract the crack pixels corresponding to each level of structural line, which are called graded cracks. Screen them according to the area ratio of the graded cracks to their circumscribed rectangles and the aspect ratio of the circumscribed rectangles, and eliminate those with an area ratio greater than S. thr And the aspect ratio is less than A thr cracks and obtain the final crack extraction results.
2. The crack extraction method under complex background according to claim 1, characterized in that: In step 2, the crack map is thinned into a crack skeleton with a width of 1 pixel using the Hilditch algorithm or other thinning methods. Except for the skeleton, the remaining pixels are assigned a value of 0.
3. The crack extraction method under complex background according to claim 1, characterized in that: In step 2, the key points in the skeleton graph are connected according to their original topological relationships to generate a crack structure line graph. The lines connecting the key points are called structure lines, and the graph composed of structure lines is called a crack structure line graph. Among them, the key points are divided into endpoints and intersections. The endpoints are points with only one non-zero value among the adjacent pixels on the skeleton, and the intersections are points with more than two non-zero values among the adjacent pixels on the skeleton. When both adjacent pixels meet the intersection condition, the point with the largest "01" pattern is taken as the intersection. The "01" pattern indicates the number of times the value of the adjacent pixels of a certain pixel changes from 0 to 1 in a clockwise direction.
4. The crack extraction method under complex background according to claim 1, characterized in that: In step 4, two judgment functions are established to determine whether the cracks are connected. The detailed definition is: Let p0 and p1 be two key points on the same structural line of a crack, where p1 is the endpoint and the direction of the structural line is Let p2 be another crack with a distance from p1 less than d thr The key point of pixels, the direction of the line connecting it to p1 is The following function can be defined: Among them, τ thr is the angle threshold, Let P cm (C j ) is the pixel set of a crack with a serial number j in the crack map, P cls (C j ,p,n)∈P cm (C j ) is P cm (C j ) is a set of n pixels closest to p pixels. A hypothesis test function can be defined to verify the two pixel sets and Is the grayscale distribution of pixels consistent? Among them, the significance level α = 0.05, the hypothesis test function includes two steps: first, the consistency of the variance of the two samples is tested using the Levene test, and then, taking into account the variance consistency, the consistency of the grayscale distribution of the two samples is tested using the t test; for each endpoint, the surrounding distance is less than d thr The key point of the other crack of the pixel is selected and the direction consistency is checked using formula (12). Then the consistency of the grayscale of the pixels around the two points is checked using formula (13). If the results of both functions are true, the two cracks are connected.
5. The crack extraction method under complex background according to claim 1, characterized in that: The length screening function and usage in step 5 are as follows. Let P s (C j ) is crack C j The pixel set of the skeleton can be defined as: Among them, L thr is the length threshold, and function (14) is executed for each individual crack, and only cracks with true results are retained.
6. The method for extracting cracks under complex background according to claim 1, characterized in that: In step 6, the shortest path between all key points is calculated using the structure line as the path using the Floyd algorithm or other shortest path algorithms; The structural lines are then graded and characterized by: The classification process is as follows: Let X = {χ0,χ1,χ2,…,χ n } is the shortest path set between all key points of a crack in descending order of path length, where χ n Refers to the nth structural line path; let the judgment path χ i and χ j The function to determine whether there are repeated line segments is: bool=f re (x i ,x j ); (15) And suppose Φ={φ0,φ1,φ2,…,φ m } is the set of currently graded structural line paths, where φ m Refers to the path with sequence number m; all structural lines of the crack can be graded by performing the following steps:
1. Traverse X and access each shortest path χ n ; 2. For χ n For each point except the two end points, use formula (11) to judge the angle between the two connected structural lines; 3. If the two structural lines connecting all points satisfy formula (11), then traverse Φ and use formula (15) to execute f re (χ,φ), to judge χ n and the path φ in φ m Whether there are repeated segments; 4. If n If there is no repeated segment with all paths in φ, then χ n Deposit Ф; 5. After the X traversal is completed, the obtained Φ is the crack classification result; After grading, the structural line of each crack will be divided into a primary result line and several secondary structural lines. The crack pixels corresponding to each structural line of different levels are regarded as different cracks, which are called graded cracks.
7. The method for extracting cracks under complex background according to claim 4, characterized in that: In step 7, whether to merge the structural lines is determined based on the grayscale distribution of the crack pixels belonging to the two structural lines of different levels near the intersection point; Set line segment and The primary structure line AOC and line segments The secondary structure lines BO have a common intersection point p O , let p O' To follow the skeleton from p O Move to p B The moving point, set O' For p O' The diameter of a circle with the length of OO' as its center increases with the increase of p O' increases with the movement of O' When both ends of the diameter touch the "0" pixel in the crack map at the same time, p O' Stop moving, take the length of OO' as the diameter, and p O Draw a circle with the center O , and extract n "1" pixels on the crack map from the two circles respectively, where n is the number of "1" pixels contained in the circle with fewer "1" pixels in the two circles, and use formula (13) to perform T(P cls (⊙ O ,p O ,n),P cls (⊙ O' ,p O' ,n)), if the result is true, BO and AOC are merged and regarded as the same structural line.
8. The method for extracting cracks under complex background according to claim 7, characterized in that: Using the circle in step 7, move from one end point of the skeleton corresponding to the structural line to the other end point, extract the "1" pixels in the crack map, and then remove the duplicate pixels to obtain the classified crack pixels; let Is graded crack C j The bounding rectangle of is a rectangle aspect ratio; is the area ratio of the crack to the circumscribed rectangle; then the following two functions can be defined: For each graded crack, equations (16) and (17) are calculated. If the results of both equations are false, the crack is considered a false crack and is removed. The crack extraction result image can be obtained by merging the remaining pixels with the original image.
9. The method for extracting cracks under complex background according to claim 1, characterized in that: The method also includes step 9, which uses a public dataset to test the final crack extraction results and compares them with existing methods. The performance comparison indicators include: TP is the correctly identified pixel, FP is the incorrectly identified pixel, and FN is the correct pixel that has not been identified.