Pavement crack image skeleton extraction method based on improved Zhang-Suen refinement algorithm

By improving the Zhang-Suen algorithm and combining boundary expansion, run-length encoding, L-shaped structure templates, and breadth-first search, the problems of topological destruction, low efficiency, and burrs in the skeleton extraction of road crack images are solved, and efficient and complete single-pixel width skeleton extraction is achieved.

CN121304703APending Publication Date: 2026-01-09SHANDONG JIAOTONG UNIV +1
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202511626073.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-11-07
Publication Date
2026-01-09

AI Technical Summary

Technical Problem

The existing Zhang-Suen algorithm suffers from problems such as topological structure destruction, low computational efficiency, and skeleton extraction results that are not entirely single-pixel wide and contain burrs in road crack image skeleton extraction.

Method used

By improving the Zhang-Suen thinning algorithm, we introduce boundary expansion, horizontal run-length encoding, predefined L-shaped structure templates, and a breadth-first search spur removal method to ensure the topological integrity, computational efficiency, and spur-free skeleton.

Benefits of technology

The skeleton extraction result is a single pixel width, which avoids topological structure destruction, improves computational efficiency, and effectively removes burrs, meeting the requirements of the planned implementation path.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121304703A_ABST
    Figure CN121304703A_ABST
Patent Text Reader

Abstract

The invention relates to a pavement crack image skeleton extraction method based on an improved Zhang-Suen refinement algorithm. The method comprises the following steps: S1, carrying out binarization processing on a pavement crack image; s2, carrying out boundary expansion on the crack binary image; s3, carrying out run-length coding on the crack binary image in the horizontal direction, and carrying out compression storage on continuous non-zero pixel segments in each row; s4, using an improved Zhang-Suen refinement algorithm to process the crack binary image processed in the step S3; s5, removing boundary extension; s6, performing simplification processing on the preliminarily refined crack skeleton image by using four predefined 3 * 3 L-shaped structure templates; s7, removing burrs in the image; and S8, outputting a crack skeleton image. The technical problems that according to an existing skeleton extraction method, a topological structure is prone to being damaged, the calculation efficiency is low, the extraction result cannot be completely a skeleton with the single pixel width, and burrs exist in the skeleton extraction result are solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image skeleton extraction technology, and in particular to a method for extracting the skeleton of road surface crack images based on an improved Zhang-Suen thinning algorithm. Background Technology

[0002] When the end effector of the automatic crack sealing machine performs the crack sealing operation, it needs to plan the implementation path, which requires the extraction of the road surface crack image skeleton.

[0003] The Zhang-Suen thinning algorithm (Zhang-Suen algorithm for short) is an iterative thinning algorithm for skeleton extraction of binary images. It uses two layers of deletion conditions to progressively remove edge pixels that meet the conditions until a skeleton of one pixel width is obtained, while completely preserving the topological features of the original target. The original Zhang-Suen algorithm terminates when no pixels are deleted in two iterations. This algorithm is very simple, but it has the following drawbacks: topological structure destruction, low computational efficiency, the skeleton extraction result cannot be guaranteed to be a completely single-pixel-width skeleton, and the skeleton extraction result contains burrs (small branches), causing the extracted crack image skeleton to fail to meet the requirements of the planned implementation path.

[0004] To address the aforementioned issues, there is an urgent need for a method for extracting the skeleton of road surface crack images that can protect the skeleton endpoints and intersections, maintain topological integrity, has high computational efficiency, and ensures that the extracted results are entirely single-pixel-width skeletons without burrs. Summary of the Invention

[0005] To address the aforementioned technical problems, this invention provides a method for extracting the skeleton of road surface crack images based on an improved Zhang-Suen thinning algorithm. This method solves the technical problems of existing image skeleton extraction methods, such as easy topological structure destruction, low computational efficiency, inability to guarantee that the skeleton extraction result is a skeleton with a single pixel width, and the presence of burrs (small branches) in the skeleton extraction result.

[0006] To achieve the above objectives, this invention provides a method for extracting the skeleton of road surface crack images based on an improved Zhang-Suen thinning algorithm, comprising the following steps:

[0007] S1. Binarize the road surface crack image to obtain a binary crack image;

[0008] S2. Expand the boundary of the binary image of the crack: fill the entire foreground image with a ring of zero-value background pixels with a total width of 1 pixel.

[0009] S3. Perform run-length encoding on the horizontal direction of the binary image of the crack, and compress and store the continuous non-zero pixel segments in each row.

[0010] S4. Process the binary crack image processed in step S3 using the improved Zhang-Suen thinning algorithm to obtain a thinned crack skeleton image with boundary extension;

[0011] S5. Remove the boundary extension to obtain a preliminary refined crack skeleton image;

[0012] S6. Use four predefined 3×3 L-shaped structure templates to perform a single-pixel crack skeleton image processing to obtain a completely single-pixel crack skeleton image.

[0013] S7. Use a breadth-first search-based scratching removal method to remove scratches from the image;

[0014] S8. Output crack skeleton image.

[0015] Furthermore, step S4 includes the following steps:

[0016] S41. Perform the first iteration, traversing the binary image of the crack processed in step S3, and determining whether each pixel simultaneously meets the following conditions. If so, mark the pixel as a deletion point; otherwise, retain the pixel.

[0017] (1) ,

[0018] In the formula For pixels In the sequential arrangement, the values ​​of adjacent pixels are The quantity of change;

[0019] (2) ,

[0020] In the formula, This represents the smaller value among the logarithms of each of two groups of adjacent pixels that contain pixel 1. ,

[0021] In the formula:

[0022] ,

[0023] In the formula, the symbol Indicates logical OR;

[0024] (3) ;

[0025] (4) ;

[0026] S42. Delete the marked pixels;

[0027] S43. Perform the second iteration, traversing the image and determining whether a pixel simultaneously meets the following conditions. If so, mark the pixel as a deletion point; otherwise, retain the pixel.

[0028] (1) ;

[0029] (2) ;

[0030] (3) ;

[0031] (4) ;

[0032] S44. Delete the marked pixels;

[0033] S45. Determine whether any pixels have been deleted in this iteration. If yes, proceed to step S41; otherwise, proceed to step S5.

[0034] Furthermore, step S6 includes the following steps:

[0035] S61. Predefine four types of 3×3 L-shaped structure templates;

[0036] S62. Traverse each pixel in the pre-refined crack skeleton image and check whether the 3×3 neighborhood of each pixel matches one of the predefined 3×3 L-shaped structure templates. If it matches and the center pixel is a foreground pixel and the number of foreground pixels in the neighborhood is ≥4, then delete the center pixel.

[0037] S63. The traversal ends when no pixels are deleted.

[0038] Furthermore, step S7 includes the following steps:

[0039] S71. Mark the burr origin: Traverse the image, calculate the sum of pixel values ​​in the eight neighborhoods of the skeleton pixel, and if the sum of pixel values ​​in the eight neighborhoods is greater than 2 and the pixel values ​​in the clockwise direction within the eight neighborhoods increase from 0 to 1, then the burr origin is marked. If the number of occurrences is greater than 2, then mark the pixel as the starting point of the burr.

[0040] S72. Endpoint Detection: Endpoint detection is performed using convolution operations. A 3×3 convolution kernel is defined, with its center element being 10 and the remaining elements being 1, i.e.:

[0041] ,

[0042] Traverse the image, extract the pixel values ​​of the current pixel and its eight neighboring pixel regions to obtain a 3×3 neighborhood matrix. Multiply this pixel value element-wise with the convolution kernel, and then sum the results to obtain the convolution result, which is calculated using the following formula:

[0043] ,

[0044] Where R represents a 3×3 neighborhood matrix extracted from the skeleton image, and the element values ​​in the matrix are all 0 or 1; K represents the convolution kernel, whose elements are defined weight values ​​used to perform weighted summation of the pixel values ​​in the neighborhood; y and x represent the coordinates of the currently processed pixel; m and n represent the offset, with values ​​ranging from [−1, 1]; The coordinates in the neighborhood matrix R are... The element value at that position; This represents the element value at the corresponding position in the convolution kernel K;

[0045] like If so, then the point is determined to be an endpoint;

[0046] S73. Calculate the length of each branch: Scan with the endpoint as the starting point and calculate the length of each branch. Use breadth-first search to calculate the branch length. Starting from the starting point, visit its unvisited adjacent nodes layer by layer. First visit all adjacent nodes of the root node, and then visit the unvisited adjacent nodes of each layer of adjacent vertices in turn until all nodes in the graph have been visited. Count the number of foreground pixels starting from the starting point as the length of the branch.

[0047] S74. Set a dynamic threshold: Set a threshold based on the number of thinning iterations in the image skeleton extraction. The threshold calculation formula is as follows:

[0048] ,

[0049] Where L represents the length of the branch; This indicates the rounding function, which adjusts the value within the parentheses upwards to the nearest integer value; t represents the number of iterations in the skeleton refinement process.

[0050] S75. Delete the shortest branch in a loop: Determine if the branch length is lower than the threshold. If so, select the shortest branch and delete the branch starting from the spur endpoint. Update the spur starting point after deleting the spur. Analyze the spur starting point. If the number of remaining connections at the spur starting point after deleting the branch is greater than 2, delete the spur starting point. Otherwise, keep the spur starting point.

[0051] S76. Repeat S75 until the length of all branches is greater than or equal to the threshold, then terminate the loop.

[0052] S77. Cancel the marking of the burr start point.

[0053] Furthermore, the four predefined 3×3 L-shaped structure templates are all nine pixels arranged in a 3×3 pattern, including four structure templates: upper left L-shaped structure template, upper right L-shaped structure template, lower right L-shaped structure template, and lower left L-shaped structure template. The center pixel of the nine pixels arranged in a 3×3 pattern is the foreground pixel.

[0054] The top left corner pixel of the L-shaped structure template is the background pixel, the two pixels to the left and above the center pixel are the foreground pixels, the two pixels to the right and below the center pixel are the background pixels, the bottom right pixel is the background pixel, and the other two pixels can be either foreground pixels or background pixels.

[0055] The upper right corner pixel of the L-shaped structure template is the background pixel, the two pixels to the right and above the center pixel are the foreground pixels, the two pixels to the left and below the center pixel are the background pixels, the lower left pixel is the background pixel, and the other two pixels can be either foreground pixels or background pixels.

[0056] The top left pixel of the lower right L-shaped structure template is the background pixel, the two pixels to the left and above the center pixel are background pixels, the two pixels to the right and below the center pixel are foreground pixels, the bottom right pixel is the background pixel, and the other two pixels can be either foreground pixels or background pixels.

[0057] The lower left corner pixel of the lower left L-shaped structure template is the background pixel, the two pixels to the left and below the center pixel are the foreground pixels, the two pixels to the right and above the center pixel are the background pixels, the upper right pixel is the background pixel, and the other two pixels can be either foreground pixels or background pixels.

[0058] The present invention also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps of the road surface crack image skeleton extraction method.

[0059] The present invention also provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the steps of the road surface crack image skeleton extraction method.

[0060] The beneficial effects of this invention are reflected in:

[0061] 1. Improve the Zhang-Suen thinning algorithm by modifying the iterative deletion conditions, and add topology protection. )constraint, Prevent endpoint deletion; Preserving key intersections can prevent topological disruption and maintain the integrity of the skeleton.

[0062] 2. Boundary expansion eliminates boundary checks for neighborhood access; the introduction of run-length encoding in the horizontal direction can skip access to background regions and supports parallel processing, thus improving the computational efficiency of the algorithm.

[0063] 3. By introducing an L-shaped structure template, multi-pixel width areas are eliminated, ensuring single-pixel width and making the skeleton extraction result a skeleton with a single-pixel width.

[0064] 4. Use a burr removal method based on breadth-first search, set a dynamic threshold so that the threshold is dynamically adjusted with the number of iterations to achieve adaptive burr removal; use breadth-first search to calculate the branch length, traverse from the endpoint to count the branch length, and ensure that burr branches on the skeleton are completely removed. Attached Figure Description

[0065] Figure 1 This is a schematic diagram of the steps of the road surface crack image skeleton extraction method based on the improved Zhang-Suen thinning algorithm of the present invention;

[0066] Figure 2 This is a schematic diagram of the method for processing the crack binary image after step S3 using the improved Zhang-Suen thinning algorithm in step S4 of the present invention.

[0067] Figure 3 This is a schematic diagram of the structure of the computer device of the present invention;

[0068] Figure 4 This is a flowchart of the procedure for obtaining a preliminary refined crack skeleton image through steps S1-S5 of the present invention.

[0069] Figure 5 This is a flowchart of the process for step S6, the unification process, and step S7, the burr removal, of the present invention.

[0070] Figure 6 This is a schematic diagram of step S6 of the present invention, which uses four predefined 3×3 L-shaped structure templates to perform a single-type processing on the initially refined crack skeleton image.

[0071] Figure 7 This is a schematic diagram of the step S7 of the present invention, which uses a breadth-first search-based burr removal method to remove burrs from an image.

[0072] Figure 8 These are diagrams showing the operational results of the improved burr removal method and the improved burr removal method of this invention. Figure 8 (a) in the figure shows the results of the burr removal method before the improvement. Figure 8 (b) in the figure shows the results of the improved burr removal method.

[0073] Figure 9 The images show the results of the present invention's method of using four predefined 3×3 L-shaped structure templates to perform a single-processing of the initially refined crack skeleton image, and the results of the unmodified single-processing method. Figure 9 (a) in the figure shows the results of the single-processing method before the improvement. Figure 9 (b) in the figure shows the results of the improved single-processing method.

[0074] Figure 10 These are four binary images of asphalt pavement cracks of different types selected for this invention;

[0075] Figure 11 These are four predefined L-shaped structure template diagrams of this invention;

[0076] Figure 12 This is a binary skeleton image after preliminary skeleton refinement according to the present invention;

[0077] Figure 13 This is a binary image of the skeleton after the simplification process of the present invention;

[0078] The objectives, features, and advantages of this invention will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation

[0079] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.

[0080] like Figures 1-13 As shown, a method for extracting the skeleton of road surface crack images based on an improved Zhang-Suen thinning algorithm includes the following steps:

[0081] S1. Binarize the road surface crack image to obtain a binary crack image;

[0082] Specifically, road surface crack images are obtained using YOLO V8. Based on the obtained images, the U-Net deep learning image segmentation model is used to classify the crack images at the pixel level, dividing each pixel into foreground and background, where the crack is the foreground and non-target objects other than the crack are the background. The crack is then extracted from the background to obtain a high-quality binary image with less noise. The obtained binary crack image is used as the input to S2.

[0083] S2. Expand the boundary of the binary image of the crack: fill the entire foreground image with a ring of zero-value background pixels with a total width of 1 pixel.

[0084] Specifically, to improve the execution efficiency of the crack image thinning algorithm, the original binary crack image is first extended at the boundary (i.e., extended by 1 pixel in both the height and width directions) before thinning. This operation fills the image with zero-value background pixels around it, ensuring that no boundary condition judgment is needed during subsequent 3×3 neighborhood traversal, eliminating redundant detection instructions and thus improving computational efficiency.

[0085] S3. Perform run-length encoding on the horizontal direction of the binary image of the crack, and compress and store the continuous non-zero pixel segments in each row.

[0086] Specifically, to further improve the computation speed of the crack image thinning algorithm, run-length encoding (RLE) is performed on the binary image in the horizontal direction before thinning. This compresses and stores consecutive non-zero pixel segments (foreground) in each row. This operation achieves the following two performance optimizations: eliminating redundant storage of consecutive identical pixels; and allowing the thinning algorithm to directly access neighborhoods based on RLE segmented data, significantly reducing the number of accesses to invalid background pixels and improving the algorithm's computation speed.

[0087] Boundary checks for neighborhood access are eliminated by boundary expansion; run-length encoding (RLE) is introduced to skip access to background regions and supports parallel processing, thus improving the computational speed of the algorithm.

[0088] S4. The improved Zhang-Suen thinning algorithm is used to process the binary image of the crack after step S3 to obtain a thinned crack skeleton image with boundary extension.

[0089] like Figure 2 As shown, specifically, to ensure the integrity of the image skeleton topology, the Zhang-Suen thinning algorithm was improved by modifying the iterative deletion conditions. The improved Zhang-Suen thinning algorithm processes the binary crack image to obtain a thinned crack skeleton image with boundary extension. The specific steps include:

[0090] S41. Perform the first iteration, traversing the binary image of the crack processed in step S3, and determining whether each pixel simultaneously meets the following conditions. If so, mark the pixel as a deletion point; otherwise, retain the pixel.

[0091] (1) ,

[0092] In the formula For pixels In the sequential arrangement, the values ​​of adjacent pixels are The quantity of change;

[0093] (2) ,

[0094] In the formula, This represents the smaller value among the logarithms of each of two groups of adjacent pixels that contain pixel 1. ,

[0095] In the formula:

[0096] ,

[0097] In the formula, the symbol Indicates logical OR;

[0098] The purpose of this condition is to prevent the deletion of endpoints and key pixels, thereby maintaining the connectivity and integrity of the skeleton during the thinning process. This indicates that the pixel may be an endpoint. Deleting the endpoint would result in incomplete skeleton information, so it must be retained.

[0099] like This indicates that the pixel may be an intersection point or an internal point. Deleting such points may cause the skeleton to break or lose critical structures, so they must be retained.

[0100] (3) That is, at least one of the pixels P2, P4, and P6 has a value of 0.

[0101] (4) That is, at least one of the pixels P4, P6, and P8 has a value of 0.

[0102] S42. Delete the marked pixels;

[0103] S43. Perform the second iteration, traversing the image and determining whether a pixel simultaneously meets the following conditions. If so, mark the pixel as a deletion point; otherwise, retain the pixel.

[0104] (1) ;

[0105] (2) ;

[0106] (3) That is, at least one of the pixels P2, P4, and P8 has a value of 0.

[0107] (4) That is, at least one of the pixels P2, P6, and P8 has a value of 0.

[0108] S44. Delete the marked pixels;

[0109] S45. Determine whether any pixels have been deleted in this iteration. If yes, proceed to step S41; otherwise, proceed to step S5.

[0110] S5. Remove the boundary extension to obtain a preliminary refined crack skeleton image;

[0111] Specifically, remove the zero-value background pixels with a total width of 1 pixel that fill the foreground image, and output a preliminary refined crack skeleton image.

[0112] The flowchart of the procedure for obtaining a preliminary refined crack skeleton image through steps S1-S5 is as follows: Figure 4 As shown.

[0113] The improved Zhang-Suen thinning algorithm can effectively ensure the integrity of the image skeleton topology. Experimental analysis shows that the precision, recall and F1 score of this method are all significantly improved compared to the original Zhang-Suen thinning algorithm.

[0114] Four binary images of asphalt pavement cracks of different types were selected, such as... Figure 10 As shown, the crack skeleton was extracted using the original Zhang-Suen thinning algorithm and the improved Zhang-Suen thinning algorithm of this invention, respectively. Under the same operating environment, the algorithm was run 300 times. The result image extracted by the algorithm was compared with the manually annotated real skeleton (the size of the skeleton binary image obtained by the algorithm must be exactly the same as the size of the manually annotated skeleton binary image). The precision, recall and F1 score were calculated in MATLAB. The results are shown in Table 1.

[0115] Table 1 Precision, Recall, and F1 Score

[0116]

[0117] S6. Use four predefined 3×3 L-shaped structure templates to perform a single-pixel crack skeleton image processing to obtain a completely single-pixel crack skeleton image.

[0118] like Figure 6 As shown, specifically, step S6 includes the following steps:

[0119] S61. Predefine four 3×3 L-shaped structure templates, such as Figure 11 As shown;

[0120] Specifically, the four predefined 3×3 L-shaped structure templates are all nine pixels arranged in a 3×3 pattern. The four structure templates are: upper left L-shaped structure template, upper right L-shaped structure template, lower right L-shaped structure template, and lower left L-shaped structure template. The center pixel of the nine pixels arranged in a 3×3 pattern is the foreground pixel.

[0121] like Figure 11As shown in (a), the top left corner pixel of the upper left L-shaped structure template is a background pixel, the two pixels to the left and above the center pixel are foreground pixels, the two pixels to the right and below the center pixel are background pixels, the bottom right pixel is a background pixel, and the other two pixels can be either foreground pixels or background pixels.

[0122] like Figure 11 As shown in (b), the upper right corner pixel of the upper right L-shaped structure template is the background pixel, the two pixels to the right and above the center pixel are the foreground pixels, the two pixels to the left and below the center pixel are the background pixels, the lower left corner pixel is the background pixel, and the other two pixels can be either foreground pixels or background pixels.

[0123] like Figure 11 As shown in (c), the upper left corner pixel of the lower right L-shaped structure template is a background pixel, the two pixels to the left and above the center pixel are background pixels, the two pixels to the right and below the center pixel are foreground pixels, the lower right corner pixel is a background pixel, and the other two pixels can be either foreground pixels or background pixels.

[0124] like Figure 11 As shown in (d), the lower left corner pixel of the lower left L-shaped structure template is the background pixel, the two pixels to the left and below the center pixel are the foreground pixels, the two pixels to the right and above the center pixel are the background pixels, the upper right corner pixel is the background pixel, and the other two pixels can be either foreground pixels or background pixels.

[0125] S62. Traverse each pixel in the pre-refined crack skeleton image and check whether the 3×3 neighborhood of each pixel matches one of the predefined 3×3 L-shaped structure templates. If it matches and the center pixel is a foreground pixel and the number of foreground pixels in the neighborhood is ≥4, then delete the center pixel.

[0126] S63. The traversal ends when no pixels are deleted.

[0127] Using four predefined 3×3 L-shaped structure templates to standardize the initially refined crack skeleton image ensures that the extracted skeleton is 1 pixel wide. In addition, setting gray areas (which can be foreground or background pixels) in the L-shaped structure can preserve key inflection point pixels and avoid excessive deletion.

[0128] Figure 11In (a)-11(d), the white area represents foreground pixels, the black area represents background pixels, and the gray area can be either foreground or background pixels. The position of the foreground pixels in the template must be completely consistent with its neighbors. To verify the effectiveness of the unification processing method in this invention, a binary skeleton image after preliminary skeleton thinning is used, as shown below. Figure 12 A simplification processing experiment was conducted using the sample image. The experiment employed both the original simplification processing method and the improved simplification processing method of this invention (using four predefined 3×3 L-shaped structure templates to perform simplification processing on the initially refined crack skeleton image). Table 2 compares the input, principle, deletion conditions, and output results of the experiment; the comparison of the processing results of the simplification algorithms before and after the improvement is shown in the figure below. Figure 9 As shown in (a)-(b). Through Figure 9 The comparison between (a) and (b) clearly shows that the method of using four predefined 3×3 L-shaped structure templates to perform single-pixel processing on the initially refined crack skeleton image can effectively ensure that the refined skeleton is a single pixel.

[0129] Table 2 Comparison of Operations

[0130]

[0131] S7. Use a breadth-first search-based scratching removal method to remove scratches from the image;

[0132] like Figure 7 As shown, specifically, redundant branches on the refined skeleton that do not belong to the skeleton structure are called burrs. A node refers to a skeleton pixel with two or more skeleton points in its eight-neighborhood; a burr origin refers to a skeleton pixel with three or more skeleton points in its eight-neighborhood. Step S7 specifically includes the following steps:

[0133] S71. Mark the burr origin: Traverse the image, calculate the sum of pixel values ​​in the eight neighborhoods of the skeleton pixel, and if the sum of pixel values ​​in the eight neighborhoods is greater than 2 and the pixel values ​​in the clockwise direction within the eight neighborhoods increase from 0 to 1, then the burr origin is marked. If the number of occurrences is greater than 2, then mark the pixel as the starting point of the burr.

[0134] S72. Endpoint Detection: Endpoint detection is performed using convolution operations. A 3×3 convolution kernel is defined, with its center element being 10 and the remaining elements being 1, i.e.:

[0135] ,

[0136] Traverse the image, extract the pixel values ​​of the current pixel and its eight neighboring pixel regions to obtain a 3×3 neighborhood matrix. Multiply this pixel value element-wise with the convolution kernel, and then sum the results to obtain the convolution result, which is calculated using the following formula:

[0137] ,

[0138] Where R represents a 3×3 neighborhood matrix extracted from the skeleton image, and the element values ​​in the matrix are all 0 or 1; K represents the convolution kernel, whose elements are defined weight values ​​used to perform weighted summation of the pixel values ​​in the neighborhood; y and x represent the coordinates of the currently processed pixel; m and n represent the offset, with values ​​ranging from [−1, 1]; The coordinates in the neighborhood matrix R are... The element value at that position; This represents the element value at the corresponding position in the convolution kernel K;

[0139] like This means that if the center pixel is 1 and only one neighboring pixel is 1, then the point is determined to be an endpoint.

[0140] S73. Calculate the length of each branch: Scan with the endpoint as the starting point and calculate the length of each branch. Use breadth-first search (BFS) to calculate the branch length. Starting from the starting point, visit its unvisited adjacent nodes layer by layer. First visit all adjacent nodes of the root node, and then visit the unvisited adjacent nodes of each layer of adjacent vertices in turn, until all nodes in the graph have been visited. Count the number of foreground pixels starting from the starting point as the length of the branch.

[0141] S74. Set a dynamic threshold: Set a threshold based on the number of thinning iterations in the image skeleton extraction. The threshold calculation formula is as follows:

[0142] ,

[0143] Where L represents the length of the branch; This indicates the rounding function, which adjusts the value within the parentheses upwards to the nearest integer value; t represents the number of iterations in the skeleton refinement process.

[0144] Specifically, since different crack images require different number of iterations during thinning, and the length of the resulting burrs also varies, in order to prevent unreasonable threshold settings from causing excessive burr removal and damaging the connectivity of the skeleton, a method is adopted to set the threshold based on the number of thinning iterations extracted from the image skeleton.

[0145] S75. Delete the shortest branch in a loop: Determine if the branch length is lower than the threshold. If so, select the shortest branch and delete the branch starting from the spur endpoint. Update the spur starting point after deleting the spur. Analyze the spur starting point. If the number of remaining connections at the spur starting point after deleting the branch is greater than 2, delete the spur starting point. Otherwise, keep the spur starting point.

[0146] Specifically, for the branch with the shortest length below the threshold, a BFS traversal is performed starting from the endpoint, and the pixel of the shortest branch is set to 0. To ensure the connectivity of the skeleton after glitch removal, the glitch origin is analyzed. If the number of remaining connections at the glitch origin after deleting the branch is greater than 2, the glitch origin is deleted. Otherwise, the glitch origin is retained to avoid disrupting the connectivity of the skeleton backbone.

[0147] S76. Repeat S75 until the length of all branches is greater than or equal to the threshold, then terminate the loop.

[0148] S77. Cancel the marking of the burr start point.

[0149] Step S6 uses four predefined 3×3 L-shaped structure templates to perform homogenization processing on the initially refined crack skeleton image, and step S7 uses a breadth-first search-based burr removal method. The flowchart of the program for removing burrs from the image is as follows. Figure 5 As shown.

[0150] To verify the effectiveness of the scratching removal method based on breadth-first search in removing scratches from an image, a binary skeleton image after single-processing was used as shown below. Figure 13 As the processing object, the burr removal method before the improvement and the burr removal method of the present invention were used to process the processing object respectively. The input, burr removal threshold, deletion conditions and output of the two methods are compared as shown in Table 3.

[0151] A comparison of the results of the burr removal methods before and after the improvement: Figure 8 As shown in the figure. The comparison clearly demonstrates that the burr removal method based on breadth-first search in this invention effectively removes burrs and isolated points from the skeleton image extracted after crack image refinement, while preserving the main topological structure of the crack.

[0152] Table 3 Comparison of Operations

[0153]

[0154] S8. Output crack skeleton image.

[0155] To verify the efficiency of the pavement crack image skeleton extraction method based on the improved Zhang-Suen thinning algorithm proposed in this invention, Figure 10 The image was used as the processing object to conduct an algorithm time efficiency analysis experiment. Since the algorithm may be affected by random factors such as the computer system during operation, the single running time may fluctuate greatly, which may lead to the result deviating from the real time. Therefore, during the experiment, the same computer was used to run each algorithm 300 times, and the average value was taken as the final result.

[0156] The time performance of each functional part of the road crack image skeleton extraction method using the unimproved Zhang-Suen thinning algorithm and the road crack image skeleton extraction method using the improved Zhang-Suen thinning algorithm of this invention is compared to analyze the time performance of the two algorithms. Tables 4 and 5 show the time required for preliminary skeleton thinning, unification, and deburring, as well as the total time required for the entire process, during the skeleton extraction using the two methods.

[0157] Table 4. Skeleton extraction time (s) for crack images using the Zhang-Suen thinning algorithm before improvement.

[0158]

[0159] Table 5. Time (s) for skeleton extraction from crack images using the improved Zhang-Suen thinning algorithm of this invention.

[0160]

[0161] Comparing the data in Tables 4 and 5, it is evident that the road surface crack image skeleton extraction method based on the improved Zhang-Suen thinning algorithm of this invention significantly improves the running efficiency compared to the original Zhang-Suen thinning algorithm, thereby enhancing the algorithm's real-time performance. The average running time of the entire process for crack image skeleton extraction using the original Zhang-Suen thinning algorithm was 2.7341 s, while the average running time of the algorithm proposed in this invention is 0.6399 s, representing an improvement in processing speed of approximately 76.6%. Experiments demonstrate that the image boundary expansion and run-length encoding employed in this paper to improve time efficiency are highly effective, and the improved thinning algorithm can extract crack skeletons much faster.

[0162] like Figure 3 As shown in the illustration, this embodiment of the invention also provides a computer device. The computer device includes a processor, memory, display screen, input device, network interface, and database connected via a system bus. The processor in this computer design provides computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores an operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage medium. The database of the computer device is used to store the data corresponding to this embodiment. The network interface of the computer device is used for communication with external terminals via a network connection. When the computer program is executed by the processor, it implements the above-described method.

[0163] Those skilled in the art will understand that Figure 3The structures shown are merely block diagrams of some structures related to the present invention and do not constitute a limitation on the computer devices on which the present invention is applied.

[0164] An embodiment of the present invention also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the above-described method. It is understood that the computer-readable storage medium in this embodiment can be a volatile readable storage medium or a non-volatile readable storage medium.

[0165] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments of the above methods. Any references to memory, storage, databases, or other media used in the present invention and embodiments can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual-rate SDRAM (SSRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), Rambus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM, etc.

[0166] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, apparatus, article, or method that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, apparatus, article, or method. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, apparatus, article, or method that includes that element.

[0167] The above description is only a preferred embodiment of the present invention and does not limit the patent scope of the present invention. Any equivalent structural or procedural transformations made based on the content of the present invention specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the patent protection scope of the present invention.

Claims

1. A method for extracting the skeleton of road surface crack images based on an improved Zhang-Suen thinning algorithm, characterized in that, Includes the following steps: S1. Binarize the road surface crack image to obtain a binary crack image; S2. Expand the boundary of the binary image of the crack: fill the entire foreground image with a ring of zero-value background pixels with a total width of 1 pixel. S3. Perform run-length encoding on the horizontal direction of the binary image of the crack, and compress and store the continuous non-zero pixel segments in each row. S4. The improved Zhang-Suen thinning algorithm is used to process the binary image of the crack after step S3 to obtain a thinned crack skeleton image with boundary extension. S5. Remove the boundary extension to obtain a preliminary refined crack skeleton image; S6. Use four predefined 3×3 L-shaped structure templates to perform a single-pixel crack skeleton image processing to obtain a completely single-pixel crack skeleton image. S7. Use a breadth-first search-based scratching removal method to remove scratches from the image; S8. Output crack skeleton image.

2. The method for extracting the skeleton of road surface crack images based on the improved Zhang-Suen thinning algorithm according to claim 1, characterized in that, Step S4 includes the following steps: S41. Perform the first iteration, traversing the binary image of the crack processed in step S3, and determining whether each pixel simultaneously meets the following conditions. If so, mark the pixel as a deletion point; otherwise, retain the pixel. (1) , In the formula For pixels In the sequential arrangement, the values ​​of adjacent pixels are The quantity of change; (2) , In the formula, This represents the smaller value among the logarithms of each of two groups of adjacent pixels that contain pixel 1. , In the formula: , In the formula, the symbol Indicates logical OR; (3) ; (4) ; S42. Delete the marked pixels; S43. Perform the second iteration, traversing the image and determining whether a pixel simultaneously meets the following conditions. If so, mark the pixel as a deletion point; otherwise, retain the pixel. (1) ; (2) ; (3) ; (4) ; S44. Delete the marked pixels; S45. Determine whether any pixels have been deleted in this iteration. If yes, proceed to step S41; otherwise, proceed to step S5.

3. The method for extracting the skeleton of road surface crack images based on the improved Zhang-Suen thinning algorithm according to claim 1, characterized in that, Step S6 includes the following steps: S61. Predefine four types of 3×3 L-shaped structure templates; S62. Traverse each pixel in the pre-refined crack skeleton image and check whether the 3×3 neighborhood of each pixel matches one of the predefined 3×3 L-shaped structure templates. If it matches and the center pixel is a foreground pixel and the number of foreground pixels in the neighborhood is ≥4, then delete the center pixel. S63. The traversal ends when no pixels are deleted.

4. The method for extracting the skeleton of road surface crack images based on the improved Zhang-Suen thinning algorithm according to claim 1, characterized in that, Step S7 includes the following steps: S71. Mark the burr origin: Traverse the image, calculate the sum of pixel values ​​in the eight neighborhoods of the skeleton pixel, and if the sum of pixel values ​​in the eight neighborhoods is greater than 2 and the pixel values ​​in the clockwise direction within the eight neighborhoods increase from 0 to 1, then the burr origin is marked. If the number of occurrences is greater than 2, then mark the pixel as the starting point of the burr. S72. Endpoint Detection: Endpoint detection is performed using convolution operations. A 3×3 convolution kernel is defined, with its center element being 10 and the remaining elements being 1, i.e.: , Traverse the image, extract the pixel values ​​of the current pixel and its eight neighboring pixel regions to obtain a 3×3 neighborhood matrix. Multiply this pixel value element-wise with the convolution kernel, and then sum the results to obtain the convolution result, which is calculated using the following formula: , Where R represents a 3×3 neighborhood matrix extracted from the skeleton image, and the element values ​​in the matrix are all 0 or 1; K represents the convolution kernel, whose elements are defined weight values ​​used to perform weighted summation of the pixel values ​​in the neighborhood; y and x represent the coordinates of the currently processed pixel; m and n represent the offset, with values ​​ranging from [−1, 1]; The coordinates in the neighborhood matrix R are... The element value at that position; This represents the element value at the corresponding position in the convolution kernel K; like If so, then the point is determined to be an endpoint; S73. Calculate the length of each branch: Scan with the endpoint as the starting point and calculate the length of each branch. Use breadth-first search to calculate the branch length. Starting from the starting point, visit its unvisited adjacent nodes layer by layer. First visit all adjacent nodes of the root node, and then visit the unvisited adjacent nodes of each layer of adjacent vertices in turn until all nodes in the graph have been visited. Count the number of foreground pixels starting from the starting point as the length of the branch. S74. Set a dynamic threshold: Set a threshold based on the number of thinning iterations in the image skeleton extraction. The threshold calculation formula is as follows: , Where L represents the length of the branch; This indicates the rounding function, which adjusts the value within the parentheses upwards to the nearest integer value; t represents the number of iterations in the skeleton refinement process. S75. Delete the shortest branch in a loop: Determine if the branch length is lower than the threshold. If so, select the shortest branch and delete the branch starting from the spur endpoint. Update the spur starting point after deleting the spur. Analyze the spur starting point. If the number of remaining connections at the spur starting point after deleting the branch is greater than 2, delete the spur starting point. Otherwise, keep the spur starting point. S76. Repeat S75 until the length of all branches is greater than or equal to the threshold, then terminate the loop. S77. Cancel the marking of the burr start point.

5. The method for extracting the skeleton of road surface crack images based on the improved Zhang-Suen thinning algorithm according to claim 1 or 3, characterized in that, The four predefined 3×3 L-shaped structure templates are all nine pixels arranged in a 3×3 pattern. The four structure templates are: upper left L-shaped structure template, upper right L-shaped structure template, lower right L-shaped structure template, and lower left L-shaped structure template. The center pixel of the nine pixels arranged in a 3×3 pattern is the foreground pixel. The top left corner pixel of the L-shaped structure template is the background pixel, the two pixels to the left and above the center pixel are the foreground pixels, the two pixels to the right and below the center pixel are the background pixels, the bottom right pixel is the background pixel, and the other two pixels can be either foreground pixels or background pixels. The upper right corner pixel of the L-shaped structure template is the background pixel, the two pixels to the right and above the center pixel are the foreground pixels, the two pixels to the left and below the center pixel are the background pixels, the lower left pixel is the background pixel, and the other two pixels can be either foreground pixels or background pixels. The top left pixel of the lower right L-shaped structure template is the background pixel, the two pixels to the left and above the center pixel are background pixels, the two pixels to the right and below the center pixel are foreground pixels, the bottom right pixel is the background pixel, and the other two pixels can be either foreground pixels or background pixels. The lower left corner pixel of the lower left L-shaped structure template is the background pixel, the two pixels to the left and below the center pixel are the foreground pixels, the two pixels to the right and above the center pixel are the background pixels, the upper right pixel is the background pixel, and the other two pixels can be either foreground pixels or background pixels.

6. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 5.

7. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 5.

Citation Information

Cited By

  • Intelligent positioning and quantifying method for pavement diseases

    CN122066777A

  • Urban travel simulation method, system and device based on functional area probability

    CN122346992A