# Edge-Aware Dual-Task Image Watermarking Against Social Network Noise
## 3 Proposed Method
### Edge-Aware Secret Hiding Module
#### 3.2.2 Edge Detection Teacher  
Through the guidance of an edge detection teacher, our method learns to generate an edge-aware watermark \(I_{\textit{hide}}\in\mathbb{R}^{H\times W\times 3}\) that aligns with image structures, which is then combined with the cover image \(I_{\textit{cov}}\in\mathbb{R}^{H\times W\times 3}\) to produce the watermarked image \(I_{\textit{wm}}\in\mathbb{R}^{H\times W\times 3}\). To achieve this goal, we adopt a knowledge distillation framework that transfers edge detection capabilities from an effective edge detection algorithm to our watermark generation network. Knowledge distillation (KD), initially proposed by [PERSON] et al. in 2015 [PERSON] et al. (2015), is an effective approach for model compression and knowledge transfer. The core idea is to utilize a well-established model (teacher model) to guide the training process of another model (student model). In our case, the edge detection teacher provides binary edge maps that help our watermark encoder learn to identify and utilize image structural information. Specifically, we employ the traditional Sobel edge detection operator as the teacher model. The Sobel operator consists of two \(3\times 3\) kernels, \(G_{x}\) and \(G_{y}\), which are used to compute approximations of the derivatives for horizontal and vertical changes, respectively:  
\[G_{x}= \begin{bmatrix}-1&0&1\\ -2&0&2\\ -1&0&1\end{bmatrix} ,G_{y}= \begin{bmatrix}-1&-2&-1\\ 0&0&0\\ 1&2&1\end{bmatrix} . \tag{1}\]  
The edge magnitude \(E_{teach}\) is then computed as  
\[E_{teach}=\sqrt{G_{x}^{2}+G_{y}^{2}}. \tag{2}\]  
The choice of traditional methods over deep learning approaches as the edge teacher is based on several considerations: first, traditional edge detection methods offer higher computational efficiency, significantly reducing the computational overhead during model training; second, traditional methods have lower hardware requirements, facilitating broader application of the method; finally, classic operators like Sobel have well-established theoretical foundations and practical effectiveness in edge detection. In implementation, we first apply the Sobel filter to the cover image \(I_{\textit{cov}}\) for edge extraction, obtaining the teacher edge map \(E_{teach}\) as the supervision signal. Note that \(E_{teach}\in\mathbb{R}^{H\times W\times 1}\) and \(E_{\textit{pred}}\in\mathbb{R}^{H\times W\times 1}\) share the same dimension for direct loss computation, while \(I_{\textit{hide}}\in\mathbb{R}^{H\times W\times 3}\) requires taking the maximum value across channels at each pixel position to obtain \(max(I_{\textit{hide}})\in\mathbb{R}^{H\times W\times 1}\) before computing loss with \(E_{teach}\). In the dual-task watermark encoder, following previous edge detection works [PERSON] et al. (2018); [PERSON] et al. (2018), both the edge detection branch and watermark embedding branch outputs are required to compute  
Figure 2: Secret diffusion process. The pipeline of it consists of transforming the binary secret message \(M_{\textit{sec}}\) through linear mapping, followed by reshape and upscaling operations to generate the information image \(I_{\textit{sec}}\), which matches the dimensions of the cover image \(I_{\textit{cov}}\). weighted binary cross-entropy losses \(\mathcal{L}_{bd}\) with \(E_{teach}\). The specific loss function calculation method is as follows:  
\[\mathcal{L}_{TP}=BCE_{w}\Big{(}E_{teach},E_{pred}\Big{)}, \tag{3}\]  
\[\mathcal{L}_{TH}=BCE_{w}(E_{teach},max(I_{hide})), \tag{4}\]  
where \(\mathcal{L}_{TP}\) and \(\mathcal{L}_{TH}\) are the loss functions of the edge detection branch and the watermark embedding branch, respectively.