# Hybrid Data Hiding Based on AMBTC Using Enhanced Hamming Code
## 3 The Proposed Scheme
### Embedding Procedure  
We introduce a way of DH using the Hamming code, DBS, and OTQL based on AMBTC and explain the details of the procedure step-by-step as follows. Additionally, the flowchart of the embedding process is described in Figure 2.  
**Input:**: Original grayscale image with a size of \(N\times N\), threshold \(T\), and secret data \(M=(m_{1},m_{2},\ldots,m_{n})\).
**Output:**: Stego AMBTC _trios_.
**Step 1:**: The original image \(G\) is divided into \(4\times 4\) non-overlapping blocks.
**Step 2:**: The \(trio(a,b,BM)\) of the AMBTC, i.e., the compressed codes, is obtained according to Equations (1)-(4), where \(\mathbf{a}\) and \(\mathbf{b}\) are the low mean and the high mean quantization levels, respectively, and \(BM\) is the bitmap.
**Step 3:**: The quantization levels are \(\mathbf{a}=(a_{8}a_{7}\ldots a_{1})\) and \(\mathbf{b}=(b_{8}b_{7}\ldots b_{1})\), where \(a_{8}\) is the Most Significant Bit (MSB) of \(\mathbf{a}\) and \(a_{1}\) is the LSB of \(\mathbf{a}\). Similarly, \(b_{8}\) is the MSB of \(\mathbf{b}\), and \(b_{1}\) is the LSB of \(\mathbf{b}\). The rearranged seven bit codeword is obtained by:  
\[y=(a_{4}a_{3}a_{2}a_{1}||b_{3}b_{2}b_{1}) \tag{8}\]  
where the symbol \(||\) denotes concatenation. Note that \(a_{4}\) and \(b_{1}\) are the MSB and LSB of the rearranged pixel \(y\), respectively.
**Step 4:**: In Figure 3b, the location of the coset leader that matches the decimal number \(d\) for \(m_{i}^{i+2}\) bits is retrieved from the Lookup Table (LUT) using the procedure in Figure 4. Assuming that \(x_{i}=(x_{7}\ x_{6}\ x_{5}\ x_{4}\ x_{3}\ x_{2}\ x_{1})\), the codewords corresponding to the retrieved coset reader are converted to \((\alpha^{\prime}\ \beta^{\prime})\). That is, \(\alpha^{\prime}=bin2 dec(x_{7}\ x_{6}\ x_{5}\ x_{4})\) and \(\beta^{\prime}=bin2 dec(x_{3}\ x_{2}\ x_{1})\). Meanwhile, for codeword \(y\) generated in Step 3, \(\alpha=bin2 dec(y_{7}\ y_{6}\ y_{5}\ y_{4})\) and \(\beta=bin2 dec(y_{3}\ y_{2}\ y_{1})\) are converted; that is, \(y^{\prime}=(\alpha\ \beta)\). The distances for \(x\) and \(y^{\prime}\) are calculated using Equation (9). After calculating \(min((\alpha-\alpha^{\prime})^{2}+(\beta-\beta^{\prime})^{2})\) for all codewords, the value with the minimum distance among them is obtained. The obtained minimum distance codeword is \(h=(\alpha^{\prime}\ \beta^{\prime})\).  
\[\epsilon=min((\alpha-\alpha^{\prime})^{2}+(\beta-\beta^{\prime})^{2}) \tag{9}\]  
For the codeword \(h\), two quantization levels, \(a\) and \(b\), are constructed as follows:  
\[\begin{cases}a=(a_{8}a_{7}a_{6}a_{5}||h_{7}h_{6}h_{5}h_{4})\\ b=(b_{8}b_{7}b_{6}b_{5}b_{4}||h_{3}h_{2}h_{1})\end{cases} \tag{10}\]Before next step, three is added to the index variable \(i\).  
1. If \(|a-b|\leq T\), it may be a smooth block. For the smooth block, we use DBS. The \(m_{i}^{i+15}\) bits replace the pixels of the BM. Fifteen is added to the index variable \(i\) before the next step. If \(|a-b|>T\) and \(|a-b|\geq 8\), OTQL is launched. If \(m_{i}^{i}=1\), transpose the order of two quantization levels, \(a\) and \(b\), of the \(trio\), otherwise put the \(trio\) as the original state.
2. Repeat Steps 2\(\sim\)5 until all image blocks are processed. Then, the stego AMBTC compressed codes' \(trio\) is constructed.