Inspection Algorithm of Welding Bead Based on Image Projection

: The shear reinforcement of dual-anchorage (SRD) is used to enhance the safety of reinforced concrete structures in construction sites. In SRD, welding is used to create shear reinforcement, and after production, a quality inspection of the welding bead is required. Since the welding bead of SRD is inspected for quality by measuring both horizontal and vertical lengths, it is necessary to obtain this information for quality inspection. However, it is difﬁcult to inspect the quality of welding beads using existing methods based on segmentation, due to the similarity in texture between the welding bead and the base material, as well as discoloration around the welded area after welding. In this paper, we propose an algorithm that detects the welding bead using an image projection algorithm for pixels and classiﬁes the quality of the welding bead. This algorithm detects the position of welding beads using the brightness values of an image. The proposed algorithm reduces the amount of computation time by ﬁrst specifying the region of interest and then performing the analysis. Results from experiments reveal that the algorithm accurately classiﬁes welding beads into good or bad classes by obtaining all brightness values in the vertical and horizontal directions in the SRD image. Furthermore, comparison tests with conventional algorithms demonstrate that the classiﬁcation accuracy of the proposed algorithm is the highest. The proposed algorithm will be helpful in the real-time welding bead inspection ﬁeld where fast and accurate inspection is crucial.


Introduction
Shear reinforcement, such as SRD, is used in reinforced concrete structures to prevent shear failure during construction. As shown in Figure 1, the SRD is composed of three base materials that are welded together at the left, right, and center positions. This requires welding to be performed at four positions on the SRD, as illustrated in Figure 2. As shown in Figure 3, the SRD is produced by welding using a robot, and the welding quality is inspected after it is moved to the inspection table. The quality of the welding is determined by several parameters during the welding process, such as optimal voltage, current supply, amount of gas, welding time, and base metal geometry [1]. If any of these factors are not appropriate, they can have a negative impact on the productivity, competitiveness, and safety of the final product. Therefore, welding quality inspection is essential to determine whether a product is good or bad. There are various methods to inspect the quality of welding bead, including visual inspection, radiographic inspection, liquid penetrant inspection, and ultrasonic inspection [2][3][4][5]. Visual inspection is direct examination by human eyes. This can reduce the reliability of the product and take a long time, as the inspection results can vary depending on the inspector's experience. However, it is still commonly used. Radiographic inspection is a non-destructive inspection technique that is effective in identifying and analyzing internal defects within a welding bead. It has relatively high resolution and can detect small defects inside the welding bead. However, there is a risk of safety issues due to the use of radiation. Ultrasonic inspection is a widely used non-destructive inspection technique that provides high sensitivity and precision, making it capable of detecting even small defects. The disadvantage of this method is that it requires trained personnel to operate the equipment. This is because its accuracy may be compromised if performed by an inexperienced inspector. Furthermore, a limitation of using ultrasonic inspection is that undetectable defects may arise depending on the shape or thickness of the welding bead. Recently, various methods have been proposed to analyze the quality of welding beads using image processing techniques such as segmentation and machine learning [6][7][8][9][10][11][12][13][14][15][16][17][18][19][20][21][22][23][24][25]. Segmentation algorithms are utilized to detect and inspect only the welding bead areas in images. Moreover, machine learning-based methods are utilized to evaluate the quality of the welding bead by using models trained on various welding bead shapes. However, this task is still challenging. This is because the texture of the welding bead and base metal is similar, and discoloration occurs around the bead after welding. This interference can compromise the accurate detection of welding beads. Therefore, there are limitations to using segmentation and machine learning algorithms for inspecting the quality of welding beads.
Electronics 2023, 12, x FOR PEER REVIEW 2 of 17 fective in identifying and analyzing internal defects within a welding bead. It has relatively high resolution and can detect small defects inside the welding bead. However, there is a risk of safety issues due to the use of radiation. Ultrasonic inspection is a widely used non-destructive inspection technique that provides high sensitivity and precision, making it capable of detecting even small defects. The disadvantage of this method is that it requires trained personnel to operate the equipment. This is because its accuracy may be compromised if performed by an inexperienced inspector. Furthermore, a limitation of using ultrasonic inspection is that undetectable defects may arise depending on the shape or thickness of the welding bead. Recently, various methods have been proposed to analyze the quality of welding beads using image processing techniques such as segmentation and machine learning [6][7][8][9][10][11][12][13][14][15][16][17][18][19][20][21][22][23][24][25]. Segmentation algorithms are utilized to detect and inspect only the welding bead areas in images. Moreover, machine learning-based methods are utilized to evaluate the quality of the welding bead by using models trained on various welding bead shapes. However, this task is still challenging. This is because the texture of the welding bead and base metal is similar, and discoloration occurs around the bead after welding. This interference can compromise the accurate detection of welding beads. Therefore, there are limitations to using segmentation and machine learning algorithms for inspecting the quality of welding beads.  fective in identifying and analyzing internal defects within a welding bead. It has relatively high resolution and can detect small defects inside the welding bead. However, there is a risk of safety issues due to the use of radiation. Ultrasonic inspection is a widely used non-destructive inspection technique that provides high sensitivity and precision, making it capable of detecting even small defects. The disadvantage of this method is that it requires trained personnel to operate the equipment. This is because its accuracy may be compromised if performed by an inexperienced inspector. Furthermore, a limitation of using ultrasonic inspection is that undetectable defects may arise depending on the shape or thickness of the welding bead. Recently, various methods have been proposed to analyze the quality of welding beads using image processing techniques such as segmentation and machine learning [6][7][8][9][10][11][12][13][14][15][16][17][18][19][20][21][22][23][24][25]. Segmentation algorithms are utilized to detect and inspect only the welding bead areas in images. Moreover, machine learning-based methods are utilized to evaluate the quality of the welding bead by using models trained on various welding bead shapes. However, this task is still challenging. This is because the texture of the welding bead and base metal is similar, and discoloration occurs around the bead after welding. This interference can compromise the accurate detection of welding beads. Therefore, there are limitations to using segmentation and machine learning algorithms for inspecting the quality of welding beads.    In this paper, we propose an algorithm for quality inspecting welding beads using image processing techniques. The algorithm detects the welding bead region by utilizing an image projection algorithm that analyzes the brightness of the welding bead, and categorizes good and bad welding beads in order to inspect the quality. The proposed algorithm reduces the computational cost by testing only the region of interest (ROI) in the image. Additionally, unlike many segmentation methods that require creating a mask followed by quality testing that involves measuring the length of the welding bead, the proposed algorithm omits this process resulting in relatively faster calculation. Furthermore, the algorithm statistically analyzes the brightness values in all directions within the ROI, which improves the detection accuracy of both the horizontal and vertical lengths, critical parameters in welding bead inspection. The remainder of this paper is organized as follows: Section 2 introduces conventional methods of segmenting the welding bead area in the image. Section 3 describes the algorithm proposed in this paper, and Section 4 presents the experimental results obtained using the proposed and existing algorithms. Finally, Section 5 presents the conclusions of this study.

Related Works
Various methods, such as segmentation and machine learning, have been proposed to inspect the quality of welding beads. Among these methods, the K-means is used to divide similar objects into clusters and has the advantage of being easy to apply. A study has been published on segmenting areas of interest in magnetic resonance imaging (MRI) using iterative Gaussian filtering, Canny edge detection, and Chan-Vese segmentation In this paper, we propose an algorithm for quality inspecting welding beads using image processing techniques. The algorithm detects the welding bead region by utilizing an image projection algorithm that analyzes the brightness of the welding bead, and categorizes good and bad welding beads in order to inspect the quality. The proposed algorithm reduces the computational cost by testing only the region of interest (ROI) in the image. Additionally, unlike many segmentation methods that require creating a mask followed by quality testing that involves measuring the length of the welding bead, the proposed algorithm omits this process resulting in relatively faster calculation. Furthermore, the algorithm statistically analyzes the brightness values in all directions within the ROI, which improves the detection accuracy of both the horizontal and vertical lengths, critical parameters in welding bead inspection. The remainder of this paper is organized as follows: Section 2 introduces conventional methods of segmenting the welding bead area in the image. Section 3 describes the algorithm proposed in this paper, and Section 4 presents the experimental results obtained using the proposed and existing algorithms. Finally, Section 5 presents the conclusions of this study.

Related Works
Various methods, such as segmentation and machine learning, have been proposed to inspect the quality of welding beads. Among these methods, the K-means is used to divide similar objects into clusters and has the advantage of being easy to apply. A study has been published on segmenting areas of interest in magnetic resonance imaging (MRI) using iterative Gaussian filtering, Canny edge detection, and Chan-Vese segmentation methods with K-means [6]. Other studies have also used K-means for image segmentation using RGB and HSV color spaces [7]. Khrissi et al. in [8] introduced a new image segmentation method based on clustering, optimized by the Sinus Cosine Algorithm (SCA) meta-heuristic algorithm. Qiao et al. in [9] applied and compared various segmentation methods, including the Otsu algorithm, K-nearest neighbors (KNN), Grabcut, and K-means, to segment rock core images of geological data, and showed that K-means performed the best. Furthermore, a study proposed a convolution-based modified adaptive K-means (MAKM) approach to divide an image so that performance does not depend on the initially set parameters [10]. Another study proposed an image segmentation method using an adaptive K-means algorithm [11]. However, K-means has the disadvantage of being sensitive to outliers, and the results may vary depending on the number of clusters pre-defined by the user. KNN is an unsupervised learning method that classifies data with similar properties into K clusters, similar to K-means. Various studies have proposed using KNN in different fields, such as medicine, marketing, character and face recognition. For example, a study used S-KNN to detect areas of interest, background, and ambiguous areas [12], and another study compared and analyzed image segmentation results using KNN and histograms for the leaf image data of crops [13]. Additionally, a study used the texture features of plant leaf for the classification of plant leaf disease images [14]. However, KNN has the disadvantage of requiring a large amount of computational time, making it difficult to apply in real-time inspections that require the quality to be determined in a short time. Grabcut is an algorithm that segments objects and backgrounds by minimizing the energy function in the distribution of a designated area in an image. Recently, there have been studies on image segmentation using Grabcut, such as a study that detected areas of interest using a hybrid segmentation method combining adaptive K-means and Grabcut [15], and a study that segmented cancer in images using Mask R-CNN and Grabcut [16]. However, the accuracy of Grabcut may be poor when the background in the image is complicated or the object and background are similar. In addition, repetitive tasks are required to obtain optimal results, resulting in a long processing time. Thus, good results are not expected since the welding bead has a similar color to the base metal corresponding to the background, and there are still limitations in computational speed compared to other algorithms [17]. Recently, deep learning methods have been proposed for image segmentation, and among them, U-Net belongs to the class of encoder-decoder-based models such as auto-encoder [18]. The initial drawback of U-Net is that during the encoding phase, it undergoes dimension reduction, leading to the loss of detailed positional information on image objects. In the decoding phase, only low-dimensional information is utilized, which can lead to the inability to recover the positional information loss. However, the research on UNET has indeed seen significant improvements through the incorporation of shortcuts. Nevertheless, U-Net still requires a large number of training samples to achieve good performance, which may not always be feasible in some applications for welding bead inspection.
The morphological geodesic active contour method is a combination of the morphological snakes introduced in [19] and the geodesic active contour in [20]. This method segments the area of interest by expanding the gradually developing contour. Recently, Mlyahilu et al. in [21] proposed a segmentation method using the morphological geodesic active contour algorithm with the histogram equalization method to normalize the distribution of the welding bead image, as shown in Figure 4. One disadvantage of the morphological geodesic active contour method is that the area parameters need to be adjusted appropriately when creating a bounding box for segmentation. However, if the same parameters are used for all welding bead images, it is possible that the welding bead may not be detected accurately. For example, as shown in Figure 4, in (a) the bright floor is detected, and in (b-d) the welding bead and base metal regions are segmented together. In particular, the entire welding bead area is not detected in (c,d). Therefore, the method may not be suitable for real-time inspection. Binarization is a segmentation method that converts grayscale images to black and white images based on a threshold value. This method includes various techniques, such as adaptive thresholding and Otsu thresholding. Adaptive thresholding divides an image into several regions and applies binarization by considering the surrounding pixels in each region. Recently, a study has proposed an optimal two-dimensional direction filter Binarization is a segmentation method that converts grayscale images to black and white images based on a threshold value. This method includes various techniques, such as adaptive thresholding and Otsu thresholding. Adaptive thresholding divides an image into several regions and applies binarization by considering the surrounding pixels in each region. Recently, a study has proposed an optimal two-dimensional direction filter to improve the contrast between regions of interest, such as thin scratches and backgrounds, and automatically detect regions of interest using adaptive thresholding [22]. Additionally, for images with low contrast or noise, another study has proposed determining the threshold value with means obtained using the standard deviation and entropy of pixels within a certain area and segmenting the area of interest [23]. Otsu's thresholding algorithm applies binarization by finding a threshold value that minimizes dispersion in the image histogram. Zhang et al. [24] proposed a method of segmenting the ROI from the real-time navigation image using an improved 2D fuzzy Fisher method based on criteria related to Otsu and entropy. Ma et al. [25] proposed a method of segmenting images with multiple threshold values based on RAV-WOA as an objective function. The Otsu algorithm has also been widely used in medical data segmentation. Recently, Alhasan [26] proposed an EFEHO-OTSU method to increase segmentation accuracy by using enhanced fuzzy elephant herding optimization (EFEHO) in image data combined with Otsu segmentation for Alzheimer's disease diagnostics in MRI images. Fazilov et al. [27] presented the result of applying image quality in CAD systems by enhancing the image quality to detect cancer. However, when applying the adaptive thresholding algorithm, the user should appropriately determine the parameter values, such as the block size, because the result value can vary greatly depending on the values. Additionally, the threshold value varies for each area, resulting in mathematical complexity. Moreover, since Otsu's algorithm requires calculating all threshold values, it can be difficult to find the optimal threshold values in an area with a lot of noise or a large distribution difference with the background. Therefore, there are limitations in using these methods in real-time welding inspections that require high accuracy.

Proposed Algorithm
As described above, existing algorithms have several disadvantages, such as being sensitive to outliers and significantly changing the result depending on the parameter values. This may cause the accuracy to be lowered when inspecting welding beads. Additionally, the complex computational processes make the computational time longer, making them difficult to use for real-time welding quality inspection. Furthermore, as shown in Figure 2, the welding bead area of the SRD in the image is relatively bright compared to the other surrounding areas, making it challenging to accurately detect welding beads. To overcome these limitations, this study proposes an algorithm based on the color difference characteristics between the welding bead and the base metal. In this section, we describe the proposed algorithm for detecting welding bead areas using the image projection algorithm and determining whether the welding bead is defective.

Image Projection
We have used and modified the image projection algorithm presented in [28] to identify only the welding bead area in the welding bead images. We define the color image as PV ∈ R 3 and PH ∈ R 3 , with each v-th vertical direction (PV) and h-th horizontal direction (PH). To calculate the mean brightness (MB) of the ROI in each vertical and horizontal direction, we compute it using the following equation: where k = 0, 1, 2 represents color channels (Red: 0, Green: 1, Blue: 2). xstart refers to the starting position of the x-axis in the image, xend refers to the ending position of the x-axis, ystart refers to the starting position of the y-axis in the image, and yend refers to the ending position of the y-axis. As shown in Figure 5, we scan the image brightness from left to right in the vertical direction and simultaneously obtain the mean of the RGB for each vertical line. After obtaining the values in the vertical direction, we repeat the process in the horizontal direction to obtain the image brightness values. From the mean RGB values obtained in Equations (2) and (4), histograms of the values are generated in the vertical and horizontal directions, respectively.
∈ R 3 and ∈ R 3 , with each -th vertical direction (PV) and ℎ-th horizontal direction ( ). To calculate the mean brightness ( ) of the ROI in each vertical and horizontal direction, we compute it using the following equation: where = 0, 1, 2 represents color channels (Red: 0, Green: 1, Blue: 2). refers to the starting position of the x-axis in the image, refers to the ending position of the x-axis, refers to the starting position of the y-axis in the image, and refers to the ending position of the y-axis. As shown in Figure 5, we scan the image brightness from left to right in the vertical direction and simultaneously obtain the mean of the RGB for each vertical line. After obtaining the values in the vertical direction, we repeat the process in the horizontal direction to obtain the image brightness values. From the mean RGB values obtained in Equations (2) and (4), histograms of the values are generated in the vertical and horizontal directions, respectively.

Inspection Algorithm for Welding Bead
We inspect the quality of the welding bead by following the procedure illustrated in Figure 6. To achieve this, first, we reduce the computational complexity by cutting out the welded bead area in the image, as shown in Figure 7. Then, we calculate the average brightness value in the vertical direction using an image projection algorithm. During this

Inspection Algorithm for Welding Bead
We inspect the quality of the welding bead by following the procedure illustrated in Figure 6. To achieve this, first, we reduce the computational complexity by cutting out the welded bead area in the image, as shown in Figure 7. Then, we calculate the average brightness value in the vertical direction using an image projection algorithm. During this process, the RGB values for all columns from left to right of the image are calculated, and the histogram of the average brightness is obtained, as shown in Figure 8. We can find points where the average brightness value changes rapidly in the histogram shown in Figure 8. These points correspond to the start and end of the welding bead. To determine this point, we calculate the axis value corresponding to 50% of the average brightness histogram using Equation (5): where T = 0.5 where MB [T] means the height corresponding to 50% of the histogram of average brightness. It can be calculated in the vertical (ver) and horizontal (hor) directions for images. The reason why the height for the average brightness was determined to be 50% is that if the value is less than 50%, only a part of the bead is divided, not the entire welding bead. On the other hand, if a value greater than 50% is used for the histogram, not only the welding bead but also various areas of the base material are divided together. For example, in Figure 7d, the x-axis positions of the upper and lower parts of the welding bead are not the same.
Therefore, we determine the 50% midpoint of the brightness change point in the histogram of Figure 8 to detect the welding bead area. In Figure 8, Next, the average brightness value is obtained in the horizontal direction using the ROI v image. In the same procedure for the vertical direction described above, the welding bead area is calculated for the horizontal direction, and the ROI h area is calculated. ROI h is a result of being performed in both vertical and horizontal directions, and finally, only the welding bead region remains as the final output. For that ROI h image, we calculate the width HT and the height VT of the welding bead. If HT and VT are greater than the threshold values T hor and T ver , the welding bead is classified as good, as shown in Equations (6) and (7).

Data and Experimental Environment
In the experiment, we extracted a total of 480 good welding bead images from 120 SRDs produced by the welding robot. In addition, 12 defective welding bead products were added to verify whether the welding bead is good or bad in the image classification Considering that the average height and width of the welding bead in the product used for this study were 480 and 70, respectively, we decided to define a welding bead as satisfactory when it has a length of approximately half, based on advice from the manufacturer. Therefore, we set the threshold values T hor and T ver to 40 and 200, respectively.

Data and Experimental Environment
In the experiment, we extracted a total of 480 good welding bead images from 120 SRDs produced by the welding robot. In addition, 12 defective welding bead products were added to verify whether the welding bead is good or bad in the image classification experiment. As shown in Figure 9, the defective products are images with or without a small welding bead. The size of the input images was 256 by 256 in terms of width and height. We conducted an experiment with an illuminance of approximately 700 lux and an average brightness of the welding bead of around 200. The PC specifications were as follows: Windows 10 Pro, i9 with NVIDIA GeForce RTX 3080 with GDDR6X 10GB, 3.7-GHz per processor, and Python 3.8.
ctronics 2023, 12, x FOR PEER REVIEW 9 of 17 experiment. As shown in Figure 9, the defective products are images with or without a small welding bead. The size of the input images was 256 by 256 in terms of width and height. We conducted an experiment with an illuminance of approximately 700 lux and an average brightness of the welding bead of around 200. The PC specifications were as follows: Windows 10 Pro, i9 with NVIDIA GeForce RTX 3080 with GDDR6X 10GB, 3.7-GHz per processor, and Python 3.8.

Evaluation Metrics
To evaluate the performance of the proposed algorithm, we calculated the evaluation metrics based on the confusion matrix between the good and bad images as follows.

•
The accuracy measures the proportion of predicted results that match the actual results out of all the results: • The recall is the proportion of instances that were actually true and were predicted as true by the model:

Evaluation Metrics
To evaluate the performance of the proposed algorithm, we calculated the evaluation metrics based on the confusion matrix between the good and bad images as follows.

•
The accuracy measures the proportion of predicted results that match the actual results out of all the results: • The recall is the proportion of instances that were actually true and were predicted as true by the model: • The precision refers to the proportion of instances that were predicted as true by the model and were actually true: • The F1-score is the harmonic mean of precision and recall, and it can accurately evaluate the performance of a model, particularly when the data labels are imbalanced: • The specificity measures the proportion of instances that were actually true and were predicted as true by the model, out of all instances that were actually true: • The loss ratio measures the proportion of predicted results that match the actual results out of all the results: where TP is true positive, TN is true negative, FP is false positive, and FN is false negative. As the number of correct images used in this study is greater than wrong, we presented four evaluation metrics together. In addition, when evaluating the proposed method, we followed the procedure in Figure 8 and used four evaluation metrics. However, when conducting experiments on comparison methods for welding quality assessment, we generated masks after segmentation. Then, the horizontal and vertical length of the detected welding bead was measured on the mask, and the quality of the welding bead was evaluated according to Equations (6) and (7). Based on the results, we created a confusion matrix and compared the performance using the evaluation metrics described earlier.

Performance of the Proposed Algorithm
We conducted an experiment to locate the positions of welding bead images in the vertical direction, as shown in Figure 10, following the algorithm procedure proposed in Figure 6. The right 'Bright' image in each result of Figure 10 represents the average RGBvalue along the vertical direction of the left 'ROI' image, which is indicated by a black curve. In the 'Bright' figure, the red line represents a portion corresponding to 50% of the height of the black curve, which is the average value of RGB by location. The two intersection points between the red line and the black curve correspond to the welding bead area in the vertical direction, as depicted in the left 'ROI' image of Figure 10. By using the proposed algorithm, all welding bead regions in the vertical direction were detected in all images ( 1 -4 ), as shown in the results of Figure 10. Figure 11 shows the results of applying the proposed algorithm to an image that was divided vertically, as shown in Figure 10, to detect the horizontal welding bead areas. Similar to the previous case, the average RGB value along the horizontal direction of the left 'ROI' image of Figure 11 is represented by a black curve in the right 'Bright' image. The red line in the histogram corresponds to the portion that is 50% of the height of the histogram. The values at both ends of the black curve where it intersects with the red line correspond to the two red lines on the 'ROI' image, which indicate the area of the welding bead detected horizontally. As shown in the results of Figure 11, it can be confirmed that all the welding bead regions were detected even in the horizontal direction of the welding bead in sub-images 1 -4 . In Figure 12, the image on the left, labeled as 'ROI-1', is the image before applying the proposed algorithm, and the image on the right, labeled as 'ROI-2', is the final welding bead image after applying the proposed algorithm. As shown in Figure 12, it was confirmed that only the welding bead could be extracted by the segmentation areas in the vertical and horizontal directions of all SRDs' welding beads using the proposed algorithm. Therefore, the proposed algorithm was found to be capable of detecting the required length of the welding bead for the inspection of the welding bead's appearance.

Comparative Experiments
To evaluate the performance of the proposed algorithm, we conducted a compara experiment using several existing algorithms, including K-means with HSV [7], KNN, proved Grabcut [26], Morphological geodesic active contour with Canny [21], adap thresholding, and Otsu thresholding algorithms. The results obtained using the exist algorithms are shown in Figure 13, where the red line in the image represents the segm tation area. In the K-means with HSV results, the welding bead area and some other ar were segmented in images ① and ②, but the welding bead was not effectively s mented in images ③ and ④. In the KNN results, image ① was well segmented, bu images ②-③, the welding bead area and another area were segmented together, and image ④, an area larger than the welding bead was segmented. In the improved Grab adaptive algorithm and Otsu algorithm results, the welding bead area and other ar were also segmented together. In the morphological geodesic active contour with Canny method, the welding bead area in the images should be set individually to mak bounding box, but we appointed the regions of the same location for segmenting the we ing beads because there are a lot of data. However, the welding beads were not prope segmented in all images, and more areas were segmented than the welding beads. For U-Net algorithm, the training and test data were split in a ratio of 7:3, and a quality spection experiment was performed. Figure 13g shows that the first image was succ fully segmented, while only some bright areas of the welding bead were segmented images ②-④. On the other hand, in Clustering with SCA, the welding bead was not s mented at all, similar to the results obtained with the morphological geodesic active c tour using the Canny method. Thus, in the segmentation experiment, the KNN, the proved Grabcut, and the Otsu algorithms showed relatively high accuracy results co pared to the others. However, in most cases, the segmentation results of the compari methods detected more areas that were not related to the welding bead, or divided welding bead area into more segments than necessary. Based on the results of the co

Comparative Experiments
To evaluate the performance of the proposed algorithm, we conducted a comparative experiment using several existing algorithms, including K-means with HSV [7], KNN, improved Grabcut [26], Morphological geodesic active contour with Canny [21], adaptive thresholding, and Otsu thresholding algorithms. The results obtained using the existing algorithms are shown in Figure 13, where the red line in the image represents the segmentation area. In the K-means with HSV results, the welding bead area and some other areas were segmented in images 1 and 2 , but the welding bead was not effectively segmented in images 3 and 4 . In the KNN results, image 1 was well segmented, but in images 2 -3 , the welding bead area and another area were segmented together, and in image 4 , an area larger than the welding bead was segmented. In the improved Grabcut, adaptive algorithm and Otsu algorithm results, the welding bead area and other areas were also segmented together. In the morphological geodesic active contour with the Canny method, the welding bead area in the images should be set individually to make a bounding box, but we appointed the regions of the same location for segmenting the welding beads because there are a lot of data. However, the welding beads were not properly segmented in all images, and more areas were segmented than the welding beads. For the U-Net algorithm, the training and test data were split in a ratio of 7:3, and a quality inspection experiment was performed. Figure 13g shows that the first image was successfully segmented, while only some bright areas of the welding bead were segmented in images 2 -4 . On the other hand, in Clustering with SCA, the welding bead was not segmented at all, similar to the results obtained with the morphological geodesic active contour using the Canny method. Thus, in the segmentation experiment, the KNN, the improved Grabcut, and the Otsu algorithms showed relatively high accuracy results compared to the others. However, in most cases, the segmentation results of the comparison methods detected more areas that were not related to the welding bead, or divided the welding bead area into more segments than necessary. Based on the results of the comparison methods, it is difficult to confirm the horizontal and vertical lengths of the welding beads in the segmented image obtained using these algorithms. Therefore, when comparing the results of the experiments shown in Figures 12 and 13, the comparison methods did not perform better than the proposed algorithm.
Otsu thresholding, morphological geodesic active contour with Canny, and adaptive thresholding algorithms were not able to classify all 12 defective welding bead products accurately, as shown in Table 1. The K-means with HSV algorithm classified 4 of the 12 defective products as bad. However, the accuracy, recall, and loss ratio of this algorithm were 76.22%, 77.29% and 31.20%, respectively, which differed significantly from the accuracy, recall and loss ratio of the proposed algorithm. The adaptive thresholding algorithm had the lowest accuracy, recall, precision, F1-score and specificity, which were at 37.20%, 38.13%, 93.85%, 54.22%, and 0.00%, respectively. Therefore, the adaptive thresholding algorithm showed the poorest performance.   An experiment was conducted to classify welding beads as either good or bad using the proposed algorithm and various comparison methods, as shown in Tables 1 and 2.  Table 1 displays the confusion matrix for the classification results of all methods and U-Net is the experimental result on the test data. As shown in Table 1, only the proposed algorithm accurately classified all the bad products, whereas all methods, except for K-means with HSV, were not able to accurately inspect the bad products. Furthermore, both K-means with HSV and adaptive thresholding methods misclassified many actual good products as bad products. Table 2 was created using evaluation metrics and Equations (8)-(13) based on the confusion matrix presented in Table 1. As shown in Table 2, the proposed algorithm precisely classified all good and defective welding beads at 100%. In contrast, the improved Grabcut, KNN, morphological geodesic active contour with Canny, Otsu thresholding algorithm, U-Net and Clustering with SCA showed high accuracy and precision, at approximately 97%. However, none of them showed higher performance than the proposed algorithm. Specifically, the U-Net, which is a machine learning method specializing in image segmentation, did not show a better performance than the proposed algorithm. As can be seen from the specificity values in Table 2, all comparison methods except for K-means with HSV resulted in 0. This implies that the improved Grabcut, KNN, Otsu thresholding, morphological geodesic active contour with Canny, and adaptive thresholding algorithms were not able to classify all 12 defective welding bead products accurately, as shown in Table 1. The K-means with HSV algorithm classified 4 of the 12 defective products as bad. However, the accuracy, recall, and loss ratio of this algorithm were 76.22%, 77.29% and 31.20%, respectively, which differed significantly from the accuracy, recall and loss ratio of the proposed algorithm. The adaptive thresholding algorithm had the lowest accuracy, recall, precision, F1-score and specificity, which were at 37.20%, 38.13%, 93.85%, 54.22%, and 0.00%, respectively. Therefore, the adaptive thresholding algorithm showed the poorest performance. The Otsu thresholding and adaptive thresholding algorithms had the fastest computation times, at 16.60 and 16.74 s, respectively, followed by our proposed algorithm at 24.79 s. On the other hand, the improved Grabcut, U-Net, and Clustering with SCA had the longest computation times, which were 669.56, 358.44, and 1054.85 s, respectively. The reason why the proposed algorithm takes longer to compute than the thresholding algorithms is that it cannot perform segmentation simultaneously in both the vertical and horizontal directions. When finding the welding bead location, the proposed algorithm calculates the mean brightness of each color image ∑ 2 k PV k ∈ R 3 by using Equations (1) and (2) vertically from left to right. The algorithm then uses Equation (5) to find the boundary between the background and the welding bead point in the histogram of mean brightness, and to subsequently find the welding bead area. After that, the algorithm repeats the same process in the horizontal direction. Therefore, finding the location of the welding bead is performed separately in both the vertical and horizontal directions, which takes slightly longer to compute compared to the thresholding algorithm. However, we prioritized accuracy over speed and focused on improving it, even if it meant sacrificing some computational time. As shown in Table 2, our algorithm achieved higher accuracy compared to other methods.

Conclusions and Discussion
In this paper, we proposed an algorithm for the quality inspection of the welding bead region using an image projection algorithm. One of the limitations of the existing methods used to detect welding beads is not accurately classifying the welding bead area due to factors such as image color and noise. To overcome this, we proposed a quality inspection method that uses statistical methods to classify whether the welding bead is of good or bad quality. The proposed algorithm analyzes the brightness values of the vertical and horizontal directions of the ROI in the entire image, and the welding bead area is found and segmented at the point where the brightness value changes rapidly, improving the inspection accuracy of the welding bead. The proposed algorithm reduces the computational time by designating a welding bead area to be analyzed in the input image and performing the analysis. Additionally, the proposed algorithm was able to detect the length of both the horizontal and vertical dimensions of the welding bead for all data. To compare the performance of the proposed algorithm, we conducted a comparative experiment using existing algorithms, including the improved Grabcut, Kmeans with HSV, KNN, morphological geodesic active contour with Canny, adaptive thresholding, and Otsu thresholding algorithms. However, it was difficult to detect the length of the horizontal and vertical dimensions of the welding bead. Most of the compared algorithms did not correctly classify the defective welding bead products due to similarities in texture between the base metal and welding bead, as well as discoloration around the bead after welding. Furthermore, the proposed algorithm was much faster than the other comparative algorithms, except for the adaptive thresholding and Otsu thresholding algorithms. Therefore, via experiments, it was confirmed that the proposed algorithm outperforms existing methods in terms of accuracy.
In future work, we plan to expand our research beyond just classifying defective welding beads and to study various types of welding bead defects, as well as investigate the geometric and morphological properties of the welding bead. Additionally, since our study was limited to analyzing only 492 image data, we plan to propose methods that can achieve high performance even with a small amount of data using deep learning algorithms such as few-shot learning.