## 3 The Proposed Method
### Reversible Adversarial Example Generation
#### 3.2.2 Data Embedding  
In each channel, the difference in the AE is  
\[\begin{split}\mathbf{S}_{i}(m,n)=\mathbf{I}^{\prime}(m,n+1)- \mathbf{I}^{\prime}(m,n)\\ 0\leq& m\leq M,0\leq n\leq N-1\end{split} \tag{2}\]  
where \(\mathbf{I}^{\prime}\) represents the AE image, and \(\mathbf{I}^{\prime}(m,n)\) represents the pixel value at coordinates \((m,n)\) in the image. The image size is \(M\times N\). The three difference matrices in the three channels are \(\mathbf{S}_{i}\) where \(i\in\{R,G,B\}\), respectively. The differential computation process is illustrated in Figure 3.  
The histograms of \(\mathbf{S}_{i}\) are generated. Figure 4 shows a histogram. The highest bar in the histogram represents the most frequent difference value (usually 0), and is denoted as \(\epsilon_{\text{max}}\), as shown in Figure 4a. The bars at the right of the highest bar are shifted to the right by one unit, as shown in Figure 4b. The binary information can be embedded into the empty space, as shown in Figure 4c.  
Figure 3: Differential computation process.  
Figure 2: The process involves the obtaining and recording of auxiliary information (the original RGB values).  
The corresponding operation on \(\mathbf{S}_{i}\) is to increase the values, which are greater than \(e_{\text{max}}\), and generate \(\mathbf{S}_{i}^{\prime}\) as  
\[\mathbf{S}_{i}^{\prime}(m,n)=\begin{cases}\mathbf{S}(m,n)&\text{if }\mathbf{S}(m,n)<e_{ \text{max}}+1\\ \mathbf{S}(m,n)+1&\text{others}\end{cases} \tag{3}\]  
The first pixel with the value of \(e_{\text{max}}\) is found. If the embedded bit is 0, the value of the current \(e_{\text{max}}\)-pixel is unchanged; if the embedded bit is 1, the value of the current \(e_{\text{max}}\)-pixel is added by 1. The subsequent pixels outside \(e_{\text{max}}\)-pixel in the same row are also added by 1 to maintain the difference between two adjacent pixels. The next \(e_{\text{max}}\)-pixel is found and processed according to the next embedded bit. After data embedding, the matrices at three channels are \(\mathbf{S}_{i}^{\prime\prime}\). Because the operations at three channels are the same, the subscript \(i\) is omitted in the following equations. \(\mathbf{S}^{\prime\prime}\) can be obtained according to Equation (4), while \(k\) represents the value of the bit that is to be currently embedded.  
\[\mathbf{S}^{\prime\prime}(m,n)=\begin{cases}\mathbf{S}^{\prime}(m,n)+1&\text{ if }k=1\\ \mathbf{S}^{\prime}(m,n)&\text{if }k=0\end{cases} \tag{4}\]  
The three matrices are added to the AE \(\mathbf{I}^{\prime}\), and we obtain the RAE \(\mathbf{I}^{\prime\prime}\) as  
\[\mathbf{I}^{\prime\prime}(m,n+1)=\mathbf{I}^{\prime}(m,n)+\mathbf{S}^{\prime \prime}(m,n) \tag{5}\]  
We take an instance to illustrate how the data are embedded into a difference histogram. In Figure 5, a \(4\times 4\) matrix represents block in a channel of an AE \(\mathbf{I}^{\prime}\). The difference matrix \(\mathbf{S}\) is a \(4\times 3\) matrix, which is computed according to Equation (2). \(e_{\text{max}}\) is 0, and the \(e_{\text{max}}\)-pixels are labeled by yellow color.  
\(\mathbf{S}^{\prime}\) represents the values after histogram shifting in Figure 4. \(\mathbf{S}^{\prime\prime}\) is obtained after the data \"1010\" are embedded. Finally, the RAE \(\mathbf{I}^{\prime\prime}\) is obtained according to Equation (5). The changed pixels after data embedding are labeled by red color.  
Figure 4: Histogram at each stage. (**a**–**c**) represent the histograms of the original image, the histogram after shifting, and the histogram after embedding, respectively.