# Convolutional Neural Network Architecture for Recovering Watermark Synchronization
## 4 Proposed Method
### Template Matching Network  
The template matching network shown in Figure 5 compares the extracted template with the original template and estimates the RST parameters. First, the feature extraction network extracts features from the extracted template and the original template. The feature extraction network mimics domain transformation methods such as DFT. Domain transforms, such as DFT, are the sum of all pixels multiplied by different weights in the image. Similar to DFT, we use the kernel size as the template size to compute the global features of the template. We compute 256 global features and reshape it by 16 \(\times\) 16. This is similar to calculating 16 \(\times\) 16 DFT coefficients from an image. As we can estimate the translation degree from the phase of the DFT, these global features will facilitate RST parameter estimation.  
The extracted features are then matched to estimate the RST parameters. These matching layers refer to the structure in [23; 24; 25]. Feature extraction networks are Siamese networks that share weights with each other. After the feature extraction network, a concatenation layer, which is fast and has good matching accuracy, is used to combine features extracted from the feature extraction networks. Later layers are identical to the structure in [25]. The final result is a five-dimensional matrix [\(R\), \(S_{x}\), \(S_{y}\), \(T_{x}\), \(T_{y}\)], which indicates the rotation, scaling of \(x\) and \(y\), and the translation of \(x\) and \(y\) parameters. The loss of the matching network is defined as,  
\[L_{d}=\frac{1}{S^{2}}\sum_{i,j=1}^{S}d[G^{e}(x_{i},y_{j}),G^{T}(x_{i},y_{j})]^ {2}, \tag{6}\]  
where \(d\) is the Euclidean distance between two points, \(G_{e}\) is the geometric transformation using the estimated RST parameters, and \(G^{T}\) is the geometric transformation using the ground-truth RST parameters. \(x_{i}\) and \(y_{i}\) correspond to the \(S\) equally divided points of the image in the horizontal and vertical directions, respectively, and \(S\) is set to 10, i.e., \(L_{d}\) corresponds to the mean squared error between the estimated points and the true points. The reason for using the Euclidean distance as a loss without using the RST parameters directly is that each RST parameter has different weights of distortion on the image. For example, when a parameter of the same value is used, the distortion of rotation is larger than the distortion of translation.  
Although the template matching network has been described separately here, the template generation and extraction network described above are attached to the template matching network, and then end-to-end learning is performed. End-to-end loss is defined as,  
\[L_{end-to-end}=\lambda L_{g}+(1-\lambda)L_{d}, \tag{7}\]  
where \(\lambda\) is the trade-off parameter between invisibility and matching accuracy. The template matching network also uses a Xavier uniform initializer to initialize the network. Since \(L_{d}\) includes training of the template extraction network, the template generation network, template extraction network, and template matching network are trained all at once by \(L_{end-to-end}\).