## 2 The Proposed RDHEI Method
### Room Reservation and Image Encryption
#### 2.1.4 Image Encryption  
In this section, we encrypt each reordered mapped prediction error bit plane using an encryption key \(K_{e}\). We first generate a pseudo-random matrix \(r\), with the same size of the original image, using the key \(K_{e}\). We then encrypt the reordered mapped prediction error image according to Equation (6) and generate the encrypted image \(x_{e}\). \[x_{e}(u,v)=e(u,v)\oplus r(u,v), \tag{6}\]  
where \(1\leq u\leq n\), \(1\leq v\leq m\), and \(\oplus\) is the exclusive-or (XOR) operation. Figure 11 presents the encryption process. With no loss of generality, in this work the Piecewise Linear Chaotic Map (PWLCM) [32; 33; 34; 35] is used to generate the encryption matrix, taking into account that any other efficient chaotic system can be used [36; 37; 38]. It is to be noted that the bits required by the data hider, which are located at the top-left corner of each bit plane, remain unencrypted. The PWLCM is a map that can be described as in Equation (7):  
\[x_{i}=F(x_{i-1},\eta)=\left\{ \begin{array}{ll}\dfrac{x_{i-1}}{\eta}&0<x_{i- 1}<\eta\\ \dfrac{x_{i-1}-\eta}{0.5-\eta}&\eta\leq x_{i-1}<0.5\\ F(1-x_{i-1},\eta)&0.5\leq x_{i-1}<1\end{array} \right., \tag{7}\]  
where \(\eta\in(0,0.5)\) is the control parameter, and \(x_{0}\in(0,1)\) is the initial value. In our encryption scheme, we suggest using the PWLCM to generate the random matrix \(r\) to be scored with the reordered mapped prediction error image \(e\), as depicted in Equation (6). We employ two distinct PWLCMs to generate two sequences, denoted as \(A=a_{1},a_{2},\ldots,a_{nm}\) and \(B=b_{1},b_{2},\ldots,b_{nm}\). It is important to maintain that both the image to be encrypted and the random matrix must share the same dimensions, specifically \(n\) rows and \(m\) columns, corresponding to the original image's size. It is noteworthy that  
Figure 10: Bit-planes of the reordered mapped prediction error Lena image before (**a**) and after (**b**) adding the corresponding auxiliary information. Bit-planes of the reordered mapped prediction error Jetplane image before (**c**) and after (**d**) adding the corresponding auxiliary information. different control parameters \((\eta_{1},\eta_{2})\) and initial values \((x_{0},y_{0})\) are employed to generate the two sequences \(A\) and \(B\). These initial values and control parameters serve as the secret key, designated as \(k_{e}=(x_{0},\eta_{1},y_{0},\eta_{2})\). The first PWLCM employs Equation (8) to convert the sequence \(X=x_{1},x_{2},\cdots,x_{nm}\) to the integer sequence \(A\) by truncating it, where \(\lfloor.\rfloor\) is the floor function. Consequently, each integer \(a_{i}\) within the sequence \(A\) comprises 14 digits. We propose further decomposing \(a_{i}\) into two integers, \(a_{i}^{1-7}\) and \(a_{i}^{8-14}\), each composed of 7 digits. As an example, if \(a_{i}=11223344556677\) the \(a_{i}^{1-7}=1122334\) and \(a_{i}^{8-14}=4556677\). \[A=\lfloor X*10^{14}\rfloor. \tag{8}\]  
The second PWLCM uses the following equation to convert \(Y=y_{1},y_{2},\cdots,y_{nm}\) into a binary sequence \(B\):  
\[B=mod(\lfloor Y*10^{14}\rfloor,2), \tag{9}\]  
where \(mod(x,y)\) is the function that returns the remainder when \(x\) is divided by \(y\). Finally, each integer within the random matrix \(r\) is generated according to the following equation:  
\[r_{i}=\left\{ \begin{array}{ll}mod(a_{i}^{1-7},256)&y_{i}=0\\ mod(a_{i}^{8-14},256)&otherwise\end{array} \right.. \tag{10}\]  
This process effectively produces the random matrix \(r\), which is crucial for the encryption process. Algorithm 3 implements the \(processImage\) procedure by calling the following functions:  
* \(mappedPredictionError\) for the mapped prediction error and label map calculation. * \(quadtreeDecomposition\) for the quadtree decomposition and the generation of the binary string and the list of the homogeneous blocks for each bit plane.