# Convolutional Neural Network Architecture for Recovering Watermark Synchronization
## 4 Proposed Method
### Template Embedding and Extraction Network  
Figure 3 presents a template insertion and extraction scheme. Template embedding is performed as a simple sum as,  
\[I_{T}=I+T_{n}, \tag{2}\]  
where \(I_{T}\) is the template inserted image, \(I\) is the original image, and \(T_{n}\) is the template noise generated from the template generation network. In the template extraction step, a template is extracted from \(I_{T}\). The goal is to learn the template generation network and extraction network so that the extracted template \(K_{64}^{\prime}\) becomes the same as the template \(K_{64}\) used at the template insertion step. The detailed template generation and extraction network structures are shown in Figure 4. We set the kernel size of all convolutional layers in the network to (3, 3). The reason is to extract the local features of the image similar to discrete wavelet transform rather than global features similar to DFT. In order to estimate the RST parameters, the same geometric transformation as that occurring in the image must occur in the extracted template. If the template is perfectly invariant and the template is  
Figure 3: Template insertion and extraction overview. Networks are trained so that the extracted template \(K_{64}^{\prime}\) and the inserted template \(K_{64}\) have the same shape. extracted without coordinate distortion, the RST parameters cannot be estimated. Thus, by exploiting local features, we induce the template to have semi-invariant properties. A semi-invariant template preserves its value from geometric distortion, but the coordinates are transformed according to the degree of geometric distortion. The template generation network is an inverse process to the template extraction network. This template generation network generates a template noise (\(T_{n}\)) of size \(512\times 512\) from a template (\(K_{r}\)) of size \(64\times 64\) using a transposed convolutional layer. The process of expanding the dimension is similar to the insertion method for conventional watermarking techniques. In conventional watermarking techniques, when the watermark inserted in the middle frequency of the transformed domain passing through the inverse transform, the watermark signal spreads to the entire image of the spatial domain. The proposed template generation network also spreads the low-dimensional signal to the high-dimensional spatial domain similar to the conventional technique. At the end of the network, the generated template noise is masked so that the template noise does not interfere with the watermark block. The loss of the template generation network is defined as,  
\[L_{g}=\frac{\sum_{i,j=1}^{U}(T_{n}^{o}(i,j))^{2}}{U^{2}}, \tag{3}\]  
\(T_{n}^{o}\) is the template noise generated from the generation network, \(i\) and \(j\) denote the horizontal and vertical coordinates of the generated template noise, respectively, \(U\) represents the width and height of the network output and is set to 512, i.e., since \(L_{g}\) corresponds to the average energy of the template to be inserted, the generation network is trained so as to improve the template invisibility. \(L_{g}\) is combined with the loss of the extraction network described below, and the generation network and the extraction network are trained together. As in (2), simply adding the template noise generated from the template generation network to the original image will complete the template embedding. The template embedded image is then sent to the template extraction network after RST distortion. The template extraction network extracts 64 \(\times\) 64 templates that are the same size as the input of the generation network from the attacked image. The loss of the template extraction network is defined as,  
\[L_{e}=\frac{1}{V^{2}}\sum_{i,j=1}^{V}[K_{V}^{\prime}(i,j)-G^{T}(K_{V}(i,j))]^{ 2}, \tag{4}\]  
Figure 4: Proposed template generation and extraction network architectures. All kernel sizes of convolutional layers are set to (3, 3), \(d\) and \(s\) denote the depth and stride, respectively.