# 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.3 Joint Data Extraction and Image Restoration  
In this phase, if receivers have both the encryption and data-hiding keys, then they can extract the embedded information bits and restore the original image. To do this, receivers first generate a random sequence, \(R_{i,j,k}\) according to the encryption key using a standard stream cipher. Then, a bitwise XOR of \(I^{\prime\prime}\) and \(R\) is performed using the following equations:  
\[D_{i,j,k}=I^{\prime\prime}_{i,j,k}\oplus R_{i,j,k} \tag{8}\]  
\[D_{i,j}=\sum_{k=1}^{8}D_{i,j,k}.2^{k-1} \tag{9}\]  
Thus, a directly decrypted image is obtained, which is similar to the original except the \(t\) th bits of some chosen pixels in the directly decrypted image differ from those in the original image.  
To extract information, receivers have to make the permutation, four sets, and \(G\), which are same with ones in the sender by using the data-hiding key. To measure the fluctuation of \(d\) th group \(Q_{d}\) and its flipped group \(\overline{Q_{d}}\), the following functions are defined:  
\[f_{0}(d)=\sum_{x=1}^{G}|D_{i,j}(x,d)-D_{i,j-1}(x,d)|+\left|D_{i,j}(x,d)-D_{i,j+1}(x,d)\right|+\left|D_{i,j}(x,d)-D_{i-1,j}(x,d)\right|+\left|D_{i,j}(x,d) -D_{i+1,j}(x,d)\right| \tag{10}\]  
\[f_{1}(d)=\sum_{x=1}^{G}|\overline{D}_{i,j}(x,d)-D_{i,j-1}(x,d)|+\left| \overline{D}_{i,j}(x,d)-D_{i,j+1}(x,d)\right|+\left|\overline{D}_{i,j}(x,d)-D _{i-1,j}(x,d)\right|+\left|\overline{D}_{i,j}(x,d)-D_{i+1,j}(x,d)\right| \tag{11}\]  
where \(D_{i,j}(x,d)\) represents the chosen pixels in the \(d\) th group, \(Q_{d}\) and \(\overline{D}_{i,j}(x,d)\) is the flipped pixels, which are achieved by flipping the \(t\) th bit of \(D_{i,j}(x,d)\) and \(f_{0}(d)\) and \(f_{1}(d)\) are fluctuation functions of \(Q_{d}\)  
Figure 3: Pixels allocation in sets.  
and \(\overline{Q_{d}}\), respectively. For the fluctuation calculation, we use the actual value of the pixels, instead of the estimated value. Besides, we have considered the absolute difference between neighboring pixels rather than the prediction error, as used in (3) and (4), to reduce the bit error rate.  
Fluctuation of the original group is generally lower than that of the flipped one due to the spatial correlation in natural images. Hence, by comparing \(f_{0}(d)\) and \(f_{1}(d)\), data extraction and image restoration can be performed. If \(f_{0}(d)<f_{1}(d)\), then \(Q_{d}\) will be the original group, and 0 will be the extracted hidden bit, that is \(E(d)=0\). Otherwise, \(\overline{Q_{d}}\) will be the original group, and 1 will be the extracted hidden bit, that is \(E(d)=1\). Eventually, extracted hidden bits \(E(1)\), \(E(2)\),..., \(E(Q)\) are concatenated to get the permuted information bits. Then, using the data-hiding key, hidden bits \(E(1)\), \(E(2)\),..., \(E(Q)\) are inversely permuted, and the original information bits are extracted. The restored groups are collected to make the original image. As the information bits are further permuted using the data-hiding key, it is impossible for attackers to get the original message without the data-hiding key.