Polygon chain-type skeleton extraction algorithm
Through the polygon chain bone extraction algorithm, the objective function is optimized by gradient flow and bone chain, and the problems of harsh applicable conditions and complex algorithms in the existing methods are solved, and efficient identification and accurate extraction of polygonal lattice lines are achieved.
Patent Information
- Application Number
- PCT/CN2023/116705
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Filing Date
- 2023-09-04
- Publication Date
- 2025-03-13
AI Technical Summary
The existing polygonal lattice extraction method has problems such as harsh applicable conditions, complex algorithms and unequal spacing of lattice anchor points, which affects the accuracy of defect identification.
The polygon chain bone extraction algorithm is used to obtain gradient flow and initialize bone chains through gradient flow, and the objective function is constructed to optimize the gradient flow direction and isometricity, and the lattice lines are iteratively extracted.
The lattice line recognition of any shape band polygon is realized, which avoids the dependence on prior knowledge, is suitable for complex defect recognition scenarios, and improves the accuracy of defect recognition.
Smart Images

Figure CN2023116705_13032025_PF_FP_ABST
Abstract
Description
A polygonal chain skeleton extraction algorithm Technical Field
[0001] The present invention relates to the technical field of image detection, and in particular to a polygonal chain skeleton extraction algorithm. Background Art
[0002] During defect image quality inspection, precise polygonal recognition of defects is often required. After identifying polygons (such as the polygons in the white area in Figure 1), it is often necessary to extract the skeleton lines of the strip polygons (such as the lines in the white area in Figure 1) to calculate their curvature, width, direction, and other information to assist in defect classification. The accuracy of skeleton line position recognition greatly affects the accuracy of defect identification.
[0003] Existing polygon skeleton line extraction methods can be roughly divided into two types: (1) relying on the prior knowledge of the width of the strip polygon, finding anchor points by inscribed circles, connecting the centers of multiple inscribed circles with the same radius to form skeleton lines. (2) using graphics operations, continuously corroding the polygon into a chain or quasi-chain shape, finding the endpoints of the single chain in the connected area, connecting all the single chain endpoints, and calculating its skeleton line. However, these existing methods still have some disadvantages: for method (1), since it is necessary to know the width range of the strip polygon in advance, its application conditions are relatively harsh. Therefore, when the width of the polygon varies greatly, its algorithm will fail at positions outside the preset radius, and the distance between the anchor points of the skeleton line is not equidistant, which will cause directional calculation deviation in the defect morphology determination. For method (2), it needs to perform multiple graphics operations on the polygon, and the iterative termination condition is whether a single pixel chain is formed. Its calculation is relatively complex and the algorithm implementation is relatively lengthy. At the same time, it still has the problem that the distance between the anchor points of the skeleton line is not equidistant.
[0004] Summary of the Invention
[0005] The present invention is made to solve the above problems, and its purpose is to provide an edge chain skeleton extraction algorithm.
[0006] In order to achieve the above-mentioned purpose, the present invention adopts the following technical solutions:
[0007] The present invention provides a polygon chain skeleton extraction algorithm, which is characterized by comprising the following steps:
[0008] Step 1: Input the polygon image to be processed and obtain the gradient flow of the polygon outline in the image;
[0009] Step 2: After generating the gradient flow, initialize the skeleton chain;
[0010] Step 3: Construct the objective function based on the gradient flow and skeleton chain;
[0011] Step 4: Iterate the constructed objective function, and when the termination condition is reached, extract the skeleton line.
[0012] Furthermore, the polygonal chain skeleton extraction algorithm provided by the present invention may also have the following features: wherein, the gradient flow obtaining process in step 1 includes: 1) using the expansion-erosion algorithm to calculate the stacking information of each point; 2) performing gradient flow calculation on the stacking information, and obtaining the full-field gradient flow direction through Laplace operation.
[0013] Furthermore, the polygonal chain skeleton extraction algorithm provided by the present invention may also have the following feature: when the skeleton chain is initialized in step 2, a series of tangent circles are generated as iterative initial values.
[0014] The objective function in step 3 is as follows: I = αG + βC (1)
[0015] In formulas (1), (2), and (3), I is the objective function; α and β are scale coefficients; G is the sum of the moduli of the gradient direction of each point; C is the sum of the moduli of the distances between the anchor points of the skeleton chain; x i is the horizontal coordinate of point i; y i is the vertical coordinate of point i; x i+1 is the horizontal coordinate of point i+1; y i+1 is the vertical coordinate of point i+1; g x (x i, y i ) is the image at (x i, y i ) along the x direction; g y (x i, y i ) is the image at (x i, y i ) point along the y direction; chain is the set of all anchor points of the skeleton chain; chain-1 is the set of all anchor points of the skeleton chain. Since the distance between two adjacent anchor points is calculated, the number of calculations is 1 less than the total number of anchor points; R is the isometric radius set during the initialization process.
[0016] Furthermore, the polygonal chain skeleton extraction algorithm provided by the present invention may also have the following features:
[0017] In step 2, the tangent circle is not used as the bone chain during the bone chain initialization process.
[0018] The objective function in step 3 is as follows: I = αG + βC (1)
[0019] In formulas (1)(2)(4)(5), I is the objective function; α and β are scale coefficients; G is the sum of the moduli of the gradient direction of each point; C is the sum of the moduli of the distances between the anchor points of the skeleton chain; x i is the horizontal coordinate of point i; y i is the vertical coordinate of point i; x i+1 is the horizontal coordinate of point i+1; y i+1 is the vertical coordinate of point i+1; g x (x i, y i ) is the image at (x i, y i ) along the x direction; g y (x i, y i ) is the image at (x i, y i ) point along the y direction; chain is the set of all anchor points of the skeleton chain; chain-1 is the set of all anchor points of the skeleton chain. Since the distance between two adjacent anchor points is calculated, the number of calculations is 1 less than the total number of anchor points; R avg is the average distance between anchor points in the skeleton chain; n is the number of all anchor points in the skeleton chain.
[0020] Furthermore, the polygonal chain skeleton extraction algorithm provided by the present invention may also have the following features: wherein, the iterative process includes two steps: gradient update and isometry update: during the gradient update process, each anchor point moves toward the direction of maximum gradient; during the isometry update process, each anchor point moves toward the direction of optimal isometry.
[0021] Furthermore, the polygonal chain skeleton extraction algorithm provided by the present invention may also have the following characteristics: wherein, the termination condition of the iteration is: the change of the objective function before and after one iteration is less than a fixed value, that is, abs(I(n)-I(n+1))<∈ (6)
[0022] Furthermore, the polygonal chain skeleton extraction algorithm provided by the present invention may also have the following feature: wherein the sum of α and β in formula (1) always remains equal to 1.
[0023] Furthermore, the polygon chain skeleton extraction algorithm provided by the present invention may also have the following feature: wherein the polygon image to be processed input in step 1 is a strip polygon image.
[0024] Beneficial effects of the present invention:
[0025] The polygon chain skeleton extraction algorithm of the present invention can realize skeleton line recognition for strip polygons of any shape. The extraction algorithm of the present invention establishes a gradient flow for the defect contour in the full-field image and initializes the equidistant chain at the same time. The constructed optimization function consists of two parts, one is the maximum direction of the gradient flow, and the other is the equidistant between each point. The two parts jointly limit the iteration direction. Since the constructed optimization function is universal, the elementary iteration method or the Newton iteration method can be used to obtain the optimal solution. The algorithm of the present invention does not rely on prior knowledge, but only needs to construct the function step by step for iteration, which is suitable for defect recognition scenarios with complex situations. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] FIG1 is an example diagram of a polygonal skeleton line;
[0027] FIG2 is a flow chart of a polygonal chain skeleton extraction algorithm according to the present invention;
[0028] FIG2 is a schematic diagram of a polygonal contour before and after gradient flow is obtained according to an embodiment of the present invention, wherein (a) is a polygonal image to be processed, and (b) is an image after processing;
[0029] FIG4 is a schematic diagram showing that initialization is to generate a series of tangent circles in an embodiment of the present invention;
[0030] FIG5 is a schematic diagram of generating several plot points in a graph after initialization in an embodiment of the present invention;
[0031] FIG6 is a schematic diagram of each anchor point moving toward the direction of maximum gradient during the gradient update process in an embodiment of the present invention;
[0032] FIG7 is a schematic diagram of each anchor point moving toward the optimal direction of isometry during the isometry update process in an embodiment of the present invention;
[0033] FIG8 is a schematic diagram of an iterative optimization process in an embodiment of the present invention. DETAILED DESCRIPTION
[0034] In order to make the technical means, creative features, objectives and effects achieved by the present invention easier to understand, the following embodiments are combined with the accompanying drawings to specifically illustrate the technical solutions of the present invention.
[0035] Referring to FIG1 , an embodiment of the present invention provides a polygon chain skeleton extraction algorithm, comprising the following steps:
[0036] Step 1: Input the polygon image to be processed and obtain the gradient flow of the polygon outline in the image.
[0037] The input polygonal image to be processed is an image of a strip polygon of any shape.
[0038] The process of obtaining the gradient flow includes:
[0039] 1) The dilation-erosion algorithm is used to calculate the stacking information of each point. The image obtained after processing is shown in Figure 3(b).
[0040] 2) Perform gradient flow calculation on the stacked information and obtain the full-field gradient flow direction through Laplace operation.
[0041] The cascade information is incremental. At points not reaching the center of the strip polygon, the maximum gradient is directed toward the center of the image. At the cascade maximum, near the image center, the gradient direction may change, but the gradient's modulus (norm) reaches a minimum.
[0042] Step 2: After generating the gradient flow, initialize the skeleton chain.
[0043] The goal of this algorithm for the skeleton chain is to output a set of equidistant skeleton chains.
[0044] In this step, when the skeleton chain is initialized, referring to Figure 4, the preferred method is to generate a series of tangent circles as the initial values for iteration. In the skeleton chain initialization process of this step, tangent circles may not be used as the skeleton chain.
[0045] Step 3: Based on the gradient flow and skeleton chain, construct the objective function.
[0046] The objective function is as follows: I = αG + βC (1)
[0047] In formula (1), I is the objective function; α and β are proportional coefficients, which can be set according to the actual situation in the actual recognition work. It is preferred to set the sum of α and β to always be equal to 1; G is the sum of the moduli of the gradient direction of each point; C is the sum of the moduli of the distances between the anchor points of the skeleton chain.
[0048] In the objective function, the first component, G, is the sum of the moduli of the gradient directions at each point. It reaches its minimum at the point of maximum stacking, i.e., the center of the polygon. The second component, C, is the sum of the moduli of the distances between the anchor points of the skeleton chain. It reaches its minimum value of 0 at equal distances, indicating optimal chain isometry. As the optimization function, I, iteratively approaches its minimum, the gradient flow provides an external force in the chain's direction of motion, while isometry provides an internal force in the chain's geometry. These internal and external forces work together to find the optimal solution.
[0049] The function of G is as follows:
[0050] In formula (2), x i is the horizontal coordinate of point i; y i is the vertical coordinate of point i; g x (x i, y i ) is the image at (x i, yi ) along the x direction; g y (x i, y i ) is the image at (x i, y i ) point along the y direction; chain is the set of all anchor points in the bone chain.
[0051] C functions are divided into two cases:
[0052] 1) When generating a series of tangent circles during initialization, the calculation of C uses the set equidistant radius R. Using an initial fixed value for R is beneficial to the convergence of the iteration. The calculation formula of C is as follows:
[0053] In formula (3), x i is the horizontal coordinate of point i; y i is the vertical coordinate of point i; x i+1 is the horizontal coordinate of point i+1; y i+1 is the vertical coordinate of point i+1; chain-1 is the set of all anchor points in the skeleton chain. Since the distance between two adjacent anchor points is calculated, the number of calculations is 1 less than the total number of anchor points; R is the isometric radius set during the initialization process.
[0054] 2) When isometric calculation is performed without using R value, the calculation formula of C is as follows:
[0055] In formulas (4) and (5), x i is the horizontal coordinate of point i; y i is the vertical coordinate of point i; x i+1 is the horizontal coordinate of point i+1; y i+1 is the vertical coordinate of point i+1; chain-1 is the set of all anchor points in the skeleton chain. Since the distance between two adjacent anchor points is calculated, the number of calculated points is 1 less than the total number of anchor points; R avg is the average distance between anchor points in the skeleton chain; n is the number of all anchor points in the skeleton chain.
[0056] Step 4: Iterate the constructed objective function, and when the termination condition is reached, extract the skeleton line.
[0057] The termination condition of the iteration is: the change of the objective function before and after one iteration is less than a fixed value, that is: abs(I(n)-I(n+1))<∈ (6)
[0058] When the iteration termination condition is reached, the bone chain changes little after each iteration and can be considered stable (the specific change is considered stable, and the value can be pre-defined manually). If the result changes greatly, the change ratio can be used as the termination condition, such as 0.5%.
[0059] The iterative process includes two steps: gradient update and isometric update:
[0060] For ease of description, we use a non-isometric skeleton chain as the initial value to describe the algorithm iteration process. The actual iteration process is completed by the optimization function. See Figure 5, where several anchor points are generated.
[0061] During the gradient update process, each anchor point moves in the direction of the maximum gradient. See Figure 6, where the arrow indicates the direction in which the anchor point moves along the gradient.
[0062] During the isometry update process, each anchor point moves toward the optimal isometry direction. Refer to Figure 7 , where the arrow indicates the direction in which the anchor point moves along the optimal isometry.
[0063] Through multiple iterations, the optimal state is eventually reached. In the early stages of the iteration, isometry can be prioritized so that the skeleton lines are "effectively spread out" at various locations of the defect. The proportional relationship between α and β is then gradually adjusted, giving the gradient more weight so that the skeleton chain iterates along the gradient. The sum of α and β always remains equal to 1. This is to normalize the relationship between the gradient flow and isometry. Although it has no meaning for the rate of change of the objective function, it has dimensionally meaningful meaning for the termination condition of the iteration. It can avoid the algorithm results from constantly oscillating around the optimal point and improve the algorithm's efficiency. Refer to Figure 8, which illustrates an iterative optimization process. It can be seen that the initialized skeleton chain gradually approaches the optimal position.
[0064] The above examples demonstrate that the polygon chain skeleton extraction algorithm of the present invention can achieve skeleton line recognition for strip polygons. Furthermore, because the constructed objective function is universal and can be optimized using elementary iteration or Newton's method, the algorithm of the present invention has the significant advantage of not relying on prior knowledge. It only requires iteration according to the step-by-step construction method, making it applicable to complex defect recognition scenarios.
[0065] The above embodiments are only preferred embodiments of the present invention and are not intended to limit the scope of protection of the present invention. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present invention are included in the scope of protection of the present invention.
Claims
1. A polygonal chain skeleton extraction algorithm, characterized in that: The following steps are involved: Step 1: Input the polygon image to be processed and obtain the gradient flow of the polygon contour in the image; Step 2: After generating the gradient flow, initialize the skeleton chain; Step 3, construct the objective function based on the gradient flow and skeleton chain; Step 4, iterate the constructed objective function, and when the termination condition is reached, extract the skeleton line.
2. The polygonal chain skeleton extraction algorithm as claimed in claim 1, Features: The process of obtaining the gradient flow in step 1 includes: 1) Use the expansion-erosion algorithm to calculate the stacking information of each point; 2) Perform gradient flow calculation on the stacked information and obtain the full-field gradient flow direction through Laplace operation.
3. The polygonal chain skeleton extraction algorithm as claimed in claim 1, characterized in that: in, In step 2, when the bone chain is initialized, a series of tangent circles are generated as the initial values for iteration.
4. The polygonal chain skeleton extraction algorithm as claimed in claim 3, characterized in that: in, The objective function in step 3 is as follows: I=αG+βC (1) In formulas (1), (2), and (3), I is the objective function; α and β are proportional coefficients; G is the sum of the moduli of the gradient direction of each point; C is the sum of the moduli of the distances between the anchor points of the skeleton chain; x i is the horizontal coordinate of point i; y i is the ordinate of point i; x i+1 is the horizontal coordinate of point i+1; y i+1 is the ordinate of point i+1; g x (x i ,y i ) is the image at (x i ,y i ) along the x direction; g y (x i ,y i ) is the image at (x i ,y i ) along the y direction; chain is the set of all anchor points of the skeleton chain; chain-1 is the set of all anchor points of the skeleton chain. Since the distance between two adjacent anchor points is calculated, the number of calculations is 1 less than the total number of anchor points; R is the isometric radius set during the initialization process.
5. The polygonal chain skeleton extraction algorithm as claimed in claim 1, characterized in that: in, In step 2, the tangent circle is not used as the bone chain during the bone chain initialization process.
6. The polygonal chain skeleton extraction algorithm as claimed in claim 5, characterized in that: in, The objective function in step 3 is as follows: I=αG+βC (1) In formulas (1), (2), (4), and (5), I is the objective function; α and β are proportional coefficients; G is the sum of the moduli of the gradient direction of each point; C is the sum of the moduli of the distances between the anchor points of the skeleton chain; x i is the horizontal coordinate of point i; y i is the ordinate of point i; x i+1 is the horizontal coordinate of point i+1; y i+1 is the ordinate of point i+1; g x (x i ,y i ) is the image at (x i ,y i ) along the x direction; g y (x i ,y i ) is the image at (x i ,y i ) along the y direction; chain is the set of all anchor points of the skeleton chain; chain-1 is the set of all anchor points of the skeleton chain. Since the distance between two adjacent anchor points is calculated, the number of calculations is 1 less than the total number of anchor points; R avg is the average distance between anchor points in the skeleton chain; n is the number of all anchor points in the skeleton chain.
7. The polygonal chain skeleton extraction algorithm according to claim 4 or 6, characterized in that: in, The iterative process includes two steps: gradient update and isometry update: During the gradient update process, each anchor point moves in the direction of maximum gradient. During the isometry updating process, each anchor point moves toward the direction of optimal isometry.
8. The polygonal chain skeleton extraction algorithm according to claim 4 or 6, characterized in that: in, The termination condition of the iteration is: the change of the objective function before and after one iteration is less than a fixed value, that is: abs(I(n)-I(n+1))<∈ (6) 9. The polygonal chain skeleton extraction algorithm according to claim 4 or 6, characterized in that: in, The sum of α and β in formula (1) always remains equal to 1.
10. The polygonal chain skeleton extraction algorithm according to claim 1, characterized in that: in, The polygonal image to be processed input in step 1 is a strip polygonal image.
Citation Information
Patent Citations
Semi-automatic medical image segmentation method based on shape constraint of point distance function
CN107240114A
A method for automatically segmenting left ventricular inner and outer membranes
CN109272512A
Blood vessel structure image plane atlas construction method
CN110689080A
Method for extracting curve skeleton line of three-dimensional tubular body model based on hierarchical diagram
CN115830211A