Method for detecting welding defects of steel pipe and copper pipe

By employing image processing and deep convolutional neural network technologies, the problems of low efficiency and insufficient accuracy in the detection of welding defects in steel and copper pipes have been solved, achieving efficient and accurate identification and classification of welding defects, and adapting to the detection needs of different specifications and processes.

CN120953261APending Publication Date: 2025-11-14ZHANGBEI YUNLIAN DATA SERVICE CO LTD

Patent Information

Application Number
CN202511435000.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-10-09
Publication Date
2025-11-14

AI Technical Summary

Technical Problem

Existing methods for detecting welding defects in steel and copper pipes suffer from low efficiency, insufficient accuracy, and poor adaptability, especially in the case of welding dissimilar materials, where it is difficult to accurately identify and classify defects.

Method used

Image processing techniques are used for grayscale conversion and noise suppression, texture features and edge gradient distribution of the welding area are extracted, a feature description matrix is ​​constructed, and a deep convolutional neural network is used for defect classification to generate visual detection results.

Benefits of technology

It achieves efficient and accurate welding defect detection, reduces false positives and false negatives, improves detection efficiency, adapts to the detection needs of different specifications and welding processes, and supports large-scale industrial production.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120953261A_ABST
    Figure CN120953261A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of steel pipe and copper pipe welding detection, and discloses a method for detecting welding defects of a steel pipe and a copper pipe. The method comprises the steps that original image data of a steel pipe and copper pipe welding area are collected, gray level conversion and noise suppression processing are conducted on the original image data, and preprocessed image data are generated; textural feature distribution and edge gradient distribution of the welding area are extracted based on the preprocessed image data, and a feature description matrix of the welding area is constructed; inputting the feature description matrix into a trained defect classification model, and outputting defect type probability distribution of the welding area; and generating positioning mark data of the welding defects according to the defect type probability distribution, and generating a visual detection result of the welding defects in combination with the original image data. The method can effectively eliminate image interference, comprehensively capture defect characteristics, improve defect identification precision, visually present detection results, adapt to steel pipe and copper pipe welding scene requirements, and meet industrial batch detection requirements.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of steel pipe and copper pipe welding inspection technology, specifically a method for detecting welding defects in steel pipes and copper pipes. Background Technology

[0002] In industrial production, welded structures of steel and copper pipes are widely used in pipeline transportation, machinery manufacturing, HVAC, and other industries. Welding quality directly affects the operational stability and safety of the entire equipment or system. During the welding process, various factors such as differences in welding material properties, fluctuations in welding process parameters, and interference from the operating environment can easily lead to defects in the welded area, including cracks, porosity, lack of fusion, and slag inclusions. If these defects are not detected promptly and accurately, they will gradually expand during subsequent use, leading to media leakage, reduced structural strength, and even equipment failure and safety accidents, resulting in economic losses and safety hazards.

[0003] The main methods for detecting welding defects in steel and copper pipes include traditional methods such as manual visual inspection, ultrasonic testing, and radiographic testing. Manual visual inspection relies heavily on the experience and responsibility of the inspectors, is significantly affected by subjective factors, has limited ability to identify minute or hidden defects, and is inefficient, making it difficult to meet the batch inspection needs of large-scale industrial production. While ultrasonic testing can detect internal defects, the operation process is complex, requires highly skilled personnel, and necessitates good coupling with the workpiece surface. For welded areas with complex shapes or uneven surfaces, the accuracy is easily affected. Radiographic testing, while providing a direct view of defect morphology, poses radiation safety risks, has expensive equipment, a long testing cycle, and is subject to strict environmental restrictions, making real-time online inspection difficult on the production site.

[0004] With the development of computer vision and artificial intelligence technologies, image-based defect detection methods have gradually gained attention. These methods detect defects by acquiring and processing images of the welding area, offering advantages such as non-contact operation, high efficiency, and automation. However, existing image-based detection methods still face many challenges when dealing with welding scenarios involving steel and copper pipes. The material differences between steel and copper pipes result in uneven grayscale distribution in the welding area images, and the spatter and arc light generated during welding create noise interference in the images. Traditional image preprocessing methods struggle to effectively eliminate this interference, affecting the accuracy of subsequent feature extraction. Furthermore, existing defect classification models are mostly designed for welding defects of single materials, lacking adaptability to identifying welding defects in dissimilar materials like steel and copper pipes. This can easily lead to misclassification or missed detection of defect types, failing to meet the accuracy and reliability requirements for welding defect detection in actual production. Summary of the Invention

[0005] The purpose of this invention is to provide a method for detecting welding defects in steel pipes and copper pipes, so as to solve the problems mentioned in the background art.

[0006] To achieve the above objectives, the present invention provides a method for detecting welding defects in steel pipes and copper pipes, the method comprising:

[0007] The original image data of the steel pipe and copper pipe welding area is collected, and grayscale conversion and noise suppression are performed on the original image data to generate preprocessed image data.

[0008] Based on the preprocessed image data, the texture feature distribution and edge gradient distribution of the welding area are extracted, and a feature description matrix of the welding area is constructed.

[0009] The feature description matrix is ​​input into the trained defect classification model, and the probability distribution of defect types in the welding area is output.

[0010] Based on the probability distribution of defect types, location marker data for welding defects is generated, and combined with the original image data, a visual detection result of the welding defects is generated.

[0011] Preferably, the specific steps for performing grayscale conversion and noise suppression processing on the original image data include:

[0012] Adaptive histogram equalization is performed on the original image data to generate equalized image data;

[0013] A nonlocal mean filtering algorithm is used to smooth the equalized image data, generating denoised preprocessed image data.

[0014] Preferably, the extraction process of texture feature distribution and edge gradient distribution of the welding area based on preprocessed image data includes:

[0015] Multi-scale wavelet transform decomposition is performed on the preprocessed image data to generate sub-band coefficient matrices for different frequency bands;

[0016] The local binary pattern feature vector of the welding area is calculated based on the sub-band coefficient matrix to generate the texture feature distribution.

[0017] The Sobel operator is used to perform edge detection on the preprocessed image data to generate edge gradient distribution.

[0018] Preferably, the process of constructing the feature description matrix includes:

[0019] The texture feature distribution and edge gradient distribution are normalized to generate standardized feature vectors;

[0020] Principal component analysis is performed on the standardized eigenvectors to reduce dimensionality and generate a low-dimensional feature matrix.

[0021] The low-dimensional feature matrix is ​​fused with the geometric parameters of the welding area to generate a feature description matrix.

[0022] Preferably, the training process of the defect classification model includes:

[0023] Collect historical welding defect sample data, label the sample data, and generate a training dataset;

[0024] A deep convolutional neural network is used to iteratively train the training dataset to generate an initial classification model;

[0025] The parameters of the initial classification model are optimized using cross-validation to generate a trained defect classification model.

[0026] Preferably, the structure of the deep convolutional neural network includes:

[0027] The input layer receives the feature description matrix and generates a high-level feature map through multiple convolution and pooling operations.

[0028] The high-level feature map is input into the fully connected layer to generate the initial probability distribution of the defect type;

[0029] The initial probability distribution is normalized using the Softmax function to generate the defect type probability distribution.

[0030] Preferably, the process of generating the defect type probability distribution includes:

[0031] Perform multi-channel convolution on the feature description matrix to generate a multi-channel feature response map;

[0032] Confidence scores for various defects are calculated based on multi-channel feature response maps, and probability distributions of defect types are generated.

[0033] Preferably, the process of generating the location marker data includes:

[0034] Candidate regions for welding defects are determined based on the probability distribution of defect types;

[0035] Non-maximum suppression is applied to the candidate regions to generate the final defect location boxes;

[0036] Align the final defect location box with the original image data to generate location marker data.

[0037] Preferably, the specific steps of the nonmaximum suppression processing include:

[0038] Calculate the overlap between candidate regions and generate an overlap matrix;

[0039] The optimal candidate regions are selected based on the overlap matrix and the probability distribution of defect types, and the final defect location box is generated.

[0040] Preferably, the process of generating the visualized detection results includes:

[0041] The location marker data is superimposed onto the original image data to generate an annotated detection image;

[0042] The labeled detection images are color-coded according to the probability distribution of defect types to generate visual detection results of welding defects.

[0043] Compared with the prior art, the beneficial effects of the present invention are:

[0044] This method for detecting welding defects in steel and copper pipes provides a more efficient and accurate solution through a systematic process of image processing, feature extraction, model classification, and result visualization. In the image preprocessing stage, after acquiring the original image data of the welding area, the method simultaneously performs grayscale conversion and noise suppression. This effectively eliminates interference information caused by material differences, welding spatter, arc light, and other factors in the original image, making the generated preprocessed image data more suitable for subsequent feature extraction. This avoids the information loss or interference residue problems caused by traditional preprocessing methods that only address a single interference factor, laying a solid foundation for accurate extraction of welding area features.

[0045] In terms of feature extraction and feature description matrix construction, this method, based on preprocessed image data, simultaneously extracts the texture feature distribution and edge gradient distribution of the welding area. Compared to traditional methods that extract only a single feature, it can more comprehensively capture key information such as the morphology and structure of welding defects. By constructing a feature description matrix, texture features and edge gradient features are integrated, making the feature information more representative. This effectively distinguishes different types of welding defects, reduces defect identification bias caused by incomplete feature information, and improves the accuracy of subsequent defect classification.

[0046] In the defect classification stage, this method inputs the feature description matrix into a trained defect classification model, which can quickly output the probability distribution of defect types in the welded area. The trained defect classification model can be adapted to the characteristics of welding defects in dissimilar materials such as steel pipes and copper pipes. Compared with traditional classification models for single materials, it is more adaptable to the welding scenarios of steel pipes and copper pipes, and can more accurately identify various defects such as cracks, porosity, lack of fusion, and slag inclusions, reducing the probability of false positives and false negatives, and meeting the requirements for defect identification accuracy in actual production.

[0047] In the result presentation stage, this method generates location marker data based on the probability distribution of defect types and combines it with the original image data to generate visualized detection results, which can intuitively display information such as the location and type of welding defects. Inspectors can quickly obtain key information about welding defects without relying on specialized equipment or complex data analysis processes, simplifying the interpretation of detection results and improving the efficiency of inspection work. At the same time, the visualized detection results facilitate subsequent tracing and analysis of welding defects, providing intuitive reference information for optimizing welding processes and improving production workflows. This helps reduce the generation of welding defects from the source and improve the overall quality of welded steel and copper pipe products.

[0048] The method has strong operability and scalability. It can adjust the image preprocessing parameters, feature extraction methods, and model training strategies according to the needs of actual production scenarios, adapting to the welding inspection needs of steel pipes and copper pipes of different specifications and welding processes. It does not require redesigning the entire inspection scheme for different scenarios, reducing the application cost of the inspection method, expanding its scope of application, and meeting the needs of batch and continuous welding defect inspection in large-scale industrial production. It promotes the development of steel pipe and copper pipe welding inspection from traditional manual or semi-automatic to fully automated and high-precision. Attached Figure Description

[0049] Figure 1 This is a schematic diagram illustrating the working principle of the method for detecting welding defects in steel pipes and copper pipes according to the present invention.

[0050] Figure 2 This diagram illustrates the working principle of grayscale conversion and noise suppression processing of raw image data.

[0051] Figure 3 A diagram illustrating the working principle of constructing the feature description matrix. Detailed Implementation

[0052] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0053] Please see Figure 1This invention provides a method for detecting welding defects in steel pipes and copper pipes. The method utilizes image processing and machine learning techniques to achieve automated defect identification and localization in the welding area. First, the method acquires raw image data of the steel pipe / copper pipe welding area using a high-resolution industrial camera, ensuring complete coverage of the weld joint. The raw image data undergoes grayscale conversion, transforming the color image into a grayscale image to simplify subsequent calculations. The grayscale conversion employs a weighted average method, assigning weights to the RGB channels based on human eye sensitivity. Noise suppression is achieved using a filtering algorithm to eliminate random noise introduced during image acquisition, improving image quality. The preprocessed image data is used for feature extraction. Texture feature distribution in the welding area is analyzed based on pixel intensity changes; texture features reflect the uniformity and continuity of the material surface. Edge gradient distribution is calculated using a differential operator to determine the image brightness change rate, identifying the contours of the welding area and potential defect boundaries. The texture feature distribution and edge gradient distribution are combined to construct a feature description matrix, which serves as a multi-dimensional feature vector representing the structural properties of the welding area. The feature description matrix is ​​input into a pre-trained defect classification model. Based on a statistical learning algorithm, the model outputs probability values ​​for different defect types within the welded area. These probability values ​​represent the confidence level of common defects such as porosity, cracks, and incomplete penetration. Based on the defect type probability distribution, location marker data for the weld defects is generated, specifying the spatial coordinates and extent of the defect in the image. Combining this with the original image data, the location marker data is overlaid onto the corresponding positions to generate a visually highlighted defect area, facilitating intuitive evaluation by operators.

[0054] Example 1: See Figure 2 Adaptive histogram equalization is applied to the original image data to improve the local contrast of the weld area image, as some details may be blurred due to uneven lighting or material reflection. This method abandons the limitations of global histogram equalization and instead employs local region analysis, dividing the image into multiple overlapping sub-blocks. The size of each sub-block is dynamically adjusted based on the total image resolution and the typical feature size of the weld area. For each sub-block, its gray-level histogram is calculated independently, and a corresponding cumulative distribution function is constructed. This function is used to remap the pixel gray-level values ​​within the sub-block, making the gray-level distribution as uniform as possible in the local area. This process is particularly helpful in enhancing the gray-level differences in the transition area between the weld and the base material, as well as in areas with potential micropores or cracks, making latent defect features in images with low overall contrast more prominent. After processing, the equalization results of all sub-blocks are smoothly fused using bilinear interpolation to generate an equalized image with significantly enhanced gray-level distribution. This data preserves the local features of different regions while avoiding artifacts caused by excessive enhancement of the overall image.

[0055] The equalized image data is then processed by a nonlocal mean filtering algorithm to suppress noise. Images acquired in industrial settings typically contain various types of random noise, which can interfere with subsequent texture and edge feature extraction. The core idea of ​​nonlocal mean filtering is to utilize the redundant information within the image itself. Unlike traditional local filtering, which only considers pixel neighborhoods, it searches for all pixels with similar neighborhood structures throughout the entire image. For each pixel to be processed, the algorithm selects a reference block of a predetermined size centered on it. Then, within a larger search window of the image, it searches for all pixel blocks that are structurally similar to the reference block. The central pixels of these similar blocks are assigned higher weights, while pixels in dissimilar blocks are assigned lower weights. Finally, the new grayscale value of the pixel to be processed is obtained by weighted averaging of its own grayscale value and the grayscale values ​​of all the searched similar pixels according to the calculated weights. The advantage of this method is that it can smooth noise in a uniform background area extremely effectively, while preserving high-frequency details such as edges, corners and textures to the maximum extent. For welding images, this means that important information such as weld edges and the outlines of potential small defects are still clearly distinguishable after denoising, while noise in the steel pipe and copper pipe substrate areas is effectively suppressed.

[0056] The denoised image data obtained after the above preprocessing enters the feature extraction stage. First, multi-scale wavelet transform decomposition is performed to reveal the image's features at different resolutions. The wavelet transform uses a pre-selected set of basis functions (e.g., Daubechies wavelets) to decompose the image into a series of sub-bands with different frequencies and directions. The transform process is typically performed in two or three layers. Each layer produces a low-frequency sub-band representing approximate image information, and multiple high-frequency sub-bands representing detailed information (e.g., horizontal, vertical, and diagonal directions). The low-frequency sub-band coefficient matrix reflects the overall structure and slowly changing grayscale information of the weld area, while the high-frequency sub-band coefficient matrix captures the fine details, edges, and noise of the image. This multi-scale analysis capability allows the algorithm to simultaneously focus on the macroscopic morphology of the weld and potential microscopic defects. For example, deeper low-frequency information may reflect the overall width and continuity of the weld bead, while shallower high-frequency information is more sensitive to minute spatter, undercut, or cracks.

[0057] Based on the sub-band coefficient matrix generated by wavelet transform, local binary pattern feature vectors are further calculated to quantize the texture feature distribution. Local binary pattern is a powerful texture descriptor that generates a unique binary encoding pattern by comparing the gray values ​​of each pixel with those of its surrounding circular neighborhood. For each coefficient point in the sub-band coefficient matrix (representing the response at a specific scale and direction), several points are sampled in a small circular neighborhood centered on that point. The gray values ​​of the neighborhood points are compared with the gray value of the center point. If the neighborhood point value is greater than or equal to the center point value, the corresponding position is marked as 1; otherwise, it is marked as 0. This ring of binary numbers is concatenated sequentially to form a binary pattern string, which can be converted into a decimal number, representing the local binary pattern code for that center point. The histogram of the local binary pattern codes for all pixels (or coefficient points) in the entire sub-band coefficient matrix is ​​then calculated. This histogram constitutes the texture feature distribution at that sub-band scale. By integrating the local binary mode features of multiple subbands (especially high-frequency detail subbands), a robust feature representation can be constructed that can effectively distinguish normal welding textures from various defect textures (such as sparse textures of pore groups and linear textures of cracks).

[0058] Edge gradient analysis was performed on the preprocessed image data using the Sobel operator. The Sobel operator consists of a pair of 3x3 integer convolution kernels, used to calculate the approximate gradient values ​​in the horizontal and vertical directions of the image, respectively. The original image was convolved with these two kernels to obtain the horizontal and vertical gradient component maps. The gradient magnitude of each pixel was obtained by calculating the square root of the sum of the squares of the two components, while the gradient direction was obtained by calculating the arctangent of the two components. In the welded area, points with larger gradient magnitudes typically correspond to material boundaries, weld edges, and the outlines of defects (such as cracks and lack of fusion). The generated edge gradient distribution map not only contains edge intensity information but also implicitly contains edge direction information, which is valuable for distinguishing different types of defects. For example, continuous and uniformly oriented strong edges may indicate cracks, while short, randomly oriented edges may correspond to pores or scattered spatter. Finally, the texture feature distribution derived from multi-scale wavelet decomposition and the edge gradient distribution calculated from the Sobel operator were analyzed.

[0059] Example 2: See Figure 3After extracting the texture and edge gradient features of the welding area, the resulting raw feature data typically exists in different numerical ranges and dimensional systems, and direct merging may introduce bias. Normalization is performed using a min-max scaling method to standardize the data. This method linearly transforms the bin values ​​of each local binary pattern histogram in the texture feature distribution and the magnitude of each gradient in the edge gradient distribution. The transformation process requires calculating the minimum and maximum values ​​in the entire feature vector. For each data point in the feature vector, the minimum value is subtracted, and then the result is divided by the difference between the maximum and minimum values, thus linearly mapping all feature values ​​to a closed interval between zero and one. This process eliminates the imbalance caused by differences in the dimensions and value ranges of the features themselves. For example, texture features may be expressed as statistical frequencies while gradient features are expressed as intensity values; after normalization, they are placed on a comparable scale. The generated standardized feature vector makes the contribution of features from different sources tend to be balanced, providing numerical stability for subsequent linear transformation algorithms and preventing certain large numerical features from dominating the calculation process.

[0060] While standardized eigenvectors have a uniform scale, they often have high dimensionality and contain a degree of redundant information. Principal component analysis (PCA) is used for dimensionality reduction to extract the most discriminative feature combinations. The process begins by calculating the covariance matrix of the standardized eigenvectors, which reflects the degree of linear correlation between different feature dimensions. Eigenvalue decomposition is performed on this covariance matrix to obtain a set of eigenvalues ​​and their corresponding eigenvectors. These eigenvectors define a new coordinate system for the original feature space, with their orientations arranged in descending order of the variance of the retained data. The eigenvectors corresponding to the k largest eigenvalues ​​are selected as principal components. The value of k is determined by the cumulative contribution rate, typically set to retain the minimum number of components that retains the vast majority of the variance, such as over 95%. The original standardized eigenvectors are projected onto the low-dimensional subspace spanned by these k principal components, generating a low-dimensional feature matrix with significantly reduced dimensionality but containing the main variation information of the original data. Dimensionality reduction not only reduces subsequent computational complexity but, more importantly, eliminates noise and redundant dimensions, improving the robustness and representativeness of the feature set.

[0061] The low-dimensional feature matrix primarily captures the texture and gradient statistics of the image itself. To more comprehensively describe the welding state, geometric parameters of the welding area need to be introduced for information fusion. These geometric parameters are obtained through morphological analysis and contour measurement of the preprocessed binarized welding area image. These parameters include the width of the weld joint (converted to millimeters from the average pixel distance perpendicular to the weld direction); the continuous length of the weld (the extent of the weld's extension in the main direction); and the total area of ​​the entire region of interest. These geometric quantities reflect the execution of the welding process; for example, abnormal width may indicate improper heat input, and abnormal length may correspond to welding interruption. The fusion process employs feature concatenation, expanding the low-dimensional feature matrix into a single-row feature vector and simultaneously combining the measured geometric parameters into a separate vector. These two vectors are then connected in the dimensional direction to form a longer, more comprehensive feature vector. The final generated feature description matrix contains both the microscopic image features and macroscopic morphological attributes of the welding area. The microscopic features help to identify the defect type, while the macroscopic geometric parameters help to determine the process background of the defect. The combination of the two provides the defect classification model with more comprehensive and discriminative input information, enhancing the model's ability to distinguish different defect states.

[0062] The construction of the feature description matrix is ​​the information hub of the entire inspection process, elevating the understanding of the original image from the pixel level to the feature level with clear engineering significance. Normalization ensures fair integration between features with different physical meanings, principal component analysis achieves information condensation and noise reduction, and the introduction of geometric parameters links image analysis with actual welding process parameters. The final generated matrix is ​​a well-formatted, fixed-dimensional, and information-dense data structure, preparing the data for subsequent classification models based on deep convolutional neural networks. Each dimension of the matrix represents a quantitative description of a certain aspect of the welded area, and the entire matrix constitutes a multi-dimensional feature signature of the welded joint, the quality of which directly affects the accuracy of the final defect classification and location. The entire feature construction process emphasizes automation and objectivity, minimizing human intervention and subjective judgment, meeting the high requirements of reliability and consistency for industrial inspection systems.

[0063] Example 3: The establishment of the defect classification model begins with the systematic collection of historical welding defect sample data. This work involves selecting representative image data from the quality inspection archives of multiple actual production lines. The sample data needs to cover various typical defect types that may occur during the welding process of steel pipes and copper pipes, such as porosity, cracks, incomplete penetration, slag inclusions, and weld beads, while also including a sufficient number of qualified weld point samples as negative samples. Each sample image must be accurately labeled by a qualified inspection engineer according to industry standards. The labeling information should not only include the defect category but also clearly define the specific bounding box location of the defect in the image. After labeling, the generated structured training dataset is randomly shuffled and then divided into a training subset for updating model parameters and a validation subset for evaluating model performance during training, in a ratio of approximately seven to three. This division aims to make full use of limited data while monitoring the model's generalization ability and preventing it from overfitting to the training data.

[0064] Deep convolutional neural networks (CNNs), as the core architecture of defect classification models, employ a hierarchical feature extraction approach. The network input layer receives a feature description matrix generated in the previous stage, which is reshaped into a two-dimensional or multi-dimensional tensor format suitable for network input. This is followed by several alternating stacked convolutional and pooling layers. The convolutional layers use small kernels (e.g., 3x3) to perform sliding window computation on the input data, combining and transforming features in local regions through a set of learnable weights. A non-linear activation function (such as ReLU) is introduced after each convolutional operation to enhance the model's expressive power. Pooling layers typically follow the convolutional layers, downsampling the feature maps output by the convolutions. Max pooling selects the maximum value within a local region to retain the most significant feature response while reducing data dimensionality, effectively controlling the model's computational complexity and enhancing the spatial invariance of features. Through multiple such convolution-pooling combinations, the original input features are progressively transformed into a series of highly abstract high-level feature maps that capture hierarchical information ranging from simple edges and textures to complex defect patterns.

[0065] The high-level feature map, after being flattened, is fed into a fully connected layer for processing. Each neuron in the fully connected layer is connected to all outputs of the previous layer, and its function is to map the distributed feature representation to the final sample label space. The fully connected layer synthesizes information from all extracted features in the entire feature map through large-scale matrix operations and bias stacking. The output of this layer is an unnormalized real vector, the dimension of which is equal to the total number of defect categories to be classified. The value of each dimension can be regarded as the model's initial confidence score for the corresponding defect type, i.e., the initial probability distribution of the defect type. To transform these initial scores into probability values ​​that conform to probability axioms, the network output layer applies the Softmax function for normalization. The Softmax function transforms the initial probability distribution so that the sum of the output probabilities of all categories is 1. The calculation of this function can be expressed as:

[0066]

[0067] in: Indicates that given input features Under the condition that the sample belongs to category The predicted probability. It is the output of the fully connected layer, corresponding to the category. The raw score (logit). This is the total number of defect categories (including the "no defects" category). It is a natural constant. The denominator is the sum of the original score indices of all categories, which serves as a normalization function. This transformation significantly amplifies the probability corresponding to the maximum score, making the model's predictions more explicit.

[0068] The model training process is an iterative optimization process based on gradient descent, aiming to minimize the difference between the model's predicted probability distribution and the true label distribution. The loss function is the cross-entropy loss, commonly used in classification tasks, which measures the "distance" between the model's predicted probability distribution and the true one-hot encoded label distribution for each training sample. The optimizer chooses stochastic gradient descent or its variants (such as momentum-driven SGD or Adam). In each iteration, it draws a mini-batch of samples from the training subset, calculates the gradient of the loss function with respect to all trainable parameters (weights and biases), and then updates these parameters in the reverse direction of the gradient, thus gradually reducing the loss value. The learning rate, as a key hyperparameter controlling the step size of parameter updates, needs to be carefully set. Training is not indefinite but terminates when the model's performance (e.g., accuracy) on an independent validation subset no longer improves significantly, or when a preset maximum number of iterations is reached, to prevent overfitting.

[0069] After the initial training of the model generates an initial classification model, parameter optimization is needed to pursue optimal performance. Cross-validation is an effective means to achieve this goal, such as k-fold cross-validation. Specifically, the original training dataset is randomly and uniformly divided into k disjoint subsets (usually k is 5 or 10), and then k rounds of training and validation are performed. In each round, k-1 subsets of data are used alternately for model training, and the remaining subset is used to validate the performance of the model trained in that round. Finally, the model's performance is comprehensively evaluated by the average of the results of these k rounds of validation. By observing the average performance of the model under different hyperparameter combinations (such as initial learning rate, number of network layers, number of convolutional kernels, regularization strength, etc.), the set of hyperparameters with the strongest and most stable generalization ability can be selected. Using this optimal set of hyperparameters, the model is trained one last time using the entire training dataset (the merged training and validation subsets), ultimately generating a well-trained defect classification model that can be used for actual welding defect detection. This fully trained and optimized model has the ability to accurately map the input feature description matrix to the defect type probability distribution.

[0070] Example 4: After receiving the feature description matrix representing the welding area, the defect classification model initiates multi-channel convolution operations to deeply explore the spatial correlation between features. This feature description matrix can be regarded as a highly abstract feature map. The multi-channel convolution operation uses a set of pre-trained three-dimensional convolution kernels. Each convolution kernel slides along the width and height dimensions of the feature map, while simultaneously traversing the entire depth dimension (i.e., feature channels). Assume the size of the feature description matrix is ​​[height=32, width=32, number of channels=64], and the applied convolution kernel size is [height=5, width=5, number of input channels=64, number of output channels=128]. This means that the depth of each convolution kernel matches the number of channels in the input feature map, both being 64. When the convolution kernel slides on the input feature map with a stride of 1, at each spatial position (e.g., row i, column j), the 64 channels of the convolution kernel are multiplied element-wise with the 64 feature values ​​at the corresponding positions in the input feature map and summed, plus a bias term, ultimately generating a single numerical value at the corresponding position in the output feature map. With 128 such convolutional kernels, 128 different values ​​are calculated for each sliding position on the input feature map, forming a depth slice of the output feature map. After traversing the entire input region, a multi-channel feature response map of size [28, 28, 128] is finally generated. Each output channel can be understood as a dedicated detector for a specific defect pattern (such as linear cracks, circular pores, irregular inclusions), and the level of its response value reflects the significance of that pattern at the corresponding position in the input feature map.

[0071] Based on the generated multi-channel feature response maps, the next step is to calculate the confidence scores for each type of defect. These scores quantify the overall probability of a particular defect type present in the image. Global average pooling is applied to each individual feature channel. For a feature response map of size [28, 28, 128], the arithmetic mean of all 28x28 spatial location response values ​​within each of its 128 channels is calculated. This operation compresses the two-dimensional feature map of each channel into a single scalar value, representing the average activation intensity of the defect pattern corresponding to that channel across the entire weld area. For example, assuming the 45th channel is trained to be sensitive to "porosity," then the global average pooling value for that channel reflects the overall saliency of the "porosity" feature in the image. After processing all 128 channels, a vector containing 128 scalar values ​​is obtained; this vector represents the initial confidence score vector for each type of defect (and the background). Subsequently, the Softmax function is used to normalize this 128-dimensional vector. Through exponential operations and a normalization factor, the Softmax function transforms the 128 initial scores into a probability distribution, ensuring that the sum of the probabilities of all defect types is 1. This final output is the defect type probability distribution, where the category with the highest probability value is determined by the model to be the most likely defect type. Table 1 shows a simplified hypothetical output, illustrating the possible probability distribution the model might provide for a given weld area.

[0072] Table 1: Probability Distribution of Defect Types

[0073]

[0074] Based on the calculated probability distribution of defect types, the model focuses on locating the physical region most likely to contain the defect. Identifying candidate regions for welding defects is the first step in accurate localization. The generation of candidate regions typically relies on interpreting high-response feature maps. In the example above, the probability of the "porosity" category is as high as 0.52, far higher than other types. Therefore, the localization process focuses on the feature response map generated by feature channels sensitive to "porosity" (such as the hypothetical 45th channel). On this 28x28 single-channel response map, the value of each pixel represents the local probability of the presence of "porosity" features at that spatial location. By setting a threshold, continuous regions with response values ​​exceeding that threshold can be marked as potential defect candidate regions. Another common approach is to use a sliding window mechanism. A series of anchor boxes of different sizes and aspect ratios are pre-defined at the original image scale. These anchor boxes are projected onto the feature response map, and each anchor box is scored based on the average feature response within its coverage area. The boxes with the highest scores are selected as candidate regions. Significant spatial overlap often exists among the large number of generated candidate regions. Non-maximum suppression is used to address this issue to select the optimal candidate regions. The algorithm first sorts all candidate boxes in descending order based on the probability of the defect category corresponding to each candidate region (e.g., the score of each candidate box is taken from the mean or maximum value of its internal feature responses). Then, the candidate box with the highest probability (denoted as box A) is selected as the first final detection result and removed from the candidate list.

[0075] Calculate the overlap ratio (IoR) between all remaining candidate boxes and box A: the ratio of the intersection area to the union area of ​​the two boxes. Any candidate boxes with an IoR exceeding a preset threshold (e.g., 0.5) are considered to be detecting the same object because they highly overlap with the currently selected best box, and are therefore directly removed from the candidate list. From the remaining candidate boxes, select the candidate box with the highest probability (denoted as box B) as the next final detection result, and repeat the above process: calculate the IoR between box B and all remaining boxes, and remove those boxes that overlap too much with box B. This iterative process continues until all candidate boxes have been processed, either selected as the final result or suppressed due to overlap with higher-scoring boxes.

[0076] This process outputs a small set of final defect localization boxes that are relatively independent in spatial location. Aligning these final defect localization boxes with the original image data is a crucial step in generating usable localization marker data; this process involves coordinate mapping. Since the feature response map (28x28) is the result of downsampling the original input image (e.g., 448x448) after multiple convolutions and pooling, it is necessary to map the coordinates of the localization boxes on the feature map (e.g., the top-left corner coordinates [x', y'] and width and height [w', h']) back to the coordinate space of the original image. This mapping is typically achieved by multiplying by a scaling factor determined by the ratio of the original image size to the feature map size (e.g., 448 / 28 = 16). The approximate coordinates of the localization boxes on the original image are: , , , For accurate alignment, the padding effects of convolution and pooling operations may need to be considered, and necessary offset corrections may be required. The final generated localization label data includes the category label (e.g., "pore"), confidence probability (e.g., 0.52), and its precise bounding box coordinates (x, y, w, h) in the original high-resolution image for each detected defect. This data is stored in a structured format (e.g., JSON or XML), providing accurate geometric information for the final visualization rendering.

[0077] Example 5: The specific steps of non-maximum suppression processing begin with the precise calculation of the overlap of candidate regions. This process aims to filter out the most representative results from a large number of potentially redundant detection boxes. Assume that after initial screening, the model generates five candidate region boxes for a suspected "crack" defect in a welding image, labeled B1 to B5, each box accompanied by a confidence probability calculated by the defect classification model. The core of the overlap calculation is the intersection-union ratio (IU), which requires calculating the ratio of the intersection area to the union area for each pair of candidate boxes. For example, to calculate the IU between candidate boxes B1 and B2, first, the overlapping area of ​​the two rectangles on the image plane is determined; the area of ​​this area is the intersection area. Then, the sum of the total areas of rectangles B1 and B2 is subtracted from the intersection area to obtain the union area. Finally, the intersection area is divided by the union area to obtain a value between 0 and 1; the closer the value is to 1, the higher the degree of overlap between the two boxes. This process requires traversing all candidate box pairs to generate an overlap matrix describing the spatial relationship between any two boxes. This matrix is ​​symmetric, and the elements on the diagonal (the intersection-union ratio of each box with itself) are 1.

[0078] Based on the calculated overlap matrix and the defect type probability distribution of each candidate box, the system begins filtering to determine the optimal candidate region. First, all candidate boxes are sorted in descending order of their confidence probability, assuming the sorted order is B3 (0.95), B1 (0.90), B4 (0.85), B2 (0.80), and B5 (0.75). The filtering process is iterative, initially with an empty final defect location box list. In the first iteration, the box with the highest confidence in the current list, B3, is selected as the first final detection result, removed from the candidate list, and added to the final list. Subsequently, the system iterates through the remaining candidate boxes (B1, B4, B2, B5), calculating the intersection-union ratio (IU) of each box with B3. Assuming that the IU of B1 and B4 with B3 both exceed a preset threshold (e.g., 0.5), this indicates that they are highly likely to mark the same defect entity as the high-confidence box B3. Therefore, B1 and B4 are suppressed (i.e., removed) from the candidate list. The remaining candidate boxes become B2 and B5. In the second iteration, B2, with the highest confidence among the remaining B2 and B5, is added to the final list and removed from the candidate list. Next, the intersection-union ratio (IUR) of B5 and B2 is calculated; if its value is below a threshold, B5 is retained in the candidate list. In the third iteration, B5 is added to the final list, at which point the candidate list is empty, and the iteration terminates. Finally, non-maximum suppression outputs three boxes—B3, B2, and B5—with low spatial overlap and relatively high confidence, as the final defect localization boxes. This process effectively avoids duplicate labeling of the same defect location.

[0079] Aligning the final defect bounding boxes with the original image data is a crucial step in generating accurate defect marker data, a process involving coordinate space transformation. Since defect detection models typically operate on low-resolution feature maps, the final bounding box coordinates (e.g., the center point x', y' and width w', height h' of box B3) are based on the feature map scale. These coordinates need to be mapped back to the high-resolution original image space. This mapping is determined by a scaling factor, which is the ratio of the original image size to the feature map size. For example, if the original image resolution is 1600x1200 pixels, and the feature map size is 40x30 pixels, then the scaling factors for width and height are 40 and 40, respectively. The formula for calculating the x-coordinate of the top-left corner of box B3 in the original image is: Similarly, the y-coordinate's width and height also need to be multiplied by the same scaling factor. After calculation, each final defect location box obtains precise geometric parameters in the original image's pixel coordinate system. The generated location marker data is typically recorded in a structured data format, such as creating a data object for each detected defect instance, containing the following fields: defect category (e.g., "crack"), confidence probability (e.g., 0.95), and the original image coordinates (x, y, w, h) of the location box. This data provides a precise geometric basis for subsequent visualization. After the location marker data is generated, the next step is to overlay it onto the original image data to generate an annotated detection image. The overlay operation is achieved through image compositing technology. The system reads the original weld area image and simultaneously draws rectangular bounding boxes using different colors and line widths on another transparent layer, based on the coordinate information of each defect box in the location marker data.

[0080] The type and confidence level of the defect will be indicated by text labels near or inside the rectangular frame, such as "Crack: 0.95" above frame B3. The drawing process must ensure that the superimposed annotations are clearly legible without completely obscuring the details of the original weld image, allowing inspectors to compare the defect annotations with the original appearance. The generated annotated inspection image is a composite image that integrates the original information and the results of automated analysis. Color coding of the annotated inspection image based on the probability distribution of defect types is an important means of enhancing visualization. The color coding scheme is based on a predefined lookup table that maps different defect types or probability ranges to different colors. For example, a warning color scheme can be used: severe defects such as "Crack" are marked with a striking red, with an RGB value set to (255,0,0); "Porosity" is marked with yellow (255,255,0); "Incomplete penetration" is marked with orange (255,165,0); while lower-probability defects or suspicious areas may use less glaring blue or green. Confidence probability can also be incorporated into color coding. For example, for the same defect, the brightness or saturation of the bounding box color can be adjusted to reflect its confidence level. High-confidence boxes are drawn with solid colors and thick lines, while low-confidence boxes are drawn with semi-transparent colors and thin or dashed lines. This visual coding method allows inspectors to quickly extract key information from images, instantly identifying the severity of the defect and the confidence level of the detection system. The final visualized inspection results can be saved in common image formats (such as PNG and JPEG) and integrated into the inspection software interface, supporting interactive operations such as zooming and panning, facilitating detailed review and judgment by users.

[0081] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus.

[0082] Although embodiments of the invention have been shown and described, it will be understood by those skilled in the art that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the appended claims and their equivalents.

Claims

1. A method for detecting welding defects in steel pipes and copper pipes, characterized in that, include: The original image data of the steel pipe and copper pipe welding area is collected, and grayscale conversion and noise suppression are performed on the original image data to generate preprocessed image data. Based on the preprocessed image data, the texture feature distribution and edge gradient distribution of the welding area are extracted, and a feature description matrix of the welding area is constructed. The feature description matrix is ​​input into the trained defect classification model, and the probability distribution of defect types in the welding area is output. Based on the probability distribution of defect types, location marker data for welding defects is generated, and combined with the original image data, a visual detection result of the welding defects is generated.

2. The method for detecting welding defects in steel pipes and copper pipes according to claim 1, characterized in that, The specific steps for grayscale conversion and noise suppression of the original image data include: Adaptive histogram equalization is performed on the original image data to generate equalized image data; A nonlocal mean filtering algorithm is used to smooth the equalized image data, generating denoised preprocessed image data.

3. The method for detecting welding defects in steel pipes and copper pipes according to claim 1, characterized in that, The extraction process of texture feature distribution and edge gradient distribution of the welding area based on preprocessed image data includes: Multi-scale wavelet transform decomposition is performed on the preprocessed image data to generate sub-band coefficient matrices for different frequency bands; The local binary pattern feature vector of the welding area is calculated based on the sub-band coefficient matrix to generate the texture feature distribution. The Sobel operator is used to perform edge detection on the preprocessed image data to generate edge gradient distribution.

4. The method for detecting welding defects in steel pipes and copper pipes according to claim 1, characterized in that, The process of constructing the feature description matrix includes: The texture feature distribution and edge gradient distribution are normalized to generate standardized feature vectors; Principal component analysis is performed on the standardized eigenvectors to reduce dimensionality and generate a low-dimensional feature matrix. The low-dimensional feature matrix is ​​fused with the geometric parameters of the welding area to generate a feature description matrix.

5. The method for detecting welding defects in steel pipes and copper pipes according to claim 1, characterized in that, The training process of the defect classification model includes: Collect historical welding defect sample data, label the sample data, and generate a training dataset; A deep convolutional neural network is used to iteratively train the training dataset to generate an initial classification model; The parameters of the initial classification model are optimized using cross-validation to generate a trained defect classification model.

6. The method for detecting welding defects in steel pipes and copper pipes according to claim 5, characterized in that, The structure of the deep convolutional neural network includes: The input layer receives the feature description matrix and generates a high-level feature map through multiple convolution and pooling operations. The high-level feature map is input into the fully connected layer to generate the initial probability distribution of the defect type; The initial probability distribution is normalized using the Softmax function to generate the defect type probability distribution.

7. The method for detecting welding defects in steel pipes and copper pipes according to claim 1, characterized in that, The process of generating the probability distribution of the defect type includes: Perform multi-channel convolution on the feature description matrix to generate a multi-channel feature response map; Confidence scores for various defects are calculated based on multi-channel feature response maps, and probability distributions of defect types are generated.

8. The method for detecting welding defects in steel pipes and copper pipes according to claim 1, characterized in that, The process of generating the location marker data includes: Candidate regions for welding defects are determined based on the probability distribution of defect types; Non-maximum suppression is applied to the candidate regions to generate the final defect location boxes; Align the final defect location box with the original image data to generate location marker data.

9. The method for detecting welding defects in steel pipes and copper pipes according to claim 8, characterized in that, The specific steps of the nonmaximum suppression process include: Calculate the overlap between candidate regions and generate an overlap matrix; The optimal candidate regions are selected based on the overlap matrix and the probability distribution of defect types, and the final defect location box is generated.

10. The method for detecting welding defects in steel pipes and copper pipes according to claim 1, characterized in that, The process of generating the visualized detection results includes: The location marker data is superimposed onto the original image data to generate an annotated detection image; The labeled detection images are color-coded according to the probability distribution of defect types to generate visual detection results of welding defects.

Citation Information

Patent Citations

  • Flue-cured tobacco leaf spot disease detection method based on image processing

    CN117351474A

  • Intelligent defect detection system for anode copper plate production

    CN118864428A

  • Circuit board welding fault identification method and system based on machine vision

    CN119648679A

  • Intelligent detection method for machining process of automobile decorative plate

    CN119919400A

  • Distribution line insulation defect type identification method and device, terminal equipment and storage medium

    CN120197092A

Cited By

  • Cathode copper defect tracing method, system and program product based on rag retrieval

    CN122473157A