## 4 Proposed Scheme for Self-Embedding
### Watermark Generation, Localization and Authentication  
Let us suppose that \(\mathbb{C}\) and \(\mathbb{M}\) denote the cover image and watermark (two maps of AMBTC), respectively, and both have a size of \(N\times N\). The two watermark \(\mathbb{M}_{1,2}\) is taken by the previously mentioned AMBTC algorithm. The watermark \(\mathbb{M}\) is randomly permuted by a key and then is subjected to the embedding procedure. The step-by-step embedding procedure is as follows:  
```
0: A original image \(\mathbb{O}\) with a size of \(N\times N\)
0: Two bitmap \(\mathbb{M}_{1}\) and \(\mathbb{M}_{2}\) sized \(N\times N\). Step 1: A compressed set \(trio(Q_{1},Q_{2},\mathcal{M})\) is obtained from the original image \(\mathbb{O}\) by using the AMBTC algorithm (Section 3.1). The sized \(N\times N\) bitmap \(\mathbb{M}_{1}\) and \(\mathbb{M}_{2}\) are initialized with zeros. Step 2: For given \(trio(Q_{1},Q_{2},\mathcal{M})\), the bitmap \(\mathbb{M}_{1}\) is constructed by adding the block bitmap \(\mathcal{M}_{n}\) to the \(\mathbb{M}_{1}\) using Equation (6), where \(n\in\{1\leq n\leq(N\times N)/(m\times m)\}\) and \(m=4\). Step 3: After converting the two quantization levels \(Q_{1}^{n}\) and \(Q_{2}^{n}\) into \(8\) bits using Equation (7) respectively, the \(b_{i,t}\) are assigned to the block \(\mathcal{M}_{n}\) sequentially. Then, \(\mathcal{M}_{n}\) is added to the bitmap \(\mathbb{M}_{2}\) like Equation (6), i.e., \(\mathbb{M}_{2}^{n}=\sum_{n=1}\mathcal{M}_{n}\), where \(\mathcal{M}\in trio(Q_{1},Q_{2},\mathcal{M})_{n}\). \[b_{i,t}=\left\lfloor\frac{Q_{1,2}}{2^{t}}\right\rfloor\bmod 2,t=0,1, \ldots,7.\] (7)
```  
**Algorithm 1** Watermark Generation  
If the watermark is concealed in the same order as the original image, the tampered area cannot be restored when the marked image is damaged. Therefore, the recovery bits, watermarks, are not embedded into the block itself. These watermarks are embedded in LSBs of the mapped block \(\mathcal{M}_{j}\). Here, blocks \(\mathcal{M}_{i}\) and \(\mathcal{M}_{j}\) are chosen such that \(\{i\
eq j|(i,j)\in[1,2,\ldots,R]\}\), where \(R\) is the total number of blocks in the cover image. The procedure of watermark localization is as follows:  
```
0: Two watermark bitmaps, \(\mathbb{M}_{1}\) and \(\mathbb{M}_{2}\) in Algorithm 1, Key \(\xi\)
0: Mapped (scrambled) bitmaps \(\mathbb{M}_{1}\), and \(\mathbb{M}_{2}\) Step 1: Divides the bitmap \(\mathbb{M}_{1}\) into non-overlapping blocks of \(m\times m\) pixels. Read a block \(\mathcal{M}_{n}\) from \(\mathbb{M}_{1}\), where \(n\in\{1\leq n\leq R\}\) and \(R=(N\times N)/(m\times m)\) and \(m=64\). The optimal position \(j\) for the block \(\mathcal{M}_{n}\) is obtained by using Equation (8), where \(\xi\) is prime number. Swap the block \(\mathcal{M}_{n}\) with the block \(\mathcal{M}_{j}\) in the map \(\mathbb{M}_{1}\). \[j=\left\{ \begin{matrix}f(i)=(\xi\times n)\bmod R\\ j=f(n)+1;\end{matrix} \right.\] (8) When dividing the image into \(16\) areas, the block location \(n\) and \(j\) must not be in the same, and the key \(\xi\) must search for its location, which can be the most distant from each other. Step 2: Read a block \(\mathcal{M}_{n}\) from the bitmap \(\mathbb{M}_{2}\). The optimal position \(j\) for the block \(\mathcal{M}_{n}\) is obtained by using Equation (8) and swap the block \(\mathcal{M}_{n}\) with the block \(\mathcal{M}_{j}\) in the map \(\mathbb{M}_{2}\). Step 3: Repeat Step-1 and Step-2 for all blocks. ```  
**Algorithm 2** Block Mapping  
If the watermark is concealed in the same order as the original image, the tampered area cannot be restored when the marked image is damaged. Therefore, the recovery bits, watermarks, are not embedded into the block itself. These watermarks are embedded in LSBs of the mapped block \(\mathcal{M}_{j}\). Here, blocks \(\mathcal{M}_{i}\) and \(\mathcal{M}_{j}\) are chosen such that \(\{i\
eq j|(i,j)\in[1,2,\ldots,R]\}\), where \(R\) is the total number of blocks in the cover image.