# An Adaptive Reversible Data Hiding Scheme Using AMBTC and Quantization Level Difference
## 3 The Proposed Scheme
### Embedding Phase  
The process of embedding phase is shown in Figure 3. Let I be an input cover image sized \(H\times W\). Each block \(b_{i}\) is sized \(k\times k\), where \(i=0,\ 1,\ \ldots,\ \frac{H}{k}\times\frac{W}{k}-1\). Secret data S is a bit stream in binary form, and \(M_{n}\) is the decimal value of secret bits. Input: Cover image I and secret data S.  
Output: Modified image \(I^{\prime}\). Step 1. Divide I into \(k\times k\) non-overlapping blocks \(b_{i}\)'s. Step 2. Calculate the current processing block \(b_{i}\) using AMBTC algorithm. Step 3. Compute \(d_{i}\) using Equation (6). \[d_{i}=h_{i}-l_{i}, \tag{6}\]  
where \(h_{i}\) and \(l_{i}\) are quantization levels of high value and low value, respectively. Step 4. Determine the value of \(d_{i}\). If \(3<d_{i}<64\), go to Step 5. Otherwise, go to Step 7. Here, if \(d_{i}\) is smaller than 3, the secret data cannot be extracted because of the middle value of two quantization levels could not be determined. For example, the values of \(h_{i}\) and \(l_{i}\) are 9 and 7, respectively. We cannot know whether the modified pixel value \(p^{\prime}_{n}\) is \(h_{i}-1\) or \(l_{i}+1\) while \(p^{\prime}_{n}\) is 8. Therefore, \(d_{i}\) must be greater than 3. And if \(d_{i}\) is greater than 63, it may cause a problem where the difference of the current processing block and its neighbor blocks are very large. As such, \(d_{i}\) should be smaller than 63. Step 5. Find out the first \(bp_{n}=0\) (FL) and the last \(bp_{n}=1\) (LH) in the bitmap, where \(bp_{n}\) is the presented value in the bitmap and \(n=0,\ 1,\ \ldots,\ k\times k-1\). FL and LH are the first value 0 and the last value 1 in the bitmap, respectively. The locations of FL and LH are \(r_{1}\) and \(r_{2}\), respectively, where \(r_{1}\) and \(r_{2}\) are \(0,\ 1,\ \ldots\) or \(k\times k-1\). We show an example in Figure 4 to describe in detail the process of scanning FL and LH. Step 6. Compute the value of \(a_{i}\) using Equation (7). Then, embed the \(M_{n}\) into each \(p_{n}\) using Equation (8),  
\[a_{i}=\ \left\lfloor\log_{2}\left(\frac{d_{i}}{2}\right)\right\rfloor, \tag{7}\]  
\[p^{\prime}_{n}=\left\{ \begin{array}{c}h_{i}\,\ \text{if}\ n=r_{2}\\ l_{i}\,\ \text{if}\ n=r_{1}\\ h_{i}-M_{n},\ \text{if}\ bp_{n}=1\ \text{and}\ n\
eq r_{1}\ \text{or}\ r_{2}\\ l_{i}+M_{n},\ \text{if}\ bp_{n}=0\ \text{and}\ n\
eq r_{1}\ \text{or}\ r_{2}, \end{array} \right. \tag{8}\]  
where \(M_{n}\) is the decimal value of the next \(a_{i}\) secret bits to be embedded, \(p_{n}\) is the pixel value in the block \(b_{i}\) and \(p^{\prime}_{n}\) is the modified pixel value in the modified block. Step 7. Modify the value of each \(p_{n}\) in block \(b_{i}\) using Equation (9) that no secret data are embedded. \[p^{\prime}_{n}=\left\{ \begin{array}{c}h_{i},\ \text{if}\ bp_{n}=1\\ l_{i},\ \text{if}\ bp_{n}=0.\end{array} \right. \tag{9}\]  
Step 8. Repeat Step 2 to Step 7 until all blocks \(b_{i}\)'s are processed. Step 9. Obtain modified image \(I^{\prime}\). We can get modified image \(I^{\prime}\) when all steps are finished. We provide an example to further clarify our embedding process in Figure 5. In Figure 5, (a) shows an example of a \(4\times 4\) sized block \(b_{i}\), (b) is the bitmap of block \(b_{i}\), (c) presents secret data S and the decimal value \(M_{n}\) of each \(a_{i}\) secret bits and (d) shows the final result of modified image \(I^{\prime}\). In the first step, utilize the AMBTC algorithm to compute the block \(b_{i}\) and obtain two quantization levels \(l_{i}\) and \(h_{i}\). As \(a_{i}\) is 3, S will be partitioned into multiple groups and each group contains three secret bits. Then, convert each group of \(a_{i}\) secret bits into decimal value \(M_{n}\). The positions of \(r_{1}\) and \(r_{2}\) are utilized to substitute the values of \(l_{i}\) and \(h_{i}\), respectively. Moreover, no secret bits are embedded in them. As such \(M_{r_{1}}\) and \(M_{r_{2}}\), we use N/A to represent. In the next step, embed \(M_{n}\) into each \(p_{n}\) using Equation (8).