Global optimization defect skeleton extraction system and method based on energy function
Through the multi-feature energy function and maximum spanning tree algorithm, the problems of noise interference and topological inconsistency in skeleton extraction are solved, and high-precision and stable defect skeleton extraction is achieved, which effectively removes pseudo branches and maintains trunk connectivity and topological consistency.
Patent Information
- Application Number
- CN202510961399.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-14
- Publication Date
- 2025-09-26
- Estimated Expiration
- 2045-07-14
AI Technical Summary
Existing skeleton extraction algorithms are susceptible to noise interference, generate pseudo branches, have inconsistent topological structures, lack a globally optimal pruning strategy, and find it difficult to balance backbone preservation and noise removal.
By adopting multi-feature energy functions and building a weighted undirected graph model, the maximum spanning tree algorithm is used to achieve global optimal pruning, retain the main trunk direction of the defective area, and effectively remove pseudo branches.
The skeleton extraction accuracy is significantly improved, the noise suppression capability is outstanding, the skeleton false branching rate is reduced by 50%, the topological structure is closer to the real form, the main trunk features of the defect are fully preserved, and the skeleton connectivity and topological consistency are ensured.
Smart Images

Figure CN120472179B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image processing and pattern recognition, and in particular to a skeleton extraction method and system based on an energy function and a maximum spanning tree, which is suitable for skeleton extraction and optimization of defective images. Background Art
[0002] Skeleton extraction is a key technology in image processing and is widely used in fields such as defect detection and biomedical image analysis. Existing skeletonization algorithms generally have the following problems:
[0003] Noise branch problem: It is easily affected by image noise, generating a large number of pseudo branches and affecting the accuracy of the skeleton.
[0004] Topological inconsistency: Different processing procedures or parameter settings may lead to differences in the skeleton topology and lack of stability.
[0005] Limitations of pruning strategies: Traditional pruning methods are mostly based on local features (such as branch length and curvature), lack a global optimal strategy, and have difficulty balancing trunk preservation and noise removal. Summary of the Invention
[0006] To address the shortcomings of existing technologies, this invention aims to provide a highly robust skeleton extraction solution. Specifically, it proposes a multi-feature energy function to measure the global importance of skeleton branches. It also constructs a weighted undirected graph model and uses the Maximum Spanning Tree (MST) algorithm to achieve globally optimal pruning. This approach preserves the main trunk orientation of defective regions, effectively removes false branches, and improves the accuracy and stability of skeleton extraction.
[0007] The present invention proposes a global optimization defect skeleton extraction system based on an energy function, which includes a refinement module, a node and branch extraction module, an energy calculation module, a graph construction and maximum spanning tree pruning module, and a skeleton reconstruction module: the refinement module is used to first perform binary segmentation on the defect image I to be processed to obtain a binary region R, and apply a morphological refinement algorithm to the binary region R to generate a preliminary skeleton S0; the node and branch extraction module is used to calculate the 8-neighborhood connectivity deg(p) of each pixel on the skeleton S0 to obtain each branch b and a branch set B; the energy calculation module calculates the normalized features for each branch b; the graph construction and maximum spanning tree pruning module obtains a global optimal skeleton structure based on the above-mentioned normalized features; the skeleton reconstruction module takes corresponding branch pixels on the skeleton S0 according to the edges retained in the global optimal skeleton structure to generate a final pruned skeleton S .
[0008] As a further solution of the present invention, the 8-neighborhood connectivity deg(p) is:
[0009] Extract all pixels with deg(p)≠2 as the node set V; start from each endpoint (deg=1) and traverse depth-first along S0 until the next node is encountered, record the path as a branch b∈B, and obtain the branch set B.
[0010] As a further solution of the present invention, the normalized features are specifically calculated as follows: the following normalized features are calculated for each branch b:
[0011] E_L(b)=|b| / L_max;
[0012] E_c(b)=1-(C_b / C_max), ;
[0013] E_d(b)=1-((d1–1+d2–1) / d_max);
[0014] ; where |b| is the branch length of branch b; L_max is the maximum |b|; is the angle between two adjacent vectors on the path; C_b is the cumulative curvature of branch b; C_max is the maximum C_b; d1, d2 are the degrees of the nodes at both ends of each branch b; d_max is the maximum degree of the nodes at both ends; D(p) is the value of pixel p on the distance transform map; D_max is the maximum D(p), E_L emphasizes branch length and retains long branches; E_c penalizes high curvature and removes noisy broken lines; E_d penalizes branches extending from high-order bifurcation points; E_r strengthens stable branches in the morphological center area,
[0015] The weighted energy is comprehensively formed: E(b)=α·E_L+β·E_c+γ·E_d+δ·E_r, where α…δ are weight coefficients.
[0016] As a further solution of the present invention, the graph construction and maximum spanning tree pruning module is specifically used to construct the node set V and the branch set B into a weighted undirected graph G=(V,E), each edge e(b)∈E connects the two end nodes of each branch b, with a weight of E(b), and runs the maximum spanning tree algorithm on the weighted undirected graph G to obtain a subgraph T , which is the global optimal skeleton structure.
[0017] The present invention also provides a global optimization defect skeleton extraction method based on an energy function, comprising the following steps:
[0018] Step S1: image input, binary segmentation of the input image, and generation of a preliminary skeleton;
[0019] Step S2: extract nodes and branches from the skeleton;
[0020] Step S3: constructing the extracted branch energy function;
[0021] Step S4: Obtain the graph model and global optimal pruning according to the branch energy function, and reconstruct and output the skeleton.
[0022] The present invention has the following beneficial effects: the skeleton extraction accuracy of the present invention is significantly improved, the noise suppression ability is outstanding, and the importance of branches is globally quantified through a multi-feature energy function, which can accurately identify and remove noise branches, with a noise removal rate of ≥70%. The skeleton misbranching rate is reduced by about 50% compared with traditional methods, ensuring that the topological structure of the defective skeleton is closer to the true form; the defect trunk features are completely retained, and the length features and distance transformation features give priority to retaining long branches and the trunks in the morphological center area to avoid trunk breaks caused by local pruning. The present invention can completely retain the trunk direction of through-going cracks, while traditional methods may cause crack skeletons to be disconnected due to the mistaken deletion of key branches; based on the global decision of the maximum spanning tree, traditional pruning algorithms (such as length pruning based on local thresholds) only consider local branch features and are prone to "short-sighted" decisions (such as mistakenly deleting short branches connecting important trunks). The present invention selects the branch combination with the optimal energy from a global perspective by constructing a weighted undirected graph and solving the maximum spanning tree, ensuring skeleton connectivity and topological consistency. For example, in leaf vein extraction, traditional methods may delete a certain section of lateral vein due to its shortness, resulting in a disconnection between the main vein and the lateral vein. The present invention retains the lateral vein through global energy evaluation to maintain the integrity of the leaf vein network. The global metric of multi-feature fusion, the energy function integrates length, curvature, node degree and distance transformation features to form a multi-dimensional evaluation system. Compared with a single feature (such as only considering length), it can more comprehensively characterize the importance of branches. For example, for branches that are "short but straight and located in the central area" (which may be important sub-trunks), the present invention assigns them higher energy values through EC and ER features to avoid accidental deletion. Through the core technology of "multi-feature energy measurement + global optimal pruning", the present invention achieves comprehensive optimization of traditional skeleton extraction algorithms in terms of accuracy, efficiency, adaptability and other dimensions.
[0023] In order to more clearly illustrate the structural features and effects of the present invention, the present invention is described in detail below with reference to the accompanying drawings and specific embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] Figure 1 It is the overall flow chart of the present invention;
[0025] Figure 2 This is a schematic diagram of system skeleton extraction optimization mentioned in the present invention;
[0026] Figure 3 This is a comparison chart of the skeleton extraction effects mentioned in the present invention. DETAILED DESCRIPTION
[0027] The present invention will be further described below with reference to the accompanying drawings and related knowledge, and described clearly and completely. Obviously, the described applications are only part of the embodiments of the present invention, rather than all of the embodiments.
[0028] Example 1, reference Figure 1-Figure 3 As shown in the figure, the global optimization defect skeleton extraction system based on the energy function includes: refinement module: accurate conversion from image to preliminary skeleton, specifically binary segmentation: Otsu adaptive threshold algorithm is used to binarize the defect image I, the optimal segmentation threshold is automatically calculated, and the image is converted into a foreground target area R (pixel value is 1) and a background area (pixel value is 0), effectively suppressing interference such as uneven illumination.
[0029] Morphological thinning: The Zhang–Suen iterative thinning algorithm is applied to the binary region R. Through the 8-neighborhood pixel connectivity judgment rule, edge pixels are gradually removed until the skeleton converges to a single pixel width, generating a preliminary skeleton S0, ensuring that the skeleton maintains the topological structure of the original defect.
[0030] Node and branch extraction module: 8 Neighborhood connectivity calculation: .
[0031] Node and branch extraction rules: Extract all pixels with deg(p)≠2 as the node set V; start from each endpoint (deg=1) and perform depth-first traversal along S0 until the next node is encountered, record the path as a branch b∈B, and obtain the branch set B.
[0032] Specifically, starting from each endpoint, perform depth-first traversal along the preliminary skeleton S0 until the next node is encountered, record the traversal path as a branch b, and finally form a branch set B to achieve structured decomposition of the skeleton topology.
[0033] Energy calculation module: multi-dimensional branch importance quantification
[0034] Normalized feature calculation system: Calculate the four core features for each branch b and eliminate dimensional differences through normalization:
[0035] Length characteristic E_L(b)=|b| / L_max;
[0036] Where |b| is the number of branch pixels, Lmax is the maximum length of all branches, and this feature prioritizes retaining long branches (such as defect trunks).
[0037] Curvature characteristic E_c(b)=1-(C_b / C_max), ;in is the angle between two adjacent vector segments on the path; C_b is the cumulative curvature of branch b; C_max is the maximum C_b, which penalizes branches with high curvature (such as broken lines caused by noise).
[0038] The node degree feature E_d(b)=1-((d1-1+d2–1) / d_max); d1 and d2 are the degrees of the two end nodes of branch b; d_max is the maximum degree of the two end nodes. This feature suppresses branches extending from high-order bifurcation points (such as secondary branches).
[0039] Distance Transform Features ;
[0040] Where D(p) is the value of pixel p on the distance transform map; D_max is the maximum D(p). This feature emphasizes stable branches in the central region of the morphology (such as the main axis of the defect). Among them, E_L emphasizes branch length and retains long branches; E_c penalizes high curvature and removes noisy broken lines; E_d penalizes branches extending from high-order bifurcations; and E_r emphasizes stable branches in the central region of the morphology.
[0041] Weighted energy function: E(b)=α·E_L+β·E_c+γ·E_d+δ·E_r, where α, β, γ, and δ are weight coefficients, satisfying α+β+γ+δ=1. It can be dynamically optimized for different defect scenarios through cross-validation (typical values: α=0.32, β=0.2, γ=0.18, δ=0.3).
[0042] Graph construction and maximum spanning tree pruning module: global optimal skeleton decision
[0043] Weighted undirected graph modeling: The node set V and the branch set B are constructed as a graph G=(V,E), where: the node v∈V is the key point of the skeleton topology; the edge e(b)∈E corresponds to the branch b, connecting its two end nodes, and the weight is the branch energy value E(b). The higher the energy, the more important the branch.
[0044] Maximum spanning tree algorithm implementation: Run Kruskal algorithm (or Prim algorithm) on graph G. The specific steps are:
[0045] Sort all edges in descending order by energy value E(b); use the union-find data structure to select edges one by one. If the two ends of the edge are not connected, add them to the spanning tree until the spanning tree contains |V|-1 edges; the final subgraph T is obtained. That is to retain the skeleton structure of the global optimal branch and ensure the skeleton connectivity and energy optimality.
[0046] Skeleton reconstruction module: mapping from graph model to final skeleton
[0047] According to the maximum spanning tree T In the preliminary skeleton S0, all pixels of the corresponding branch are extracted and set as foreground (value 1), and the remaining branch pixels are set as background (value 0), generating a noise-free and topologically consistent final pruned skeleton S , achieving accurate conversion from graph model to image space.
[0048] The present invention can achieve topological feature quantification: accurately identify nodes through 8-neighborhood connectivity, and realize branch structured extraction in combination with depth-first traversal, providing a reliable basis for energy calculation. Multi-feature energy system: integrate length, curvature, node degree and distance transformation features to form a multi-dimensional evaluation model to avoid the limitations of a single feature. Global optimal pruning: based on weighted graph and maximum spanning tree algorithm, branches are screened from a global perspective to solve the topological break problem caused by traditional local pruning. Parameter adaptive optimization: the weight coefficient can be dynamically adjusted according to the defect type, combined with GPU parallel computing, to balance accuracy and efficiency.
[0049] Example 2, a global optimization defect skeleton extraction method based on energy function, the specific process is as follows:
[0050] Step S1: Image preprocessing and preliminary skeleton generation
[0051] Input and binarization: Input the defect image I to be processed, use the Otsu adaptive threshold algorithm to perform binary segmentation on the image, convert the grayscale image into the foreground target area R (pixel value 1) and the background area (pixel value 0), and automatically suppress interference such as uneven lighting.
[0052] Morphological thinning to generate a preliminary skeleton: The Zhang–Suen iterative thinning algorithm is applied to the binary region R. The edge pixels are peeled off layer by layer according to the 8-neighborhood pixel connectivity judgment rule until the skeleton converges to a single pixel width, generating a preliminary skeleton S0 that retains the original defect topology.
[0053] Step S2: Skeleton node and branch structure extraction
[0054] Node identification: Calculate the 8-neighborhood connectivity deg(p) (i.e., the number of foreground pixels in the 8-neighborhood) of each pixel in the preliminary skeleton S0, extract all pixels with deg(p) ≠ 2 as the node set V; start from each endpoint (deg = 1) and perform a depth-first traversal along S0 until the next node is encountered. Record the path as a branch b∈B to obtain the branch set B.
[0055] Branch traversal extraction: Starting from each endpoint, perform depth-first traversal along the skeleton S0 until the next node is encountered. The traversal path is recorded as a branch b, and finally a set B containing all skeleton branches is formed to complete the structural decomposition of the topological structure.
[0056] Step S3: Branch energy function construction and multi-feature quantization
[0057] Normalized feature calculation: Calculate the following normalized features for each branch b:
[0058] E_L(b)=|b| / L_max;
[0059] E_c(b)=1-(C_b / C_max), ;
[0060] E_d(b)=1-((d1-1+d2-1) / d_max);
[0061] ;
[0062] Where |b| is the branch length of branch b; L_max is the maximum |b|; is the angle between two adjacent vectors on the path; C_b is the cumulative curvature of branch b; C_max is the maximum C_b; d1, d2 are the degrees of the two end nodes of branch b; d_max is the maximum degree of the two end nodes; D(p) is the value of pixel p on the distance transformation graph; D_max is the maximum D(p).
[0063] Among them, E_L emphasizes branch length and retains long branches; E_c penalizes high curvature and removes noisy broken lines; E_d penalizes branches extending from high-order bifurcation points; and E_r strengthens stable branches in the morphological center area.
[0064] Weighted energy function construction:
[0065] By integrating multiple features, we obtain the energy function E(b)=α·E_L+β·E_c+γ·E_d+δ·E_r, where α…δ are weight coefficients.
[0066] Step S4: Graph model construction, global pruning and skeleton reconstruction
[0067] Weighted undirected graph modeling and maximum spanning tree solution: Construct the node set V and branch set B into a weighted undirected graph G = (V, E), where the weight of each edge is the energy value E(b) of the corresponding branch; use the Kruskal algorithm (sort edges in descending energy order and merge nodes based on union-check) to solve the maximum spanning tree T , and obtain the global optimal skeleton branch combination.
[0068] Skeleton reconstruction and output: According to the maximum spanning tree T The retained branches extract the corresponding pixels in the preliminary skeleton S0 to generate the final skeleton S without noise and with consistent topology. , complete the high-precision extraction and output of the defect skeleton.
[0069] Example 3, a global optimization defect skeleton extraction system based on an energy function, specifically includes: 1) binarization and preliminary refinement, first performing binary segmentation on the defect image I to be processed to obtain a binary region R; applying a morphological refinement algorithm (such as the Zhang–Suen algorithm) to R to generate a preliminary skeleton S0.
[0070] (2) Node and branch extraction, calculate the 8-neighborhood connectivity deg(p) of each pixel on the skeleton:
[0071] Extract all pixels with deg(p)≠2 as the node set V; start from each endpoint (deg=1) and traverse depth-first along S0 until the next node is encountered, record the path as a branch b∈B, and obtain the branch set B.
[0072] Branch energy function construction: Calculate the following normalized features for each branch b:
[0073] E_L(b)=|b| / L_max;
[0074] E_c(b)=1-(C_b / C_max), ;
[0075] E_d(b)=1-((d1-1+d2-1) / d_max);
[0076] ; where |b| is the branch length of branch b; L_max is the maximum |b|; is the angle between two adjacent vectors on the path; C_b is the cumulative curvature of branch b; C_max is the maximum C_b; d1, d2 are the degrees of the two end nodes of branch b; d_max is the maximum degree of the two end nodes; D(p) is the value of pixel p on the distance transformation graph; D_max is the maximum D(p).
[0077] Among them, E_L emphasizes branch length and retains long branches; E_c penalizes high curvature and removes noisy broken lines; E_d penalizes branches extending from high-order bifurcation points; and E_r strengthens stable branches in the morphological center area.
[0078] The weighted energy is comprehensively formed: E(b)=α·E_L+β·E_c+γ·E_d+δ·E_r, where α…δ are weight coefficients.
[0079] Through the above normalized indicators, the "importance" of branches can be measured as a whole under the same dimension, providing accurate weight input for subsequent maximum spanning tree pruning.
[0080] (4) Graph model and global optimal pruning: The node set V and branch set B are constructed into a weighted undirected graph G = (V, E). Each edge e(b)∈E connects the two end nodes of branch b, with a weight of E(b). Run the maximum spanning tree algorithm on G to obtain the subgraph T , which is the global optimal skeleton structure.
[0081] (5) Skeleton reconstruction, according to T The edges retained in the original image S_0 are taken from the corresponding branch pixels to generate the final pruned skeleton S .
[0082] In the present invention, the weight coefficients α…δ can be dynamically adjusted according to different defect morphologies and accuracy requirements; node extraction, branch construction, energy calculation and MST algorithm can all be parallelized and GPU accelerated.
[0083] The present invention has the following advantages:
[0084] Global Optimization: Automatically select the most important branches globally through energy functions and maximum spanning trees to avoid local greed;
[0085] High precision: Main trunk connectivity and orientation are well maintained, ≥70% of noisy branches are removed, and the skeleton false branching rate is reduced by approximately 50%;
[0086] Scalability: The energy function can be flexibly expanded to include more feature items (such as grayscale consistency, centrality index, etc.) to adapt to multiple scenarios;
[0087] High efficiency: GPU parallelizes branch extraction and energy calculation, processing megapixel images in less than 100ms.
[0088] More specifically:
[0089] The system mainly consists of three core modules: gradient map calculation module, weight map generation module and filter processing module. These modules work together to achieve adaptive filtering of the input image.
[0090] Binarization and thinning: The grayscale defect image is binarized using the Otsu method, and the threshold is automatically selected; then the Zhang–Suen thinning algorithm is iterated until the skeleton no longer changes, and S_0 is obtained.
[0091] # Pseudocode: Zhang–Suen thinning algorithm
[0092] #enter:
[0093] BinaryImage—foreground pixels are 1, background pixels are 0
[0094] #Output:
[0095] S0—Final refined skeleton
[0096] S←BinaryImage.copy()
[0097] changed←true
[0098] Define the coordinate offset of 8 neighboring pixels P2…P9 relative to P1=(x,y):
[0099] P2=(x,y-1),P3=(x+1,y-1),P4=(x+1,y),
[0100] P5=(x+1,y+1),P6=(x,y+1),P7=(x-1,y+1),
[0101] P8=(x-1,y),P9=(x-1,y-1)
[0102] Loop while changed is true:
[0103] changed←false
[0104] ──Subiteration 1──
[0105] Marker set M1←∅
[0106] For each foreground pixel P1=(x,y) in the image, do:
[0107] Take its 8 neighborhood values P2…P9
[0108] B←P2+P3+…+P9#Number of foreground neighbors
[0109] A←(#0→1Conversion times P2→P3→…→P9→P2)
[0110] Condition 1: 2≤B≤6
[0111] Condition 2:A==1
[0112] Condition 3: P2*P4*P6==0
[0113] Condition 4: P4*P6*P8==0
[0114] If condition 1∧condition 2∧condition 3∧condition 4 are all true:
[0115] Add P1 to M1
[0116] If M1 is not empty:
[0117] Set S[P]=0 for all pixels P in M1
[0118] changed←true
[0119] ──Subiteration 2──
[0120] Marker set M2←∅
[0121] For each foreground pixel P1=(x,y) in the image, do:
[0122] Calculate B and A in the same way and get P2…P9
[0123] Condition 1: 2≤B≤6
[0124] Condition 2:A==1
[0125] Condition 3: P2*P4*P8==0
[0126] Condition 4: P2*P6*P8==0
[0127] If condition 1∧condition 2∧condition 3∧condition 4 are all true:
[0128] Add P1 to M2
[0129] If M2 is not empty:
[0130] Set S[P]=0 for all pixels P in M2
[0131] changed←true
[0132] Returns the final refined skeleton S0
[0133] Node and branch traversal
[0134] Calculate the deg matrix and enter it into the node list V. For each endpoint with degree 1, traverse the 8 neighboring skeleton points in a depth-first manner and record the path until reaching the next node.
[0135] (3) Energy function parameter setting
[0136] On the laboratory sample set, α=0.32,β=0.2,γ=0.18,δ=0.3 were determined through cross-validation.
[0137] #Pseudo code: Cross validation process
[0138] Parameter list P←all candidate quadruples satisfying α+β+γ+δ=1
[0139] Optimal parameter best←None
[0140] The highest average score best_score←-∞
[0141] foreachpinPdo
[0142] scores←[]
[0143] forfold=1toKdo
[0144] D_train,D_val←divide D into training set and validation set
[0145] Run skeleton extraction (S_0 → node / branch → energy function E(b;p) → MST)
[0146] score←Calculate the F1-score of the skeleton extraction result and the true value of D_val
[0147] append(scores,score)
[0148] endfor
[0149] avg_score←mean(scores)
[0150] ifavg_score>best_scorethen
[0151] best_score←avg_score
[0152] best←p
[0153] endif
[0154] endfor
[0155] Output best and best_score
[0156] (4) Global pruning
[0157] Implement the maximum spanning tree algorithm to obtain the skeleton subgraph T .
[0158] # Pseudocode: Maximum Spanning Tree algorithm based on Kruskal
[0159] enter:
[0160] V—Node Collection
[0161] E—edge set, each edge e=(u,v,w), w is the edge weight
[0162] Output:
[0163] T—edge set of the maximum spanning tree
[0164] Function MAX_SPANNING_TREE(V,E):
[0165] #1. Initialize and query
[0166] UF←UnionFind(V)
[0167] #Union-find UF supports UF.find(x) and UF.union(x,y)
[0168] #2. Sort by weight in descending order
[0169] E_sorted←sort(E) by ew from largest to smallest
[0170] #3. Select edges one by one and build a spanning tree
[0171] T←∅
[0172] foreacheinE_sorteddo
[0173] (u,v,w)←e
[0174] if UF.find(u)≠UF.find(v)then
[0175] T←T∪{e}
[0176] UF.union(u,v)
[0177] endif
[0178] #If the number of selected edges = |V|-1, you can end early
[0179] if|T|=|V|-1then
[0180] break
[0181] endif
[0182] endfor
[0183] returnT
[0184] (5) Skeleton output
[0185] T The corresponding pixel points on S_0 are set as foreground, and the rest are set to zero to obtain the final skeleton S .
[0186] Experimental results and performance evaluation
[0187] like Figure 2 As shown, the method of the present invention has a significant effect on removing noise from the defect skeleton. In practical applications, this method can retain the true defect features while effectively removing noise, thereby improving the accuracy of defect skeleton extraction.
[0188] Performance evaluation indicators include:
[0189] Signal-to-noise ratio improvement: The signal-to-noise ratio increased by approximately 6-10dB before and after processing; Stripe noise suppression rate: More than 90% of the noise was effectively removed; Defect retention rate: The information retention rate of the defect area is greater than 95%; Processing speed: For a 1024×768 resolution image, the processing time is less than 50ms on a medium-configuration PC.
[0190] The technical principles of the present invention have been described above in conjunction with specific embodiments, which are merely preferred embodiments of the present invention. The scope of protection of the present invention is not limited to the above embodiments. All technical solutions based on the principles of the present invention fall within the scope of protection of the present invention. Those skilled in the art will be able to conceive of other specific embodiments of the present invention without inventive effort, and such methods will fall within the scope of protection of the present invention.
Claims
1. A global optimization defect skeleton extraction system based on energy function, characterized by: The system includes a refinement module, a node and branch extraction module, an energy calculation module, a graph construction and maximum spanning tree pruning module, and a skeleton reconstruction module: the refinement module is used to first perform binary segmentation on the defect image I to be processed to obtain a binary region R, and apply a morphological refinement algorithm to the binary region R to generate a preliminary skeleton S0; the node and branch extraction module is used to calculate the 8-neighborhood connectivity deg(p) of each pixel on the skeleton S0 to obtain each branch b and a branch set B; the energy calculation module calculates the normalized features of each branch b; The graph construction and maximum spanning tree pruning module obtains the global optimal skeleton structure based on the above normalized features; the skeleton reconstruction module takes the corresponding branch pixels on the skeleton S0 according to the edges retained in the global optimal skeleton structure to generate the final pruned skeleton S*. The 8-neighborhood connectivity deg(p) is: Extract all pixels with deg(p)≠2 as the node set V; start with each endpoint deg=1 and traverse along S0 depth-first until the next node is encountered, record the path as a branch b∈B, and obtain the branch set B. The normalized features are specifically calculated as follows: For each branch b, calculate the following normalized features: E_L(b)=|b| / L_max; E_c(b)=1-(C_b / C_max), ; E_d(b)=1-((d1–1+d2–1) / d_max); ; Where |b| is the branch length of branch b; L_max is the maximum |b|; is the angle between two adjacent vectors on the path; C_b is the cumulative curvature of branch b; C_max is the maximum C_b; d1, d2 are the degrees of the nodes at both ends of each branch b; d_max is the maximum degree of the nodes at both ends; D(p) is the value of pixel p on the distance transform map; D_max is the maximum D(p), E_L emphasizes branch length and retains long branches; E_c penalizes high curvature and removes noisy broken lines; E_d penalizes branches extending from high-order bifurcation points; E_r strengthens stable branches in the morphological center area, The weighted energy is synthesized: E(b)=α·E_L+β·E_c+γ·E_d+δ·E_r, where α, β, γ, and δ are weight coefficients. The graph construction and maximum spanning tree pruning module is specifically used to construct the node set V and the branch set B into a weighted undirected graph G=(V,E). Each edge e(b)∈E connects the two end nodes of each branch b, with a weight of E(b). The maximum spanning tree algorithm is run on the weighted undirected graph G to obtain the subgraph T , The global optimal skeleton structure , The specific steps of running the maximum spanning tree algorithm on the weighted undirected graph G are as follows: sort all edges in descending order according to their energy values E(b); use the union-find data structure to select edges one by one. If the nodes at both ends of the edge are not connected, add them to the spanning tree until the spanning tree contains |V|-1 edges; the resulting subgraph T* is the skeleton structure that retains the global optimal branch.
2. A method for extracting a defect skeleton based on a global optimization system of energy function according to claim 1, characterized in that: The following steps are involved: Step S1: image input, binary segmentation of the input image, and generation of a preliminary skeleton; Step S2: extract nodes and branches from the skeleton; Step S3: constructing the extracted branch energy function; Step S4: Obtain the graph model and global optimal pruning according to the branch energy function, and reconstruct and output the skeleton.
Citation Information
Patent Citations
A sonar image segmentation method and device
CN109559321A
Skeleton-based plane area high-quality isogeometric parameterization method
CN118608548A