Academic Journal of Science and Technology ISSN: 2771-3032 | Vol. 12, No. 2, 2024 125 Research on Weld Seam Marking Based on Machine Vision Technology Shunyang Hu, Chenlei Zhao, Qian Fu Geely University of China, Chengdu 641402, China Abstract: The rapid development of machine vision technology has made it widely used in various industrial fields. The detection of welding quality can also be achieved through this technology. The core of welding quality inspection is to realize the marking of weld features. To solve the problem of weld feature marking, the GUI weld marking interface is built based on MATLAB. After the process of image acquisition, image preprocessing, edge detection and feature extraction, the weld marking experiment of is finally completed. Based on data analysis of the experiment, it can be concluded that Canny edge detection operator has the best marking effect and the most stable detection for the research object used. Keywords: Machine Vision Technology; Image Processing; Weld Marking. 1. Introduction Machine vision technology is used to measure and identify the target shape and size, color and other information of the workpiece, and with this advantage, it has slowly replaced manual work in the industrial production line and greatly enhanced the workpiece quality and its sensitivity and accuracy. Relying on machine vision weld technology, China has achievindustrial automation with much lower costs in labor, time costs money costs, etc., which made the technolog a rigid demand for manufacturing. The automation and intelligent development of the industry will only become more and more rapid, providing a solid foundation for welding technology. The weld images obtained by machine vision technology can be directly provided after computer processing along with the feature data of various images for optimizing the welding method and parameters, so that the welding quality is guaranteed. 2. Detection and Principle of Machine Vision Weld Marks Figure 1. Image processing Machine vision is to replace the human eyes with a machine to measure and judge the work. The system converts the captured object into an image signal and transmits it to a special image processing system. The image can be analyzed according to the relationship between pixel distribution and brightness, color and other information. Combined with related algorithms, the system can obtain the required information for recognition, and then realize the recognition and judgment of the target weld. Then the data is processed by the computer and output on the display. The complete image processing includes image acquisition, image preprocessing, detection of target edge and feature information extraction and so on. It can simulate human visual process by computer and control it automatically. 2.1. Image Preprocessing 2.1.1. Grayscale Conversion The gray-scale transformation is mainly based on independent pixels, which enhances the quality of the picture by changing the gray-scale range of the original image data, making the image clearer and easier to recognize. In practice, it is also necessary to pay attention to the problems that may occur at various stages for the machine vision system to better play a role. Usually, the dynamic range of pixels is enlarged by gray-scale transformation, and the image contrast is expanded. For different types of gray transformation, different effects can be obtained. If it is assumed that the pixel value k in the source image is located at a certain image position and transformed by the algorithm formula F (k), the pixel value at the position becomes H. Since there is a mapping relationship between gray images of function F (k), the formula after gray transformation is the expansion of its mapping formula. 2.1.2. Binary Image Usually a normal view is that black and white image refers to gray scale image, in practice, in addition to gray scale image, there is a class of binary image. Strictly speaking, binary image is a real black and white image, because the gray scale of the binary image can only reach 0 and 255, the color of 0 represents black, 255 white. In this paper, a new histogram equalization method based on gray space is introduced, which can adjust the brightness and color of the image according to the actual needs. When the gray value of an image pixel exceeds the set threshold, the pixel value in the figure is 255, otherwise, it is 0. 2.2. Image Denoising The existing digital images are all noisy images, which means that the image data contains some useless clutter information and interference information, which is usually in the form of pixels. Pixel blocks and other visual effects are strong, so it is very necessary to carry out image processing after image noise reduction, which not only improves the quality of the image, but also avoids its useless information interfering with people's detection of the data. Image filtering can suppress the noise in the target image while ensuring that the image features are preserved. Usually, there are two kinds of filtering, linear and nonlinear, while the mean filtering is linear, averaging all pixel values in a certain area and giving the average value of pixels at the center of the image. Non- linear is more difficult than linear, and the maximum or 126 minimum value of pixels in a certain range, which is nonlinear, needs to be calculated. 2.2.1. Linear Filtering Commonly used kinds of linear filtering include mean value filtering, Gaussian filtering, etc. Mean filtering processes the average value of the pixel in the target area, and gives the average value of the pixel in the center position. Gaussian filtering is a method which averages all pixels in the image and then calculating the coordinates of the center points. Gaussian filtering refers to the filtering of the unknown pixel in the center after the Gaussian weighting of the pixel values in the target range. This method is suitable for images with little change in gray level or strong local contrast. The mapping function of linear filtering is linear, so the convolution form is expressed as Y=h*X, and the convolution kernel is h [9], so formulas 1 are as follows: , ∑ ∑ , , (1) 2.2.2. Nonlinear Filtering The nonlinear filtering usually used is the median filtering, bilateral filtering, etc., each nonlinear filtering has no specific manifestation, so the general nonlinear filtering is to filter the pixel value in a certain region after the maximum or minimum value, and the pixel value in the center position will be replaced. The Gaussian filter method is suitable for images with little change in gray level or strong local contrast. Median filtering is to arrange the pixel values within the region in an orderly manner and then filter, replacing the center position of the pixel values in the region with the middle value. Formula 2 of nonlinear filtering is as follows: (X represents the input image, i represents the abscissa, j represents the ordinate) , — , — ,… , , , … , , (2) 2.3. Object Detection Algorithm The feature extraction of weld marks generally includes image features of texture, color, shape, spatial relationship, etc. After image reading, image features are extracted, and image feature data is collected and uploaded to the classifier. In the process of image feature data classifying, the basic principle is to distinguish the distinctive feature data of the image from other images. Due to the diversity of the image itself, the extracted feature vectors are also different, which makes it impossible for the traditional method to achieve the expected effect. 2.3.1. Textural Features Texture is an attribute that shows the relationship between the structure arrangement of the surface of things and the environment, and also reflects the homogenous visual features in the image. Usually, the image features that are repeatedly displayed by the structure arrangement and local pattern are texture features. Texture features have the advantages of resisting noise to a certain extent, and can also be used for statistical calculation of areas containing several pixels. In the face of rotating photos, data can also be extracted correctly. However, there will be big errors in obtained features data under the influence of blurred images or light irradiation. Texture feature extraction usually adopts statistical method, geometric method, model method and structure analysis method. 2.3.2. Colour Signature The color feature in an image is one of the important features, which generally refers to the properties of the corresponding surface in the image area. Texture feature extraction methods are mainly divided into two algorithms based on mathematical morphology and neural network. The advantage of color features is that color is not sensitive enough to the shape, rotation and other changes of the image, and the connection between color and the object contained in the image is closer. Color feature extraction is usually carried out by the method of color histogram, color aggregation amount, color set and so on. 2.3.3. Shape Feature The shape of the general image is composed of points, lines and surfaces, and the shape features have limitations, and some are even one-sided, usually used on the edge features of the image, but when the picture is rotated, blurred, under the action of deformation and other factors, the data extracted from the shape features will lose reliability and cannot be used in the test. In order to overcome the above shortcomings, an improved algorithm is proposed to extract the feature information with better stability and accuracy, so as to obtain more complete and accurate shape feature data. There are two types of shape features in general. One is the feature of the whole area of the image, and the other is the contour feature of the edge area of the local image. 2.3.4. Spatial Relationship Feature The so-called spatial relationship refers to the three types of adjacency and cross, overlap or inclusion relations between the multiple objects segmented in the image. In order to overcome the above shortcomings, an improved algorithm is proposed to extract the feature information with better stability and accuracy, so as to obtain more complete and accurate shape feature data. Generally, spatial position information can be divided into relative spatial information and absolute spatial position information. 3. Weld Marking and Inspection Feature extraction of welds is to use machine vision technology to mark welds in the image region. Since welds are linear features, experiments and analysis can be carried out by using edge extraction algorithms. At present, the most widely used edge detection methods include Sobel, Prewitt, Roberts, Canny and other operators. In order to correctly extract useful feature data, the above four operators will be compared and analyzed combined with weld features. 3.1. Edge Detection Operator Edge detection is actually a filtering algorithm, and the difference between it and other filtering algorithms lies in the selection of filters. The characteristic of ordinary filters is that Gaussian filters use the normalized kernel formed by discretized Gaussian functions, while the filter algorithm of edge detection generates grayscale matrix by calculating the target image through Gaussian kernel. Edge detection algorithm is a is edge detection technology widely used in computer vision which can display the small structure and details on the surface clearly. (1) Robert operator Among these classical operators, edge detection operator is the simplest. Robert operator uses some regions of the image to search edges by difference, and locates edge positions with greater advantages than other operators. However, for photos with large noise, the effect is poor, and for target images, the edge lines are inaccurate. This algorithm is often used as an image with steep low noise. The basic image is f (x,y), and 127 the edge detection image of Robert operator is g (x,y). The algorithm 3 can be expressed as: g x,y ={[f(x,y)-f(x+1,y+1)]²+[f(x+1,y)-f(x,y+1)]²}0.5 (3) (2) Prewitt operator Compared with Robert operator, Prewitt operator has stronger resistance to noise and is less affected by waves. In essence, it is a differential operator, that is, the gray-scale of pixels in the image in the region is used for differentiation. Therefore, Prewitt operator is more suitable for images with high noise waves. Suppose the basic image representation function is f (x,y), and the pixel at a certain point in the image is represented by (i,j). The horizontal difference ( ) and vertical difference (j): G(i)=|[f(i-1,j-1)+f(i-1,j)+f(i-1, j+1)]-[f(i+1,j-1)+f(i+1, j)+f(i+1, j+1)]| (4) G(j)=|[f(i-1,j+1)+f(i,j+1)+f(i+1, j+1)]-[f(i-1,j-1)+f(i,j- 1)+f(i+1, j-1)]| (5) By formula 6: P(i,j)=max[G(i),G(j)] (6) Or formula 7: P(i,j)=G(i)+G(j) (7) The gradient amplitude P(i,j) of pixel point (i,j) is calculated. By setting threshold T0, when P(i,j) is less than T0, it can be judged as contour edge, and the contour feature is marked. (3) Sobel operator Sobel operator belongs to a class of discrete differentiation, it is a combination of Gaussian smoothing and differential derivation, usually used to approximate the calculation of image brightness, according to the target image edge processing of the region, the region of a brightness greater than a certain threshold value of the special point marked. The edge detection technology is widely used in computer vision, which can clearly show the tiny structures and details existing on the surface of objects. When detecting edges, Sobel operator uses the gradient ᐁf to represent the probability and direction of the edge of an image f at the position of pixel (x,y) : ᐁ grad g g (8) (4)Canny operator Canny operator is a multi-level detection algorithm. Compared with other basic edge detection operators, it is one of the most advanced edge detection operators at present. The main optimal edge is defined as the number of marks that the algorithm can mark the edge of the target image more times, and the marked edge can be closer to the edge in the actual image. While using Canny operator for edge detection, firstly, the noise interference in the target image should be eliminated by Gaussian filtering, and then the target image should be processed gradiently, and then the non-maximum value of the gradient image should be suppressed. Due to the edge interference in the gradient image, the maximum value of the pixel in the target area should be searched by non-maximum suppression method. Finally, to achieve the goal, the method of double threshold edge connection is adopted, and the existence of false edge is further tested. That is, the single- channel gray image is filtered and denoised, and then the amplitude of the image gradient (x,y and direction Angle θ) is calculated, and the image edge is finally determined by the double threshold. (x,y= (9) θ=arctan () (10) In the formula, the gradient amplitudes in the horizontal and vertical directions of the image are respectively represented. 3.2. Comparison and Analysis of Experimental Results 3.2.1. Experimental Raw Data As shown in the following figure 2, the research objects of weld marks are: Figure 2. The research objects of weld marks 3.2.2. Experimental Analysis For edge processing in 3.2 (a), Canny operator has the clearest detection, while Prewitt and Roberts operators are affected by image noise. Although Prewitt operator is interfered with, it obviously has some resistance, and Roberts operator is the most interfered with, which seriously affects weld marks. However, among these operators, Sobel operator is the most accurate in detecting regional edge markers and the least affected by interference factors. Figure 3. The detection effect of operators Figure 4. Operator detection is affected by interference In the original figure 4, the detection of Roberts, Prewitt and Canny operators were all affected by interference, but the detection results of Roberts and Canny operators were the 128 clearest, so the detection results of Roberts and Canny operators were better. Although Sobel operator marked the contour, However, Sobel operator leads to unsatisfactory image result because of the large pixel distance in the image area. 3.2.3. Analysis of Experimental Results In terms of the overall data of the experiment, the detection of Canny operator is the most stable, and the picture is very clear. With the interference of various image factors considered, the operator itself has a high resistance. The detection of Roberts operator can achieve an ideal level in the processing of low-noise images. When the Prewitt operator labels high-noise images, the significant resistance effect is more significant. However, when comparing the results of Roberts and Canny operator, the clarity of the images detected by the Prewitt operator is significantly lower than that of the two operators. Through the analysis and comparison of several commonly used algorithms, it is found that for different types of objects, the corresponding image processing technology can get more satisfactory processing results, and these methods have certain applicability. When the Sobel operator is marked as the weld contour, the image marking effect is much more obvious than that of the rest operator. However, in the face of objects with not dense pixels in the image area, the result is not clear enough and cannot be accurately marked. 4. Conclusion In the weld seam marking, interference by different factors is unavoidable, and the high-noise image should be pre- processed by noise reduction to achieve the effect of optimizing the image quality and reducing the interference degree. Based on the edge detection algorithm of Sobel, Roberts, Prewitt and Canny operator, the experimental verification is carried out for the analysis of image weld marks. The experimental results show that the detection effect of Canny operator is the most stable. References [1] Kiddee, Prasarn, Zaojun Fang, and Min Tan. "An automated weld seam tracking system for thick plate using cross mark structured light." The International Journal of Advanced Manufacturing Technology 87 (2016): 3589-3603. [2] Sreedharan, J., and A. K. Jeevanantham. "Optimization of injection molding process to minimize weld-line and sink-mark defects using Taguchi based grey relational analysis." Materials Today: Proceedings5.5 (2018): 12615-12622. [3] Wei, Guoqian, et al. "Experiment and simulation investigation of multiple cracks evolution at the weld toe." International Journal of Fatigue 144 (2021): 106037. [4] Shi, Wen, et al. "Wire melted mark metallographic image recognition and classification based on semantic segmentation. "Expert Systems with Applications 238 (2024): 122146. [5] Wang, Weifeng, et al. "Study on the microstructure characteristics of melting marks in copper-clad aluminum wires under overcurrent faults." Journal of Thermal Analysis and Calorimetry149.1 (2024): 345-357. [6] Wang, Ren**, and Yong Lei. "Application of Computer Virtual Reality Technology in Welding Simulation Training of Complex Structures Based on Unity3D." Journal of Electrical Systems 20.2 (2024): 641-652. [7] Wiegand, Michael, et al. "High-strength dissimilar welds between a NiTi shape memory alloy and titanium obtained by intermixing niobium using pulsed laser beam welding." Metallurgical and Materials Transactions A55.1 (2024): 278- 290. [8] He, Jiadong, Haibo Wang, and Yajun Zhang. "Weld quality measurement of T-joints based on three-dimensional scanner." The International Journal of Advanced Manufacturing Technology (2024): 1-12.