Battery Surface and Edge Defect Inspection Based on Sub-Regional Gaussian and Moving Average Filter

: Detecting the defects of a battery on the surface and edge has always been di ﬃ cult, especially for concave and convex ones, thereby seriously a ﬀ ecting its quality. Thus, sub-regional Gaussian and moving average ﬁltering are innovatively proposed in this study considering the e ﬀ ect of the nonuniform background illumination of the battery edge and the di ﬀ erence between the edge background and the internal surface defects of the battery. The battery surface image is divided into two areas, namely, edge area W 1 and inner area W 2 . Gaussian and moving average ﬁltering are carried out row-by-row and column-by-column in the inner area W 2 and the edge area W 1 , respectively. The algorithm is tested on 600 battery samples that mainly possess concave and convex defects. The proposed method has higher detection accuracy and lower omission detection rate than the traditional unpartitioned processing method, especially in detecting the accuracy of edge defects. The accuracy rates were approximately 20% higher than that obtained by the traditional processing algorithm. The proposed method has remarkable real-time performance that can process four 8192 × 10,240 pixel battery images per second, thereby meeting the industrial production line speed requirements while satisfying accuracy. The proposed method has been applied in actual production for defect inspection.


Introduction
The battery is an essential product that has been widely used in many fields, such as electronics, communication, instrument, transportation, and machinery manufacturing [1][2][3][4]. The demand for a battery with high surface, performance, and quality increases annually given the rapid development of modern science and technology. Various defects, such as scratch [5], concave, and convex, appear on the battery's surface during production due to defects of raw material, rolling equipment, and processing technology [6,7]. These defects would not only affect the battery's appearance, but also the product's quality and performance. The battery's surface defect inspection is repetitive and needs tremendous concentration. Traditional inspection methods, including artificial visual [8], frequency flight [9], infrared [10], magnetic flux leakage [11], and ultrasonic [12], have disadvantages, such as being time consuming and having a high missing rate and low inspection precision due to complex and extreme environment. Among these problems, edge defect detection has always been difficult to solve because of curved edges and uneven reflections ( Figure 1). Thus, the results of the traditional methods do not satisfy the requirements. In addition, companies need to store the data information of the battery's surface, especially its defect information, to revalidate its quality upon completion. above image detection methods are generally used for the detection of defects on the surface of metal plates. Therefore, we proposed an efficient algorithm for battery surface and edge defect inspection based on sub-regional Gaussian and moving average filtering. The algorithm mainly identifies the concave and convex defects on the surface and batteries' edges because these are defects that affect the batteries' quality during the production process. Moreover, detecting defects on edges has always been difficult.  Computer vision has been widely used and has been proven to have advantages, such as high speed, effective, and high inspection precision [13][14][15]. Defects are caused by different factors and appear in various types. The core of image processing is to extract useful features from the surface images and to track and address the cause of the different types of defects. Several popular feature extraction methods can be used in image processing. Li proposed an efficient scale-invariant feature transform (SIFT) algorithm to accelerate feature extraction [16]. Bay proposed other efficient speed-up robust feature (SURF) algorithms to further accelerate feature extraction based on SIFT [17]. Ojala presented a local binary pattern (LBP) algorithm, which was a redefinition of the grayscale values of the original image and a simple combination of histograms [18]. Li presented a segmentation algorithm based on Canny edge defects on the surface of the battery cathode [19]. Tian introduced an extreme learning machine algorithm combined with a genetic algorithm for the surface defect identification of hot-rolled steel plates, which improved detection accuracy by self-learning through training samples [20]. Li used Gabor filters and the pulse coupled neural network (PCNN) to identify defects. Gabor filters are used to enhance the contrast of images captured by camera, and the defect areas are automatically segmented by PCNN with an adaptive parameter setting [21]. Li used local normalization (LN) to enhance image contrast, which was nonlinear and illumination independent, and to detect defects using the defect localization based on the projection profile (DLBP), which was robust to noise and prompt [22].

System Structure
There are few articles that detect concave and convex defects of the battery we mentioned; the above image detection methods are generally used for the detection of defects on the surface of metal plates. Therefore, we proposed an efficient algorithm for battery surface and edge defect inspection based on sub-regional Gaussian and moving average filtering. The algorithm mainly identifies the concave and convex defects on the surface and batteries' edges because these are defects that affect the batteries' quality during the production process. Moreover, detecting defects on edges has always been difficult.
The system structure of the battery surface and edge defect inspection based on sub-regional Gaussian and moving average filtering mainly include linear array charge-coupled device (CCD) camera, light source, and industrial personal computer (IPC) with screen and test samples ( Figure  2a). The uncertain geometrical defects on the battery's surface (especially the concave and convex defects) are the drawbacks of the battery surface defect inspection. The battery's test samples ( Figure  2b) are made of metal, and uneven illumination may occur during the test. The linear array light-emitting diode (LED) [23] and linear array CCD camera [24] have been used to avoid these effects during image acquisition and defect inspection. The linear array LED light source is used to provide suitable illumination. The linear array CCD camera continuously scans the battery's surface to form a uniform 2D image that can complete image acquisition on the entire battery's surface. The image of the battery's surface collected through this approach is rectangular in shape. This shape easily and accurately segments the defects. Feature extraction is convenient, and the accuracy of detecting the battery's microdefects is improved.
The linear array CCD camera has higher inspection precision and lower cost than the face array CCD camera when inspecting images with the same size and resolution. The linear array CCD camera has high scanning speed, high frequency response, and can realize dynamic measurement and work under low illumination intensity.
The images are acquired using one 2048

Software Structure
Image processing methods are the core components of this study, which are divided into several sections. Figure 3 shows the proposed software structure, including image acquisition, ROI extraction, median filtering, sub-regional Gaussian and moving average filtering, threshold setting, binary large object (blob) analysis, mainly about noise reduction and operation, analysis of defect characteristics, and defects marked on the original image. The linear array CCD camera has higher inspection precision and lower cost than the face array CCD camera when inspecting images with the same size and resolution. The linear array CCD camera has high scanning speed, high frequency response, and can realize dynamic measurement and work under low illumination intensity.
The images are acquired using one 2048 × 1 pixel linear array CCD camera produced by Teledyne DALSA. The pixel size of the camera is 7.04 µm × 7.04 µm, the maximum line frequency can reach up to 80 KHz, and sensitivity is 320 DN nJ cm 2 , 12 bit, 1 × gain, and supports multiple regions of interest (ROI) functions.

Software Structure
Image processing methods are the core components of this study, which are divided into several sections. Figure 3 shows the proposed software structure, including image acquisition, ROI extraction, median filtering, sub-regional Gaussian and moving average filtering, threshold setting, binary large object (blob) analysis, mainly about noise reduction and operation, analysis of defect characteristics, and defects marked on the original image.

ROI Extraction
Region of interest (ROI) extraction is the first step of image processing. The original image captured by the linear CCD array camera is a constant 2D image (Figure 4a). The size of the original acquired image is 8192 10240 × pixel according to the parameter settings of the linear CCD array camera used. The original image also includes invalid areas. Determining the vertical line that best fits the ROI position of the battery edge in the image is necessary because of the battery's constant width and the different luminance between the background and the battery surface. The specific ROI extraction processing can be described as follows:

ROI Extraction
Region of interest (ROI) extraction is the first step of image processing. The original image captured by the linear CCD array camera is a constant 2D image (Figure 4a). The size of the original acquired image is 8192 × 10, 240 pixel according to the parameter settings of the linear CCD array camera used. The original image also includes invalid areas. Determining the vertical line that best fits the ROI position of the battery edge in the image is necessary because of the battery's constant width and the different luminance between the background and the battery surface. The specific ROI extraction processing can be described as follows: 1.
The pixel value px i of each line is identified, and the maximum value px max is obtained. The pixel value of each point is divided by the maximum value px i px max . Correspondingly, the same procedure is performed for column The pixel value between ROI and the background dramatically changes. The boundary point py i py max is determined using this feature, where n is the total number of rows in the image, and m is the total number of columns. 3.
The column width of ROI was extracted from left to right (Figure 4b). 4.
The row width of ROI was extracted from top to bottom (Figure 4c). 5.
ROI extraction is completed, and ROI is divided into two sections, namely, edge part W 1 and inner part W 2 ( Figure 4d).  After ROI extraction, a series of image processing algorithms, including Gaussian filtering [25], moving average filtering (MAF) [26], blob analysis [27], and defect characteristic analysis [28], are applied. The sub-regional processing method is creatively proposed on the basis of Gaussian filtering and MAF considering the effect of nonuniform background illumination of the battery edge and the difference between the edge background and the internal surface defects of the battery. Gaussian filtering and MAF are carried out row-by-row in the inner area 2 w and After ROI extraction, a series of image processing algorithms, including Gaussian filtering [25], moving average filtering (MAF) [26], blob analysis [27], and defect characteristic analysis [28], are applied. The sub-regional processing method is creatively proposed on the basis of Gaussian filtering and MAF considering the effect of nonuniform background illumination of the battery edge and the difference between the edge background and the internal surface defects of the battery. Gaussian filtering and MAF are carried out row-by-row in the inner area W 2 and column-by-column in the edge area W 1 . This approach is different from most module or global processing methods. The proposed method has higher defect detection accuracy and lower omission detection rate than the traditional unpartitioned processing methods. The detailed principles of the proposed algorithm are described in the following section. To prove the advancement of our proposed algorithm, we compared it with the traditional unpartitioned processing.

Gaussian Filtering
Enhancing image quality is necessary because the images from the image acquisition module contain noise. Row-by-row Gaussian filtering is applied to filter image noises according to the speed and performance of image-enhancing processes. The 1D digital Gaussian filter can be expressed as Equation (1). In noise filtering, a model is commonly assumed as the convolution of two signals (Equation (2)).
where σ represents the standard deviation of the Gaussian filter, x is the pixel index, M(x) is the observed signal, S(x) is the original signal, Z (x) is the identical distribution Gaussian noise with zero mean, and σ 2 is the variance. The partition Gaussian process is applied, considering the effect of the nonuniform background illumination of the battery edge and the difference between the edge background and the internal surface defects of the battery. Gaussian filtering is processed row-by-row in the inner area W 2 and column-by-column in the edge area W 1 . Figure 5 shows the results of partition Gaussian method and traditional Gaussian methods.
proposed algorithm, we compared it with the traditional unpartitioned processing.

Gaussian Filtering
Enhancing image quality is necessary because the images from the image acquisition module contain noise. Row-by-row Gaussian filtering is applied to filter image noises according to the speed and performance of image-enhancing processes. The 1D digital Gaussian filter can be expressed as Equation (1). In noise filtering, a model is commonly assumed as the convolution of two signals (Equation (2)).

( )
where σ represents the standard deviation of the Gaussian filter, x is the pixel index, noise with zero mean, and 2 σ is the variance.
The partition Gaussian process is applied, considering the effect of the nonuniform background illumination of the battery edge and the difference between the edge background and the internal surface defects of the battery. Gaussian filtering is processed row-by-row in the inner area 2 w and column-by-column in the edge area 1 w . Figure 5 shows the results of partition Gaussian method and traditional Gaussian methods. Figure 6 shows the grayscale variation on the surface and edge of the battery. We proposed to find a grayscale trend curve by analyzing the grayscale curve. The defect position is highlighted, and the gray background is weakened through subtraction. Therefore, we used these features to smoothen the curves, perform subtraction, highlight the defects, and set an adaptive threshold to identify the defects.   Figure 6 shows the grayscale variation on the surface and edge of the battery. We proposed to find a grayscale trend curve by analyzing the grayscale curve. The defect position is highlighted, and the gray background is weakened through subtraction. Therefore, we used these features to smoothen the curves, perform subtraction, highlight the defects, and set an adaptive threshold to identify the defects.  MAF is defined by averaging a number of points from the input signal to produce each point in the output signal. MAF can be regarded as a window of a certain size (N, in this case) that moves along the array that constitutes from the input signal, one element at a time (Figure 7). The average of all elements in the current window correspond to the MAF output. MAF is defined by averaging a number of points from the input signal to produce each point in the output signal. MAF can be regarded as a window of a certain size (N, in this case) that moves along the array that constitutes from the input signal, one element at a time (Figure 7). The average of all elements in the current window correspond to the MAF output.  The relationship between the signal of the input and the output of the MAF can be clearly described in Equations (3) and (4), respectively:

Moving Average Filtering (MAF)
where X(n) and Y(n) are the pixel values of the input and output signals of the MAF, respectively, and N is the size of the moving window, that is, the number of samples of the input pixel per moving period. (4), the transfer function from the MAF input to its output in the time-domain can be described in Equation (5) as follows:

Integrating Equation (3) into Equation
The transfer function indicates that MAF is a finite impulse response (FIR) filter, which has linear phase characteristics and good robustness. Figure 8 illustrates the results of MAF. Figure 8a shows the MAF curve plots with different numbers of samples, whereas Figure where X(n) and Y(n) are the pixel values of the input and output signals of the MAF, respectively, and N is the size of the moving window, that is, the number of samples of the input pixel per moving period. Integrating Equation (3) into Equation (4), the transfer function from the MAF input to its output in the time-domain can be described in Equation (5) as follows: The transfer function indicates that MAF is a finite impulse response (FIR) filter, which has linear phase characteristics and good robustness. Figure 8 illustrates the results of MAF. Figure 8a shows the MAF curve plots with different numbers of samples, whereas Figure 8b shows the residual changes correspondingly.

Blob Analysis
In this section, blob analysis is mainly applied for noise cancellation and area feature extraction. In computer vision, blob refers to a connected area composed of features, such as similar colors and textures in an image. In a word, blob analysis refers to the geometric analysis of a connected area to obtain important geometric features, such as area, center point coordinates, centroid coordinates, minimum circumscribed rectangle, and spindle. It can separate the target from the background and can calculate the target number, location, shape, orientation, and size, as well as the topology among related spots. Figure 10 shows the use of open operation to separate the defect from the background and to remove some of the noise. Figure 11 shows the area extraction.

Blob Analysis
In this section, blob analysis is mainly applied for noise cancellation and area feature extraction. In computer vision, blob refers to a connected area composed of features, such as similar colors and textures in an image. In a word, blob analysis refers to the geometric analysis of a connected area to obtain important geometric features, such as area, center point coordinates, centroid coordinates, minimum circumscribed rectangle, and spindle. It can separate the target from the background and can calculate the target number, location, shape, orientation, and size, as well as the topology among related spots. Figure 10 shows the use of open operation to separate the defect from the background and to remove some of the noise. Figure 11 shows the area extraction.

Blob Analysis
In this section, blob analysis is mainly applied for noise cancellation and area feature extraction. In computer vision, blob refers to a connected area composed of features, such as similar colors and textures in an image. In a word, blob analysis refers to the geometric analysis of a connected area to obtain important geometric features, such as area, center point coordinates, centroid coordinates, minimum circumscribed rectangle, and spindle. It can separate the target from the background and can calculate the target number, location, shape, orientation, and size, as well as the topology among related spots. Figure 10 shows the use of open operation to separate the defect from the background and to remove some of the noise. Figure 11 shows the area extraction.

Analysis of Defect Characteristics
A bright and dark defect with a certain symmetry relationship is formed on the image due to the nonuniformity of the reflected light of the concave and convex defects, and boundary search is performed on the image after blob analysis based on the characteristics of defects. Figure 12 shows the defects marked on the original image after the boundary search of defects. The figure also shows that the partition processing has higher accuracy than the traditional processing without partition. This difference is especially reflected in the edge defect detection.

Analysis of Defect Characteristics
A bright and dark defect with a certain symmetry relationship is formed on the image due to the nonuniformity of the reflected light of the concave and convex defects, and boundary search is performed on the image after blob analysis based on the characteristics of defects. Figure 12 shows the defects marked on the original image after the boundary search of defects. The figure also shows that the partition processing has higher accuracy than the traditional processing without partition. This difference is especially reflected in the edge defect detection.

Analysis of Defect Characteristics
A bright and dark defect with a certain symmetry relationship is formed on the image due to the nonuniformity of the reflected light of the concave and convex defects, and boundary search is performed on the image after blob analysis based on the characteristics of defects. Figure 12 shows the defects marked on the original image after the boundary search of defects. The figure also shows that the partition processing has higher accuracy than the traditional processing without partition. This difference is especially reflected in the edge defect detection.

Experiments and the Analysis of Results
A total of 600 battery samples with 8192 × 10, 240 pixels are divided into 5 groups and applied in our defection system to evaluate the effectiveness of the proposed algorithm. Figure 13 shows the experimental results of the proposed processing algorithm based on sub-regional Gaussian and MAF compared with other processing methods. Tables 1 and 2 illustrate critical data to demonstrate the superiority of the proposed algorithm. Table 1 shows the comparison of partition and traditional unpartitioned detection results, it means that the traditional method is to process horizontally or vertically on the whole picture directly, while the partition processing takes into account the uneven illumination distribution of the edge of the image, the vertical processing at the edge, and the horizontal processing inside image. Table 2 illustrates the accuracy rates and detection time with different concave and convex defect inspection methods, because there is almost no research on the surface defects of the battery, battery surface images we acquired are applied into the current popular metal surface defect detection algorithms, and the performance index is analyzed. Both algorithms were developed with MATLAB (Version R2017b, MathWorks Inc., Natick, MA, USA) and Microsoft Visual Studio 2013 and operated in a computer with Windows system (CPU 3.6 GHz Intel Core i7, Memory 8 GB).

Experiments and the Analysis of Results
A total of 600 battery samples with 8192 10240 × pixels are divided into 5 groups and applied in our defection system to evaluate the effectiveness of the proposed algorithm. Figure 13 shows the experimental results of the proposed processing algorithm based on sub-regional Gaussian and MAF compared with other processing methods. Tables 1 and 2 illustrate critical data to demonstrate the superiority of the proposed algorithm. Table 1 shows the comparison of partition and traditional unpartitioned detection results, it means that the traditional method is to process horizontally or vertically on the whole picture directly, while the partition processing takes into account the uneven illumination distribution of the edge of the image, the vertical processing at the edge, and the horizontal processing inside image. Table 2 illustrates the accuracy rates and detection time with different concave and convex defect inspection methods, because there is almost no research on the surface defects of the battery, battery surface images we acquired are applied into the current popular metal surface defect detection algorithms, and the performance index is analyzed. Both algorithms were developed with MATLAB (Version R2017b, MathWorks Inc., Natick, MA, USA) and Microsoft Visual Studio 2013 and operated in a computer with Windows system (CPU 3.6 GHz Intel Core i7, Memory 8 GB).

Conclusions
This study investigates the method for battery surface and edge defect inspection, especially for the concave and convex defects that affect battery quality. Sub-regional Gaussian and MAF is innovatively proposed. The partition processing method fully considers the characteristics of uneven distribution of edge illumination, processing the image sub-region to improve the detection rate of edge defects. The proposed method has been proven to have higher defect detection accuracy and lower miss detection rate and performed very efficiently in edge defect detection compared with the traditional unpartitioned processing method which processes horizontally or vertically on the whole picture directly (Figure 13). Table 1 shows that the accuracy rates are approximately 20% higher than that obtained without the use of the partition processing algorithm. In addition, Table 2 summarizes the performances of our method and other recently reported metal surface defect inspection methods. It can be seen that our method exhibits a high accuracy and low detection time, which is comparable with the best results reported in the literature. Furthermore, our method has been applied to actual factory inspection; the detection speed required by the factory is four batteries per second, and the detection accuracy is not less than 92%. Therefore, some methods like local binary patterns (LBP), deep convolutional neural network(DCNN), and polynomial filtering do not satisfy the speed requirement although they meet accuracy requirement. The proposed method can satisfy both requirements in Visual Studio 2013, has better real-time performance and can guaranteed the accuracy. The results also show that the proposed method is effective in detecting metals surface defects and has further research significance.