# MRS-Transformer: Texture Splicing Method to Remove Defects in Solid Wood Board
## 4 Experiments
### Comparative Experiments  
To validate the effectiveness of the proposed MRS-Transformer, we compared it with two state-of-the-art image inpainting algorithms, namely Deepfill v2 and TG-Net, on the solid wood boards dataset. Both these algorithms are based on the GAN model and use a two-stage inpainting approach, where the coarse generative network completes the missing region contours and the fine generative network produces refined results. The main distinction lies in the network structures used in the coarse and refinement stages of Deepfill v2 and TG-Net. Deepfill v2 employs a 16-layer hourglass network with gated convolutions for both stages. It consists of four encoder layers, eight bottom-neck layers, and four decoder layers. Each gated convolution layer performs two convolution operations, one on the image features and the other on the mask features. TG-Net utilizes a simpler architecture. The coarse generator employs a 16-layer CNN network, with eight upsampling layers and eight downsampling layers. In the refinement stage, TG-Net employs a 32-layer U-Net structure, where each group consists of two layers. The first eight groups perform downsampling, while the latter eight groups handle  
Figure 10: Comparison of results of ablation experiments. upsampling. Additionally, the refinement network incorporates an attention mechanism with ten layers. In terms of computational complexity, the models' FLOPs (Floating Point Operations) are used as a measure. Convolution operations are the primary source of computational workload for both Deepfill v2 and TG-Net. The choice of convolutional layer parameters significantly affects the computational complexity of the models. The formula for calculating the computational complexity of a convolutional layer is as follows:  
\[\Omega(\text{Conv})=(2K^{2}C_{\text{in}})C_{\text{out}}HW, \tag{9}\]  
where \(H\) is the height of the input feature map; \(W\) is the width of the input feature map; \(C_{\text{in}}\) is the number of input channels; \(C_{\text{out}}\) is the number of output channels; and \(K\) is the size of the convolutional kernel. The computation in the Transformer mainly comes from the matrix multiplication involved in calculating attention scores. Due to the two-dimensional nature of images, the number of patches increases quadratically with the image size. As a result, the computational complexity of ViT grows quadratically with the image size. In the MRS model, the encoder discards the input of masked patches, reducing the computational complexity by almost half. The decoder utilizes a windowed attention mechanism, which calculates attention scores within fixed-size windows. This leads to a linear increase in computational complexity, significantly reducing the overall computation burden of the model. As a result, the MRS algorithm achieves lower computational complexity compared to the other two algorithms while delivering superior restoration performance. The experimental results, shown in Table 2, indicate that the MRS-Transformer achieved a superior performance with MSE, PSNR, LPIPS, and SSIM values of 0.0003, 40.12, 0.154, and 0.9173, respectively. Compared to Deepfill v2 and TG-Net, MRS-Transformer reduced the MSE metric by 47.0% and 66.9%, and the LPIPS metric by 60.6% and 42.5%, respectively. Meanwhile, our algorithm achieved higher PSNR and SSIM metrics, with improvements of 16.1% and 26.2%, and 7.3% and 5.8%, respectively. Moreover, MRS-Transformer reduced the GFLOPs metric by 70.6% and 53.5%, respectively, and completed a single wood texture image in only 0.05s, which is nearly five times faster than the other two algorithms. To further evaluate and compare the performance of the proposed algorithm with other methods, we conducted a visual analysis of the completed images. As shown in Figure 11, we displayed the original image in the first column, followed by the masked image with 50% of the central region masked in the second column, and the completed images generated by different methods in the remaining columns.