## 2 Methodology
### Regional Wavelet Fusion Denoising Model  
Imaging quality is related to the effect of full-focus real-time dynamic detection, and there are many interference factors in industrial detection; the poor flatness of the artificial welding surface at the connection between the main pipe and branch pipe of the oil and gas pipeline makes it difficult for the wedge to make contact closely with the surface of the main pipe, which leads to serious artifacts and seriously affects the effective identification of defects. Therefore, image filtering is an effective method to improve the recognition rate of branch filled weld defects. Wavelet analysis can better represent the local features of images in the time and frequency domains and has great advantages in image denoising and feature extraction. In the process FMC, each burst element has the function of transmitting and receiving, and the array element width is small, the acoustic beam diffusion angle generated by the array is large, and the scanning angle is increased, so the imageable area is large; the position of the branch pipe welding area relative to the main pipe is determined, so the image region denoising can retain the image features of the target region to the greatest extent without affecting the weld detection so as to provide a high-quality data set for the subsequent research on the classification and size quantization of full-focus defect images.  
In this paper, a wavelet region denoising method is used for branch pipe full-focus ultrasound images. The specific method is shown in Figure 3, which mainly includes three steps:
Generate a TFM noise image containing artifacts through the detection of branch pipe corner welds and then perform region division to select the weld area. Adaptive filtering denoising is applied to the weld seam area, followed by wavelet denoising for non-weld seam areas. In the process of wavelet denoising, high-frequency and low-frequency coefficients are first generated, and the threshold quantization method is used to process the high-frequency coefficients. Finally, the TFM image is reconstructed using the wavelet inverse transform method based on two types of coefficients.  
(1) Firstly, according to the cross-sectional morphology of the welding area, the region of the full-focus original image was selected. Combined with the location of the welding area and the pre-experiment, the defect location was located on the right side of the image. In order to retain the image characteristics of the welding area to the greatest extent, the welding area was defined as a rectangular area.  
(2) Secondly, pixel adaptive filtering was applied to the welding region.  
(3) Finally, the non-welding area was denoised by wavelet filtering: multi-resolution wavelet decomposition was adopted, and the number of decomposition layers was set to 3; then, the compromise threshold method was used to process the wavelet coefficients, and finally, the multi-scale two-dimensional discrete wavelet was used for image reconstruction.  
The soft and hard threshold compromise functions can improve the defect that the soft threshold function has a large constant deviation and alleviate the image distortion caused by discontinuous threshold points.  
\[W_{j,k}^{*}=\begin{cases}sign\Big{(}W_{j,k}\Big{)}\left(\left|W_{j,k}\right|- \alpha T\right),&\left|W_{j,k}\right|\geq T\\ 0&,\left|W_{j,k}\right|<T\end{cases} \tag{4}\]  
where \(W_{j,k}^{*}\) is the estimated wavelet high-frequency coefficient; \(W_{j,k}\) is the high-frequency coefficient after wavelet decomposition; the sign is a symbolic function, as shown in Formula (5); \(j\) and \(k\) are the positions of wavelet coefficients; \(T\) is the wavelet threshold; \(\alpha\) is the adjustment parameter with a value range of 0-1. When \(\alpha\) is 0, the threshold function is a hard threshold function, and when \(\alpha\) is 1, the threshold function is a soft threshold function.  
\[sign=\begin{cases}1&,\quad W_{j,k}>0\\ 0&,\quad W_{j,k}=0\\ -1,\quad W_{j,k}<0\end{cases} \tag{5}\]