## 2 Materials and Methods
### The Design of a Task Method for the Restoration of Damaged Finger Vein Images
#### 2.2.2 The Second Stage of the Finger Vein Image Damage Restoration Task: Original Image Restoration  
The vein damage image inpainting stage is based on the image of the pattern features after feature inpainting to guide the restoration of the original image. The finger vein images generated in this way are guided and constrained by their own vein features, substantially preserving the vein feature information of the image. This stage of the network has an input image consisting of the original ROI image \(I_{R}\), the image to be restored \(I_{R\_m}\) after masking, and the feature image \(I_{t\_p}\) from the first stage of the restoration, combining \(I_{R\_m}\)  
Figure 5: The feature-guided finger vein image restored based method of architecture.  
with the restored \(I_{t\_p}\) to form \(I_{comp}=I_{R\_m}\odot(1-I_{m})+I_{t\_p}\odot I_{m}\). We designed a generator network which predicts the vein image of the damaged region to obtain the restored finger vein image \(I_{R\_p}\). \(I_{R\_p}\) is defined as:  
\[I_{R\_p}=G_{2}\big{(}I_{R\_m},I_{comp}\big{)} \tag{11}\]  
We used a joint loss consisting of \(\mathcal{L}_{1}\) loss, perceptual loss \(\mathcal{L}_{perc}\), style transfer loss \(\mathcal{L}_{style}\), and generative adversarial loss \(\mathcal{L}_{adv,d_{2}}\) for the training of the second stage restoration network. Where the generative adversarial loss \(\mathcal{L}_{adv,d_{2}}\) is similar to \(\mathcal{L}_{adv,d_{1}}\) and is defined as:  
\[\mathcal{L}_{adv,d_{2}}=\mathbb{E}_{(I_{comp},\ I_{R})}\big{[}logD_{2}\big{(} I_{comp},I_{R}\big{)}\big{]}+\mathbb{E}_{(I_{comp})}\big{[}log\big{[}1-D_{2} \big{(}I_{R\_p},I_{comp}\big{)}\big{]}\big{]} \tag{12}\]  
The perceptual loss \(\mathcal{L}_{perc}\) that we use for training in this task is similar to the perceptual loss in the image deblurring task, where \(\mathcal{L}_{perc}\) is defined as:  
\[\mathcal{L}_{perc}=\mathbb{E}\Bigg{\{}\sum_{i}\frac{1}{N_{i}}\big{\|}\phi_{i} (I_{R\_p})-\phi_{i}\big{(}I_{R\_p})\big{\|}\Bigg{\}} \tag{13}\]  
\(\phi_{i}\) is the activation maps of \(relu1\_1/relu2\_1/relu3\_1/relu4\_1/relu5\_1\) of the VGG-19 network that has been pre-trained on the ImageNet dataset. \(\mathcal{L}_{perc}\) determines the degree of difference between the network-generated finger vein images and the original finger vein images at the perceptual level by defining the distance between the activation maps of the pre-trained network. In this study, we used the activation map of the pre-trained network to calculate the style loss \(\mathcal{L}_{style}\). Given feature maps of sizes \(C_{i}\times W_{i}\times H_{i}\), \(\mathcal{L}_{style}\) is computed by:  
\[\mathcal{L}_{style}=\mathbb{E}_{i}\Big{\{}\Big{\|}G_{i}^{\phi}(I_{R})-G_{i}^{ \phi}\big{(}I_{R\_p})\Big{\|}\Big{\}} \tag{14}\]  
where \(G_{i}^{\phi}\) is a \(C_{i}\times C_{i}\) Gram matrix constructed from activation maps \(\phi_{i}\). For our experiments, the final loss of the original image restoration of the finger vein images is defined as:  
\[\mathcal{L}_{stage-2}=1\times\mathcal{L}_{1}+0.1\times\mathcal{L}_{adv,d_{2}} +0.1\times\mathcal{L}_{perc}+250\times\mathcal{L}_{style} \tag{15}\]