# GAN-Based Image Dehazing for Intelligent Weld Shape Classification and Tracing Using Deep Learning
## 2 Methods
### Dehazing Techniques for Weld Fume Removal
#### 2.2.2 DWT Branch Using U-Net  
In the first stage, the U-Net-based discrete wavelet transform (DWT) branch has a contracting path (encoder) and expansive path (decoder), as well as massive skip connections to preserve the texture details during the dehazing process to learn from both high-frequency and low-frequency components [20]. As the name suggest, the U-Net is 'U-shaped'; the down-sampling module on the left performs convolution operation and the up-sampling module on the right performs transpose 2D convolution operation. The convolution operation with max pooling increases the depth of the image and reduces the size, while transposed convolution applies padding and upscales the image, creating a clean image pixel by pixel, and thereby removing the weld fumes. The detailed U-Net DWT architecture for weld images is shown in Table 2.  
\begin{table}
\begin{tabular}{l l l l l l} \hline \hline  & \multicolumn{2}{c}{**Contracting Path**} & \multicolumn{4}{c}{**Expansive Path**} \\ \hline
**Layer** & **Details** & **Output Size** & **Layer** & **Details** & **Output Size** \\ \hline \multirow{3}{*}{Input} & \multirow{3}{*}{Weld Images} & \multirow{3}{*}{572 \(\times\) 572 \(\times\) 3} & DWT & \(2\times 2\times 1024\) up sample of & \multirow{3}{*}{56 \(\times\) 56} \\  & & & UpSampling\_1 & Conv5\_2; & & \\ \cline{1-1} \cline{5-5} \multirow{2}{*}{Conv1\_1} & \multirow{2}{*}{3 \(\times\) 3 \(\times\) 64; Linear ReLU} & \multirow{2}{*}{570 \(\times\) 570} & \multirow{2}{*}{Conv6\_1} & \multirow{2}{*}{3 \(\times\) 3 \(\times\) 512; Linear ReLU} & \multirow{2}{*}{54 \(\times\) 54} \\  & & & & Conv6\_2 & 3 \(\times\) 3 \(\times\) 512; Linear ReLU & 52 \(\times\) 52 \\ \cline{1-1} \cline{5-5} \multirow{2}{*}{Pool 1} & \multirow{2}{*}{2 \(\times\) 2 Max Pool} & \multirow{2}{*}{284 \(\times\) 284} & DWT & \(2\times 2\times 512\) up sample of & \multirow{2}{*}{104 \(\times\) 104} \\  & & Stride 2 & & UpSampling\_2 & Conv5\_2; & \\ \cline{1-1} \cline{5-5} \multirow{2}{*}{Conv2\_1} & \multirow{2}{*}{3 \(\times\) 3 \(\times\) 128; Linear ReLU} & \multirow{2}{*}{284 \(\times\) 284} & Conv7\_1 & \(3\times 3\times 256\); Linear ReLU & \multirow{2}{*}{102 \(\times\) 102} \\  & & & & Conv7\_2 & 3 \(\times\) 3 \(\times\) 256; Linear ReLU & 100 \(\times\) 100 \\ \cline{1-1} \cline{5-5} \multirow{2}{*}{Conv2\_2} & \multirow{2}{*}{2 \(\times\) 2 Max Pool} & \multirow{2}{*}{140 \(\times\) 140} & DWT & \(2\times 2\times 256\) up sample of & \multirow{2}{*}{100 \(\times\) 100} \\  & & Stride 2 & & UpSampling\_3 & Conv7\_2; & \\ \cline{1-1} \cline{5-5} \multirow{2}{*}{Pool 2} & \multirow{2}{*}{2 \(\times\) 2 Max Pool} & \multirow{2}{*}{140 \(\times\) 140} & \multirow{2}{*}{UpSampling\_3} & \multirow{2}{*}{Conv7\_2;} & \multirow{2}{*}{200 \(\times\) 200} \\  & & & & Conv7\_2 & \\ \hline \hline \end{tabular}
\end{table}
Table 2: U-Net architecture using the DWT branch.  
Figure 3: DW-GAN architecture for weld fume removal.  
Here, input features are converted into low-frequency and high-frequency components where low frequency components are added to the convolution and high-frequency components are added to the DWT up-sampling module. In 2D DWT, four filters are used, i.e., a low-pass filter and high-pass filters with stride 2 convolution operation. Using convolution operation with these filters, images or feature maps are decomposed into four sub bands, i.e.,\(x_{LL}\), \(x_{LH}\), \(x_{HL}\), and \(x_{HH}\).The equation for \(x_{LL}\) is given by:  
\[x_{LL}=x(2i-1,2j-1)+x(2i-1,2j)+x(2i,2j-1)+x(2i,2j) \tag{1}\]  
The equations of \(x_{LH}\), \(x_{HL}\), \(x_{HH}\) are same as \(x_{LL}\), which is helpful in retaining the hazy images and thereby learning spatial and frequency information.