Research on Feature Extraction and Classification Methods to Improve the Recognition Rate of Monomers Assembly Defects in Thermal Battery

In the assembly process of thermal battery monomers, problems such as inversion, wrong order, and missing collectors often occur. Defect detection is important for the normal use of thermal batteries. In order to improve the defect recognition rate, this paper proposes a feature extraction and classification method based on x-ray images. A new method is formed by combining Gray Level Co-occurrence Matrix and Local Binary Pattern, and improving the traditional Random Forest. Extract the gray texture of the monomer respectively by the Improved Gray Level Co-occurrence Matrix and Local Binary Pattern Equivalent Mode. Analyze the extracted results for serial feature fusion. The classification experiments are performed by Particle Swarm Optimized Random Forest Algorithm. The experimental results show that this method’s final defect recognition rate is 98.9%. It provides a new way to identify thermal battery defects accurately and is of great significance in improving the thermal battery defect identification rate.


I. INTRODUCTION
The thermal battery is a one-time reserve power source. It is widely used in the power supply equipment of nuclear weapons, missiles, and other weapon systems. In the manual assembly of thermal batteries, it is extremely easy to have internal assembly errors. These errors can lead to battery failure or even severe accidents such as spontaneous combustion and explosion. Hence, it is necessary to perform a defect inspection on the batteries inside the thermal battery. Since the inspectors cannot disassemble the battery, a nondestructive inspection method is required. The X-ray inspection system can provide a visual image of the internal structure non-destructively and perform defect detection through an algorithm.
At present, many scholars have carried out defect detection and analysis based on X-ray imaging technology. Lopez The associate editor coordinating the review of this manuscript and approving it for publication was Antonio J. R. Neves . et al. [1] used X-ray imaging technology to detect the defect location of parts in wire and arc-fed additive manufacturing. Yokoshima et al. [2] used a high-speed X-ray scanner to photograph lithium batteries and analyzed the runaway phenomenon due to an electrical short. Zhang et al. [3] proposed a defect identification and classification method based on X-ray images and grayscale scanning, which realized the identification and classification of thermal battery assembly defects. Chen [4] identified and classified battery cathode defects based on X-ray images and support vector machines. Thripuranthaka et al. [5] used 3D X-ray microtomography to estimate the nature of sulfur impregnation and distribution in lithium-sulfur batteries. Yi et al. [6] proposed a method to identify defects and structural deformations in Li-ion batteries based on CT, providing a practical scheme for parameter setting. Rahe et al. [7] proposed an aging anode defect analysis method for lithium batteries based on submicron CT imaging and image processing. Chen et al. [8] proposed a detection scheme based on CT technology to observe and VOLUME 10, 2022 This work is licensed under a Creative Commons Attribution 4.0 License. For more information, see https://creativecommons.org/licenses/by/4.0/ analyze lithium battery failures at low temperatures. Patel et al. [9] used CT technology to study lithium batteries' thermal failure characteristics and identify key features. Hou [10] proposed an X-ray-based detection and analysis method for the capacity decay of lithium batteries. Hao et al. [11] used in-situ synchrotron CT and image processing to observe and analyze the cracks of electrolyte sheets during battery electroplating. Yang et al. [12] proposed a lithium battery detection method that combines CT technology with an improved U-Net convolutional neural network and deep learning. Zhao et al. [13] proposed an image enhancement algorithm based on NSST and gradient-domain guided filtering. According to the above research status, X-ray imaging technology has made great progress in the field of defect detection, but there are some problems that cannot be ignored, they are as follows: 1) Currently, most commonly related technologies focus on analyzing rechargeable and dischargeable secondary batteries, and there are few studies on stacked primary batteries. Now, there is still a lack of an identification method for the problem of monomer defects in the thermal battery. 2) A defect identification method is lacking in the current thermal battery field. In most cases, the identification of thermal battery defects relies on manual disassembly of the shell and visual inspection of the thermal battery X-ray image.
Traditional image feature extraction and classification methods have problems such as difficulty identifying target regions, low algorithm adaptability, long model training time, and slow classification speed. Therefore, it is necessary to study a new defect feature extraction and classification method. The method should satisfy the non-destructive requirements for thermal batteries and the requirements of defect recognition rate. This paper proposes a feature extraction and classification method based on an X-ray imaging system, which combines feature extraction and defect recognition. Feature extraction is to extract the features of X-ray images with the equivalent mode of Improved Gray Level Co-occurrence Matrix (IGLCM) and Local Binary Pattern (LBP), and perform feature fusion on them by serial fusion method. Defect recognition is to send the fused features into a Random Forest (RF) classification model for training. In order to improve the classification performance, this paper introduces the Particle Swarm Optimization (PSO) to optimize the parameters of the traditional Random Forest (RF). The experimental results show that the method can accurately identify the monomer defect of the thermal battery and is of great significance for the improvement of the thermal battery fabrication process and the evaluation of safety and reliability.
The main innovations and contributions of this paper are as follows: 1) This article proposes a method for defect detection in stacked batteries. The inspection method eliminates the tedious operation of disassembling the battery case for traditional inspection and improves the inefficiency of manual visual inspection of X-ray images. 2) This article optimizes the feature extraction algorithm. This paper uses the IGLCM and LBP Equivalent Mode to extract features from the monomer images. The serial fusion mode fuses the extracted features. It achieves high feature extraction accuracy. 3) This paper optimizes the RF model. The RF model based on PSO classifies the extracted monomer features and realizes the identification of monomer defect types. This paper firstly presents the research status of related works and innovative work of this paper, the remainder is structured as follows: Section II analyzes the structure of the monomer and its detection system. In Section III, algorithm fusion is performed on the equivalent mode of IGLCM and LBP. Section IV uses PSO to optimize the RF. Section IV is to carry out the monomer classification and recognition experiment. Section VI is the conclusion.

II. MONOLITHIC STRUCTURAL INSPECTION SYSTEMS
X-ray imaging systems are widely used in industrial nondestructive testing due to their rapidity and visualization. Such detection systems can convert the differences in the internal structure of a substance into a visible image to visualize the structure of the defective part of the object under test. X-rays interact with matter in the process of penetrating objects, resulting in changes in intensity due to absorption and scattering. These different intensities of X-rays are captured and imaged, resulting in images of varying contrast [14]. The detection process of the imaging system is shown in Figure 1. Due to the different properties of the internal materials of the thermal battery, the transmitted ray intensity of X-rays after passing through the battery is different. These rays, which contain information about the internal structure, are converted into visible light and are captured by a flat panel detector. Then output the thermal battery image [15]. The thermal battery, also known as the molten salt battery, is a disposable storage power source with no energy output in the reserve state. The self-heating system ignites the uniformly distributed heating paper inside the thermal battery by mechanical or electrical signal activation to generate energy. This causes the internal temperature of the thermal battery to rise rapidly, melting the non-conductive solid salt electrolyte into a liquid conductive state and outputting electricity simultaneously. Its main components include shell, cover body, ignition head, terminal, battery stack, heating system, insulation system, etc. [16], as shown in Fig. 2(a). As the core structure of the thermal battery, the battery stack is mainly composed of several battery monomers (hereinafter referred to as ''monomers'') in series and parallel. The monomer is the smallest unit in the thermal battery chemical system. A monomer is usually composed of four layers of materials. From top to bottom, negative electrodes, electrolytes, positive electrodes, and heating plates correspond to different grayscales in X-ray images, as shown in Fig. 2(b). A layer of stainless steel current collector separates the monoliths. The current collector can effectively isolate the heating powder and the negative electrode to prevent the monomers from overlapping each other, so the length of the current collector in the production process is slightly larger than other lamellae in the monomer [17].
The internal assembly features of the thermal battery are mainly concentrated in the battery stack area. Currently, most domestic thermal battery assembly is manual semi-automatic pressing assembly, and mistakes are inevitable in the implementation process. The four-layer sheet of each monomer is manually powdered by hand with powder and then covered with a layer of collector, forming a ''five-layer monolith'' structure. During the assembly process, there are three main assembly errors in this ''five-layer monomer'': overall inverted, wrong assembly sequence, and lack of current collectors, all of which may lead to poor monomer response. The diagram of thermal battery monomer assembly defects is shown in Figure 3.
According to the hidden dangers and defects in the above-mentioned thermal battery assembly process, assembly features to be inspected inside the thermal battery can be determined. The internal assembly features of the thermal battery are mainly concentrated in the monomer region of the battery stack. For the collected X-ray images, the monomer part is positioned and segmented. After image pre-processing, suitable feature extraction algorithms and classifiers need to be selected for the classification and identification of the assembly defects existing in the monomer. Extraction algorithms and classifiers are used for classification and recognition. Therefore, this paper proposes to optimize the feature extraction method by serial fusion and improve the RF method by PSO for defect identification. It fills the gap in existing research on thermal battery detection methods and enriches the research content of feature extraction and classification methods. The overall flow of this paper is shown in Figure 4.

III. FEATURE EXTRACTION ALGORITHM AND FUSION
As can be seen from the X-ray images, the greyscale of the monolithic four-layer sheet layers is arranged in a certain pattern, and there are differences in the greyscale distribution between the different assembly types. If the local properties within the image change slowly or approximately periodically, it can be called texture. The texture is an image feature that reflects the spatial distribution properties of pixels. It is one of the most important features in image applications [18], usually exhibiting local irregularities but macroscopic regularities. Extracting representative gray texture features is an important part of monomer feature analysis, which directly impacts subsequent classification accuracy, computational efficiency, and robustness. This paper uses two more classical extraction methods for monomer features: the GLCM based on the overall gray level anaysis and LBP based on the local gray level analysis.

A. IGLCM
The Gray Level Co-occurrence Matrix (GLCM) is the basis of texture feature extraction [19], a matrix function of pixel distance and angle.
Let the pixel point (x, y) move on the whole image, then form (i, j) composed of different grayscale values. Let N g be the image's gray level, and then there are N 2 g combinations of (i, j). Traverse the whole image, count the number of occurrences of each (i, j), and form a matrix, the gray-level co-occurrence matrix, which is represented by P d (i, j). The pixel pair distribution is shown in Figure 5.
Different grayscale co-occurrence matrices are generated by different θ and d, with θ often chosen to be 0 • , 45 • , 90 • , and 135 • . Then, after determining d, the following  gray-level co-occurrence matrix can be obtained, as shown in formula (1), at the bottom of the page. N g , is directly affects the dimension of the gray level co-occurrence matrix. For an image with a gray level of 256, according to the above theoretical calculation, the elements in the gray level co-occurrence matrix will reach 65536, and the amount of calculation is large. To solve this problem, the grey levels are usually compressed, and the formula is shown in equation (2).
where, INT represents the rounding operation, f M is the grayscale before compression, and N g is the grayscale after compression. Usually, N g is set to 16, that is, the grayscale is reduced from 256 to 16, which significantly reduces the dimension of the grayscale co-occurrence matrix. The extraction works best through multiple experiments on a single image when the step size d is 2 pixels away. In addition, the grayscale of the monomer is distributed vertically from top to bottom, its horizontal grayscale is unchanged, and the texture has obvious directionality, so this paper only calculates its 90 • grayscale co-occurrence matrix.
Since the gray level co-occurrence matrix cannot directly reflect the texture features between different images, Haralick uses quadratic statistics to calculate the matrix and obtains 14 statistical features [20]. In this paper, considering the respective meanings of secondary statistics, the following five commonly used statistics are selected to describe the texture features of thermal battery images [21].

Inverse Different Moment (IDM):
Each of the four representative single images is selected, and its grayscale co-occurrence matrix is calculated. The results are shown in Figure 6. Then, multiple images were selected to calculate the above five statistics, and the results were analyzed. It was found that the difference between the inverted and the standard monomer was slight in these five parameters and could not be effectively distinguished. Therefore, it is necessary to improve GLCM, starting from the grayscale co-occurrence matrix itself, and study new parameters to distinguish the difference between inverted defects and other assembly types.
Observing the four types of gray-level co-occurrence matrices in Figure 6, it can be seen that in the gray-level cooccurrence matrix of the overall inverted defect, the sum of the elements of the upper triangular part of the main diagonal (excluding the main diagonal) is significantly smaller than the sum of the elements of the lower triangular part. While the former is substantially larger than the latter for the other three assembly types. Therefore, a new parameter, R, is designed to judge the difference between the inverted and the other three, the formula is as in (12).
R represents the ratio of the sum of the elements of the upper triangular part of the main diagonal (excluding the main diagonal) to the sum of the elements of the lower triangular part (excluding the main diagonal). The relationship between R and 1 is judged as the basis for distinguishing defect types: when R is less than 1, it is an inverted defect; when R is greater than 1, it is not an inverted defect. This paper selects two images with darker gray and two with lighter gray for each assembly type to calculate the five original quadratic statistics and the R-value of the IGLCM. The calculation results are shown in Table 1.
As seen in Table 1, the different types of monomers have apparent differences in some statistical parameters of GLCM. The IDM of the wrong-sequence monomer is generally smaller than the other three. The two parameters of COR and ENT of the missing collector piece are different from those of the other three, which can be further distinguished by combining these two parameters. The R-value of the overall inverted monomer is significantly different from the R values of the other three, which can be well distinguished from the other three. In addition, R can also reflect the texture trend of grayscale. When R > 1, the longitudinal texture grayscale shows a movement from light to dark and vice versa. Therefore, the IGLCM in this paper can extract monomer assembly features more comprehensively.

B. LBP EQUIVALENT MODE
Local Binary Pattern (LBP) is a texture feature extraction algorithm proposed by Ojala, M. Pietikäinen, and  D. Harwood [22]. Differences in the environment during monomer collection will cause the grayscale of the same type of monomers to appear brighter or darker. Since LBP is insensitive to grayscale changes, it can better extract monomer texture features with lighter or darker overall grayscales.
The original LBP algorithm takes the grayscale at the center of a window of size 3 × 3 as the threshold. If the grayscale of the adjacent pixel is greater than the threshold, it is recorded as 1; otherwise, it is 0. Nevertheless, primitive operators have limited description ability. Therefore, this paper adopts an improved LBP operator: replace the original square neighborhood with a circular neighborhood of any size. The schematic diagram of the LBP circular operator is shown in Figure 7. And the definition of the LBP circular operator is shown in formula (13).
where, LBP ri P,R is the new LBP operator, and the ROR(x, i) function represents the cyclic right shift of x by i bits.
According to the above definition, when there are P sampling points in the neighborhood of the LBP operator, there are 2 P kinds of corresponding binary patterns. With the increase of sampling points, the corresponding pattern increases exponentially, and the amount of data is enormous, which is not conducive to the subsequent feature identification and classification.Thus, this paper adopts LBP's ''Uniform Pattern'' to solve the above problems [23].
A transition refers to from 0 to 1 or from 1 to 0. When the cyclic binary number corresponding to a certain LBP has at most two transitions, the corresponding binary is called an equivalent mode class, and the rest are all classified as mixed mode classes U LBP P,R is defined as formulas in (14) and (15).
U LBP P,R = s g p−1 − g c − s (g 0 − g c ) where riu represents that the number of jumps is less than two times, all modes satisfying U ≤ 2 are called equivalent modes, and the rest are mixed modes. In this way, the LBP mode is directly reduced from the original 2 P to P(P − 1) + 2 + 1, dramatically reducing the feature vector's dimension.
In this paper, the LBP Equivalent Model is used to extract the grayscale texture of the monomer. Firstly, a single image with a size of 50 × 60 is divided into 5 × 6 = 30 sub-regions, using a circle with a neighborhood radius R = 1 and a total number of adjacent pixels P = 8LBP 1,8 to the monomer. The image is processed to obtain the LBP image, as shown in Figure 8.
Then calculate the LBP statistical histogram of each subregion, normalize it, and connect it to a feature vector to obtain the LBP texture feature vector of the entire image.

C. FEATURE FUSION
From the above analysis, it can be seen that the greyscale co-occurrence matrix is mainly biased towards the description of overall texture features. At the same time, the LBP is primarily little towards describing local texture features. There is a specific complementary relationship between the two [24]. An image can be described more comprehensively if the two methods are fused, thereby improving the accuracy of subsequent classification and recognition.
The feature fusion method generally includes serial fusion and parallel fusion. The serial fusion method can fully retain all the extracted information, improving the recognition rate. The process is simple and requires less computation [25]. Therefore, this paper adopts the serial fusion method to fuse the features extracted from the IGLCM and the LBP.
Serial fusion directly merges multiple features extracted from the same sample after processing. The basic idea is: Assuming that A and B are a pair of normalized feature vectors on the sample space , for any sample in ξ ∈ mode, the corresponding two feature vectors are set as α A, and β B, respectively, and the fused feature is γ = (α, β) T . In this paper, the two feature vectors extracted by IGLCM and LBP are normalized by the above serial fusion method using a procedure to string them into a set of data, i.e., 5 * 1 and 1770 * 1 are strung together into a set of 1775 * 1. Finally, a set of 1776-dimensional feature vectors is obtained, which are fed into the classifier to be introduced in the following section for classification experiments.

IV. RANDOM-FOREST ALGORITHM OPTIMIZATION
Ensemble Learning combines the classification results of a single primary classifier to obtain a better classification model [26]. The most commonly used methods in ensemble learning are Bagging and Boosting [27]. As the most representative algorithm in Bagging ensemble learning, RF can efficiently process large data sets and solve various practical classification problems. Therefore, this paper uses the RF to classify and identify single assembly types.
Random Forest (RF) is an ensemble algorithm based on decision trees [28]. Its training phase can be described as follows: Suppose there are M decision attributes in the overall sample space, and each decision tree is constructed using Bootstrap to extract from the data set. Some samples from a subspace, that is, m attributes, are randomly selected to build a decision tree. During this process, the value of m remains unchanged. Finally, the voting results of each tree are aggregated to output the final classification result. The schematic diagram of RF classification is shown in Figure 9.
When the training sample set is the same, the key factors affecting the classification performance of RF are the number of decision trees n, and the number of split attribute features m randomly selected when generating a decision tree. These two parameters are described as below: The final generated decision tree n: If n is too small, the model's performance will deteriorate, and the classification error will be enormous. When n increases gradually, according to the law of large numbers [29], it isn't easy to appear over-training. The classification performance tends to be stable when n reaches a particular value, a larger n will increase the time cost and waste resources. Therefore, it is necessary to find an acceptable n value within a specific range while ensuring high classification accuracy.
The number m of split attribute features: m represents the subset size of the total attributes randomly selected when the RF node is split. Its value is usually much smaller than the total number of attributes in the dataset M [30]. If m increases, the classification performance of each tree can be improved. However, the similarity between trees becomes high, leading to a decrease in overall classification performance.
The above analysis shows that the number of decision trees n and the number of split attribute features m are two important parameters that affect the performance of RF classification, and the settings of the two directly affect the output of the entire model. However, these two parameters can only be selected through experience or multiple experiments. This paper improves the RF by introducing the PSO.
Particle Swarm Optimization (PSO) is an intelligent optimization algorithm to find optimal parameters [31]. The basic principle is as follows: In an M -dimensional space, there is a populationwith the number of particles L, and the position vector of the i-th particle in the population is After substituting x i into the objective function, the solution of the particle is evaluated, and P i = (P i1 , P i2 , . . . P id ) is obtained by iteratively solving the i-th particle. The individual extreme value P best of the particle can be obtained. Then the global extreme value g best is obtained from the best position of the population P g = P g1 , P g2 , . . . P gd . The calculation formulas of particle swarm velocity and position during loop iteration are shown in equations (16) and (17), respectively. (16) x id = x id + v id (17) where, ω is the inertia weight; c 1 and c 2 are the acceleration constants, and rand() refers to the random function of fluctuation in the limited interval, which is fixed in the interval [0, 1]. The process of Particle Swarm Optimized Random Forest (PSO-RF) is shown in Figure 10.
In this paper, the accuracy, precision, recall, and F1-Score are used as the performance evaluation metrics of the classifier. If the total number of samples is N , N = TP+TN +FP+ FN . Among them TP: judging the correct batteries as the correct batteries; TN : judging a defective cell as a defective cell; FP: misjudge the defective batteries as the correct batteries; FN : misjudge the correct batteries as the defective batteries. The calculation formulas of the classification performance evaluation index are as follows. Accuracy: Precision: Recall: F1-Score:

V. EXPERIMENTAL VERIFICATION AND ANALYSIS
Aiming at the X-ray images of thermal battery batteries, to verify the algorithm's effectiveness in this paper, three different thermal batteries are tested and analyzed. The image processing section uses Intel's open-source computer vision library OpenCV. The software development platform is Visual Studio and the programming language is C++.

A. EXPERIMENTAL VALIDATION OF FEATURE FUSION
In order to verify the validity of the fused features, this paper compares the algorithm after the fusion of IGLCM and LBP Equivalent Model with IGLCM, LBP and Hu-Moment and Template Matching Based on Grayscale for experiments. For each of the four single-body images, 240 images were selected, and a total of 960 images were used for experiments. The feature parameters extracted from the above methods are sent to the RF classifier mentioned below to make classification decisions for individual monomer types. Among them, the parameters of the RF are selected according to the empirical value. Here, the number of decision trees is set to 100, and the number of split attribute features is usually log 2 (M ) + 1, where M refers to the total number of attributes in the data set. Here, the number of split attribute features is set to 12.
The other parameters were selected mainly by referring to the literature [32] for their settings. In the experiment, the average of 20 results is taken as the final accuracy, and the results are shown in Table 2.
It can be seen from Table 2 that the recognition accuracy of the feature vector after the fusion of the two is better than the extraction effect of a single algorithm. At the same time, it is more accurate than Hu-Moment and Template Matching Based on Grayscale. Among them, Hu-Moment extract the shape features of monomer, which cannot detect the overall inverted defects due to its rotation invariance. Although the Template Matching is comprehensive, it can detect all assembly defects, but its detection accuracy is lower than IGLCM and LBP. In addition, the recognition accuracy of the IGLCM for standard monomer and the overall flip chip is higher than that of the LBP. The recognition accuracy of the LBP for the wrong order and the lack of a collector chip is slightly higher than that of the IGLCM. After analysis, compared with GLCM, LBP is less sensitive to grayscale and can ensure a better feature extraction effect when processing bright or dark images, especially in the wrong extraction order and lack of features of the single collector chip, when the LBP algorithm is more adaptable and robust.
It can also be seen in Table 2 that the recognition rate of the overall inverted and the wrong order is relatively high, mainly because the grayscale distribution of the overall inverted monomer is rather apparent. The grayscale texture step of the wrong-order monomer is more significant. That is, it is said that the grayscale characteristics of the two are pretty obvious and relatively easier to distinguish. In addition, the above algorithms have relatively poor recognition effects for the lack of collector pieces. After analysis, the main reason is that some collector pieces are too subtle and easily confused with their adjacent slices, resulting in misjudgment.

B. PSO-RF METHOD PERFORMANCE TEST
The PSO selects two parameters in the RF for an experiment. Let the RF initial parameters n and m be 100 and 12, respectively. In accordance with the general experience of using the particle swarm algorithm, the parameters for a sample of 1000 are chosen as follows. The particle swarm size is 3, the number of population updates is 30, the learning factor c 1 = c 2 = 2, the maximum number of iterations is 1000, and the training stops when the error is less than 0.005 or the number of iterations is greater than 1000.
Finally, the number of decision trees, n, is 30, the number of split attribute features m is 7, and other parameters are set refer to the literature [32]. The optimized RF is  experimentally verified, and 250 pieces of regular, flipped, wrong order, and missing collector pieces are extracted from the sample library, totaling 1,000 pieces. The hold-out method was used for validation, seventy percent of the data set was used as the training set, and the remaining thirty percent was used as the test set. The feature vector fused in Section 3.3 is input into the RF algorithm for training and prediction, and the classification result is shown in Figure 11.
It can be seen from Figure 11(a) that the algorithm can reduce the error to 0.01 in 12 iterations and reach the specified iterative error value in 30 iterations. According to the classification confusion matrix in Figure 11(b), it can be obtained that the classification accuracies of normal monomers, flipped chip, wrong order, and missing collector chip are 98.7%, 100%, 100%, and 98.7%, respectively. Among them, the recognition results of single inversion and wrong order are higher. The main reason is that the difference is noticeable, the feature vector has a significant degree of discrimination, and RF can classify them with high precision. The classification accuracy of normal monomers and missing current collectors is relatively low, mainly because the features of some current collectors are too subtle or the grayscale of their adjacent layers is similar, so it is easy to confuse the missing current collectors and normal monomers.

C. MONOMER FEATURE EXTRACTION EXPERIMENT
In order to verify the effectiveness of the single assembly feature extraction method, this paper randomly selects 300 battery image samples for each of the three types, a total of 900 pieces. We use the IGLCM, LBP, IGLCM, and LBP fusion algorithms to perform feature extraction comparison experiments. We adopt PSO-RF as a classifier, and its corresponding parameters are same as the PSO-RF method performance test in 5.2. The average recognition accuracy of each assembly feature is obtained by taking the average of multiple experiments. The experimental results are shown in Figure 12.
Then, according to the results in the figure, the average recognition accuracy of each assembly feature is calculated, and the statistical results are shown in Figure 13. It can be seen from Figure 13 that the IGLCM is better than LBP in recognition of standard monomers and inverted monomers, and the LBP is better than GLCM in recognition of order errors and lack of current collectors.
Combining the statistical results in Figure 12 and Figure 13, it can be seen that the improved algorithm after the fusion of IGLCM and LBP has improved the recognition accuracy of the four types of assembly features to a certain extent compared with the single algorithm. In addition, the IGLCM and LBP have relatively high recognition accuracy for assembly order errors, mainly because their internal grayscale steps are giant, making them easier to distinguish. However, the two algorithms have relatively low recognition rates for the lack of collector sheet defects.
After analysis, it is found that some of the wrongly identified monomers have rather subtle internal collector pieces. Even after morphological processing, some collector pieces still do not have a high degree of discrimination with their adjacent areas, so classification errors are more likely to occur, resulting in incorrect features being extracted. The calculation and analysis show that the overall recognition accuracy of the fusion algorithm for the three types of batteries with reversed monomers, wrong order and lack of current collectors is 99.4%, 99.8%, and 98.6%, respectively, which can meet the corresponding detection requirements.

D. MONOMER CLASSIFICATION AND RECOGNITION EXPERIMENT
To verify the classification effect of PSO-RF, we compared its classification performance with that of RF. We randomly VOLUME 10, 2022     Calculate according to Equation (18)(19)(20)(21), in which the accuracy rate is calculated according to the number of correct overall identification. The accuracy rate is calculated by the weighted Calculate according to the above formula, in which the accuracy rate is calculated according to the number of correct overall identification. The accuracy rate is calculated by the weighted value average of the accuracy rate of each category. The size of the weight is determined according to the proportion of each type. The remaining parameter is the same. Finally, the F1 value is calculated from the relevant numerical values. The final obtained classifier performance comparison results and classification experimental results are shown in Table 3 and 4, respectively.
It can be seen from Table 3 that the classification performance of PSO-RF is better than that of traditional RF, and higher classification accuracy can be achieved for the four monomer types. In addition, the two have no significant difference in the test time. Still, the training time of the optimized RF is shortened. The main reason is that the optimized RF speeds up the running speed after the optimal parameters are selected, thus avoiding the waste of resources.
By comparing and evaluating the classification results in Table 4, it can be seen that the recognition accuracy of PSO-RF is higher than that of BP Neural Network, CART and RF for the four monomer types. Tables 3 and 4 demonstrate the effectiveness of the PSO-RF proposed in this paper.
The PSO-RF was used to classify the three kinds of batteries A, B, and C. 400 batteries were selected for each battery.
A total of 1200 batteries were used for the experiment. The information on the relevant data set for this experiment is shown in Table 5.
In this paper, we study the defect detection of three different models of thermal batteries. For easy differentiation, we use A, B and C to indicate the corresponding models. The three types of thermal batteries are all sheet-like structures inside, assembled by multi-layer monolithic cells. The four-layer monolithic cells in model A and model B are inseparable as a whole. However, each layer of model C thermal battery is independent, and the monomer thickness is different from the other two models.
Here, the false detection rate, missed detection rate, and accuracy rate is used as detection indicators. Let the total number of test samples be M . Missing detection refers to misjudging defective batteries as correct batteries, and the number is denoted as N f ; false detection refers to misjudging correct batteries as defective batteries, and the number is denoted as N l ; the number of correctly classified batteries is denoted as N p . The calculation formulas of the above indicators are as follows: where, R f represents the miss detection rate; R l represents the error detection rate; R p represents the accuracy rate.
The experimental results are shown in Table 6. It can be seen from Table 6 that the detection accuracy of the monomer classification and identification algorithm for the three batteries can reach more than 98.8%, and the average accuracy is 98.9%. The overall recognition accuracy is high and meets the detection requirements. In addition, the algorithm has an average false detection rate of 0.8% for normal cells, and an average missed detection rate of 0.3% for defective cells. That   is, the leakage detection rate of the faulty battery is low, which meets the requirements of industrial detection.
By analyzing the images of the wrongly detected and missed batteries, it can be seen that these single cells are mostly located in the upper part and lower part of the battery. Because when imaging X-ray, the upper part and the lower part will have certain overlapping parts, as shown in Figure 14.
At the same time, defects are more often detected in the first single cell and the last single cell position by mistake. The reason is that the upper or lower part of the battery stack of the hot battery has the structure of fixed battery stack, which will be more or less partitioned in when segmenting the image, resulting in incomplete segmentation of the battery stack, as shown in Figure 15. In addition, the quality and clarity of x-ray imaging and the image acquisition environment will also affect the classification results.

VI. CONCLUSION
This paper takes the X-ray image of the thermal battery cell as the analysis object. Given that the target area is difficult to identify, the algorithm adaptability is not high, and the recognition accuracy rate is low when the X-ray images are processed in subsequent processing, a thermal battery monomer defect detection method is studied. The defect detection method is used for feature extraction and identification of three defect types in thermal battery monomers. In order to improve the accuracy of feature extraction, the algorithm optimization of GLCM and LBP is carried out. Using the IGLCM and LBP Equivalent Model to extract the texture features of the single body, analyze the extraction characteristics of the two algorithms, and perform serial feature fusion of the feature extraction results. The experimental results show that the improved algorithm after fusion of IGLCM and LBP improves the recognition accuracy of inverted monomers, wrong order, and lack of current collectors, which are 99.4%, 99.8%, and 98.6%, respectively. Aiming at the low performance of the RF algorithm, the PSO is used to optimize the parameters of the RF, and the PSO-RF is used to classify and identify the fused feature vectors. Then the classification results are compared with RF, BP Neural Network and CART. Through the experimental verification, the classification accuracy and operation speed of PSO-RF are improved by experimental verification. Finally, a monomer defect classification model with an average recognition rate of 98.9% is obtained. Then, three kinds of batteries were used to carry out the monomer classification and identification experiment. The average detection accuracy, false detection rate, and missed detection rate were 98.9%, 0.8%, and 0.3%, respectively. The detection accuracy was high, which verifies the correctness of the algorithm in this paper. And effectiveness, providing a feasible solution for identifying internal assembly features of thermal batteries. The defect-recognition rate of the thermal battery monomer assembly is effectively improved, and the safe and effective use of the thermal battery is ensured.