Battery glue line skeleton extraction method based on improved zs thinning algorithm
By improving the ZS thinning algorithm and combining it with odd and even subdomain batch processing, T-shaped 4-neighborhood deletion template and 8-chain code tracking mechanism, the problems of redundant pixels and burrs in battery adhesive wire skeleton extraction are solved, achieving high-precision and complete adhesive wire skeleton extraction, which is suitable for online inspection of battery assembly lines.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- HEFEI UNIV OF TECH
- Filing Date
- 2026-03-30
- Publication Date
- 2026-06-23
AI Technical Summary
The existing ZS thinning algorithm has problems such as redundant pixel residue in oblique areas, destruction of topological integrity due to over-thinning, and burr generation in the extraction of battery adhesive wire skeleton, which makes it difficult to meet the online inspection requirements of high cycle time and high reliability of battery assembly line.
By improving the ZS thinning algorithm, introducing odd and even subdomain batch processing, T-shaped 4-neighborhood deletion template and 8-chain code tracking mechanism, the iterative deletion conditions are optimized, redundant pixels and glitch are eliminated, and the topological integrity and single-pixelization of the skeleton are ensured.
It significantly improves the precision and integrity of the skeleton, achieving complete single-pixel rendering of the adhesive wire skeleton. It has strong adaptability to industrial scenarios and real-time performance, meeting the high-speed online inspection requirements of battery assembly lines.
Smart Images

Figure CN122265245A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of image processing technology, and in particular relates to a method for extracting the skeleton of battery adhesive wires based on an improved ZS thinning algorithm. Background Technology
[0002] In the automated assembly process of power batteries for new energy vehicles, the adhesive coating process plays a decisive role in the sealing performance and structural strength of the battery module, and the quality of the adhesive lines directly affects the safety of the battery and the entire vehicle. Therefore, online defect detection after adhesive coating has become a critical link in production, and the accurate extraction of the adhesive line skeleton is the core prerequisite for achieving efficient defect detection. Skeleton extraction is usually achieved through image thinning algorithms. This technology iteratively removes redundant pixels at the target edges, retaining a skeleton with a single-pixel width that reflects the target's topological structure and morphological features.
[0003] One of the most widely used thinning algorithms in the industry today is the ZS algorithm, a classic parallel thinning algorithm. This algorithm defines two sets of deletion conditions and, in two sub-iterations, marks and deletes boundary pixels that meet the conditions in parallel, thereby gradually thinning the target region. The ZS algorithm performs well in preserving straight lines, T-junctions, and corners, and has high processing efficiency, thus it is widely used in industrial vision inspection scenarios.
[0004] However, existing ZS thinning algorithms still have significant shortcomings in practical applications. The thinned skeleton tends to retain a large number of redundant pixels in the diagonal regions, making it difficult to achieve true single-pixel width. Simultaneously, the algorithm suffers from over-thinning, easily deleting critical nodes and causing skeleton disconnections, thus compromising the topological integrity of the target. Furthermore, in industrial environments, noise interference such as glue overflow and uneven application can generate numerous burrs in the thinning results, severely impacting the accuracy of subsequent defect detection. Although subsequent improved algorithms such as Guo-Hall and MZS have been developed, they still fail to simultaneously balance skeleton integrity, single-pixel accuracy, burr suppression capabilities, and processing efficiency, making it difficult to meet the high-speed, high-reliability online inspection requirements of battery assembly lines. Summary of the Invention
[0005] The purpose of this invention is to provide a method for extracting the skeleton of battery adhesive wires based on an improved ZS thinning algorithm, which aims to solve the problems existing in the background art.
[0006] This invention is implemented as follows: a method for extracting the skeleton of battery adhesive wires based on an improved ZS thinning algorithm, comprising the following steps:
[0007] Step 1: Preprocess the acquired battery adhesive wire image to obtain a binary image. This step uses median filtering, image enhancement, threshold segmentation, and hole filling to eliminate image noise and holes caused by reflections on the adhesive wire surface, resulting in a binary image with clear target features.
[0008] Step 2: Improved ZS thinning is performed on the binary image obtained in Step 1 to obtain a preliminary skeleton. This step divides the image into odd and even subdomains for batch processing and introduces new constraints. Redundant pixels are repeatedly marked and deleted through two iterative subprocesses until no pixels can be deleted, thereby solving the problems of oblique redundancy and over-thinning in the traditional ZS algorithm and obtaining a topologically complete preliminary skeleton.
[0009] Step 3: Perform T-shaped redundant pixel removal on the preliminary skeleton obtained in Step 2. Use a predefined T-shaped 4-neighborhood deletion template to traverse the image and delete the target pixels that match the template to completely eliminate the T-shaped redundant structure and achieve complete single-pixelization of the glue line skeleton, thus obtaining a completely single-pixel skeleton.
[0010] Step 4: Remove burrs from the fully single-pixel skeleton obtained in Step 3 by identifying and deleting burr branches through 8-chain code tracing. This step starts from the endpoint and traces each branch along the 8-connected direction. It determines whether a branch is a burr based on the continuous direction of the chain code sequence, deletes the burr branch, and protects the node. This process is repeated until no new burrs are generated, resulting in the final glue wire skeleton.
[0011] The battery adhesive wire skeleton extraction method based on the improved ZS thinning algorithm provided by this invention has the following beneficial effects:
[0012] Significantly improves skeleton refinement accuracy and integrity: By optimizing the iterative deletion conditions of the ZS algorithm, the problems of redundant and over-refined oblique skeletons in traditional algorithms are solved. The skeleton refinement rate can reach 99.87%, which is far higher than the existing mainstream algorithms. It completely preserves the topological structure and morphological features of the adhesive line and avoids skeleton disconnection and skewness.
[0013] Complete single-pixelization of the adhesive line skeleton was achieved: by introducing a T-shaped 4-neighbor deletion template, the remaining redundant pixels of the skeleton were completely eliminated, and the redundant pixel ratio was reduced to 0, providing a reliable foundation for the accurate detection of the adhesive line width, position and shape in the future.
[0014] It has strong adaptability to industrial scenarios: Through the 8-chain code tracking mechanism, it accurately identifies and removes burrs caused by excess glue and uneven glue application in battery adhesive lines based on the branch extension trend, without damaging the main skeleton. This solves the problem of excessive burrs and easy false detection and missed detection in existing algorithms in industrial noise environments.
[0015] Balancing detection accuracy and real-time performance: While significantly improving the accuracy of skeleton extraction, the algorithm's running time only increases slightly, fully meeting the high-speed online inspection requirements of battery assembly lines. It can be directly integrated into industrial vision inspection systems and applied to the automated defect detection of battery adhesive lines, effectively ensuring the quality of battery adhesive coating and the safety of vehicle use. Attached Figure Description
[0016] Figure 1 The overall flowchart of the battery adhesive wire skeleton extraction method based on the improved ZS thinning algorithm provided by the present invention is shown below.
[0017] Figure 2 For target pixel Schematic diagram of the 8-neighborhood;
[0018] Figure 3 For target pixel A schematic diagram of the 4-neighborhood;
[0019] Figure 4 A schematic diagram defining the direction of an 8-connected chain code;
[0020] Figure 5 The images show the results of the image preprocessing process, where (a) is the original image of the adhesive line, (b) is the result of median filtering, (c) is the result of image enhancement, and (d) is the final binary image after hole filling.
[0021] Figure 6 This is a magnified view of the skeleton and a part of it after the ZS refinement in step two.
[0022] Figure 7 This is a schematic diagram of a T-shaped skeleton structure;
[0023] Figure 8 To correspond to different and T-shaped 4-neighbor deletion template with selectable values;
[0024] Figure 9 This is a rendering of the final extracted adhesive thread skeleton from the present invention; Detailed Implementation
[0025] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.
[0026] The specific implementation of the present invention will be described in detail below with reference to specific embodiments.
[0027] like Figure 1 As shown, in this embodiment of the invention, it includes:
[0028] Step 1: Image Preprocessing
[0029] This step involves systematically preprocessing the original image of the battery adhesive lines captured by the industrial camera to obtain a binary image that meets the requirements of the thinning algorithm.
[0030] The original image of the adhesive line ( Figure 5a) Median filtering is performed to reduce noise from the image shooting environment and hardware, smoothing the image while preserving the edge features of the adhesive lines. The result is as follows: Figure 5 As shown in b.
[0031] Edge enhancement is performed on the filtered image using Laplacian transform to strengthen the edge information of the adhesive line area; then, gamma transform is used to adjust the image contrast, further improving the distinction between the adhesive line and the background, while removing residual noise around the adhesive area. The processing result is as follows: Figure 5 As shown in c.
[0032] The enhanced image is segmented using the OTSU adaptive thresholding algorithm. The optimal segmentation threshold is calculated based on the grayscale values of all pixels in the image, dividing the image into foreground glue line pixels (pixel value 1) and background pixels (pixel value 0), thus obtaining the initial binary image.
[0033] To address the issue of internal holes in binary images caused by surface reflection of the adhesive line, morphological hole filling processing is performed to obtain a final binary image without holes, redundant noise, and complete adhesive line features. Figure 5 d), which serves as the input for subsequent refinement algorithms.
[0034] Step 2: Improve ZS refinement
[0035] This step performs Zygmalion thinning on the preprocessed binary image to obtain a preliminary skeleton. For ease of description, the following concepts are first defined: 8-neighborhood: the area surrounding the target pixel. The set of 8 adjacent pixels is the 8-neighborhood of the target pixel, such as... Figure 2 As shown.
[0036] Cross number The number of times the pixel value changes from 1 to 0 when traversing the 8-neighborhood of the target pixel in a clockwise or counterclockwise direction is calculated using the following formula:
[0037]
[0038] Number of connections The total number of foreground points in the 8-neighborhood of the target pixel is calculated using the following formula:
[0039]
[0040] Number of 8-connected black components The number of 8-connected white components in the 8-neighborhood of the target pixel is calculated using the following formula:
[0041]
[0042] Minimum number of adjacent pairs The minimum number of neighborhood connections in two different directions within the 8-neighborhood of the target pixel is calculated using the following formula:
[0043]
[0044] in:
[0045]
[0046]
[0047] The improvement lies in using the parity of the sum of the target pixel coordinates as a constraint to divide the image into two subdomains, odd and even, for batch processing, thus avoiding over-refinement and topological damage caused by simultaneously deleting adjacent pixels; it also introduces... and Two constraints replace the basic deletion condition of the traditional ZS algorithm, tighten the endpoint protection rules, and solve the problem of slanted skeleton redundancy.
[0048] The improved refinement algorithm consists of two iterative sub-processes, both of which adopt the rule of marking before deleting, as follows:
[0049] Process 1: If the target pixel point If the 8-neighborhood of a given element satisfies all of the following five conditions, then it will be... Pixels marked as to be deleted:
[0050]
[0051] Process 2: If the target pixel point If the 8-neighborhood of a given element satisfies all of the following five conditions, then it will be... Marked for deletion:
[0052]
[0053] After completing the marking in the two sub-processes, delete all pixels marked as to be deleted. Repeat the above two sub-processes until no pixels are marked for deletion in a complete iteration, at which point a preliminary skeleton is obtained. Figure 6 The image shows the skeleton after refinement in step two and its magnified parts. Rectangular areas 1 and 2 in the image show that the problem of diagonal pixel redundancy has been solved, while circular area 3 shows that the over-refinement problem has also been improved accordingly.
[0054] The improved deletion condition, based on the ZS thinning algorithm, constrains the parity of the sum of the target pixel coordinates, dividing the binary image into two sub-domains (odd and even) for processing. This effectively avoids over-thinning caused by simultaneously deleting adjacent elements. The number of 8-connected white components is also introduced. ,constraint The value of 1 is used to replace the first deletion condition in the ZS thinning algorithm, which solves the problem of diagonally redundant pixels in the ZS thinning algorithm. The minimum number of adjacent pairs and the sum of these values are introduced. , The value is between 2 and 3, replacing the second deletion condition of the ZS thinning algorithm. This preserves the endpoints of the glue line skeleton to a greater extent because when When the target pixel is an endpoint, the ZS thinning algorithm may delete that endpoint, while using... It can tighten the deletion criteria, reducing the occurrence of this situation. Other deletion criteria are consistent with the ZS refinement algorithm.
[0055] Step 3: Clear T-shaped redundant pixels
[0056] Even after the refinement in step two, the skeleton may still contain T-shaped pixel redundancy structures (such as...). Figure 7 As shown), these redundant pixels generate extra nodes, interfering with subsequent burr removal and defect detection. Therefore, this invention introduces two sets of 4-neighborhood T-shaped deletion templates (e.g., Figure 8 (As shown). In the template, 1 represents that the location is the foreground point. and The pixel value is 0 or 1, and and At least one pixel in the array has a value of 1.
[0057] Iterate through all pixels in the preliminary skeleton image output from step two. If the 4-neighborhood of the target pixel is equal to... Figure 8 If any set of templates matches, the target pixel is deleted. This operation completely removes redundant T-shaped pixels, achieving complete single-pixelization of the glue line skeleton, resulting in a fully single-pixel skeleton.
[0058] Step 4: Deburring
[0059] After completing the first three steps, only redundant burrs remain in the skeleton caused by industrial noise such as glue overflow and uneven glue application. This step uses an 8-chain code tracking mechanism to accurately identify and remove burrs based on the branch extension trend.
[0060] First, define the relevant concepts: Endpoint: If there is only one foreground pixel in the 8-neighborhood of the target pixel, this point is the skeleton endpoint.
[0061] Node: If there are at least 3 foreground pixels in the 8-neighborhood of the target pixel, the point is a skeleton node.
[0062] 8-connected chain code: An encoding rule used to represent the 8 connected directions of a target pixel, such as... Figure 4As shown, 0 represents right, 1 represents top right, 2 represents top, 3 represents top left, 4 represents left, 5 represents bottom left, 6 represents bottom, and 7 represents bottom right. The specific steps are as follows: Mark endpoints and nodes: Traverse all pixels of the fully single-pixel skeleton and mark all endpoints and nodes according to the definition.
[0063] 8-chain code tracing: Start 8-chain code tracing from each endpoint, move step by step along the 8-connected direction, record the corresponding pixel coordinates for each move, and select an unvisited neighboring pixel that is connected to the current pixel as the next step. The tracing ends when a node is reached or there are no subsequent connected pixels.
[0064] Generate branch information: Record the direction of each movement using 8-connected chain codes, generate the chain code sequence for each branch, and record the endpoint and node coordinates corresponding to the branch.
[0065] Spike branch identification: Analyze the chain code sequence originating from each node in each branch:
[0066] If five consecutive chain codes are all one of 0, 1, or 7, the branch is determined to be a spur branch extending to the right.
[0067] If five consecutive chain codes are all one of 3, 4, or 5, the branch is determined to be a spur branch extending to the left.
[0068] If a branch chain code has fewer than 5 elements and all branch chain codes belong to either {0, 1, 7} or {3, 4, 5}, it is also considered a glitch branch. Branches that meet the above conditions are marked as branches to be deleted.
[0069] Delete spiky branches: Delete all branches marked as to be deleted, and set a node protection mechanism, that is, only delete the last pixel from the endpoint to the node, and keep the node itself to avoid skeleton disconnection.
[0070] Iterate until stable: Repeat steps 1-5 above until there are no new endpoints or node markers in the skeleton, completing burr removal and obtaining the final glue wire skeleton, as shown. Figure 9 As shown. Verification of beneficial effects.
[0071] The method of this invention was tested on actual battery coating images. The results show that the skeleton refinement rate can reach 99.87%, the redundant pixel ratio is reduced to 0, the algorithm running time meets the production line cycle requirements, and it can effectively extract complete, single-pixel, burr-free glue line skeletons, providing a reliable basis for subsequent defect detection. This invention is particularly suitable for industrial sites with noise such as glue overflow and uneven coating, and has good robustness and real-time performance.
[0072] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A method for extracting the skeleton of battery adhesive wires based on an improved ZS thinning algorithm, characterized in that, The battery adhesive wire skeleton extraction method based on the improved ZS thinning algorithm includes: Step 1: Preprocess the acquired battery adhesive wire image to obtain a binary image that meets the algorithm requirements; Step 2: Perform improved ZS thinning iterative deletion on the binary image obtained in Step 1. The improved ZS thinning includes dividing the image into odd and even subdomains for batch processing and introducing the number of 8-connected black components. Sum of minimum adjacent pairs As a constraint, redundant pixels are iteratively deleted until no pixels are marked for deletion, thus obtaining a preliminary skeleton. Step 3: Remove the T-shaped redundant pixels in the preliminary skeleton by introducing two sets of 4-neighbor T-shaped deletion templates. Traverse all pixels in the preliminary skeleton image. If the 4-neighborhood of the target pixel matches the deletion template, delete the target pixel to completely remove the T-shaped redundant pixels and obtain a completely single pixelated glue line skeleton. The T-shaped redundant pixels in the preliminary skeleton are removed, and the matching pixels are deleted using a T-shaped deletion template to obtain a completely single pixelated skeleton. Step 4: For a completely single pixelated skeleton, use an 8-chain code tracking mechanism to identify and remove burrs based on the branch extension trend to obtain the final glue line skeleton.
2. The method for extracting battery adhesive wire skeleton based on the improved ZS thinning algorithm according to claim 1, characterized in that, The preprocessing of the acquired battery adhesive wire image described in step one specifically includes: Median filtering was applied to the original image of the adhesive line captured by the visual camera to reduce noise. Edge enhancement is performed on the filtered image using Laplace transform, and image contrast is adjusted using gamma transform. The enhanced image is thresholded using the OTSU adaptive thresholding algorithm to obtain an initial binary image. Morphological hole filling processing is performed on the initial binary image to obtain a final binary image without holes, redundant noise, and complete adhesive line features.
3. The method for extracting battery adhesive wire skeleton based on the improved ZS thinning algorithm according to claim 1, characterized in that, The improved ZS refinement described in step two includes two iterative sub-processes: Iterative sub-process 1: If the target pixel point The 8-neighborhood of a given value simultaneously satisfies the following conditions. The pixels marked as to be deleted are used to mark the southeastern boundary and northwestern convex corner of the target image: Iterative sub-process 2: If the target pixel point If the 8-neighborhood of a given element simultaneously satisfies the following conditions, then it will be... The pixels marked as to be deleted are used to mark the northwest boundary and southeast convex corner of the target image: in, - yes The surrounding eight pixels After marking is complete, delete all pixels marked as pending deletion. Repeat iterative sub-procedure 1 and iterative sub-procedure 2 until no pixels are marked for deletion in a complete iteration.
4. The method for extracting battery adhesive wire skeleton based on the improved ZS thinning algorithm according to claim 1, characterized in that, The T-shaped deletion template mentioned in step three consists of two sets of 4-neighbor templates; Traverse all pixels in the initial skeleton image. If the 4-neighborhood of the target pixel matches the deletion template, then delete the target pixel.
5. The method for extracting battery adhesive wire skeleton based on the improved ZS thinning algorithm according to claim 1, characterized in that, Step four, which describes the identification and removal of glitch based on branch extension trends using an 8-chaincode tracing mechanism, specifically includes: S1: Traverse all pixels of the completely single pixelated skeleton and mark all endpoints and nodes on the completely single pixelated skeleton. S2: Start 8-chain code tracing from the endpoint, move step by step along the 8-connected direction, record the corresponding pixel coordinates for each move, select an unvisited adjacent pixel that is connected to the current pixel, and terminate when tracing to the node and there are no subsequent connected pixels; S3: Record the movement direction using 8-connected chain codes, and generate the chain code sequence, corresponding endpoints and node coordinates for each branch; S4: Analyze the chain code sequence originating from each node in each branch: If five consecutive chain codes are all one of {0, 1, 7}, the branch is determined to be a spur branch extending to the right. If five consecutive chain codes are all one of {3, 4, 5}, the branch is determined to be a spur branch extending to the left. If the branch chain code length is less than 5, and all branch chain codes belong to one of the groups {0, 1, 7} and {3, 4, 5}, they are judged as spurious branches; branches that meet the conditions are marked as branches to be deleted. S5: Delete all branches marked as pending deletion, and set a node protection mechanism to delete only the last pixel from the endpoint to the node, while keeping the node itself. S6: Repeat steps S1-S5 until there are no new endpoints and node markers in the skeleton, thus completing burr removal.