# Edge-Aware Dual-Task Image Watermarking Against Social Network Noise
## 3 Proposed Method
### Edge-Aware Secret Hiding Module
#### 3.2.3 Dual-Task Watermark Encoder  
To enable the watermark encoder to understand image edge features during the embedding process, we propose a dual-task encoder with maximally shared parameters that simultaneously performs watermark embedding and edge detection. This design not only promotes structural awareness in watermark generation but also ensures efficient parameter utilization. The encoder adopts a U-Net architecture with carefully designed input and output layers to accommodate different task requirements while maximizing parameter sharing. Specifically, for the edge detection task, the network takes a three-channel RGB cover image \(I_{cov}\) as input and outputs a single-channel edge map. For the watermark embedding task, it processes a six-channel input formed by concatenating the cover image \(I_{cov}\) and the diffused secret message \(I_{sec}\) along the feature dimension, producing a three-channel watermark \(I_{hide}\) that can be directly added to \(I_{cov}\).  
To achieve maximal parameter sharing while handling these different input-output configurations, we design task-specific input and output convolution layers while sharing all intermediate layers of the U-Net. The first convolution layer employs different numbers of input channels (three for edge detection and six for watermark embedding), and the final convolution layer produces outputs with different channel dimensions (one for edge detection and three for watermark embedding). This design ensures that the feature dimensions align after the first convolution and before the last convolution, enabling the network to leverage a shared parameter space for both tasks throughout the intermediate layers. Such parameter sharing not only reduces the model complexity but also facilitates the transfer of edge understanding capabilities to the watermark embedding process. Both the watermark embedding output \(I_{hide}\in\mathbb{R}^{H\times W\times 3}\) and edge detection output \(E_{pred}\in\mathbb{R}^{H\times W\times 1}\) are processed through a sigmoid activation function, normalizing them to the range [0, 1].  
Through this dual-task learning strategy and the guidance of the edge detection teacher, our encoder learns to generate a structure-aware watermark \(I_{hide}\) that naturally aligns with image edges, which is then combined with the cover image \(I_{cov}\) to produce visually pleasing watermarked images \(I_{vm}\). Figure 3, from top to bottom, shows the cover image \(I_{cov}\) containing rich visual details, followed by the watermarked image \(I_{vm}\) that maintains high visual quality with imperceptible differences from the original. The edge detection teacher output \(E_{touch}\) clearly highlights the structural edges and contours, while the edge detection output \(E_{pred}\) demonstrates similar edge perception capabilities. Finally, the watermark embedding output \(I_{hide}\) showcases the successful integration of the watermark under edge-aware guidance. These visualizations effectively demonstrate how our module achieves watermark embedding while preserving image quality through edge-aware processing.  
The encoder is trained using the loss function \(\mathcal{L}_{CW}\) to make \(I_{vm}\) closer to \(I_{cov}\). The loss function \(\mathcal{L}_{CW}\) can be expressed as  
\[\mathcal{L}_{CW}=MSE(I_{cov},I_{vm}), \tag{7}\]  
where \(MSE(\cdot)\) computes the mean square error.