# Enhanced Dual Reversible Data Hiding Using Combined Approaches
## 2 Preliminaries
### Arithmetic Coding
To embed the binary message \(m\), combine the upper 4 bits and upper 3 bits of the pixel \(x_{j}\) to generate a codeword \(P\) (Equation (3)). For the codeword \(P\), calculate the Hamming syndrome \(S\) using Equation (4). Perform an XOR operation between the syndrome \(S\) and the corresponding secret bit \(m_{k}\): \(S^{\prime}=S\oplus(m_{k},m_{k+1},m_{k+2})\). Append the resulting syndrome \(S^{\prime}\) sequentially to the array \(M\): \(M(k:k+2)=S^{\prime}\). Continue the process for all pixels in both blocks until each pixel pair is processed. \[ \begin{cases}x_{j}^{1}=\sum_{k=0}^{7}b_{j,k}^{1}\cdot 2^{k},&b_{j,k}^{1}=\left| \begin{array}{c}x_{j}^{1}\\ 2^{k}\end{array}\right|\bmod 2\\ x_{j}^{2}=\sum_{k=0}^{7}b_{j,k}^{2}\cdot 2^{k},&b_{j,k}^{2}=\left| \begin{array}{c}x_{j}^{2}\\ 2^{k}\end{array}\right|\bmod 2\\ \text{Codeword: }P=\{b_{j,7}^{1},b_{j,6}^{1},b_{j,5}^{1},b_{j,A}^{1},b_{j,7}^{2}, b_{j,6}^{2},b_{j,5}^{2}\}\\ \end{cases}  \tag{4}\]

\[S=H\cdot P^{T} \tag{5}\]
**Step 4**: If all pixels in the block have been processed, move to step 5. Otherwise, repeat step 3 for the remaining pixels. **Step 5**: Compress the encoded message \(M\) using the arithmetic encoding function \(A(\cdot)\) defined in Algorithm 1. The compressed data \(D_{comp}\) and its length \(L\) are given by \(D_{comp}=A(M)\) and \(L=len(D_{comp})\). Figure 1: Framework of the proposed scheme. **Step 6:**: The compressed data \(D_{comp}\) are hidden in the LSB (least significant bit) of the pixels within the blocks \(B_{i}^{1}\) and \(B_{i}^{2}\). \(D_{comp}\) is embedded into pixel pairs (\(x_{k}^{1}\) and \(x_{k}^{2}\)) using Equation (5). The calculation results in _pos_, which is used to adjust the pixel values according to the rules in Equation (6) to hide the data. This process is repeated for all pixels in the block. The data length \(L\) is stored in the pixel positions \(\{x_{250},x_{251},\ldots,x_{256}\}\) within the blocks (\(B_{i}^{1}\)) and (\(B_{i}^{2}\)) using the methods described in Equations (5) and (6). The length information \(L\) is an essential payload for the data extraction process. \[\forall k\in\{1,\ldots,L/2\} \tag{5}\] \[ \begin{cases}f=(x_{k}^{1}+x_{k}^{2}\times 2)\bmod 5\\ d_{decimal}(k)=D_{comp}^{2r}\cdot 2^{1}+D_{comp}^{2r+1}\cdot 2^{0}\\ pos=(d_{decimal}(k)-f)\bmod 5\\ \text{if }(pos<0)\ pos=5-abs(pos)\end{cases} \] \[ \begin{cases}\text{If }pos=0,&\text{No change needed}\\ \text{If }pos=1,&x_{j}^{r1}\gets x_{j}^{1}+1\\ \text{If }pos=2,&x_{j}^{r2}\gets x_{j}^{2}+1\\ \text{If }pos=3,&x_{j}^{r1}\gets x_{j}^{1}-1,&x_{j}^{r2}\gets x_{j}^{2}+2\\ \text{If }pos=4,&x_{j}^{r1}\gets x_{j}^{1}+1,&x_{j}^{r2}\gets x_{j}^{2}-1 \end{cases}  \tag{6}\]
**Step 7:**: The block with hidden data is swapped with the corresponding block at its designated location according to Equation (7). This process is repeatedly applied to all blocks. If there are remaining blocks to process, return to step 2. If no more blocks remain to be processed, this procedure is complete. \[I_{i}^{1}= \begin{bmatrix}B_{1}^{r1}&B_{2}^{r1}&B_{3}^{r1}&\cdots&B_{16}^{r1}\\ B_{17}^{r1}&B_{18}^{r1}&B_{19}^{r1}&\cdots&B_{32}^{r1}\\ B_{33}^{r1}&B_{34}^{r1}&B_{35}^{r1}&\cdots&B_{48}^{r1}\\ \vdots&\vdots&\vdots&\ddots&\vdots\\ B_{241}^{r1}&B_{242}^{r1}&B_{243}^{r1}&\cdots&B_{256}^{r1}\\ \end{bmatrix}  \tag{7}\]

Finally, two marked images \(I_{1}^{\prime}\) and \(I_{2}^{\prime}\) containing the embedded data are created, and these two marked images are sent to different recipients. Algorithm 3 represents the detailed description provided above in the form of a pseudocode algorithm. This algorithm performs the process of hiding secret data in two cover images, namely \(I_{1}\) and \(I_{2}\). The images are divided into \(16\times 16\) non-overlapping blocks, and the upper bits of pixels in each block are extracted to generate codewords. The Hamming code is used to compute the syndrome, which is then XORed with the secret data. The encoded data are compressed using arithmetic coding, and the least significant bits (LSBs) of the pixels are modified to embed the data.