A crack skeleton line extraction method based on an improved ZS thinning algorithm

CN122798705APending Publication Date: 2026-09-22SHANXI XISHAN COAL & ELECTRICITY CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610758828.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-05-29
Publication Date
2026-09-22

AI Technical Summary

Technical Problem

(1)经典ZS细化算法虽然能够对二值裂缝目标进行快速细化,但在处理边界起伏明显、局部形态复杂的裂缝图像时,容易在Z字型结构、T字型结构和十字型结构处残留冗余骨架像素,导致骨架线不满足严格单像素宽度要求,影响裂缝中心线表达精度

Benefits of technology

(1)本发明利用骨架像素8邻域结构分析和冗余像素删除模板匹配原理,通过骨架局部冗余结构识别步骤计算出待检测骨架像素的连接数和交叉数,并识别出Z字型结构、T字型结构和十字型结构;通过冗余像素删除模板匹配步骤调用对应冗余像素删除模板,将满足模板匹配条件的骨架像素判定为冗余骨架点并删除,得到单像素化骨架图像,技术效果是提高裂缝骨架线的单像素性和中心线表达精度,解决了经典ZS细化算法在复杂局部邻域中容易残留冗余像素的问题。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122798705A_ABST
    Figure CN122798705A_ABST
Patent Text Reader

Abstract

This invention belongs to the field of image processing and structural health detection technology, and particularly relates to a crack skeleton line extraction method based on an improved ZS thinning algorithm. The method includes a crack binary image acquisition step, a ZS parallel thinning step, a skeleton local redundant structure identification step, a redundant pixel deletion template matching step, a directional chain code burr branch identification step, a skeleton burr branch deletion step, and a skeleton endpoint principal component growth step. Utilizing the principles of skeleton pixel 8-neighborhood structure analysis, redundant pixel deletion template matching, 8-directional chain code branch tracking, adaptive burr discrimination, and principal component analysis endpoint growth, the initial crack skeleton image obtained by ZS parallel thinning is subjected to redundant skeleton point deletion, burr branch deletion, and skeleton endpoint compensation to obtain the final crack skeleton line, improving the single-pixel integrity, continuity, smoothness, and end integrity of the crack skeleton line.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of image processing and structural health detection technology, and particularly relates to a method for extracting crack skeleton lines based on an improved ZS thinning algorithm. Background Technology

[0002] Cracks are a common form of damage in concrete structures, well walls, rock surfaces, pavements, and bridge surfaces. Crack length, width, area, number of branches, and topological morphology can reflect the degree of local damage and its propagation trend. With the development of machine vision and image processing technologies, extracting crack skeleton lines from crack images has become an important foundation for calculating crack geometric parameters and assessing structural health. Crack skeleton lines can express the direction of the crack center and topological relationships, which is of great significance for subsequent crack length calculation, width measurement, branch analysis, and damage evaluation.

[0003] The existing technology has at least the following problems that need to be improved: (1) Although the classic ZS thinning algorithm can quickly thin out binary crack targets, when processing crack images with obvious boundary undulations and complex local morphology, it is easy to leave redundant skeleton pixels at Z-shaped, T-shaped and cross-shaped structures, which causes the skeleton lines to not meet the strict single pixel width requirement and affect the accuracy of crack center line expression.

[0004] (2) The classic ZS thinning algorithm is prone to local burr branches and end shortening at crack boundary disturbances, intersection areas and the end of slender cracks, resulting in insufficient smoothness, continuity and end integrity of the skeleton line, which in turn affects the reliability of crack length, width, area and topological morphology parameter calculation. Summary of the Invention

[0005] To address the above issues and overcome the shortcomings of existing technologies, this invention provides a crack skeleton line extraction method based on an improved ZS thinning algorithm. Utilizing skeleton pixel 8-neighborhood structure analysis, redundant pixel deletion template matching, 8-direction chain code branch tracing, adaptive spur discrimination, and principal component analysis endpoint growth principles, the method performs redundant skeleton point deletion, spur branch deletion, and skeleton endpoint compensation on the initial crack skeleton image obtained through ZS parallel thinning, resulting in the final crack skeleton line. This improves the single-pixel integrity, continuity, smoothness, and end integrity of the crack skeleton line, solving the problems of redundant pixel residue, local spur branches, erroneous deletion of effective tail branches, and shortened skeleton endpoints present in the classic ZS thinning algorithm.

[0006] This invention provides a crack skeleton line extraction method based on an improved ZS thinning algorithm, including a crack binary image acquisition step, a ZS parallel thinning step, a skeleton local redundant structure identification step, a redundant pixel deletion template matching step, a directional chain code burr branch identification step, a skeleton burr branch deletion step, and a skeleton endpoint principal component growth step.

[0007] The crack binary image acquisition step obtains the crack image to be processed and performs crack region segmentation on the crack image to be processed to obtain the crack binary image. The ZS parallel thinning step receives the binary image of the crack, uses the ZS parallel thinning algorithm to iteratively thin the target region of the crack to obtain an initial crack skeleton image, and records the number of thinning iterations. The skeleton local redundancy structure identification step receives an initial crack skeleton image, calculates the number of connections and crosses of the skeleton pixels to be detected based on the 8-neighborhood structure of the skeleton pixels in the initial crack skeleton image, and identifies the skeleton local redundancy structure according to the number of connections, crosses and the distribution of the skeleton pixel neighborhood. The redundant pixel deletion template matching step receives the local redundant structure of the skeleton, calls the redundant pixel deletion template to perform template matching on the skeleton pixels to be detected, and determines the skeleton pixels that satisfy any redundant pixel deletion template as redundant skeleton points and deletes them to obtain a single-pixel skeleton image. The directional chain code spur branch identification step receives a single-pixel skeleton image, tracks and encodes the skeleton branches in the single-pixel skeleton image based on 8-directional chain codes, calculates the geometric length of the skeleton branches, determines the spur discrimination threshold based on the number of thinning iterations, and identifies the spur branches based on the geometric length of the skeleton branches and the spur discrimination threshold. The skeleton burr branch deletion step starts from the skeleton intersection point, scans and judges each skeleton branch connected to the same skeleton intersection point, deletes burr branches whose geometric length is less than the burr discrimination threshold and do not belong to the effective crack structure, and obtains a deburred skeleton image. The principal component growth step of the skeleton endpoint receives the deburred skeleton image. For the skeleton endpoints in the deburred skeleton image, the principal component analysis method is used to estimate the local principal direction of the skeleton pixels in the neighborhood of the endpoint. The actual growth direction of the endpoint is corrected by combining the spatial distribution relationship between the skeleton endpoint and the neighboring skeleton pixels. The actual growth direction of the endpoint is mapped to the discrete pixel position in the 8-neighborhood of the skeleton endpoint, and iteratively grows along the outer direction of the crack until the candidate growth point no longer belongs to the crack region, and the final crack skeleton line is output.

[0008] Furthermore, the ZS parallel thinning step alternately executes two sub-processes in each iteration, uniformly marking target pixels that meet the deletion conditions, and deleting them in a concentrated manner after the current round of scanning, until there are no new deletable pixels in the crack binary image.

[0009] Furthermore, the skeleton local redundancy structure includes a Z-shaped structure, a T-shaped structure, and a cross-shaped structure; the redundant pixel deletion template includes a redundant pixel deletion template set for the Z-shaped structure, a redundant pixel deletion template set for the T-shaped structure, and a redundant pixel deletion template set for the cross-shaped structure.

[0010] Furthermore, the directional chain code burr branch identification step uses 8-directional chain codes to represent the 8 connected directions between adjacent skeleton pixels, and calculates the geometric length of the skeleton branch based on the number of even-numbered chain codes and the number of odd-numbered chain codes in the skeleton branch chain code sequence.

[0011] Furthermore, the directional chain code burr branch identification step calculates the burr discrimination threshold based on the number of refinement iterations recorded in the ZS parallel refinement step, and identifies the burr branch based on the skeleton branch geometric length and the burr discrimination threshold.

[0012] Furthermore, the skeleton burr branch deletion step scans each skeleton branch starting from the skeleton intersection point and deletes the skeleton pixels that are determined to be burr branches to obtain a deburred skeleton image.

[0013] Furthermore, in the principal component growth step of the skeleton endpoint, local analysis samples are selected along the skeleton direction inside the skeleton endpoint. A covariance matrix is ​​constructed based on the local analysis samples. Eigenvalue decomposition is performed on the covariance matrix, and the eigenvector corresponding to the largest eigenvalue is taken as the candidate principal direction. The actual growth direction of the endpoint is corrected based on the spatial distribution relationship between the skeleton endpoint and the neighboring skeleton pixels.

[0014] Furthermore, the principal component growth step of the skeleton endpoint maps the actual growth direction of the endpoint to the discrete pixel position in the neighborhood of the skeleton endpoint 8, determines the candidate growth point, and iteratively grows along the outer direction of the crack until the candidate growth point no longer belongs to the crack region.

[0015] The beneficial effects of this invention are as follows: (1) This invention utilizes the principle of skeleton pixel 8-neighborhood structure analysis and redundant pixel deletion template matching. Through the skeleton local redundant structure identification step, the number of connections and intersections of the skeleton pixels to be detected are calculated, and Z-shaped structure, T-shaped structure and cross-shaped structure are identified. Through the redundant pixel deletion template matching step, the corresponding redundant pixel deletion template is called, and the skeleton pixels that meet the template matching conditions are determined as redundant skeleton points and deleted to obtain a single-pixel skeleton image. The technical effect is to improve the single-pixel performance of the crack skeleton line and the accuracy of the center line expression, and solve the problem that the classic ZS thinning algorithm is prone to leaving redundant pixels in complex local neighborhoods.

[0016] (2) This invention utilizes the principle of 8-direction chain code branch tracking and adaptive spur discrimination. The skeleton branches in the single-pixel skeleton image are tracked and encoded through the directional chain code spur branch identification step, the geometric length of the skeleton branches is calculated, and the spur discrimination threshold is determined according to the number of thinning iterations. The skeleton spur branch deletion step scans each skeleton branch with the skeleton intersection as the starting point and deletes spur branches whose geometric length is less than the spur discrimination threshold and do not belong to the effective crack structure. The technical effect is to improve the smoothness and structural stability of the crack skeleton line and solve the problem that the classic ZS thinning algorithm is prone to generating short spur branches and is prone to accidentally deleting effective tail branches when deleting from the endpoint.

[0017] (3) This invention utilizes principal component analysis and the principle of growing on the outer side of the endpoint. By selecting local analysis samples along the inner skeleton direction of the skeleton endpoint through the principal component growth step of the skeleton endpoint, constructing the covariance matrix and performing eigenvalue decomposition, the candidate principal direction is obtained. Then, the actual growth direction of the endpoint is corrected according to the spatial distribution relationship between the skeleton endpoint and the neighboring skeleton pixels, and iteratively grown along the outer direction of the crack until the candidate growth point no longer belongs to the crack region. The technical effect is to compensate for the shrinkage of the skeleton endpoint during the ZS thinning process, improve the end integrity of the final crack skeleton line, and solve the problem of the existing crack skeleton line end shortening causing the calculation deviation of crack length and morphological parameters. Attached Figure Description

[0018] The accompanying drawings are provided to further understand the present invention and form part of the specification. They are used together with the embodiments of the present invention to explain the invention and do not constitute a limitation thereof.

[0019] Figure 1 This is an overall flowchart of the crack skeleton line extraction method of the present invention; Figure 2 This is a schematic diagram of the 8-neighborhood structure of a pixel in this invention; Figure 3 A schematic diagram showing the crack skeleton extraction results and problems of the classic ZS refinement algorithm; Figure 3 The left and right images in the first image are (a) the crack skeleton extracted by the ZS algorithm and (b) a magnified view of pixel redundancy. Figure 4 These are schematic diagrams illustrating the local structures of different types of skeleton redundant pixels in this invention; Figure 5 This is a schematic diagram of different types of skeleton redundant pixel deletion templates of the present invention; Figure 5 The first image in the document is (a) a template for deleting a Z-shaped redundant structure. Figure 5 The second image in the image is (b) the template for deleting the T-shaped redundant structure. Figure 6 This is a schematic diagram illustrating the 8-direction chain code direction definition and encoding of the present invention; Figure 7 This is a flowchart of the skeleton glitch elimination method based on directional chain code of the present invention; Figure 8 This is a schematic diagram illustrating the determination of the growth direction of the skeleton endpoints based on principal component analysis according to the present invention. Figure 9 Comparison of crack skeleton extraction results using different refinement algorithms. Detailed Implementation

[0020] Example 1, see Figures 1-9 The present invention provides a crack skeleton line extraction method based on an improved ZS thinning algorithm, including a crack binary image acquisition step, a ZS parallel thinning step, a skeleton local redundant structure identification step, a redundant pixel deletion template matching step, a directional chain code burr branch identification step, a skeleton burr branch deletion step, and a skeleton endpoint principal component growth step. The crack binary image acquisition step obtains the crack image to be processed and performs crack region segmentation on the crack image to be processed to obtain the crack binary image, wherein the crack target pixel is 1 and the background pixel is 0. The ZS parallel thinning step receives the binary image of the crack, uses the ZS parallel thinning algorithm to iteratively thin the target region of the crack to obtain an initial crack skeleton image, and records the number of thinning iterations. The skeleton local redundancy structure identification step receives an initial crack skeleton image, calculates the number of connections and crosses of the skeleton pixels to be detected based on the 8-neighborhood structure of the skeleton pixels in the initial crack skeleton image, and identifies the skeleton local redundancy structure according to the number of connections, crosses and the distribution of the skeleton pixel neighborhood. The redundant pixel deletion template matching step receives the local redundant structure of the skeleton, calls the redundant pixel deletion template to perform template matching on the skeleton pixels to be detected, and determines the skeleton pixels that satisfy any redundant pixel deletion template as redundant skeleton points and deletes them to obtain a single-pixel skeleton image. The directional chain code spur branch identification step receives a single-pixel skeleton image, tracks and encodes the skeleton branches in the single-pixel skeleton image based on 8-directional chain codes, calculates the geometric length of the skeleton branches, determines the spur discrimination threshold based on the number of thinning iterations, and identifies the spur branches based on the geometric length of the skeleton branches and the spur discrimination threshold. The skeleton burr branch deletion step starts from the skeleton intersection point, scans and judges each skeleton branch connected to the same skeleton intersection point, deletes burr branches whose geometric length is less than the burr discrimination threshold and do not belong to the effective crack structure, and obtains a deburred skeleton image. The principal component growth step of the skeleton endpoint receives the deburred skeleton image. For the skeleton endpoints in the deburred skeleton image, the principal component analysis method is used to estimate the local principal direction of the skeleton pixels in the neighborhood of the endpoint. The actual growth direction of the endpoint is corrected by combining the spatial distribution relationship between the skeleton endpoint and the neighboring skeleton pixels. The actual growth direction of the endpoint is mapped to the discrete pixel position in the 8-neighborhood of the skeleton endpoint, and iteratively grows along the outer direction of the crack until the candidate growth point no longer belongs to the crack region, and the final crack skeleton line is output.

[0021] Through the above steps, the present invention can reduce redundant skeleton points and burr branches in the initial crack skeleton image based on the classic ZS thinning algorithm, and compensate for the shortening of skeleton endpoints, so that the final crack skeleton line has single-pixel integrity, continuity, smoothness and end integrity.

[0022] Example 2: This example is based on all the above examples. The steps for acquiring the binary image of the crack and the ZS parallel thinning step specifically include: Acquisition of crack images to be processed; acquisition of crack images to be processed on well wall structures, concrete structures, rock surfaces, road surfaces, or bridge surfaces; Crack region segmentation: The crack image to be processed is segmented into a crack region to obtain a binary crack image. The crack target pixel in the binary crack image is set to 1, and the background pixel is set to 0. 8-neighborhood structure construction: For any target pixel P0 in the binary image of the crack, a 3×3 window is constructed with the target pixel P0 as the center, and the 8 neighboring pixels in the 3×3 window other than the target pixel P0 are used as the 8-neighborhood structure of the target pixel P0. ZS Parallel Thinning: Using a binary image of a crack as input, the ZS parallel thinning algorithm is used for iterative thinning. In each iteration, two sub-processes are executed alternately. The two sub-processes combine the deletion conditions of the target pixels from different directions. Unified marking and centralized deletion: In each sub-process, target pixels that meet the deletion conditions are first uniformly marked, and then centrally deleted after the current round of scanning is completed; The iteration stops; the two sub-processes are repeated until there are no new deletable pixels in the binary image of the crack, the initial crack skeleton image is obtained, and the number of thinning iterations is recorded.

[0023] Example 3: This example is based on all the above examples. The skeleton local redundancy structure identification step and the redundant pixel deletion template matching step specifically include: The skeleton pixel to be detected is determined; the initial crack skeleton image is scanned pixel by pixel, and the currently scanned skeleton pixel is taken as the skeleton pixel to be detected P0; Connection count calculation: Based on the 8-neighborhood structure of the skeleton pixel P0 to be detected, the connection count is calculated, where the connection count is the number of skeleton pixels in the 8-neighborhood of the skeleton pixel P0 to be detected. Crossover count calculation: Traverse the 8-neighborhood structure of the skeleton pixel P0 to be detected clockwise, count the number of times it changes from a background pixel to a skeleton pixel, and calculate the crossover count. Skeleton local redundancy structure identification; based on the number of connections, the number of intersections, and the distribution of 8-neighbor skeleton pixels, Z-shaped structures, T-shaped structures, and cross-shaped structures are identified; Redundant pixel deletion template construction: 8 redundant pixel deletion templates are set for Z-shaped structures, 4 redundant pixel deletion templates are set for T-shaped structures, and 1 redundant pixel deletion template is set for cross-shaped structures. Template matching: Centered on the skeleton pixel P0 to be detected, the 8-neighborhood structure of the skeleton pixel P0 to be detected is matched item by item with the redundant pixel deletion template; when the position marked "1" in the template corresponds to the skeleton pixel and the position marked "0" corresponds to the background pixel, the current 8-neighborhood structure is considered to meet the template matching condition; the position marked "X" in the template is not included in the constraint. Redundant skeleton point deletion: When the skeleton pixel P0 to be detected satisfies any redundant pixel deletion template, the skeleton pixel P0 to be detected is determined as a redundant skeleton point and deleted, resulting in a single-pixel skeleton image.

[0024] By performing the above operations, selective deletion of local redundant pixels corresponding to the Z-shaped, T-shaped, and cross-shaped structures in the initial crack skeleton image can be achieved, further enabling the crack skeleton to meet the single-pixel width requirement.

[0025] Example 4: This example is based on all the above examples. The directional chain code glitch branch identification step specifically includes: Skeleton branch tracing: In a single-pixel skeleton image, starting from the skeleton intersection or skeleton endpoint, the next skeleton pixel is searched step by step along the skeleton pixel connectivity direction until another skeleton endpoint or another skeleton intersection is reached, thus obtaining the skeleton branch. Directional chain code encoding; 8-directional chain code is used to track and encode the skeleton branches. The 8-directional chain code uses numbers 0 to 7 to represent the 8 connected directions between adjacent skeleton pixels. Even-numbered chain codes correspond to the horizontal or vertical direction, and odd-numbered chain codes correspond to the diagonal direction. Chain code count; count the number of even-numbered and odd-numbered chain codes in the skeleton branch chain code sequence; Calculation of skeleton branch geometric length: The geometric length of the skeleton branch is calculated based on the number of even-numbered and odd-numbered chain codes, using the following formula:

[0026] in, It is the geometric length of the skeleton branches; It is the number of even-numbered chain codes in the skeleton branch chain code sequence; It is the number of odd-numbered chain codes in the skeleton branch chain code sequence; Burr detection threshold calculation: The burr detection threshold is calculated based on the number of refinement iterations recorded in the ZS parallel refinement step. Burr branch identification: The geometric length of the skeleton branch is compared with the burr discrimination threshold. When the geometric length of the skeleton branch is less than the burr discrimination threshold and the corresponding skeleton branch does not belong to the effective crack structure, the corresponding skeleton branch is identified as a burr branch.

[0027] Regarding parameter adjustments: Step 1: Adjust the burr detection threshold; When there are many short spur branches remaining in the single-pixel skeleton image, the spur discrimination threshold is increased so that more short branches are included in the spur branch candidate range. When a valid short branch of a crack is mistakenly deleted, the burr discrimination threshold is lowered, and the judgment is re-evaluated based on the continuity relationship between the skeleton branch and the main crack direction. Step 2: Adjust the chaincode tracing direction; When the skeleton branches become confused in the intersection area, each connecting branch is traced separately starting from the skeleton intersection point to avoid multiple short branches being mistakenly merged into the same skeleton branch. When there are continuous short branches near the skeleton endpoints, a secondary judgment is made by combining the geometric length and branch direction changes of the skeleton branches to avoid effective tail branches being judged as burr branches. Step 3: Refine the iteration count correction; When the binary image of the crack is wide and the number of ZS parallel thinning iterations is large, the burr discrimination threshold increases with the number of thinning iterations. When the binary image of the crack is relatively fine and the number of ZS parallel refinement iterations is relatively small, the burr discrimination threshold decreases as the number of refinement iterations decreases, in order to adapt to the fine crack skeleton structure.

[0028] Example 5: This example is based on all the above examples. The skeleton burr branch deletion step specifically includes: Skeleton intersection recognition: Perform 8-neighbor detection on each skeleton pixel in the single-pixel skeleton image. When the number of skeleton pixels connected in the 8-neighborhood of a skeleton pixel is greater than or equal to 3, the skeleton pixel is recognized as a skeleton intersection. Cross-point branch scanning: Starting from the skeleton cross-point, scan each skeleton branch connected to the same skeleton cross-point to obtain the chain code sequence corresponding to each skeleton branch; Branch length determination: Calculate the geometric length of the skeleton branch based on the chain code sequence corresponding to each skeleton branch, and compare the geometric length of the skeleton branch with the burr discrimination threshold; Burr branch deletion; when the geometric length of the skeleton branch is less than the burr discrimination threshold and the skeleton branch does not belong to the effective crack structure, delete the skeleton pixel corresponding to the skeleton branch. Effective branch protection: When multiple short branches are connected at the same skeleton intersection, the geometric length of each short branch is calculated and burr is identified separately. Then, the branches identified as burrs are deleted to avoid the accidental deletion of effective branches due to newly generated tail branches when scanning from the skeleton endpoint. Generate a deburred skeleton image; after deburring branches, output the deburred skeleton image.

[0029] Regarding parameter adjustments: Step 1: Adjust the scanning order of intersection points; When the skeleton intersection connects multiple short branches, the geometric length of the skeleton branch is calculated independently for each short branch first, and then the burr branch deletion is performed uniformly to avoid changes in the skeleton topology caused by deleting one branch at a time. When there are effective crack bifurcations near the skeleton intersection, increase the protection strength of the effective branches and retain short branches that are continuous with the direction of the main crack and whose length is close to the burr discrimination threshold. Step 2: Effective crack structure assessment and adjustment; When a short branch is located in the actual bifurcation region of a crack, its validity as a crack structure is determined by combining the branch direction, branch width, and continuity of the adjacent crack region. When a short branch is formed only by boundary disturbance and does not connect to an obvious crack area, it is identified as a burr branch and deleted. Step 3: Check and adjust connectivity after deletion; When deleting a burr branch causes the main crack to break, restore the key connected pixels in the deleted branch. If deleting burr branches does not affect the connectivity of the crack backbone, retain the deletion result and output the deburred skeleton image.

[0030] Example 6: This example is based on all the above examples. The principal component growth step at the skeleton endpoints specifically includes: Skeleton endpoint identification: In the deburred skeleton image, perform 8-neighbor detection on each skeleton pixel. When there is only one adjacent skeleton pixel in the 8-neighborhood of a skeleton pixel, the skeleton pixel is identified as a skeleton endpoint. Local analysis sample selection: For the skeleton endpoint P0, samples are continuously selected along the skeleton direction inside the endpoint. One skeleton pixel is used as a local analysis sample; Covariance matrix construction: Based on the coordinates of each skeleton pixel in the local analysis sample, calculate the mean, mean, variance, variance, and covariance in the x-axis, y-axis, and xy directions, and construct the covariance matrix. The calculation formula is as follows:

[0031] in, It is the covariance matrix; It is the variance of the local analysis sample along the x-axis; It is the variance of the local analysis sample along the y-axis; It is the covariance of the local analysis sample in the x-axis and y-axis directions; Candidate principal direction calculation: Perform eigenvalue decomposition on the covariance matrix, and take the eigenvector corresponding to the largest eigenvalue as the candidate principal direction of the skeleton pixel distribution in the endpoint neighborhood; Endpoint actual growth direction correction; calculate the total change of the skeleton endpoint relative to the neighboring skeleton pixels in the x and y directions, and determine whether the candidate main direction is facing the skeleton interior based on the total change; when the candidate main direction is facing the skeleton interior, take the opposite direction of the candidate main direction as the endpoint actual growth direction; when the candidate main direction is not facing the skeleton interior, take the candidate main direction as the endpoint actual growth direction. Discrete pixel position mapping: Map the actual growth direction of the endpoint to the discrete pixel position in the 8-neighborhood of the skeleton endpoint to determine candidate growth points; Endpoint iterative growth; when the candidate growth point still belongs to the crack region, the candidate growth point is updated to a new skeleton endpoint, and the local analysis sample selection, candidate main direction calculation, endpoint actual growth direction correction and discrete pixel position mapping are repeated; when the candidate growth point no longer belongs to the crack region, the growth of the current skeleton endpoint is stopped. The final crack skeleton line is output; after iterative growth of all skeleton endpoints is completed, the final crack skeleton line is output.

[0032] Regarding parameter adjustments: Step 1: Adjusting the sample size for local analysis; When the skeleton trend stabilizes near the endpoints, increase the number of local analysis samples to make the principal component analysis results smoother. When there are sharp turns or local bifurcations near the skeleton endpoints, reduce the number of local analysis samples to make the actual growth direction of the endpoints closer to the local trend at the ends; Step 2: Adjusting the growth direction at the endpoints; When the actual growth direction of the endpoint is towards the inside of the skeleton, its opposite direction is taken as the outside direction of the crack. When the crack tip shows a bending tendency, the actual growth direction of the tip is corrected based on the distribution of crack areas in the vicinity of the tip to prevent the tip from growing off the crack area. Step 3: Adjusting the endpoint iteration stopping condition; Stop endpoint growth when the candidate growth point does not belong to the crack region; When the endpoint grows into the background area or a non-crack texture area, it regresses to the previous valid growth point. When the endpoint growth length exceeds the endpoint growth length threshold, stop the growth of the current skeleton endpoint to avoid over-extension.

[0033] Example 7: This example is based on all the above examples. The final crack skeleton line output and experimental results are specifically described as follows: The final crack skeleton line is output; the skeleton line obtained by the principal component growth step at the skeleton endpoints is used as the final crack skeleton line. Overlay display of skeleton results: The final crack skeleton lines are overlaid onto the crack image or the binary crack image to generate a visual result of the crack skeleton lines; Crack parameter calculation; calculate crack length, crack width, crack area, and topological morphology parameters based on the final crack skeleton line; Method comparison: The skeleton extraction of the same crack binary image was performed using the median transformation method, the classic ZS thinning algorithm, and the method of this invention, respectively. Effect evaluation: When using the central axis transformation method, burrs are easily generated at complex boundaries and the ends shorten. When using the classic ZS thinning algorithm, the crack topology can be well preserved, but there are still non-single-pixel, burr and end shrinkage phenomena. When using the method of this invention, redundant skeleton points are eliminated by redundant pixel deletion template, burr branches are identified and deleted by directional chain code, and skeleton endpoint growth is achieved by principal component analysis, resulting in a more single-pixel, continuous, smooth and complete final crack skeleton line.

[0034] By performing the above operations, the present invention can improve the single-pixel quality, continuity, smoothness, and end integrity of the crack skeleton line while maintaining the overall stability of the crack topology, thus providing a reliable basis for calculating crack width, length, area, and morphological characteristic parameters.

Claims

1. A method for extracting crack skeleton lines based on an improved ZS thinning algorithm, characterized in that, The steps include the following: Steps for obtaining a binary image of a crack: Obtain the image of the crack to be processed, and segment the crack region in the image of the crack to be processed to obtain a binary image of the crack; ZS Parallel Refinement Steps: Receive the binary image of the crack, use the ZS parallel refinement algorithm to iteratively refine the target region of the crack to obtain the initial crack skeleton image, and record the number of refinement iterations; The steps for identifying local redundancy structures in the skeleton are as follows: Receive the initial crack skeleton image, calculate the number of connections and crosses of the skeleton pixels to be detected based on the 8-neighborhood structure of the skeleton pixels in the initial crack skeleton image, and identify the local redundancy structure of the skeleton based on the number of connections, crosses and the distribution of the skeleton pixels' neighborhood. Redundant pixel deletion template matching steps: Receive the local redundant structure of the skeleton, call the redundant pixel deletion template to perform template matching on the skeleton pixels to be detected, determine the skeleton pixels that satisfy any redundant pixel deletion template as redundant skeleton points and delete them to obtain a single-pixel skeleton image. The steps for identifying burr branches using directional chain code are as follows: Receive a single-pixel skeleton image, track and encode the skeleton branches in the single-pixel skeleton image based on 8-directional chain code, calculate the geometric length of the skeleton branches, determine the burr discrimination threshold based on the number of thinning iterations, and identify the burr branches based on the geometric length of the skeleton branches and the burr discrimination threshold. Skeleton burr branch deletion steps: Starting from the skeleton intersection point, scan and identify each skeleton branch connected to the same skeleton intersection point, delete skeleton branches whose geometric length is less than the burr discrimination threshold and do not belong to the effective crack structure, and obtain the deburred skeleton image. Principal component growth steps at skeleton endpoints: Receive the deburred skeleton image. For the skeleton endpoints in the deburred skeleton image, use principal component analysis to estimate the local principal direction of the skeleton pixels in the neighboring area of ​​the endpoint. Combine the spatial distribution relationship between the skeleton endpoint and its neighboring skeleton pixels to correct the actual growth direction of the endpoint. Map the actual growth direction of the endpoint to the discrete pixel position in the 8-neighborhood of the skeleton endpoint, and iteratively grow along the outer direction of the crack until the candidate growth point no longer belongs to the crack region. Output the final crack skeleton line.

2. The crack skeleton line extraction method based on the improved ZS thinning algorithm according to claim 1, characterized in that: The ZS parallel thinning step alternately executes two sub-processes in each iteration. In each sub-process, target pixels that meet the deletion conditions are uniformly marked and then centrally deleted after the current round of scanning, until there are no new deletable pixels in the crack binary image.

3. The crack skeleton line extraction method based on the improved ZS thinning algorithm according to claim 2, characterized in that: The 8-neighborhood structure is the 8 neighboring pixels in a 3×3 window centered on the skeleton pixel to be detected, excluding the skeleton pixel itself; the connection number is the number of skeleton pixels in the 8-neighborhood of the skeleton pixel to be detected; the crossover number is the number of times a background pixel is transformed into a skeleton pixel when traversing the 8-neighborhood structure of the skeleton pixel to be detected clockwise.

4. The crack skeleton line extraction method based on the improved ZS thinning algorithm according to claim 3, characterized in that: The skeleton local redundancy structure includes a Z-shaped structure, a T-shaped structure, and a cross-shaped structure; the redundant pixel deletion template includes a redundant pixel deletion template set for the Z-shaped structure, a redundant pixel deletion template set for the T-shaped structure, and a redundant pixel deletion template set for the cross-shaped structure.

5. The crack skeleton line extraction method based on the improved ZS thinning algorithm according to claim 4, characterized in that: The redundant pixel deletion template matching step takes the skeleton pixel to be detected as the center and matches the 8-neighborhood structure of the skeleton pixel to be detected with the redundant pixel deletion template item by item; when the position marked "1" in the template corresponds to the skeleton pixel and the position marked "0" corresponds to the background pixel, it is determined that the current 8-neighborhood structure meets the template matching condition; the position marked "X" in the template does not participate in the constraint.

6. The crack skeleton line extraction method based on the improved ZS thinning algorithm according to claim 5, characterized in that: The directional chain code burr branch identification step uses 8-directional chain codes to represent the 8 connected directions between adjacent skeleton pixels, counts the number of even-numbered chain codes and odd-numbered chain codes in the skeleton branch chain code sequence, and calculates the geometric length of the skeleton branch based on the number of even-numbered chain codes and odd-numbered chain codes.

7. The crack skeleton line extraction method based on the improved ZS thinning algorithm according to claim 6, characterized in that: The directional chain code burr branch identification step calculates the burr discrimination threshold based on the number of refinement iterations recorded in the ZS parallel refinement step. When the geometric length of the skeleton branch is less than the burr discrimination threshold and the corresponding skeleton branch does not belong to the effective crack structure, the corresponding skeleton branch is identified as a burr branch.

8. A method for extracting crack skeleton lines based on an improved ZS thinning algorithm according to claim 7, characterized in that: The skeleton burr branch deletion step performs 8-neighbor detection on each skeleton pixel in the single-pixel skeleton image. When the number of skeleton pixels connected in the 8-neighborhood of a skeleton pixel is greater than or equal to 3, the skeleton pixel is identified as a skeleton intersection point. Starting from the skeleton intersection point, each skeleton branch is scanned separately, and burr branches are deleted according to the geometric length of the skeleton branch and the burr discrimination threshold to obtain a burr-free skeleton image.

9. A method for extracting crack skeleton lines based on an improved ZS thinning algorithm according to claim 8, characterized in that: The principal component growth step of the skeleton endpoints identifies the skeleton endpoints in the deburred skeleton image, continuously selects multiple skeleton pixels as local analysis samples along the skeleton direction inside the skeleton endpoints, constructs a covariance matrix based on the local analysis samples, performs eigenvalue decomposition on the covariance matrix, and takes the eigenvector corresponding to the largest eigenvalue as the candidate principal direction of the skeleton pixel distribution in the endpoint neighborhood. The total change of the skeleton endpoint relative to the neighboring skeleton pixels in the x and y directions is calculated. Based on the total change, it is determined whether the candidate main direction is facing the inside of the skeleton, and the actual growth direction of the endpoint is corrected.

10. A method for extracting crack skeleton lines based on an improved ZS thinning algorithm according to claim 9, characterized in that: The principal component growth step of the skeleton endpoint maps the actual growth direction of the endpoint to the discrete pixel position in the 8-neighborhood of the skeleton endpoint to determine the candidate growth point; when the candidate growth point still belongs to the crack region, the candidate growth point is updated to a new skeleton endpoint, and the local analysis sample selection, candidate principal direction calculation, endpoint actual growth direction correction and discrete pixel position mapping are repeated. When a candidate growth point no longer belongs to the crack region, stop the growth of the current skeleton endpoint and output the final crack skeleton line.