A weld defect identification method and system of frequency domain-color domain joint decoupling
Patent Information
- Application Number
- CN202611253163.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-18
- Publication Date
- 2026-09-18
AI Technical Summary
[0005]第一,特征提取尺度单一
[0041]1. This invention combines two-dimensional discrete wavelet transform with RGB color channel decomposition, decoupling twelve frequency-color sub-bands within the joint frequency-color domain space. This overcomes the limitations of a single four-sub-band decomposition in the frequency domain, achieving a joint representation of the color and frequency dimensions. Different weld defects exhibit varying responses in different color channels. The twelve-sub-band decomposition can more precisely characterize the multi-scale, multi-directional, and multi-channel features of complex weld defects, improving the model's fine-grained discrimination capability for color-sensitive defects.
Smart Images

Figure CN122780291A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of industrial non-destructive testing and computer vision technology, and in particular to a method and system for weld defect identification with joint decoupling of frequency domain and color domain. Background Technology
[0002] Weld quality directly affects the safety and reliability of welded structures such as pipelines and containers. X-ray non-destructive testing is the core method for identifying internal weld defects and is widely used in industrial production. Weld defects typically include various types such as porosity, cracks, slag inclusions, undercut, lack of fusion, and incomplete penetration. These defects differ significantly in morphology, size, grayscale distribution, and edge characteristics, posing a challenge to high-precision automatic identification.
[0003] Currently, weld defect identification methods mainly fall into two categories: those based on traditional image processing and those based on deep learning. In traditional methods, some research attempts to introduce wavelet transform into this field, decomposing the image into multiple frequency sub-bands using a two-dimensional discrete wavelet transform, and then using a convolutional neural network for defect identification. However, such schemes often employ fixed computational paths, lack specific attention to the frequency domain features of defects, and fail to fully utilize the color domain information of the image, resulting in limited accuracy in identifying defects with significant morphological differences.
[0004] With the development of deep learning technology, methods based on convolutional neural networks have become mainstream. However, existing technologies have the following shortcomings:
[0005] First, the feature extraction scale is limited. Deep learning models based on a single scale struggle to simultaneously capture both macroscopic structural information and microscopic edge details in weld images. Weld defects include large areas of unfused metal as well as tiny pores or cracks. Single-scale feature extraction methods cannot take into account both global context and local edge responses, resulting in insufficient accuracy in identifying certain types of defects.
[0006] Second, color domain information is not fully utilized. Most existing wavelet transform methods rely solely on frequency domain information, neglecting the rich discriminative information carried by the R, G, and B color channels in color weld images. In real-world images, different defects exhibit significant differences in response across different color channels, and the same defect may display drastically different edge and texture features in the high-frequency subbands of different channels. However, existing schemes only perform frequency domain decomposition on a single channel or grayscale image, failing to fully exploit the discriminative information inherent in the color dimension and limiting further improvements in recognition performance.
[0007] Third, there is a poor balance between computational efficiency and accuracy. Traditional models use fixed computational paths, requiring the execution of the complete network structure even for samples with low discrimination difficulty, lacking dynamic reasoning capabilities. In scenarios with high real-time requirements, such as industrial online inspection, this "one-size-fits-all" approach results in unnecessary computational redundancy and resource waste, failing to meet the dual requirements of efficiency and real-time performance in actual production. Summary of the Invention
[0008] To address the shortcomings of the existing technologies, the present invention aims to provide a method and system for weld defect identification with joint decoupling of the frequency domain and color domain. By combining two-dimensional discrete wavelet transform with RGB color channel decomposition, twelve frequency-color sub-bands are obtained by decoupling in the joint space of the frequency domain and color domain. Furthermore, a cross-color channel collaborative spatial attention mechanism, a competitive weight allocation strategy, and a confidence-triggered single-condition early stopping strategy are introduced to achieve efficient and accurate identification of weld defects.
[0009] To solve the above-mentioned technical problems, the technical solution adopted by the present invention is as follows:
[0010] A method for weld defect identification with joint decoupling of frequency domain and color domain includes the following steps:
[0011] Step S1: Obtain a color weld defect image containing three color channels: R, G, and B; sequentially perform denoising, color space conversion and contrast enhancement processing, and region of interest segmentation on the color weld defect image, and output the weld defect region of interest image T.
[0012] Step S2: Perform a single-layer two-dimensional discrete wavelet transform on the region of interest image to decouple and obtain low-frequency approximate sub-bands, horizontal low-frequency and vertical high-frequency detail sub-bands, horizontal high-frequency and vertical low-frequency detail sub-bands, and diagonal high-frequency detail sub-bands; then decompose each frequency domain sub-band into three single-channel sub-images (R, G, B) according to the color channel, thereby decoupling and obtaining twelve frequency-color sub-bands in the joint space of frequency domain and color domain;
[0013] Step S3: Based on the frequency-color characteristics of each frequency-color sub-band, construct twelve differentiated parallel convolutional neural network branches to extract the defect features of each color channel at different frequency scales.
[0014] Step S4: Embed a frequency-color collaborative spatial attention module in the convolutional neural network branch of each frequency-color sub-band. In view of the spatial distribution difference of the defect response of the same frequency sub-band in different color channels, perform color sensitivity quantization on the feature map of each color channel branch respectively. Generate a two-dimensional attention weight map that adapts to the spatial response characteristics of the frequency-color sub-band by calculating the cross-color channel response correlation. Then perform pixel-by-pixel modulation operation with the corresponding branch input feature map to achieve cross-color channel differential spatial feature enhancement in the same frequency dimension.
[0015] Step S5: Each frequency-color sub-band convolutional neural network branch independently outputs a defect classification probability distribution vector; the discrimination certainty of each frequency-color sub-band is jointly evaluated based on the maximum class probability and distribution information entropy of the predicted probability distribution of each branch, and a normalized confidence index is generated; further, a competitive weight allocation is performed on the confidence of each sub-band using a normalized exponential function, so that the contribution of different color channels in the same frequency domain presents a differentiated weight distribution, and the probability output of each branch is weighted and aggregated according to the differentiated weights to obtain the comprehensive classification probability;
[0016] Step S6: Set the inference confidence threshold; During the inference process, each frequency-color sub-band branch is activated sequentially and independently in a predetermined execution order; When the normalized confidence of any frequency-color sub-band reaches or exceeds the inference confidence threshold, the current defect category identification result is directly output, triggering streaming early stop and terminating the forward propagation of subsequent branches that have not yet been executed.
[0017] Step S7: When the streaming early stop is not triggered, the defect category is determined in the frequency domain-color domain joint discrimination space based on the comprehensive classification probability. The target defect category index is determined by the maximum probability selection operator, and the classification confidence index of the frequency-color dimension is generated by combining the weight distribution of each color channel branch. The final weld defect classification and identification decision result is output.
[0018] A further improvement to the technical solution of this invention is as follows: In step S1, the specific processes of denoising, color space conversion and contrast enhancement, and region of interest segmentation are as follows: First, the colored weld defect image is subjected to Gaussian filtering for denoising; then, the denoised colored image is converted from the RGB color space to the LAB color space, the L luminance channel is extracted, and the L luminance channel is subjected to contrast-limited adaptive histogram equalization, while the A chrominance channel and the B chrominance channel remain unchanged. Then, the enhanced LAB image is converted back to the RGB color space to complete the contrast enhancement; finally, the enhanced colored weld defect image is subjected to adaptive threshold segmentation, spatial geometric constraint filtering, and Hough transform edge consistency verification in sequence, and the region of interest image T containing the complete defect region is output.
[0019] A further improvement of the technical solution of the present invention is that: in step S2, the four frequency domain sub-bands include a low-frequency approximate sub-band, a horizontal low-frequency vertical high-frequency detail sub-band, a horizontal high-frequency vertical low-frequency detail sub-band, and a diagonal high-frequency detail sub-band;
[0020] First, a two-dimensional discrete wavelet transform is performed on the region of interest image to obtain four frequency domain sub-bands. Then, each frequency domain sub-band is decomposed into R, G, and B color channels to obtain a total of twelve frequency-color sub-bands. Among them, the three sub-bands obtained after the three-color channel decomposition of the same frequency domain sub-band capture the response differences of the frequency component in the R, G, and B channels, respectively. The decomposed sub-bands of different frequency domain sub-bands in the same color channel capture the response characteristics of weld defects at different frequency scales.
[0021] A further improvement of the technical solution of this invention is that: in step S3, the twelve differentiated parallel convolutional neural network branches are grouped and constructed according to color channels and frequency directions, and the convolutional kernel parameters of each branch are independently optimized for the R, G, and B response characteristics of the corresponding color channel; including: a low-frequency branch corresponding to each color channel, which uses a large-size convolutional kernel to extract the macroscopic contour features of weld defects in that color channel; a vertical abrupt change feature extraction branch corresponding to each color channel, which targets the horizontal low-frequency and vertical high-frequency detail sub-bands of that color channel, and uses an anisotropic convolutional kernel optimized for the R / G / B response characteristics of that color channel to extract the longitudinal defect features along the weld direction; a horizontal abrupt change feature extraction branch corresponding to each color channel, which targets the horizontal high-frequency and vertical low-frequency detail sub-bands of that color channel, and uses an anisotropic convolutional kernel optimized for the R / G / B response characteristics of that color channel to extract the transverse defect features perpendicular to the weld direction; and a diagonal high-frequency branch corresponding to each color channel, which uses a small-size convolutional kernel to extract the subtle defect features in that color channel.
[0022] A further improvement to the technical solution of the present invention is that, in step S4, the processing procedure of the frequency-color collaborative spatial attention module is as follows:
[0023] First, the feature maps of the three color channel branches corresponding to the same frequency domain sub-band are used as input. Based on the difference in sensitivity of each color channel to the defect color features, the color sensitivity quantization processing is performed on the feature maps of each color channel, and the spatial attention preference map of each color channel is output.
[0024] Subsequently, the attention preference maps of the three color channels are subjected to cross-channel feature interaction and competition suppression processing to generate a two-dimensional attention weight map that takes into account the joint characteristics of frequency and color.
[0025] Finally, the weight map and the corresponding frequency-color sub-band input feature map are subjected to pixel-by-pixel modulation operation to achieve differential spatial feature enhancement across color channels within the same frequency dimension, and the enhanced frequency-color sub-band feature map is output.
[0026] A further improvement to the technical solution of the present invention is that, in step S5, the calculation process of the competitive weight allocation is as follows:
[0027] First, based on the defect prediction probability distribution output by each frequency-color sub-band branch, the prediction information entropy corresponding to each branch is calculated to quantify the uncertainty of the probability distribution. Then, the discrimination certainty of the current sub-band is calibrated by combining the maximum class probability of each branch. After normalization, the confidence index of each frequency-color sub-band is generated.
[0028] Subsequently, a smoothness scaling factor is introduced to numerically regulate the confidence index. The normalized exponential function is then fed into the confidence index of each sub-band to perform competitive exponential transformation and proportional normalization, so that the branch weights of different color channels in the same frequency domain present a differentiated distribution that matches the discrimination contribution of each channel, and the contribution weight of each frequency-color sub-band branch to the final decision is adaptively output.
[0029] A further improvement of the technical solution of the present invention is that, in step S6, the predetermined execution order is one of the following two execution strategies:
[0030] First, traverse all color branches of the same frequency domain sub-band in color channel order, then switch to the next frequency domain sub-band, until all twelve frequency-color sub-bands have been traversed;
[0031] Alternatively, you can first traverse all frequency sub-bands of the same color channel in order of frequency direction, and then switch to the next color channel, until all twelve frequency-color sub-bands have been traversed.
[0032] A frequency domain-color domain jointly decoupled weld defect identification system includes the following modules:
[0033] The region of interest segmentation module is used to acquire a color weld defect image containing three color channels: R, G, and B. The color weld defect image is then subjected to Gaussian filtering for noise reduction, L-channel contrast-limited adaptive histogram equalization under LAB color space conversion, and region of interest segmentation in sequence, and the region of interest image is output.
[0034] The frequency domain-color domain joint decoupling module is used to perform a single-layer two-dimensional discrete wavelet transform on the region of interest image to obtain low-frequency approximate sub-bands, horizontal low-frequency and vertical high-frequency detail sub-bands, horizontal high-frequency and vertical low-frequency detail sub-bands, and diagonal high-frequency detail sub-bands; and decomposes each frequency domain sub-band into three single-channel sub-images (R, G, B) according to the color channel, and decouples them in the frequency domain-color domain joint space to obtain twelve frequency-color sub-bands;
[0035] The twelve-branch feature extraction neural network module is used to construct twelve differentiated parallel convolutional neural network branches. The convolutional kernel parameters of each branch are independently optimized for the R, G, and B response characteristics of the corresponding color channel. For each frequency-color sub-band, the defect features of the corresponding color channel at different frequency scales are extracted.
[0036] The frequency-color co-spatial attention weighting module is used to embed the frequency-color co-spatial attention module in each frequency-color sub-network branch. It performs color sensitivity quantization and cross-channel feature interaction on the feature maps of the three color channel branches corresponding to the same frequency domain sub-band, generates a two-dimensional attention weight map that takes into account the joint characteristics of frequency and color, and performs pixel-by-pixel modulation operation with the corresponding feature map to achieve differentiated spatial feature enhancement across color channels in the same frequency dimension.
[0037] The competitive weighted decision module is used to evaluate the discrimination certainty of each sub-band based on the defect classification probability distribution vector independently output by each frequency-color sub-band convolutional neural network branch, using the maximum class probability and distribution information entropy. The module competitively assigns weights to the confidence of each sub-band through a normalized exponential function, so that the contribution of different color channels in the same frequency domain presents a differentiated weight distribution. The probability output of each branch is weighted and aggregated according to the differentiated weights to generate a comprehensive classification probability.
[0038] The confidence-triggered early stop control unit is used to activate and independently distinguish each frequency-color sub-band branch in a predetermined execution order during the inference process. When the normalized confidence of any frequency-color sub-band reaches or exceeds the inference confidence threshold, the current defect category identification result is directly output and the forward propagation of subsequent branches that have not yet been executed is terminated.
[0039] The joint discrimination classification output module is used to execute the maximum selection operator on the weighted aggregated comprehensive classification probability in the frequency domain-color domain joint discrimination space when the confidence-triggered early stop control unit does not trigger early stop or completes all branch calculations, and generate a classification confidence index in the frequency-color dimension by combining the weight distribution of each color channel branch, and output the final weld defect classification result.
[0040] The technological advancements achieved by this invention due to the adoption of the above technical solutions are as follows:
[0041] 1. This invention combines two-dimensional discrete wavelet transform with RGB color channel decomposition, decoupling twelve frequency-color sub-bands within the joint frequency-color domain space. This overcomes the limitations of a single four-sub-band decomposition in the frequency domain, achieving a joint representation of the color and frequency dimensions. Different weld defects exhibit varying responses in different color channels. The twelve-sub-band decomposition can more precisely characterize the multi-scale, multi-directional, and multi-channel features of complex weld defects, improving the model's fine-grained discrimination capability for color-sensitive defects.
[0042] 2. This invention constructs twelve differentiated parallel convolutional neural network branches. The convolutional kernel parameters of each branch are independently optimized for the R, G, and B response characteristics of its respective color channel. A frequency-color collaborative spatial attention module is embedded in each branch. This module calculates the cross-color channel response correlation to achieve feature interaction and competition suppression between different color channels within the same frequency domain sub-band. This enables the model to adaptively highlight spatial regions with strong defective responses in specific color channels, suppress background noise and redundant information, and enhance the effectiveness and discriminative power of feature representation.
[0043] 3. This invention employs a confidence-triggered single-condition early stopping strategy. Early stopping is triggered when the normalized confidence of any frequency-color sub-band reaches or exceeds the inference confidence threshold, eliminating the need to wait for multiple sub-band categories to align. In a twelve-sub-band scenario, this allows for earlier termination of redundant calculations, significantly reducing inference latency. Simultaneously, a competitive weight allocation mechanism ensures differentiated contributions from different color channel branches within the same frequency domain, preventing weaker sub-bands from diluting the contributions of stronger sub-bands and improving the accuracy and reliability of the final classification decision. Attached Figure Description
[0044] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0045] Figure 1 This is a flowchart of a weld defect identification method with joint decoupling of frequency domain and color domain provided in an embodiment of the present invention;
[0046] Figure 2 This is a schematic diagram of frequency domain-color domain joint decoupling in an embodiment of the present invention;
[0047] Figure 3 This is a diagram of the twelve-branch differentiated CNN network architecture in an embodiment of the present invention;
[0048] Figure 4This is a schematic diagram of the internal structure of a frequency-color collaborative spatial attention module in an embodiment of the present invention (taking the LL frequency domain sub-band as an example).
[0049] Figure 5 This is a flowchart of competitive weight allocation and confidence-triggered early stopping in an embodiment of the present invention. Detailed Implementation
[0050] It should be noted that the terms "comprising" and "having" and any variations thereof in the specification, claims and accompanying drawings of this invention are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such process, method, product or device.
[0051] The present invention will be further described in detail below with reference to the accompanying drawings and embodiments:
[0052] Example 1
[0053] This embodiment provides a method for weld defect identification based on joint decoupling of the frequency domain and color domain, such as... Figure 1 As shown, the process includes steps S1 to S7. Each step will be described in detail below with reference to the accompanying drawings.
[0054] Step S1: Image Preprocessing
[0055] Step S1 corresponds to Figure 1 The "S1 Image Preprocessing" section describes the weld defect image in this embodiment, which is obtained from weld images acquired by an X-ray non-destructive testing system. The acquired weld defect image is a color weld defect image containing three color channels: R, G, and B. The specific preprocessing steps include:
[0056] (1) Gaussian filtering for noise reduction. Gaussian filtering is applied to the color weld defect image. A two-dimensional Gaussian function is used as the convolution kernel to smooth the image, effectively suppressing random noise generated during X-ray imaging while preserving effective information about the defect edges. The kernel size of the Gaussian filter can be set according to the actual image resolution and noise level. In this embodiment, a 3×3 or 5×5 Gaussian convolution kernel is used.
[0057] (2) LAB Color Space Enhancement. The denoised color image is converted from the RGB color space to the LAB color space. The L luminance channel is extracted and contrast-limited adaptive histogram equalization (CLAHE) is performed on the L luminance channel. The A and B chrominance channels remain unchanged. The enhanced LAB image is then converted back to the RGB color space to complete the contrast enhancement. The reason for choosing the LAB color space for processing is that luminance and chrominance information are coupled in the RGB color space. If histogram equalization is performed on the R, G, and B channels separately, the different stretching of each channel will lead to an imbalance in color proportions and color shift. The LAB color space completely separates the L luminance channel from the A and B chrominance channels. CLAHE is performed on the L channel alone, which can enhance the contrast between the defective areas and the background while completely preserving the color proportions of the original image. CLAHE divides the image into multiple sub-regions, performs histogram equalization in each sub-region, and limits the contrast enhancement, thus avoiding excessive noise amplification.
[0058] (3) ROI Segmentation. The enhanced color weld defect image is sequentially subjected to adaptive threshold segmentation, spatial geometric constraint screening, and Hough transform edge consistency verification to output a region of interest image T containing the complete defect region. Adaptive threshold segmentation adaptively determines the segmentation threshold based on the local grayscale distribution of the image, separating the candidate defect region from the background. Spatial geometric constraint screening calculates geometric features such as the area, aspect ratio of the bounding rectangle, and compactness of each candidate contour to eliminate invalid contours that are too small, too narrow, or have unreasonable compactness. Hough transform edge consistency verification uses the Hough transform to detect straight line features in the image, verifying the consistency between the edge of the candidate defect region and the weld direction, further eliminating false defect regions. After the above processing, the region of interest image T containing the complete defect region is output as the input for subsequent frequency domain-color domain joint decoupling.
[0059] Step S2: Frequency domain-color domain joint decoupling
[0060] Step S2 corresponds to Figure 1 The "S2 frequency domain-color domain joint decoupling" section and Figure 2 The frequency domain-color domain joint decoupling process is shown. For example... Figure 2 As shown, this step sequentially performs frequency-scale two-dimensional discrete wavelet transform and RGB color channel decomposition.
[0061] First, a single-layer two-dimensional discrete wavelet transform is performed on the region of interest image T. In this embodiment, the db2 or db4 wavelet from the Daubechies wavelet family is selected as the wavelet basis function. The two-dimensional discrete wavelet transform performs cascaded low-pass filtering, high-pass filtering, and downsampling operations along the horizontal and vertical directions of the image, mapping the spatial local energy of the image to four independent frequency domain sub-bands: the LL sub-band (low-frequency approximation sub-band) is obtained through low-pass filtering in the horizontal and vertical directions, representing the overall contour and macroscopic morphology information of the image; the LH sub-band (horizontal low-frequency vertical high-frequency detail sub-band) is obtained through horizontal low-pass and vertical high-pass filtering, representing the longitudinal abrupt change features along the weld direction; the HL sub-band (horizontal high-frequency vertical low-frequency detail sub-band) is obtained through horizontal high-pass and vertical low-pass filtering, representing the transverse abrupt change features perpendicular to the weld direction; and the HH sub-band (diagonal high-frequency detail sub-band) is obtained through horizontal high-pass and vertical high-pass filtering, representing the fine texture and local anomalies in the diagonal direction.
[0062] After completing wavelet decomposition, as follows Figure 2 As shown in the "Color Channel Decomposition" section, each frequency domain sub-band is decomposed into three single-channel sub-images: R, G, and B. For each frequency domain sub-band, its components in the R, G, and B channels are extracted, resulting in three independent single-channel sub-images. Through this decomposition, four frequency domain sub-bands multiplied by three color channels yield a total of twelve frequency-color sub-bands. These frequency-color sub-bands possess dual physical properties: on the one hand, they inherit the frequency scale characteristics of their respective frequency domain sub-bands; on the other hand, they carry the color response characteristics of their respective color channels. The three sub-bands obtained after decomposing the same frequency domain sub-band into three color channels respectively capture the response differences of that frequency component in the R, G, and B channels; the decomposed sub-bands of different frequency domain sub-bands in the same color channel respectively capture the response characteristics of weld defects at different frequency scales.
[0063] Step S3: Twelve-branch differential CNN feature extraction
[0064] Step S3 corresponds to Figure 1 The "S3 Twelve-Branch CNN Feature Extraction" section and Figure 3 The twelve-branch differential CNN network architecture is shown. Figure 3 As shown, the twelve parallel convolutional neural network branches are constructed in groups according to three color channels (R, G, B) and four frequency domain directions (LL, LH, HL, HH), totaling 12 branches (e.g., LL-R, LL-G, LL-B, LH-R, LH-G, LH-B, HL-R, HL-G, HL-B, HH-R, HH-G, HH-B). The convolutional kernel parameters of each branch are independently optimized for the R, G, and B response characteristics of its respective color channel. The construction details are as follows:
[0065] (1) Low-frequency branches (LL-R, LL-G, LL-B): Targeting the low-frequency approximate subbands under the corresponding color channel, large-size convolutional kernels (7×7 or 5×5) are used to extract the macroscopic contour features of weld defects under this color channel. The specific network structure is as follows: 7×7 convolution (32 channels), 3×3 convolution (32 channels), max pooling, 3×3 convolution (64 channels), 3×3 convolution (64 channels), max pooling, 3×3 convolution (128 channels), adaptive average pooling to 1×1, fully connected layer and Softmax classification layer.
[0066] (2) Vertical mutation feature extraction branches (LH-R, LH-G, LH-B): Targeting the horizontal low-frequency and vertical high-frequency detail subbands under the corresponding color channels, anisotropic convolution kernels optimized for the R / G / B response characteristics of the color channels are used to extract longitudinal defect features along the weld direction. The anisotropic convolution kernels have asymmetrical sizes in the horizontal and vertical directions, which can selectively enhance the gray-scale mutation response in the vertical direction. The specific network structure is as follows: 1×5 anisotropic convolution (32 channels), 3×3 convolution (32 channels), max pooling, 1×5 anisotropic convolution (64 channels), 3×3 convolution (64 channels), adaptive average pooling to 1×1, fully connected layer, and Softmax classification layer.
[0067] (3) Horizontal mutation feature extraction branch (HL-R, HL-G, HL-B): Targeting the horizontal high-frequency and vertical low-frequency detail subbands under the corresponding color channel, anisotropic convolution kernels optimized for the R / G / B response characteristics of the color channel are used to extract the transverse defect features perpendicular to the weld direction. The specific network structure is as follows: 5×1 anisotropic convolution (32 channels), 3×3 convolution (32 channels), max pooling, 5×1 anisotropic convolution (64 channels), 3×3 convolution (64 channels), adaptive average pooling to 1×1, fully connected layer and Softmax classification layer.
[0068] (4) Diagonal high-frequency branches (HH-R, HH-G, HH-B): These branches target the diagonal high-frequency detail subbands of the corresponding color channels, using small-sized convolutional kernels (3×3) to extract subtle defect features in that color channel. Since the HH subbands have limited information and relatively high noise, a Dropout operation (with a dropout probability of 0.4) is introduced before pooling to suppress overfitting. The specific network structure is as follows: 3×3 convolution (32 channels), 3×3 convolution (32 channels), Dropout (0.4), max pooling, 3×3 convolution (64 channels), adaptive average pooling to 1×1, fully connected layers, and a Softmax classification layer.
[0069] The twelve CNN branches mentioned above are essentially a homologous extension of the four-subband CNN structure of the WAC4 model: the number of branches is increased from 4 to 12. The convolutional kernel parameters of each branch are independently learned and optimized according to the response characteristics of its respective color channel (R / G / B), enabling the model to specifically capture the differentiated feature representation of weld defects at different frequency scales for each color channel. Each branch embeds a frequency-color co-space attention module (see step S4 for details), and finally each branch independently outputs a C-dimensional defect classification probability distribution vector P. k (k=1,2,...,12, C is the number of defect categories).
[0070] Step S4: Frequency-Color Co-spatial Attention Enhancement
[0071] Step S4 corresponds to Figure 1 The "S4 Frequency-Color Co-spatial Attention" section and Figure 4 The diagram shows the internal structure of the frequency-color collaborative spatial attention module. Figure 4 As shown, taking the LL frequency domain subband as an example, the processing flow of this module includes four sub-steps (the same applies to the LH, HL, and HH frequency domain subbands, only the input feature maps are different):
[0072] Step S41: Color Sensitivity Quantization. Using the feature maps FR, FG, and FB corresponding to the three color channel branches of the same frequency domain sub-band (e.g., LL) as input, spatial statistical compression is performed independently for each color channel based on their varying sensitivity to defect color features. Specifically, the average feature map and maximum feature map are calculated along the channel dimension for each channel's feature map. These two statistical feature maps are concatenated and fed into a convolutional layer, then processed by a sigmoid activation function to obtain the spatial attention preference maps AR, AG, and AB for each color channel. The mathematical expression for this operation is:
[0073]
[0074] Where y∈{R,G,B}, and [;] represents the concatenation operation.
[0075] Step S42: Cross-channel feature interaction and competition suppression. The attention preference maps AR, AG, and AB of the three color channels are concatenated and fed into a 1×1 convolutional layer to achieve cross-channel interaction and competition suppression of the feature maps of the three color channels under the same frequency domain subband. The 1×1 convolution can learn the weighted relationship between the R, G, and B channels in the channel dimension. If the defect response of a certain color channel at a certain spatial location is significantly stronger than that of the other two channels, the attention weight at that spatial location will be competitively amplified, while suppressing the corresponding responses of other channels. Finally, the output value is compressed to the interval (0, 1) by the Sigmoid activation function.
[0076] Step S43: Generate a two-dimensional attention weight map W. After Sigmoid processing, a two-dimensional attention weight map W that takes into account the joint frequency-color characteristics is output. This weight map has the same spatial size as the input feature map, and the value of each pixel reflects the importance of the corresponding spatial location for defect detection: the closer the value is to 1, the more important the frequency-color joint features of that spatial location are for defect detection; the closer the value is to 0, the more likely that the location is redundant information such as background or noise.
[0077] Step S44: Pixel-wise modulation. The two-dimensional attention weight map W is multiplied pixel-wise with the three original input feature maps FR, FG, and FB respectively, resulting in enhanced frequency-color sub-band feature maps FWR = W⊙FR, FWG = W⊙FG, and FWB = W⊙FB, where ⊙ denotes pixel-wise multiplication. This operation amplifies the feature responses of spatial regions with high attention weights and suppresses the feature responses of regions with low weights (background or noise). The entire feature extraction module can be expressed as:
[0078]
[0079] Among them, A k z is the subband attention mapping function, CNN is the subband CNN feature extraction function. k This is the effective feature vector for sub-band discrimination.
[0080] Step S5: Confidence Calculation and Competitive Weight Allocation
[0081] Step S5 corresponds to Figure 1 The "S5 Competitive Weight Allocation" section. The formula for the independent output defect classification probability distribution vector of each frequency-color subband CNN branch is:
[0082]
[0083] Where C is the number of defect categories (C=6 in this embodiment), p k (C) represents the probability that the sample in the k-th branch belongs to the C-th type of defect.
[0084] The calculation process for competitive weight allocation is as follows:
[0085] The first step is to calculate the prediction information entropy H for each branch. k This quantifies the degree of uncertainty in the probability distribution. The specific formula is as follows:
[0086]
[0087] The lower the information entropy, the more concentrated the discrimination of that branch and the less uncertainty it has. Simultaneously, the maximum class probability p of each branch is extracted. maxkThe discrimination certainty of the current sub-band is jointly calibrated by combining information entropy. The normalized confidence index for each frequency-color sub-band after normalization is as follows:
[0088]
[0089] The second step involves introducing a smoothness scaling factor β to numerically adjust the confidence index, feeding it into the normalized exponential function Softmax for competitive exponential transformation and proportional normalization, and calculating the contribution weight w of each branch. k :
[0090]
[0091] The competitive nature of the Softmax function allows subbands with higher confidence to receive significantly amplified weights, while the weights of subbands with lower confidence are suppressed. This results in a differentiated distribution of branch weights for different color channels in the same frequency domain, which matches the discrimination contribution of each channel.
[0092] The third step is to weight and aggregate the probability outputs of each branch according to their differential weights to obtain the comprehensive classification probability. :
[0093]
[0094] The aggregation result serves as the basis for joint judgment when early stopping is not triggered (step S7).
[0095] Step S6: Confidence-triggered streaming early stop
[0096] Step S6 corresponds to Figure 1 In the decision node where "normalized confidence of any subband of S6 is greater than or equal to the threshold" and Figure 5 The flowchart shown illustrates the competitive weight allocation and confidence-triggered early stopping mechanism. (See attached diagram.) Figure 5 As shown: First, the inference confidence threshold τ is set. The value of τ is determined experimentally: if τ is too small, effective features will be discarded prematurely, reducing recognition accuracy; if τ is too large, the goal of improving inference efficiency will not be achieved, and invalid features may be introduced, leading to overfitting. In this embodiment, the value of τ is 0.8.
[0097] During inference, each frequency-color sub-band branch is activated sequentially and independently according to a predetermined execution order. When the normalized confidence γ of any frequency-color sub-band (let's call it the k-th branch)... k When the threshold τ is reached or exceeded, the defect category identification result of the current sub-band is directly output, triggering early stopping of the streaming process and terminating the forward propagation of subsequent branches that have not yet been executed (branches k+1 to 12). When γ kWhen < τ, continue to the next sub-band k=k+1. If all twelve frequency-color sub-bands have been traversed (k>12) and no sub-band triggers streaming early stop, then proceed to step S7 for joint discrimination and output.
[0098] The predetermined execution order is one of the following two execution strategies (see...) Figure 5 (Explanation of the execution order strategy on the right)
[0099] Strategy A (Color Priority):
[0100] First, traverse all color branches of the same frequency domain sub-band in color channel order (LL-R to LL-G to LL-B to LH-R to LH-G to LH-B to HL-R to HL-G to HL-B to HH-R to HH-G to HH-B), then switch to the next frequency domain sub-band.
[0101] Strategy B (Frequency Priority):
[0102] First, traverse all frequency subbands of the same color channel in frequency direction (LL-R to LH-R to HL-R to HH-R to LL-G to LH-G to HL-G to HH-G to LL-B to LH-B to HL-B to HH-B), then switch to the next color channel. Two strategies can be selected based on the application scenario: Strategy A is used when the expected defect is mainly manifested as a difference in color channels, and Strategy B is used when the expected defect is mainly manifested as a difference in frequency direction.
[0103] Step S7: Frequency domain-color domain joint discrimination output
[0104] Step S7 corresponds to Figure 1 The "S7 frequency domain-color domain joint discrimination output" section and Figure 5 The path is "subband joint discrimination" and "output final result". When streaming early stopping is not triggered, the comprehensive classification probability calculated in step S5 is used. Defect category determination is performed within the joint frequency-color domain discrimination space. The target defect category index is determined using the maximum probability selection operator argmax.
[0105]
[0106] Simultaneously, by combining the weight distribution of each color channel branch, a classification credibility index of frequency-color dimension is generated, and the final weld defect classification and identification decision result is output.
[0107] In summary, steps S1 to S7 constitute a complete weld defect identification method flow of "preprocessing - joint decoupling - differential feature extraction - collaborative attention enhancement - competitive weight allocation - single-condition streaming early stopping - joint discrimination output".
[0108] Example 2
[0109] This embodiment provides a weld defect identification system for implementing a joint decoupling method for frequency domain and color domain weld defect identification. The system includes the following seven modules:
[0110] (1) Region of Interest Segmentation Module: Acquire a color weld defect image, perform Gaussian filtering for noise reduction, LAB color space L channel CLAHE contrast enhancement and ROI segmentation on the color weld defect image in sequence, and output the region of interest image T of the weld defect.
[0111] (2) Frequency domain-color domain joint decoupling module: used to perform single-layer two-dimensional discrete wavelet transform on the region of interest image T to obtain four frequency domain sub-bands LL, LH, HL and HH. Each frequency domain sub-band is then decomposed into three single-channel sub-images R, G and B according to the color channel. Twelve frequency-color sub-bands are obtained by decoupling in the frequency domain-color domain joint space.
[0112] (3) Twelve-branch feature extraction neural network module: used to construct differentiated parallel CNN branches. The convolution kernel parameters of each branch are independently optimized for R / G / B response characteristics. For each frequency-color sub-band, the defect features of the corresponding color channel at different frequency scales are extracted respectively.
[0113] (4) Frequency-color collaborative spatial attention weighting module: used to embed a collaborative attention mechanism across color channels in each branch, perform color sensitivity quantization and cross-channel interaction on the three-channel feature map under the same frequency domain sub-band, generate a two-dimensional attention weight map and perform pixel-wise modulation with the corresponding feature map.
[0114] (5) Competitive weighted decision module: Based on the probability vectors output independently by each branch, the module evaluates the certainty of the judgment by combining the maximum class probability and information entropy, and uses Softmax to perform competitive weight allocation, and weights and aggregates the probability outputs of each branch to generate a comprehensive classification probability.
[0115] (6) Confidence-triggered early stop control unit: used to activate each branch in a predetermined execution order and independently judge it. When the normalized confidence of any sub-band reaches or exceeds the inference confidence threshold, the result is output and the subsequent branch is terminated.
[0116] (7) Joint discriminant classification output module: When early stopping is not triggered, the argmax selection operator is executed on the weighted aggregated comprehensive classification probability, and the frequency-color dimension credibility index is generated by combining the weight distribution to output the final classification result.
[0117] Example 3
[0118] Taking an X-ray online inspection scenario on a welded pipe production line as an example, the implementation process of this invention will be further explained. Weld defect images are acquired in real time through an X-ray imaging system, including six common weld defects: porosity, cracks, slag inclusions, undercut, lack of fusion, and incomplete penetration. The dataset used in this embodiment contains 4800 images of the six defect types, with 800 images for each type, randomly divided into training and testing sets at an 8:2 ratio.
[0119] First, the original 512×512 pixel weld seam image is subjected to Gaussian filtering for noise reduction (Gaussian kernel size 3×3), LAB color space CLAHE enhancement, and ROI segmentation through the region of interest segmentation module, outputting a 256×256 pixel region of interest image T.
[0120] Secondly, through the frequency domain-color domain joint decoupling module, a single-layer two-dimensional discrete wavelet transform is performed on the region of interest image T using the Daubechies db4 wavelet basis to obtain four frequency domain sub-bands LL, LH, HL, and HH (each sub-band has a size of 128×128). Then, each frequency domain sub-band is decomposed according to the three color channels R, G, and B to obtain twelve frequency-color sub-bands with a size of 128×128.
[0121] Then, the twelve frequency-color subbands are fed into the corresponding differential CNN branches, and the structure of each branch is as follows: Figure 3 As shown. The twelve CNN branches are mathematically equivalent to a four-subband CNN structure of the WAC4 model. The attention mechanism of each branch adopts the frequency-color collaborative spatial attention module described in step S4, realizing cross-channel collaboration and competition suppression of feature maps of the three color channels under the same frequency domain subband. The Adam optimizer is used for model training with an initial learning rate of 0.001. After training, each branch is activated sequentially in a predetermined execution order during the inference phase.
[0122] Finally, after competitive weight allocation and confidence-triggered early stopping unit (steps S5-S6), the weld defect category identification result and corresponding confidence level are output, completing the automated detection. Experimental results show that in the six-class weld defect identification task, the accuracy of the method of this invention reaches 91.61%, precision 89.31%, recall 89.62%, and F1 score (harmonic mean of precision and recall) is 89.48%. When the early stopping threshold is set to 0.8, the average inference time is approximately 20.81 ms, significantly reducing inference latency while ensuring high accuracy. The training results of the twelve subband weights show that the HL-G subband has the highest weight (approximately 0.135), followed by the LL-G subband (approximately 0.12), indicating that the comprehensive discrimination features of the six defects are mainly concentrated in the vertical high-frequency direction and low-frequency region of the G color channel. The above results demonstrate that this invention has good practicality and deployment value in industrial online inspection scenarios.
[0123] All matters not covered in this invention are common knowledge.
[0124] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for weld defect identification based on joint decoupling of frequency domain and color domain, characterized in that, Includes the following steps: Step S1: Obtain a color weld defect image containing R, G, and B channels, and sequentially perform denoising, color space conversion and contrast enhancement, and region of interest segmentation to output the region of interest image; Step S2: Perform a single-layer two-dimensional discrete wavelet transform on the region of interest image to decouple and obtain four low-frequency sub-bands. Decompose each sub-band into three single-channel sub-images according to the RGB channels, thereby decoupling and obtaining twelve frequency-color sub-bands in the joint space of frequency domain and color domain. Step S3: Based on the characteristics of each frequency-color sub-band, construct twelve differentiated parallel convolutional neural network branches to extract the defect features of each channel at different frequency scales; Step S4: Each branch embeds a frequency-color collaborative spatial attention module to generate a two-dimensional attention weight map for the response distribution differences of the same frequency domain sub-band in different channels, and performs pixel-by-pixel modulation with the branch input feature map to achieve cross-channel differential spatial feature enhancement. Step S5: Each branch independently outputs the classification probability distribution vector. The determination of the judgment is jointly evaluated based on the maximum class probability and the distribution information entropy. A normalized confidence index is generated, and the confidence of each sub-band is competitively weighted using a normalized exponential function. The probability outputs of each branch are weighted and aggregated to obtain the comprehensive classification probability. Step S6: Set the inference confidence threshold, and activate each branch in the predetermined execution order; when the normalized confidence of any branch reaches or exceeds the threshold, directly output the current recognition result and trigger early stop, terminating the forward propagation of subsequent branches; Step S7: If early stopping is not triggered, select the operator with the highest probability based on the comprehensive classification probability to determine the target defect category, generate the classification credibility index by combining the weight distribution of each branch, and output the final identification result.
2. The weld defect identification method based on frequency domain-color domain joint decoupling according to claim 1, characterized in that, In step S1, the specific processes of denoising, color space conversion and contrast enhancement, and region of interest segmentation are as follows: First, the colored weld defect image is subjected to Gaussian filtering for denoising; then, the denoised colored image is converted from the RGB color space to the LAB color space, the L luminance channel is extracted, and contrast-limited adaptive histogram equalization is performed on the L luminance channel, while the A and B chrominance channels remain unchanged. Then, the enhanced LAB image is converted back to the RGB color space to complete the contrast enhancement; finally, the enhanced colored weld defect image is subjected to adaptive threshold segmentation, spatial geometric constraint filtering, and Hough transform edge consistency verification in sequence, and the region of interest image T containing the complete defect region is output.
3. The weld defect identification method based on frequency domain-color domain joint decoupling according to claim 1, characterized in that: In step S2, the four frequency domain sub-bands include a low-frequency approximation sub-band, a horizontal low-frequency vertical high-frequency detail sub-band, a horizontal high-frequency vertical low-frequency detail sub-band, and a diagonal high-frequency detail sub-band. First, a two-dimensional discrete wavelet transform is performed on the region of interest image to obtain four frequency domain sub-bands. Then, each frequency domain sub-band is decomposed into R, G, and B color channels to obtain a total of twelve frequency-color sub-bands. Among them, the three sub-bands obtained after the three-color channel decomposition of the same frequency domain sub-band capture the response differences of the frequency component in the R, G, and B channels, respectively. The decomposed sub-bands of different frequency domain sub-bands in the same color channel capture the response characteristics of weld defects at different frequency scales.
4. The weld defect identification method based on frequency domain-color domain joint decoupling according to claim 1, characterized in that: In step S3, the twelve differentiated parallel convolutional neural network branches are constructed in groups according to color channels and frequency directions, and the convolutional kernel parameters of each branch are independently optimized for the R, G, and B response characteristics of the corresponding color channel. This includes: a low-frequency branch for each color channel, which uses a large-size convolutional kernel to extract the macroscopic contour features of weld defects in that color channel; a vertical abrupt change feature extraction branch for each color channel, which targets the horizontal low-frequency and vertical high-frequency detail sub-bands of that color channel and uses an anisotropic convolutional kernel optimized for the R / G / B response characteristics of that color channel to extract longitudinal defect features along the weld direction; a horizontal abrupt change feature extraction branch for each color channel, which targets the horizontal high-frequency and vertical low-frequency detail sub-bands of that color channel and uses an anisotropic convolutional kernel optimized for the R / G / B response characteristics of that color channel to extract transverse defect features perpendicular to the weld direction; and a diagonal high-frequency branch for each color channel, which uses a small-size convolutional kernel to extract subtle defect features in that color channel.
5. The weld defect identification method based on frequency domain-color domain joint decoupling according to claim 1, characterized in that: In step S4, the processing procedure of the frequency-color collaborative spatial attention module is as follows: First, the feature maps of the three color channel branches corresponding to the same frequency domain sub-band are used as input. Based on the difference in sensitivity of each color channel to the defect color features, the color sensitivity quantization processing is performed on the feature maps of each color channel, and the spatial attention preference map of each color channel is output. Subsequently, the attention preference maps of the three color channels are subjected to cross-channel feature interaction and competition suppression processing to generate a two-dimensional attention weight map that takes into account the joint characteristics of frequency and color. Finally, the weight map and the corresponding frequency-color sub-band input feature map are subjected to pixel-by-pixel modulation operation to achieve differential spatial feature enhancement across color channels within the same frequency dimension, and the enhanced frequency-color sub-band feature map is output.
6. The weld defect identification method based on frequency domain-color domain joint decoupling according to claim 1, characterized in that: In step S5, the calculation process for the competitive weight allocation is as follows: First, based on the defect prediction probability distribution output by each frequency-color sub-band branch, the prediction information entropy corresponding to each branch is calculated to quantify the uncertainty of the probability distribution. Then, the discrimination certainty of the current sub-band is calibrated by combining the maximum class probability of each branch. After normalization, the confidence index of each frequency-color sub-band is generated. Subsequently, a smoothness scaling factor is introduced to numerically regulate the confidence index. The normalized exponential function is then fed into the confidence index of each sub-band to perform competitive exponential transformation and proportional normalization, so that the branch weights of different color channels in the same frequency domain present a differentiated distribution that matches the discrimination contribution of each channel, and the contribution weight of each frequency-color sub-band branch to the final decision is adaptively output.
7. The weld defect identification method based on frequency domain-color domain joint decoupling according to claim 1, characterized in that: In step S6, the predetermined execution order is one of the following two execution strategies: First, traverse all color branches of the same frequency domain sub-band in color channel order, then switch to the next frequency domain sub-band, until all twelve frequency-color sub-bands have been traversed; Alternatively, you can first traverse all frequency sub-bands of the same color channel in order of frequency direction, and then switch to the next color channel, until all twelve frequency-color sub-bands have been traversed.
8. A frequency-domain-color-domain jointly decoupled weld defect identification system, used to implement the method as described in any one of claims 1 to 7, characterized in that, Includes the following modules: The region of interest segmentation module is used to acquire a color weld defect image containing three color channels: R, G, and B. The color weld defect image is then subjected to Gaussian filtering for noise reduction, L-channel contrast-limited adaptive histogram equalization under LAB color space conversion, and region of interest segmentation in sequence, and the region of interest image is output. The frequency domain-color domain joint decoupling module is used to perform a single-layer two-dimensional discrete wavelet transform on the region of interest image to obtain low-frequency approximate sub-bands, horizontal low-frequency and vertical high-frequency detail sub-bands, horizontal high-frequency and vertical low-frequency detail sub-bands, and diagonal high-frequency detail sub-bands; and decomposes each frequency domain sub-band into three single-channel sub-images (R, G, B) according to the color channel, and decouples them in the frequency domain-color domain joint space to obtain twelve frequency-color sub-bands. The twelve-branch feature extraction neural network module is used to construct twelve differentiated parallel convolutional neural network branches. The convolutional kernel parameters of each branch are independently optimized for the R, G, and B response characteristics of the corresponding color channel. For each frequency-color sub-band, the defect features of the corresponding color channel at different frequency scales are extracted. The frequency-color co-spatial attention weighting module is used to embed the frequency-color co-spatial attention module in each frequency-color sub-network branch. It performs color sensitivity quantization and cross-channel feature interaction on the feature maps of the three color channel branches corresponding to the same frequency domain sub-band, generates a two-dimensional attention weight map that takes into account the joint characteristics of frequency and color, and performs pixel-by-pixel modulation operation with the corresponding feature map to achieve differentiated spatial feature enhancement across color channels in the same frequency dimension. The competitive weighted decision module is used to evaluate the discrimination certainty of each sub-band based on the defect classification probability distribution vector independently output by each frequency-color sub-band convolutional neural network branch, using the maximum class probability and distribution information entropy. The module competitively assigns weights to the confidence of each sub-band through a normalized exponential function, so that the contribution of different color channels in the same frequency domain presents a differentiated weight distribution. The probability output of each branch is weighted and aggregated according to the differentiated weights to generate a comprehensive classification probability. The confidence-triggered early stop control unit is used to activate and independently distinguish each frequency-color sub-band branch in a predetermined execution order during the inference process. When the normalized confidence of any frequency-color sub-band reaches or exceeds the inference confidence threshold, the current defect category identification result is directly output and the forward propagation of subsequent branches that have not yet been executed is terminated. The joint discrimination classification output module is used to execute the maximum selection operator on the weighted aggregated comprehensive classification probability in the frequency domain-color domain joint discrimination space when the confidence-triggered early stop control unit does not trigger early stop or completes all branch calculations, and generate a classification confidence index in the frequency-color dimension by combining the weight distribution of each color channel branch, and output the final weld defect classification result.