# Enhanced Dual Reversible Data Hiding Using Combined Approaches
## 2 Preliminaries
### Arithmetic Coding
```  
**Algorithm 1** Arithmetic encoding  
```
1:Data sequence \(D=\{d_{1},d_{2},\ldots,d_{n}\}\), symbol probabilities \(\mathcal{P}\)
2:Encoded value \(E\)
3:Initialize low \(\gets 0\)
4:Initialize high \(\gets 1\)
5:Initialize range \(\leftarrow\) high - low
6:for each symbol \(d_{i}\) in \(D\)do
7:\(range\leftarrow\) high - low
8:\(high\gets low+range\times\) CDF(\(d_{i}\))
9:\(low\gets low+range\times\) CDF(\(d_{i-1}\))
10:endfor
11:\(E\leftarrow(low+high)/2\)
12:returnE
```  
**Algorithm 2** Arithmetic encoding  
```
1:Initialize low \(\gets 0\)
2:Initialize high \(\gets 1\)
3:Initialize range \(\leftarrow\) high - low
4:for each symbol \(d_{i}\) in \(D\)do
5:\(range\leftarrow\) high - low
6:\(high\gets low+range\times\) CDF(\(d_{i}\))
7:\(low\gets low+range\times\) CDF(\(d_{i-1}\))
8:endfor
9:\(E\leftarrow(low+high)/2\)
10:returnE
```  
**Algorithm 3** Arithmetic encoding  
```
1:Initialize low \(\gets 0\)
2:Initialize high \(\gets 1\)
3:Initialize range \(\leftarrow\) high - low
4:for each symbol \(d_{i}\) in \(D\)do
5:\(range\leftarrow\) high - low
6:\(high\gets low+range\times\) CDF(\(d_{i}\))
7:\(low\gets low+range\times\) CDF(\(d_{i-1}\))
8:endfor
9:\(E\leftarrow(low+high)/2\)
10:returnE
```  
**Algorithm 4** Arithmetic encoding  
```
1:Initialize low \(\gets 0\)
2:Initialize high \(\gets 1\)
4:Initialize range \(\leftarrow\) high - low
5:for each symbol \(d_{i}\) in \(D\)do
6:\(range\leftarrow\) high - low
7:\(high\gets low+range\times\) CDF(\(d_{i}\))
8:\(low\gets low+range\times\) CDF(\(d_{i-1}\))
9:endfor
10:\(E\leftarrow(low+high)/2\)
11:returnE
```  
**Algorithm 5** Arithmetic encoding  
```
1:Initialize low \(\gets 0\)
2:Initialize high \(\gets 1\)
3:Initialize range \(\leftarrow\) high - low
4:for each symbol \(d_{i}\) in \(D\)do
5:\(range\leftarrow\) high - low
6:\(high\gets low+range\times\) CDF(\(d_{i}\))
7:\(low\gets low+range\times\) CDF(\(d_{i-1}\))
8:endfor
11:\(E\leftarrow(low+high)/2\)
12:returnE
```  
**Algorithm 6** Arithmetic encoding  
```
1:Initialize low \(\gets 0\)
3:Initialize high \(\leftarrow 1\)
4:Initialize range \(\leftarrow\) high - low
5:\(high\gets 1\)
6:\(high\gets 1\)
7:\(low\gets low+range\times\) CDF(\(d_{i-1}\))
8:endfor
12:\(E\leftarrow(low+high)/2\)
13:returnE
```  
**Algorithm 7** Arithmetic encoding  
```
1:Initialize low \(\leftarrow 0\)
2:Initialize high \(\leftarrow 1\)
3:Initialize range \(\leftarrow\) high - low
4:for each symbol \(d_{i}\) in \(D\)do
5:\(range\leftarrow\) high - low
6:\(high\gets low+range\times\) CDF(\(d_{i}\))
7:\(low\gets low+range\times\) CDF(\(d_{i-1}\))
8:endfor
13:\(E\leftarrow(low+high)/2\)
14:returnE
```  
**Algorithm 8** Arithmetic encoding  
```
1:Initialize low \(\leftarrow 0\)
3:Initialize high \(\leftarrow 1\)
4:Initialize range \(\leftarrow\) high - low
5:for each symbol \(d_{i}\) in \(D\)do
6:\(range\leftarrow\) high - low
7:\(high\gets low+range\times\) CDF(\(d_{i}\))
8:\(low\gets low+range\times\) CDF(\(d_{i-1}\))
9:endfor
10:\(E\leftarrow(low+high)/2\)
11:returnE
```  
**Algorithm 8** Arithmetic encoding  
```
1:Initialize low \(\leftarrow 0\)
4:Initialize high \(\leftarrow 1\)
5:Initialize high \(\leftarrow 1\)
6:\(range\leftarrow\) high - low
7:\(high\gets low+range\times\) CDF(\(d_{i}\))
8:endfor
14:\(E\leftarrow(low+high)/2\)
15:\(E\leftarrow(low+high)/2\)
16:returnE
```  
**Algorithm 9** Arithmetic encoding  
```
1:Initialize low \(\leftarrow 0\)
2:Initialize high \(\leftarrow 1\)
3:Initialize range \(\leftarrow\) high - low
4:for each symbol \(d_{i}\) in \(D\)do
5:\(range\leftarrow\) high - low
6:\(high\gets low+range\times\) CDF(\(d_{i}\))
7:\(low\gets low+range\times\) CDF(\(d_{i-1}\))
8:endfor
17:\(E\leftarrow(low+high)/2\)
18:endfor
19:\(E\leftarrow(low+high)/2\)
20:returnE
```  
**Algorithm 10** Arithmetic encoding  
```
1:Initialize low \(\leftarrow 0\)
3:Initialize high \(\leftarrow 1\)
4:\(range\leftarrow\) high - low
5:\(high\gets low+range\times\) CDF(\(d_{i}\))
8:endfor
21:\(E\leftarrow(low+high)/2\)
8:endfor
22:\(E\leftarrow(low+high)/2\)
8:endfor
23:\(E\leftarrow(low+high)/2\)
8:endfor
24:\(E\leftarrow(low+high)/2\)
8:endfor
25:\(E\leftarrow(low+high)/2\)
8:endfor
26:\(E\leftarrow(low+high)/2\)
8:endfor
27:\(E\leftarrow(low+high)/2\)
8:endfor
28:\(E\leftarrow(low+high)/2\)
8:endfor
29:\(E\leftarrow(low+high)/2\)
9:endfor
30:\(E\leftarrow(low+high)/2\)
10:returnE
```  
**Algorithm 11** Arithmetic encoding  
```
1:Initialize low \(\leftarrow 0\)
4:Initialize high \(\leftarrow 1\)
5:\(range\leftarrow\) high - low
6:\(high\gets low+range\times\) CDF(\(d_{i}\))
7:\(high\gets low+range\times\) CDF(\(d_{i}\))
8:endfor
31:\(E\leftarrow(low+high)/2\)
8:endfor
32:\(E\leftarrow(low+high)/2\)
8:endfor
43:\(E\leftarrow(low+high)/2\)
8:endfor
44:\(E\leftarrow(low+high)/2\)
8:endfor
55:\(E\leftarrow(low+high)/2\)
8:endfor
56:\(E\leftarrow(low+high)/2\)
8:endfor
57:\(E\leftarrow(low+high)/2\)
8:endfor
60:\(E\leftarrow(low+high)/2\)
8:endfor
81:\(E\leftarrow(low+high)/2\)
8:endfor
82:\(E\leftarrow(low+high)/2\)
8:endfor
83:\(E\leftarrow(low+high)/2\)
8:endfor
84:\(E\leftarrow(low+high)/2\)
8:endfor
85:\(E\leftarrow(low+high)/2\)
8:endfor
86:\(E\leftarrow(low+high)/2\)
8:endfor
87:\(E\leftarrow(low+high)/2\)
8:endfor
88:\(E\leftarrow(low+high)/2\)
8:endfor
89:\(E\leftarrow(low+high)/2\)
8:endfor
90:\(E\leftarrow(low+high)/2\)
91:endfor
92:\(E\leftarrow(low+high)/2\)
93:endfor
94:\(E\leftarrow(low+high)/2\)
95:endfor
95:\(E\leftarrow(low+high)/2\)
96:endfor
97:\(E\leftarrow(low+high)/2\)
97:endfor
98:\(E\leftarrow(low+high)/2\)
99:endfor
99:\(E\leftarrow(low+high)/2\)
10:endfor
99:\(E\leftarrow(low+high)/2\)
111:endfor
12:\(E\leftarrow(low+high)/2\)
12:endfor
13:\(E\leftarrow(low+high)/2\)
14:endfor
15:\(E\leftarrow(low+high)/2\)
16:endfor
17:\(E\leftarrow(low+high)/2\)
18:endfor
19:\(E\leftarrow(low+high)/2\)
19:endfor
19:\(E\leftarrow(low+high)/2\)
12:endfor
18:\(E\leftarrow(low+high)/2\)
19:endfor
20:\(E\leftarrow(low+
```
0: Encoded value \(E\), symbol probabilities \(\mathcal{P}\), data length \(n\)
0: Decoded sequence \(\{D^{\prime}=d_{1}^{\prime},d_{2}^{\prime},\ldots,d_{n}^{\prime}\}\)
1: Initialize \(low\gets 0\)
2: Initialize \(high\gets 1\)
3: Initialize \(range\gets high-low\)
4: Initialize \(encoded\_value\gets E\)
5:for\(i\gets 1\) to \(n\)do
6:\(range\gets high-low\)
7:\(value\leftarrow(encoded\_value-low)/range\)
8: Find the largest \(j\) such that \(\mathrm{CDF}(d_{j})\leq value\)
9:\(d_{i}^{\prime}\gets d_{j}\)
10:\(high\gets low+range\times\mathrm{CDF}(d_{j})\)
11:\(low\gets low+range\times\mathrm{CDF}(d_{j-1})\)
12:endfor
13:return\(S^{\prime}\)
```
**Algorithm 2** Arithmetic decoding

### Exploiting Modification Direction Method

The EMD method [30] is a technique that utilizes the modification direction of pixels to conceal data within digital images.