Battery shell surface defect detection method based on linear gray scale and multi-scale adaptive SPD-Conv
Through the detection method based on linear grayscale and multi-scale adaptive SPD-Conv, the problem of low detection accuracy of the outer surface defects of the cylindrical battery case is solved, and more efficient background noise and light interference suppression, as well as the extraction of complex defect features are achieved.
Patent Information
- Application Number
- CN202510233639.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-28
- Publication Date
- 2025-06-17
AI Technical Summary
The prior art is difficult to realize high-precision detection of defects in the outer surface of the cylindrical battery case, especially in the background noise and light interference caused by large length-to-diameter ratio of the case, metal reflectivity and curved surface properties, the detection accuracy is low.
The battery shell defect detection method based on linear grayscale and multi-scale adaptive SPD-Conv is adopted. Through image segmentation, linear fitting of grayscale distribution curves and multi-scale adaptive feature extraction modules, background interference is eliminated, light influence is weakened, and the convolution kernel sampling point distribution is adaptively adjusted to extract complex defect features.
It effectively improves the accuracy of defect detection on the outer surface of the battery case, reduces the influence of background noise and uneven light, and enhances the ability to extract complex defect features.
Smart Images

Figure CN120163784A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of defect detection on the outer surface of a battery case, and particularly to a method for detecting defects on the battery case surface based on linear grayscale and multi-scale adaptive SPD-Conv. Background Art
[0002] Cylindrical lithium batteries are widely used in the fields of electronic products and new energy vehicles due to their advantages such as high energy density and stable performance. The case is an important part of a cylindrical lithium battery. Affected by the processing technology, defects such as scratches and pits are likely to appear on the outer surface of the case. These defects are likely to cause battery leakage, thus triggering phenomena such as electric leakage, fire, and explosion. Therefore, the defect detection work on the outer surface of the case is an important link in the production process of the battery case.
[0003] SPD-Conv (Space-to-depth layer followed by convolution layer, from the literature "No more strided convolutions or pooling: a new CNN building block for low-resolution images and small objects", included in the conference proceedings "Joint European conference on machine learning and knowledge discovery in databases", pages 443-459).
[0004] The main difficulties in detecting defects on the outer surface of a cylindrical battery case are as follows:
[0005] 1) The large aspect ratio of the case results in a small proportion of the target area in the entire image, and the detection effect is easily interfered by background noise.
[0006] 2) The metallic reflectivity and curvature of the case cause the entire image to be greatly interfered by light, resulting in low image quality.
[0007] The existing methods for detecting defects on the outer surface of a cylindrical battery case are mainly divided into two categories:
[0008] The first category is image - processing - based methods. Aiming at the problems that the large aspect ratio of the shell leads to a small proportion of the target area in the whole image and the detection effect is easily interfered by background noise, in 2019, Yu Xia et al. from Shenyang University of Technology proposed a visual inspection method for concave pits on the circumferential surface of cylindrical lithium batteries (authorization announcement number: CN109191421B). This method first detects the upper edge of the target area of the shell through the Canny edge operator, then calculates the center point according to the aspect ratio of the shell length and width, and draws a rectangle to extract the target area. Although this method can segment the target area from the image background, when using the edge operator, high and low double thresholds need to be set to extract the edge line, and the method of calculating and solving the effective area based only on the obtained upper edge of the shell has a large error.
[0009] Aiming at the above problems, in 2019, Tan Wen et al. from Hunan University of Science and Technology proposed in the article "Visual Inspection of Curved Surface Defects of Cylindrical Batteries Based on HV&VHS" (published in the journal "Control Engineering", pages 17 - 22) to scan the shell image from top to bottom, and find the boundary vertices of the gradient change of the image target area at a certain width to achieve image segmentation. Although this method avoids the problem of low detection accuracy caused by artificially setting thresholds, detecting boundary points at a certain width is prone to false detection and missed detection of boundary points.
[0010] Aiming at the problems that the metal reflectivity and curvature of the shell lead to large interference of the whole image by light and low image quality, in 2019, Hu et al. from Hefei University of Technology proposed in the article "Battery Surface and Edge Defect Inspection Based on Sub - Regional Gaussian and Moving Average Filter" (published in the journal "Applied Sciences", issue 16): By dividing the shell surface image into an edge area and an internal area, performing column - by - column average filtering on the edge area and row - by - row Gaussian filtering on the internal area to reduce noise. Although this method can weaken the influence of uneven illumination on the edge area of the shell through the partition filtering process of the shell image, this area division method is easily affected by the light source distribution position and does not have universality.
[0011] In response to the above problems, in 2020, Guo Shaotao et al. from Shenyang University of Technology proposed in the article "Research on the Detection Method of Circular Surface Pits of Cylindrical Film-Coated Lithium Batteries" (published in the journal Chinese Journal of Scientific Instrument, pages 146-156): calculating the mutation points on the gray distribution curve using a gray difference model that is insensitive to the light distribution, and selecting the extraction threshold of the mutation points according to the reflective characteristics of the circumferential surface, so as to realize the detection of pits. This method utilizes the distribution characteristics of uneven light on the surface of the shell to achieve the detection task of pit-type defects on the surface of the shell, but it is only applicable to defects with obvious gray mutations in the pit category, and the types of defect detection are relatively single.
[0012] The second category is the method based on deep learning. In 2022, Xu Zhenying et al. from Jiangsu University proposed a battery defect detection method and system based on deep learning (publication number: CN115170550A). This invention eliminates background interference by judging whether the defect coordinate information is within the effective area of the shell; and improves the recognition accuracy of the model for different types of defects on the surface of the cylindrical shell by introducing operations such as a hybrid attention mechanism and improving the clustering algorithm in the YOLOv5 network. Although this method can realize the detection of different types of defects on the surface of the shell and is not affected by background interference, it is easily affected by environmental factors such as light.
[0013] In 2023, Peng Jinmin et al. from Fujian University of Technology proposed a method for detecting minute defects on the surface of a new energy battery shell (publication number: CN118314085A). This invention weakens the interference of uneven light by introducing the SE-SP module into the YOLOv7 backbone network to give a higher feature weight to the defect area; and enhances the defect feature extraction ability by introducing the deep feature fusion module MFAK into the neck network. Although this method can reduce the impact of uneven light on the detection accuracy, it does not consider the influence of the shell curvature on the detection accuracy when extracting features, and its detection accuracy still needs to be improved.
[0014] In summary, the existing technologies cannot achieve high-precision detection of defects on the outer surface of the cylindrical battery shell. On the one hand, it is impossible to preprocess the shell image to weaken the interference of background noise and uneven light; on the other hand, it is impossible to enhance the network's ability to extract complex defect features on the surface of the shell. Summary of the Invention
[0015] The object of the present invention is to overcome the defects of the prior art and provide a method for detecting defects on the surface of a battery case based on linear gray scale and multi-scale adaptive SPD-Conv. By introducing size parameters of defects at different scales to construct conditional convolution, the spatial size of the output feature map is used to adjust the division of the feature channel dimension of the original SPD module. By introducing an offset for the sampling points of the Conv convolution kernel, a partial convolution layer is constructed to adaptively adjust the distribution of the sampling points of the convolution kernel, which can effectively solve the problem of low detection accuracy of defects on the outer surface of the case caused by uneven illumination and background noise of the case.
[0016] The object of the present invention is achieved as follows: A method for detecting defects on the surface of a battery case based on linear gray scale and multi-scale adaptive SPD-Conv includes the following steps:
[0017] Step 1) Perform image segmentation on the target area based on the extreme value of the linear gray scale gradient mutation. According to the gray scale difference between the image background and the effective area of the case, calculate the extreme values of the gray scale gradient mutation of each row and column of pixels in the image, and determine the boundary line of the effective area; use the selected boundary line as a reference to achieve image segmentation of the target area and eliminate background interference;
[0018] Step 2) Perform enhancement processing on the target area image based on the mean value of the linear fitting gray scale distribution curve function: Fit the gray scale distribution curve of each row of the image through a linear function; use the mean value of the fitting function of each row of pixels in the image as a reference to perform filtering processing on the image, adjust the gray scale distribution of the image, weaken the interference of uneven illumination, and achieve image enhancement processing;
[0019] Step 3) A feature extraction module based on multi-scale adaptive SPD-Conv; construct conditional convolution based on the defect annotation size parameters, so that the SPD layer in the original module adjusts the division of the feature channel dimension according to the spatial size of the output feature map; construct an offset convolution layer based on the offset introduced by the defect morphology to adaptively adjust the distribution of the sampling points of the Conv convolution kernel and extract complex defects on the surface of the case; integrate the constructed multi-scale adaptive SPD-Conv module into the YOLOv8 backbone network to enhance the network's ability to extract defect features on the outer surface of the case.
[0020] As a further limitation of the present invention, the specific content of the step 1) includes:
[0021] 1-1) Perform gray scale processing on the collected original image;
[0022] 1-2) Perform regional segmentation on the image based on the extreme value of the linear gray scale gradient mutation of each row: According to the gray scale difference between the image background area and the effective area, scan the gray scale processed image row by row from top to bottom to find the positive extreme value G of the gray scale gradient mutation of each row of pixels in the image row-max, the row where it is located is the upper boundary line of the effective area of the housing; find the negative extreme value G of the sudden change in the gray level gradient of each row of pixels in the image row-min , the row where it is located is the lower boundary line of the effective area of the housing; the formula is defined as follows:
[0023]
[0024] Among them, G row-max is the positive extreme value of the sudden change in the gray level gradient of each row of pixels in the image; G row-min is the negative extreme value of the sudden change in the gray level gradient of each row of pixels in the image; max() is the function for obtaining the positive extreme value of the sudden change in the gray level gradient of each row of pixels; min() is the function for obtaining the negative extreme value of the sudden change in the gray level gradient of each row of pixels; is the gray level gradient value of each row of pixels in the image, where I(x, y) is the gray level value at point (x, y), n is the number of pixel columns in the entire image, is the sum of the gray level values of the pixels in the y-th row;
[0025] 1 - 3) Scan the grayscale-processed image column by column from left to right, find the positive extreme value of the gray level gradient of each column of pixels in the image, and the column where it is located is the left boundary line of the effective area of the housing; find the negative extreme value of the gray level gradient of each column of pixels in the image, and the column where it is located is the right boundary line of the effective area of the housing, and the calculation is as shown in formula (2); and divide the effective area of the housing according to the selected upper, lower, left, and right boundary lines to eliminate background interference;
[0026]
[0027] Among them, G column-max is the positive extreme value of the sudden change in the gray level gradient of each column of pixels in the image; G column-min is the negative extreme value of the sudden change in the gray level gradient of each column of pixels in the image; max() is the function for obtaining the positive extreme value of the sudden change in the gray level gradient of each column of pixels; min() is the function for obtaining the negative extreme value of the sudden change in the gray level gradient of each column of pixels; is the gray level gradient value of each column of pixels in the image, where I(x, y) is the gray level value at point (x, y), m is the number of pixel rows in the entire image, is the sum of the gray level values of the pixels in the x-th column.
[0028] As a further limitation of the present invention, step 2) specifically includes:
[0029] 2 - 1) Construct a linear fitting function of the gray level distribution curve of each row of the image by the least squares method;
[0030] 2 - 2) Based on the mean value of the linear fitting function of the gray level distribution characteristics, perform filtering processing on the image: Calculate the spatial domain weight w according to the spatial distance between the central pixel point (i, j) in the filtering window and each point (k, j) in its neighborhood s , the spatial domain weight ws The calculation is as shown in formula (3);
[0031]
[0032] where i is the abscissa of the center point within the filtering window, k is the abscissa of the point within the neighborhood of the center point, and σ s is the standard deviation in the spatial domain;
[0033] According to the gray value difference between the central pixel point (i, j) within the filtering window and each point (k, j) within its neighborhood, calculate its range weight w r , and the range weight w r The calculation is as shown in formula (4):
[0034]
[0035] where f(i, j) is the gray value of the center point within the filtering window, f(k, j) is the gray value of the pixel point within the neighborhood of the center point, and σ r is the standard deviation of gray value;
[0036] Weight-sum the pixel values of each point within the neighborhood and perform normalization processing; use the ratio of the mean value of the fitting function of each row of the entire image to the fitting function value of the row where the central pixel point is located as the weight coefficient, perform row-by-row filtering on the image, and adjust the gray distribution of the image; perform focused filtering on the current area based on the mean value of the fitting function as shown in formula (5):
[0037]
[0038] where g(i, j) is the gray value of the output pixel point after filtering, n is the number of pixel columns of the image, S(i, j) refers to the point set within the filtering window with a size of 1×(2N + 1) centered on (i, j), and (k, j) are each point within the neighborhood of the center point of the filtering window; represents the fitting function value of the j-th row of the image, represents the mean value of the fitting functions of each row of the image; w s represents the spatial domain weight, and w r represents the range weight.
[0039] As a further limitation of the present invention, step 3) specifically includes:
[0040] 3-1) Construct conditional convolution based on the defect annotation size parameters to optimize the division of the feature channel dimension of the SPD module: introduce the defect annotation size as a conditional variable, generate convolution kernel parameters through a fully connected layer network, perform conditional convolution operation with the upper-layer convolution features as the input, and output a feature map; input the feature map after conditional convolution into the SPD layer, so that the SPD module adjusts the division of the feature channel dimension according to the spatial size of the feature map;
[0041] 3-2) Introduce an offset parameter based on the defect morphology to construct an offset convolutional layer, and adaptively adjust the sampling point distribution of the Conv convolutional kernel: Introduce an offset parameter for each sampling point of the SPD-Conv convolution to construct an offset convolutional layer; Use the upper-layer convolutional feature map as the input, learn the offset parameter, and output the offset parameter to the non-strided convolution of the original module to output the offset parameter to adjust the sampling point distribution of the non-strided convolutional kernel;
[0042] 3-3) Construction of the YOLOv8 network based on the multi-scale adaptive SPD-Conv module: Connect the improved SPD layer and the Conv convolution in sequence to construct a multi-scale adaptive SPD-Conv module; Incorporate the constructed multi-scale adaptive SPD-Conv module into the 1st, 3rd, 5th, and 7th layers of the YOLOv8 backbone network.
[0043] The present invention adopts the above technical solutions. Compared with the prior art, the beneficial effects are as follows:
[0044] 1) The present invention realizes image segmentation by respectively performing gradient scanning on the pixels of each row and column of the shell image, seeking the positive and negative extreme values of the gradient of each row and column of pixels according to the difference between the area to be measured and the background image, and locating the boundary line of the effective area, thus eliminating background interference.
[0045] 2) The present invention fits the image gray distribution curve through a linear function, and uses the ratio of the mean value of the fitting function of each row of the entire image to the value of the fitting function of the row where the central pixel point is located as the weight coefficient to perform differential filtering on the image, adjust the gray distribution, and weaken the influence of uneven illumination.
[0046] 3) The present invention constructs conditional convolution by introducing the size parameters of different-scale defects, and adjusts the division of the feature channel dimension of the original SPD module with the spatial size of the output feature map. Compared with the method of artificially setting fixed parameters in the SPD layer of the original module to divide the feature channel dimension, this method can realize multi-scale division of the feature channel dimension according to different feature sizes, reduce the calculation amount, and better allocate computing resources at the same time;
[0047] 4) The present invention constructs a partial convolutional layer by introducing an offset for the sampling points of the Conv convolutional kernel, and adaptively adjusts the sampling point distribution of the convolutional kernel with the output offset parameter. Compared with the fixed convolutional kernel size of the non-strided convolution in the original module, this method can adjust the sampling point distribution of the convolutional kernel according to the defect morphology, better adapt to complex defect features, and improve the extraction accuracy of surface complex features. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] Figure 1 is the overall flow schematic diagram of the present invention.
[0049] Figure 2 is the schematic diagram of the improved YOLOv8 network structure of the present invention.
[0050] Figure 3 Schematic diagram of the improved multi-scale adaptive SPD-Conv module of the present invention. Detailed implementation manners
[0051] As Figure 1 shown, a battery case surface defect detection method based on linear grayscale and multi-scale adaptive SPD-Conv includes the following steps:
[0052] Step 1) Since the aspect ratio of the case is large, the proportion of the target area in the whole image is small, and the detection effect is easily interfered by background noise. To solve this problem, a target area image segmentation method based on the extreme value of linear grayscale gradient mutation is proposed; according to the difference in grayscale between the image background and the effective area of the case, calculate the extreme values of the grayscale gradient mutation of each row and each column of pixels in the image, and determine the boundary line of the effective area; based on the selected boundary line, implement target area image segmentation to eliminate background interference;
[0053] 1-1) Perform grayscale processing on the collected original image;
[0054] 1-2) Perform regional segmentation on the image based on the extreme values of linear grayscale gradient mutation of each row: According to the difference in grayscale between the image background area and the effective area, scan the grayscale-processed image row by row from top to bottom to find the positive extreme value G row-max of the grayscale gradient mutation of each row of pixels in the image. The row where it is located is the upper boundary line of the effective area of the case; find the negative extreme value G row-min of the grayscale gradient mutation of each row of pixels in the image. The row where it is located is the lower boundary line of the effective area of the case; the formula is defined as follows:
[0055]
[0056] Where, G row-max is the positive extreme value of the grayscale gradient mutation of each row of pixels in the image; G row-min is the negative extreme value of the grayscale gradient mutation of each row of pixels in the image; max() is the function for obtaining the positive extreme value of the grayscale gradient mutation of each row of pixels; min() is the function for obtaining the negative extreme value of the grayscale gradient mutation of each row of pixels; is the grayscale gradient value of each row of pixels in the image, where I(x, y) is the grayscale value at point (x, y), n is the number of pixel columns in the whole image, is the sum of the grayscale values of the pixels in the y-th row;
[0057] 1 - 3) Scan the grayscale - processed image column - by - column from left to right to find the positive extreme values of the pixel grayscale gradients of each column of the image. The column where the positive extreme value is located is the left - boundary line of the effective area of the shell; find the negative extreme values of the pixel grayscale gradients of each column of the image. The column where the negative extreme value is located is the right - boundary line of the effective area of the shell. The calculation is shown in formula (2). And divide the effective area of the shell according to the selected upper, lower, left, and right boundary lines to eliminate background interference.
[0058]
[0059] Among them, G column-max is the positive extreme value of the mutation of the pixel grayscale gradient of each column of the image; G column-min is the negative extreme value of the mutation of the pixel grayscale gradient of each column of the image; max() is the function for obtaining the positive extreme value of the mutation of the pixel grayscale gradient of each column; min() is the function for obtaining the negative extreme value of the mutation of the pixel grayscale gradient of each column; is the pixel grayscale gradient value of each column of the image, where I(x, y) is the grayscale value at point (x, y), m is the number of pixel rows of the entire image, is the sum of the grayscale values of the pixels in the x - th column.
[0060] Step 2) Due to the metallic reflectivity and curvature of the shell, the entire image is greatly affected by light interference and the image quality is low. To solve this problem, an image enhancement processing method for the target area based on the mean value of the linear - fitting grayscale distribution curve function is proposed; First, fit the grayscale distribution curves of each row of the image through a linear function; based on the mean value of the fitting function of each row of pixels in the image, perform filtering on the image, adjust the grayscale distribution of the image, weaken the interference of uneven illumination, and achieve image enhancement processing;
[0061] 2 - 1) Construct a linear - fitting function for the grayscale distribution curves of each row of the image through the least - squares method;
[0062] 2 - 2) Perform filtering on the image based on the mean value of the linear - fitting function of the grayscale distribution characteristics: According to the spatial distance between the central pixel point (i, j) in the filtering window and each point (k, j) in its neighborhood, calculate its spatial - domain weight w s , and the spatial - domain weight w s is calculated as shown in formula (3);
[0063]
[0064] Among them, i is the abscissa of the center point in the filtering window, k is the abscissa of the point in the neighborhood of the center point, and σ s is the spatial - domain standard deviation;
[0065] According to the grayscale value difference between the central pixel point (i, j) in the filtering window and each point (k, j) in its neighborhood, calculate its value - domain weight w r , and the value - domain weight wr The calculation is as shown in formula (4):
[0066]
[0067] where f(i,j) is the grayscale value of the center point within the filtering window, f(k,j) is the grayscale value of the pixel points within the neighborhood of the center point, and σ r is the standard deviation of grayscale;
[0068] The pixel values of each point within the neighborhood are weighted and summed, and then normalized; taking the ratio of the mean value of the fitting function of each row of the entire image to the fitting function value of the row where the central pixel point is located as the weight coefficient, the image is filtered row by row to adjust the grayscale distribution of the image; focusing on filtering the current area based on the mean value of the fitting function as shown in formula (5):
[0069]
[0070] where g(i,j) is the grayscale value of the output pixel point after filtering, n is the number of pixel columns of the image, S(i,j) refers to the set of points within the filtering window of size 1×(2N + 1) centered on (i,j), and (k,j) are the points within the neighborhood of the center point of the filtering window; represents the fitting function value of the j-th row of the image, represents the mean value of the fitting functions of each row of the image; w s represents the spatial domain weight, and w r represents the range domain weight.
[0071] As Figure 2 shown is the schematic diagram of the improved YOLOv8 network structure of the present invention, which specifically includes the following steps:
[0072] Step 3) Due to the curved surface of the shell, the external surface defects are distorted and deformed, and the detection accuracy of the surface defect morphology is low. To address this problem, a multi-scale adaptive SPD-Conv module is proposed; first, conditional convolution is generated based on the defect annotation size parameters to optimize the division of the feature channel dimension of the SPD module, and computing resources are reasonably allocated according to the size of the defect features; second, an offset convolution layer is constructed based on the offset introduced by the defect morphology to adaptively adjust the sampling point distribution of the Conv convolution kernel and extract complex defects on the shell surface; finally, the constructed multi-scale adaptive SPD-Conv module is integrated into the YOLOv8 backbone network to enhance the network's ability to extract defect features on the shell external surface and improve the detection accuracy of the shell surface defect morphology.
[0073] As Figure 3 shown is the schematic diagram of the improved multi-scale adaptive SPD-Conv module of the present invention, which specifically includes steps 3-1) to 3-2):
[0074] 3-1) Construct conditional convolution based on the defect annotation size parameters to optimize the division of the feature channel dimension of the SPD module: Introduce the defect annotation size as a conditional variable, generate convolution kernel parameters through a fully connected layer network, perform conditional convolution operations with the upper-layer convolution features as the input, and output the feature map; Input the feature map after conditional convolution into the SPD layer, so that the SPD module adjusts the division of the feature channel dimension according to the spatial size of the feature map; Compared with the method of artificially setting fixed parameters in the SPD layer of the original module to divide the feature channel dimension, this method can achieve multi-scale division of the feature channel dimension according to different feature sizes, reduce the computational amount, and better allocate computing resources;
[0075] 3-2) Construct an offset convolution layer by introducing offset parameters based on the defect morphology to adaptively adjust the sampling point distribution of the Conv convolution kernel: Introduce offset parameters for each sampling point of the SPD-Conv convolution to construct an offset convolution layer; Use the upper-layer convolution feature map as the input, learn the offset parameters, and output the offset parameters to the non-strided convolution of the original module to output the offset parameters to adjust the sampling point distribution of the non-strided convolution kernel; Compared with the fixed convolution kernel size of the non-strided convolution in the original module, this method can adaptively adjust the sampling point distribution of the convolution kernel according to the defect morphology, better adapt to complex defect features, and improve the extraction accuracy of surface complex features;
[0076] 3-3) Construction of the YOLOv8 network based on the multi-scale adaptive SPD-Conv module: Connect the improved SPD layer and the Conv convolution in sequence to construct a multi-scale adaptive SPD-Conv module; Incorporate the constructed multi-scale adaptive SPD-Conv module into the 1st, 3rd, 5th, and 7th layers of the YOLOv8 backbone network; Enhance the network's ability to extract defect features on the shell surface, retain detailed features, and improve the detection accuracy of complex defect morphologies on the shell surface.
[0077] The present invention provides a method for detecting battery shell surface defects based on linear grayscale and multi-scale adaptive SPD-Conv. By introducing size parameters of defects at different scales to construct conditional convolution, the division of the feature channel dimension of the original SPD module is adjusted according to the spatial size of the output feature map. By introducing an offset for the sampling points of the Conv convolution kernel to construct an offset convolution layer, the sampling point distribution of the convolution kernel is adaptively adjusted by outputting the offset parameters, which can effectively solve the problem of low detection accuracy of defects on the outer surface of the shell caused by uneven illumination and background noise of the shell.
[0078] The present invention is not limited to the above embodiments. Based on the technical solutions disclosed in the present invention, those skilled in the art can make some substitutions and deformations to some technical features without creative labor according to the disclosed technical content, and these substitutions and deformations are all within the protection scope of the present invention.
Claims
1. A battery shell surface defect detection method based on linear grayscale and multi-scale adaptive SPD-Conv, characterized in that: The following steps are involved: Step 1) performing image segmentation based on the target area of linear gray gradient mutation extreme value, calculating the extreme value of gray gradient mutation of each row and column of the image according to the difference in gray between the image background and the effective area of the shell, and determining the boundary line of the effective area; achieving image segmentation of the target area based on the selected boundary line to eliminate background interference; Step 2) Enhance the target area image based on the mean of the linear fitting grayscale distribution curve function: fit the grayscale distribution curve of each row of the image through a linear function; filter the image based on the mean of the fitting function of each row of pixels in the image, adjust the grayscale distribution of the image, weaken the interference of uneven illumination, and achieve image enhancement; Step 3) Feature extraction module based on multi-scale adaptive SPD-Conv; Conditional convolution is constructed based on the defect annotation size parameters, so that the SPD layer in the original module adjusts the feature channel dimension division according to the spatial size of the output feature map; an offset convolution layer is constructed based on the offset introduced by the defect morphology, and the distribution of Conv convolution kernel sampling points is adaptively adjusted to extract complex defects on the shell surface; the constructed multi-scale adaptive SPD-Conv module is integrated into the YOLOv8 backbone network to enhance the network's ability to extract defect features on the outer surface of the shell.
2. The battery shell surface defect detection method based on linear grayscale and multi-scale adaptive SPD-Conv according to claim 1 is characterized in that: The step 1) specifically includes: 1-1) grayscale the collected original image; 1-2) Image region segmentation based on the extreme value of linear gray gradient mutation in each row: According to the difference in grayscale between the background area and the effective area of the image, the grayscale processed image is scanned line by line from top to bottom to find the positive extreme value G of the gray gradient mutation of each row of pixels in the image row-max , the row where it is located is the upper boundary line of the shell effective area; find the negative extreme value G of the gray gradient mutation of each row of pixels in the image row-min , the row where it is located is the lower boundary line of the shell effective area; the formula is defined as follows: Among them, G row-max G is the positive extreme value of the gray gradient mutation of each row of pixels in the image; row-min is the negative extreme value of the gray gradient mutation of each row of pixels in the image; max() is the function for obtaining the positive extreme value of the gray gradient mutation of each row of pixels; min() is the function for obtaining the negative extreme value of the gray gradient mutation of each row of pixels; is the grayscale gradient value of each row of pixels in the image, where I(x,y) is the grayscale value at point (x,y), and n is the number of pixel columns in the entire image. is the sum of the grayscale values of the pixels in the yth row; 1-3) Scan the grayscale processed image from left to right column by column, find the positive extreme value of the grayscale gradient of each column of the image pixels, and the column where it is located is the left boundary line of the shell effective area; find the negative extreme value of the grayscale gradient of each column of the image pixels, and the column where it is located is the right boundary line of the shell effective area, and the calculation is shown in formula (2); and divide the shell effective area according to the selected upper, lower, left and right boundary lines to eliminate background interference; Among them, G column-max G is the positive extreme value of the gray gradient mutation of each column of pixels in the image; column-min is the negative extreme value of the gray gradient mutation of each column of pixels in the image; max() is the function for obtaining the positive extreme value of the gray gradient mutation of each column of pixels; min() is the function for obtaining the negative extreme value of the gray gradient mutation of each column of pixels; is the grayscale gradient value of each column of the image, where I(x,y) is the grayscale value at point (x,y), and m is the number of pixel rows in the entire image. is the sum of the grayscale values of the pixels in the xth column.
3. The battery shell surface defect detection method based on linear grayscale and multi-scale adaptive SPD-Conv according to claim 1 is characterized in that: The step 2) specifically includes: 2-1) Construct a linear fitting function of the grayscale distribution curve of each row of the image by the least squares method; 2-2) Based on the mean of the linear fitting function of the grayscale distribution characteristics, the image is filtered: according to the spatial distance between the central pixel point (i, j) in the filter window and each point (k, j) in its neighborhood, its spatial domain weight w is calculated s , spatial domain weight w s The calculation is shown in formula (3); Among them, i is the horizontal coordinate of the center point in the filter window, k is the horizontal coordinate of the point in the neighborhood of the center point, σ s is the standard deviation in the spatial domain; According to the gray value difference between the central pixel (i, j) in the filter window and each point (k, j) in its neighborhood, calculate its range weight w r , range weight w r The calculation is shown in formula (4): Among them, f(i,j) is the gray value of the center point in the filter window, f(k,j) is the gray value of the pixel in the neighborhood of the center point, σ r is the grayscale standard deviation; The pixel values of each point in the neighborhood are weighted and summed, and then normalized. The ratio of the mean value of the fitting function of each row of the entire image to the value of the fitting function of the row where the central pixel is located is used as the weight coefficient to filter the image row by row and adjust the image grayscale distribution. The current area is filtered with the mean value of the fitting function as the reference, as shown in formula (5): Among them, g(i,j) outputs the grayscale value of the pixel after filtering, n is the number of pixel columns in the image, S(i,j) refers to the point set within the filter window size of 1×(2N+1) with (i,j) as the center, and (k,j) is the point in the neighborhood of the center point in the filter window; represents the fitting function value of the jth row of the image, represents the mean value of the fitting function of each row of the image; w s represents the spatial domain weight, w r Represents the range weight.
4. The battery shell surface defect detection method based on linear grayscale and multi-scale adaptive SPD-Conv according to claim 1 is characterized in that: The step 3) specifically includes: 3-1) Construct conditional convolution based on defect annotation size parameters to optimize the division of feature channel dimensions by the SPD module: introduce defect annotation size as a conditional variable, generate convolution kernel parameters through the fully connected layer network, perform conditional convolution operation with the upper layer convolution features as input, and output feature maps; input the feature maps after conditional convolution into the SPD layer, so that the SPD module adjusts the division of feature channel dimensions according to the spatial size of the feature maps; 3-2) Introduce offset parameters based on defect morphology to construct an offset convolution layer, and adaptively adjust the distribution of Conv convolution kernel sampling points: Introduce offset parameters for each sampling point of SPD-Conv convolution to construct an offset convolution layer; take the upper layer convolution feature map as input, learn the offset parameters, and output the offset parameters to the non-step convolution of the original module, and adjust the distribution of non-step convolution kernel sampling points with the output offset parameters; 3-3) Construction of YOLOv8 network based on multi-scale adaptive SPD-Conv module: Connect the improved SPD layer and Conv convolution in sequence to construct a multi-scale adaptive SPD-Conv module; integrate the constructed multi-scale adaptive SPD-Conv module into the 1st, 3rd, 5th and 7th layers of the YOLOv8 backbone network.
Citation Information
Patent Citations
Visual inspection method for circumferential pits in cylindrical lithium batteries
CN109191421B
Battery defect detection method and system based on deep learning
CN115170550A
New energy battery shell surface tiny defect detection method
CN118314085A