# Enhanced Dual Reversible Data Hiding Using Combined Approaches
## 2 Preliminaries
### Arithmetic Coding
The length of the embedded data is stored in each block, and after processing all blocks, the final marked images are generated. As a result, the modified images can be sent to different recipients. ```
0: Cover images \(I_{1}\), \(I_{2}\), secret data bits \(m=\{b\in\{0,1\}^{n}\}\)
0: Marked images \(I_{1}^{\prime}\), \(I_{2}^{\prime}\)
1:Initialization:
2: Divide \(I_{1}\) and \(I_{2}\) into non-overlapping blocks of size \(16\times 16\)
3:for each block pair \((B_{i}^{1},B_{i}^{2})\)do
```
**Algorithm 3** Data hiding algorithm
```
4:Encoding:
5:for each pixel pair \((x_{k}^{1},x_{k}^{2})\)do
6: Extract upper bits to form codeword \(P\)
7: Compute syndrome \(S\gets H\cdot P^{T}\)
8:\(S^{\prime}\gets S\oplus(m_{k},m_{k+1},m_{k+2})\)
9: Store \(S^{\prime}\) in encoded message \(M\)
10:endfor
11:Compression:
12:\(D_{comp}\gets A(M)\)\(\triangleright\) Apply arithmetic encoding
13:\(L\leftarrow\text{len}(D_{comp})\)
14:Embedding (RDH EMD) method:
15:for\(k=1\) to \(L/2\)do
16: Compute \(f\leftarrow(x_{k}^{1}+x_{k}^{2}\cdot 2)\) mod 5
17:\(d_{decimal}(k)=D_{comp}^{2\epsilon}\cdot 2^{1}+D_{comp}^{2\epsilon+1}\cdot 2^{0}\)\(\triangleright\) binary to decimal value
18: Compute \(pos=(d_{decimal}(k)-f)\) mod 5
19:if\(pos<0\)then
20:\(pos\gets 5-\text{abs}(pos)\)
21:endif
22:if\(pos==1\)then
23:\(x_{k}^{1}\gets x_{k}^{1}+1\)
24:elseif\(pos==2\)then
25:\(x_{k}^{2}\gets x_{k}^{2}+1\)
26:elseif\(pos==3\)then
27:\(x_{k}^{1}\gets x_{k}^{1}-1\)
28:\(x_{k}^{2}\gets x_{k}^{2}+2\)
29:elseif\(pos==4\)then
30:\(x_{k}^{1}\gets x_{k}^{1}+1\)
31:\(x_{k}^{2}\gets x_{k}^{2}-1\)
32:endif
33:endfor
34: Store length \(L\) in pixels \(\{x_{250},x_{251},\dots,x_{256}\}\) of \(B_{i}^{1}\)
35:endfor
36:Finalization:
37:Replace original blocks in \(I_{1}\), \(I_{2}\) with modified blocks \(B_{i}^{1}\), \(B_{i}^{2}\)
38:return Marked images \(I_{1}^{\prime}\), \(I_{2}^{\prime}\)
```
**Algorithm 3**_Cont._

### Data Extraction and Image Recovering Procedure

The receiver, who has the two marked images \(I_{1}^{\prime}\) and \(I_{2}^{\prime}\) sent by the sender, can extract the data from these images using the data extraction and image restoration algorithm that is shared between the sender and receiver. The process of data extraction and cover image restoration is the reverse of the data hiding process, and the detailed procedure is as follows:
```
1:Two marked images \(I_{1}^{\prime}\) and \(I_{2}^{\prime}\). 2:One original image \(O\) and hidden bits, \(m\). 3:The marked images \(I_{1}^{\prime}\) and \(I_{2}^{\prime}\) are divided into non-overlapping blocks of size \(16\times 16\). 4:Read blocks \(B_{i}^{1}\) and \(B_{i}^{2}\) from the marked image \(I_{1}^{\prime}\) and \(I_{2}^{\prime}\). 5:To extract the length of the binary data embedded in a block, Equations (5) and (6) are applied to the pixel positions \((x_{250},\dots,x_{256})\) of blocks \(B_{i}^{1}\) and \(B_{i}^{2}\) to extract binary digits, which are then converted to a decimal number and assigned to the variable \(L\). Given the length \(L\) in the block, the following process is performed: Equation (5) is applied to the pixels \(x_{j}^{1}\) and \(x_{j}^{2}\) of blocks \(B_{i}^{1}\) and \(B_{i}^{2}\), respectively, to calculate the value \(f\). The extracted data are assigned to \(M\), where \(M(k)=d2b(f)\). Here, the \(d2b(\cdot)\) is a function that converts a decimal integer \(f\) to a binary integer. **Step 4:**: The calculation result of Equation (8) restores the original pixel \(x_{j}=p_{j}\). The pixel \(x_{j}\) is replaced by the corresponding pixel at the same position as the two blocks. This process is repeated for a length of \(L/2\) to recover the block. By replacing the pixels \(x_{j}^{1}\) and \(x_{j}^{2}\) in blocks \(B_{i}^{1}\) and \(B_{i}^{2}\) that constitute the block, the restored block (as described in Equation (9) can be obtained. Each block is completed through the process explained in Equation (10) along with the original cover image. \[p=\left\lfloor\frac{x_{j}^{1}\times x_{j}^{2}}{2}\right\rfloor \tag{8}\]  
\[B_{i}^{1}=B_{2}^{2}=