# Convolutional Neural Network Architecture for Recovering Watermark Synchronization
## 4 Proposed Method
### Watermark Embedder and Decoder  
The watermark has the role of inserting and decoding bit information. Similar to conventional techniques, the watermark is inserted/decoded in the transformed domain, and the curvelet is used as the transform domain. The reason for using this domain is that it is easy to insert multiple bits into one block through parameter adjustment while the watermark in this domain remains invisible and robust.  
The curvelet transform is a multi-scale decomposition-like wavelet transform, and the curvelet represents the curve shape for various directions in the spatial domain [26; 27; 28; 29]. In the image, the frequency domains are decomposed into various scales and directions by the curvelet transform as shown in Figure 6, and the curvelet coefficients are expressed as \(C^{s,l}(i,j)\), where \(s\) means scale and \(l\) means direction. \(i\) and \(j\) represent the horizontal and vertical coordinates of the coefficients in each scale and direction, respectively.  
Figure 5: Template matching network architecture. Two feature extraction networks share weights with each other. \(k\) means kernel size, and zero-padding is not used in matching networks.  
In this paper, we divide the watermark block into 5 scales and 8 directions in total. The watermark is inserted using the QIM method as in Algorithm 1 on a scale of 3 levels.  
```
1:Input: curvelet coefficients \(C^{sJ}(i,j)\) over scale \(s\) and direction \(l\)
2:Output: modified curvelet coefficients \(C^{sJ}_{m}(i,j)\)
3:\(q\) : quantization step
4:\(b\) : bit to be inserted
5:
6:\(A^{sJ}=\frac{1}{mn}\sum_{i=1}^{m}\sum_{j=1}^{n}abs(C^{sJ}(i,j))\)
7:if\(\text{mod}[\text{round}(A^{sJ}/q),2]=b\)then
8:\(c=0\)
9:else
10:if\(\text{mod}(abs(A^{sJ})/q,1)\leq 0.5\)then
11:\(c=0.5\)
12:elseif\(\text{mod}(abs(A^{sJ})/q,1)>0.5\)then
13:\(c=-0.5\)
14:endif
15:endif
16:\(Q^{sJ}_{m}(i,j)=C^{sJ}(i,j)\cdot Q^{sJ}\)
```  
**Algorithm 1** QIM-based watermark embedding procedure.  
In Algorithm 1, \(m\) and \(n\) denote the horizontal and vertical sizes of the curvelet coeffcient, respectively, and \(i\) and \(j\) denote the horizontal and vertical coordinates of the curvelet coefficient. \(Q\) is a quantization operation, \(q\) is a quantization step, and \(b\) is the bit to be inserted. This algorithm is the same as in other QIM techniques and is designed to find the nearest quantization level corresponding to the bit to be inserted.  
Because the curvelet coefficient expresses a curved shape with directionality, it is related to the surrounding coefficients. As a result, when one coefficient is modified, the modification spreads to the surrounding coefficients [30]. Therefore, when quantization is performed, the entire \(C^{sJ}(i,j)\) should be adjusted by a multiplication operation as,  
\[C^{sJ}_{m}(i,j)=C^{sJ}(i,j)\cdot Q^{sJ}, \tag{8}\]  
where \(C_{m}\) denotes the modified curvelet coefficients. \(A^{sJ}\) is adjusted by applying (8) to all coefficients.  
The curvelet has a symmetry property similar to DFT. Therefore, the same modification should be applied in opposite directions. Since scale 3 has a total of 16 directions, a total of 8 bits can be inserted  
Figure 6: Frequency spectrum coverage of curvelet transform. The curvelet decomposes the frequency domain into various scales and directions.  
into one block considering the symmetry property. If this process is applied to all watermark blocks, the total bit capacity becomes the number of 'watermark blocks' \(\times\) 8.  
The watermark decode proceeds as shown in Algorithm 2. \(C_{d}\) denotes the curvelet coefficient of the image to be decoded, and \(b_{d}\) denotes the decoded bit. This process is repeated for all watermark blocks to decode all the bits.  
```
1:Input: watermarked curvelet coefficients \(C^{sJ}(i,j)\)
2:Output: decoded bit pattern \(b_{d}\)
3:\(A_{d}^{sJ}=\frac{1}{mn}\sum_{i=1}^{m}\sum_{i=1}^{n}abs(C_{d}^{sJ}(i,j))\)
4:\(b_{d}=\text{mod}[\text{round}(A_{d}^{sJ}/q)2]\)
```  
**Algorithm 2** Watermark decoding procedure.