# Enhanced Joint and Separable Reversible Data Hiding in Encrypted Images with High Payload
## 3 The Proposed Joint Data Hiding System
### Procedures of Proposed Method
#### 3.1.2 Data Hiding  
After the encryption phase, the encrypted image is sent to the data hider. Although the data hider does not know anything about the original image, the data hider can embed additional data into the encrypted image by changing a small portion of it. Before embedding, \(Q\) bits of information are permuted by using the data-hiding key; let \(A(1)\), \(A(2)\),..., \(A(Q)\) be the permuted information bits to be embedded. It is assumed that \(Q=Q_{\text{B}}+Q_{\text{W}}\), where \(Q_{\text{B}}\) and \(Q_{\text{W}}\) are nonnegative integers for the number of embedded information bits in the two sets. In the data hiding phase, according to the data-hiding key, the pixels except the border pixels in the encrypted image, are divided into four sets, \(B_{1}\), \(B_{2}\), \(W_{1}\), and \(W_{2}\), where pixels in \(B_{1}\) and \(W_{1}\) can be used for embedding \(Q_{\text{B}}\) and \(Q_{\text{W}}\) information bits, respectively, and pixels in \(B_{2}\) and \(W_{2}\) can be used for data extraction. Border pixels can be the elements of \(B_{2}\) or \(W_{2}\) but cannot be the elements of \(B_{1}\) or \(W_{1}\), i.e., border pixels can be used for data extraction but cannot be used for data embedding. To embed one information bit, it is assumed that \(G\) pixels are considered. Therefore, the elements of \(B_{1}\) and \(W_{1}\) are \(Q_{\text{B}}G\) and \(Q_{\text{W}}G\), respectively. For convenience, it is assumed that \(B_{1}\) and \(B_{2}\) can be located at position (\(i\),\(j\)), where \((i+j)\) mod \(2=0\). Similarly, the elements of \(W_{1}\) and \(W_{2}\) can be located at position (\(i+j\)), where \((i+j)\) mod \(2=1\) as shown in Figure 3. In the first round, according to the data-hiding key, pixel \(I^{\prime}_{i,j}\) is selected, and pixel \(I^{\prime}_{i,j}\) is assigned to \(B_{1}\) or \(W_{1}\), if \((i+j)\) mod \(2\) is 0 or 1, respectively. Then, neighboring pixels \(I^{\prime}_{i+1,j}\), \(I^{\prime}_{i-1,j}\), \(I^{\prime}_{i,j+1}\), and \(I^{\prime}_{i,j-1}\) are assigned to \(W_{2}\) or \(B_{2}\), respectively. For the next round, we choose a new pixel \(I^{\prime}_{i,j}\) with \(i\) and \(j\) that are different from \(i\) and \(j\) in the previous round. If \((i+j)\) mod \(2\) is 0, then the chosen pixel \(I^{\prime}_{i,j}\) becomes an element in \(B_{1}\), regardless of whether the chosen pixel \(I^{\prime}_{i,j}\) is an element of \(B_{2}\) or not, and neighboring pixels \(I^{\prime}_{i+1,j}\), \(I^{\prime}_{i-1,j}\), \(I^{\prime}_{i,j+1}\), and \(I^{\prime}_{i,j-1}\) are elements of \(W_{1}\) or \(W_{2}\) or not. However, the neighboring pixels that are not in \(W_{2}\) become elements in \(W_{2}\). The neighboring pixels in \(W_{1}\) or \(W_{2}\) are not changed. Similarly, if \((i+j)\) mod \(2=1\), then the chosen pixel \(I^{\prime}_{i,j}\) is assigned to set \(W_{1}\), and the neighboring pixels not in set \(B_{2}\), become elements of \(B_{2}\). For example, as shown in Figure 3, we choose a pixel at position (\(2\), \(2\)) where \(i=2\) and \(j=2\). Since \((2+2)\) mod \(2=0\), the first chosen pixel belongs to set \(B_{1}\) and neighboring pixels will be the elements in set \(W_{2}\). If the second selected pixel is located at the (\(3\), \(3\)) position, the chosen pixel belongs to set \(B_{1}\) since \((3+3)\) mod \(2=0\). Since the top and left pixels are already in set \(W_{2}\), only the bottom and right pixels will be the elements in set \(W_{2}\). The thirdchosen pixel at position (5, 2) will belong to set \(W_{1}\) as \((5+2)\) mod 2 = 1 and adjacent pixels will be the elements in \(B_{2}\). The next pixel can be selected at position (4, 3) and will belong to set \(W_{1}\). Though this pixel was already an element of set \(W_{2}\), the pixel can belong to \(W_{1}\) and the neighboring pixels that are not in \(B_{2}\) become the elements of \(B_{2}\). The selection process terminates when the elements of \(B_{1}\) and \(W_{1}\) become \(Q_{\rm B}G\) and \(Q_{\rm W}G\).