# Edge-Guided Dual-Stream U-Net for Secure Image Steganography
## 3 The Proposed Method
### Loss Function  
We have developed a combined loss function aimed at ensuring the stego image both effectively embeds secret information and visually maintains high similarity to the original image. This loss function consists of three components: decoding information loss (\(L_{D}\)), image quality loss (\(L_{E}\)), and critic loss (\(L_{C}\)). These components are optimized together to improve the embedding effectiveness and visual quality of the stego image while minimizing information recovery errors and image distortions.  
Decoding Information Loss (\(L_{D}\)): The purpose of the information recovery loss \(L_{D}\) is to ensure accurate recovery of the hidden information from the stego image. We use Binary Cross-Entropy Loss (BCE Loss) to measure the degree of match between the decoded message \(M^{\prime}\) from the stego image \(S\) and the original secret message \(M\). The formula for this loss is as follows:  
\[L_{D}\big{(}M^{\prime},M\big{)}=\big{\langle}M,log\big{(}M^{\prime}\big{)} \big{\rangle}+\big{\langle}(1-M),log\big{(}1-M^{\prime}\big{)}\big{\rangle} \tag{15}\]  
where \(\langle\cdot\rangle\) represents the dot product. Minimizing this loss ensures efficient recovery of accurate secret information from the stego image.  
Image Quality Loss \((L_{E})\): To ensure that the stego image visually resembles the original cover image, we introduce the image quality loss \(L_{E}\), which measures the pixel-wise differences between the stego image and the original cover image using Mean Squared Error (MSE):  
\[L_{E}(S,X)=\frac{\|S-X\|_{2}^{2}}{C\times H\times W} \tag{16}\]  
where \(X\) is the original cover image, \(S\) is the stego image, and \(N=H\times W\times 3\) is the total number of pixels. By minimizing \(L_{E}\), we ensure that the generated stego image retains a high visual similarity to the original image, avoiding noticeable artifacts or distortions.  
Critic Loss \((L_{C})\): To enhance the concealment of the stego image and make it harder for detectors or the human eye to differentiate it, we design the critic loss \(L_{C}\). Similar to the discriminator in Generative Adversarial Networks (GANs), the critic network's objective is to determine if the generated stego image \(S\) is indistinguishable from the original image \(X\). This loss is defined as follows:  
\[L_{C}(S,X)=\text{Critic}(S)-\text{Critic}(X) \tag{17}\]where \(\text{Critic}(S)\) and \(\text{Critic}(X)\) represent the critic's output scores for the stego image and the original cover image, respectively. Minimizing this loss ensures that the generated stego image appears more natural and less detectable.  
Total Loss Function: The final loss function is a weighted combination of the three losses, considering the accuracy of information recovery, image quality, and concealment:  
\[L_{total}=\sum_{t=1}^{T}\gamma^{T-t}\big{[}L_{D}\big{(}M,M^{\prime}_{t}\big{)} +\alpha L_{E}(X,S_{t})+\beta L_{C}(X,S_{t})\big{]} \tag{18}\]  
where \(\alpha\) and \(\beta\) are the weights that regulate the image quality loss and the commenter loss, and \(\gamma\) is a decay factor that controls the effect of the loss during the iteration. \(M^{\prime}_{t}\) is at each step of iteration \(t\), and the model uses the decoder to recover the message \(M^{\prime}\) from the steganographic image at that step \(S_{t}\). \(S_{t}\) is the steganographic image at step \(t\).