## 3. Designed Scheme
### Authentication and Reconstruction
#### 3.2.3 Post-Processing and Recovery  
A binary image is generated at this stage, representing the blocks affected by the tampering coincidence problem in each reconstruction image generated by Pseudocode 3 (\(iRGB_{R}\), \(iRGB_{G}\), \(iRGB_{B}\)). Each authentication image generated in Section 3.2.2 (\(autentImg_{R}\), \(autentImg_{G}\), \(autentImg_{B}\)) is used for this process. Pseudocode 4 presents the image generation process as follows:  
\[autent_{ummrad[j+(i-1)B/4]}=\left\{ \begin{array}{cc}255,&\textbf{if}\;autentImg _{i,j}\;\textbf{is}\;255\\ 0,&\textbf{otherwise}\end{array} \right., \tag{4}\]  
for all \(i\) and \(j\) subject to \(1\leq i\leq A/4\), and \(1\leq j\leq B/4\). Finally, the generated image is interpolated to \(A\times B\) size. Pseudocode 4 presents the processes, resulting in three images being obtained, denoted as \(TCP_{R}\), \(TCP_{G}\) and \(TCP_{B}\). If a large amount of the original image information is altered, the information used for reconstruction could be overwritten, although it is redundant. Therefore, maps to point to the tampering coincidence problem are computed using binary images (Pseudocode 4). Then, an AND operand between each one of these maps' bits is applied, resulting in a binary image denoted as \(iTCP\), i.e., \(iTCP_{i,j}\;=\;TCP_{R,i,j}\ast TCP_{G,i,j}\ast TCP_{B_{ij}}\), \(\forall\;i,j,\;\text{s.t. }\;1\leq i\leq A,\;1\leq j\leq B\). This image marks the regions affected by the tampering coincidence problem. **Pseudocode 4** Detection of tampering coincidence problem  
**Input:** Authentication image **autent Img:** Seed **S**  
\([A,B]=size(autentImg)\)  
\(rng(S)\;\rightarrow\;Control\;random\;number\;generator\)  
\(numRand=random(AB/16)\;\rightarrow\;Random\;permutation\;of\; integers\;in\;range\;[1,AB/16]\)  
\(autentImg=intresize(autentImg,0.25)\)  
Equation (4)  
\(TCP=vec2 mat(autent,A/4,B/4)\;\rightarrow\;vector\;to\;matrix\;conversion\)  
\(TCP=intresize(TCP,4)\)  
**Output:** Tampering coincidence problem image **TCP**  
Subsequently, Equation (5) is applied to the reconstruction images obtained by Pseudocode 3 and their corresponding binary images given by the Pseudocode 4, resulting in a single reconstruction image named \(iR\) :  
\[iR_{i,j}=\frac{\sum_{\alpha=1}^{n}\Bigl{(}1-TCP_{\alpha_{i,j}}\Bigr{)}\,Iw_{ \alpha_{i,j}}}{\sum_{\alpha=1}^{n}\Bigl{(}1-TCP_{\alpha_{i,j}}\Bigr{)}},\quad \forall\;i,j\;:\;1\leq i\leq A,\;1\leq j\leq B, \tag{5}\]  
where \(\alpha\) represents the \(i\)-th processed copy, \(Iw\) represents a recovery image, \(TCP\) represents a binary image, which indicates the regions affected by the tampering coincidence problem of \(Iw\), where the values \"1\" indicate that the \(i\), \(j\)-th position is authentic and a value of \"0\" indicates that this position was affected by this problem. Implementation of Equation (5) is given for \(TCP=\bigl{[}TCP_{R},TCP_{G},TCP_{B}\bigr{]}\) and \(Iw=\bigl{[}iRGB_{R},iRGB_{G},iRGB_{B}\bigr{]}\). The previous sequence is valid when the 1-LSB method is selected for embedding. If the scheme is presented in their variants 2-LSB or 3-LSB, further copies of the watermarks should be computed from the bit panels, and the reconstruction method requires single instances of \(iR\) and \(iTCP\). Consequently, the following equations for the \(N\)-LSB method must be applied:  
\[iTCP\;=\;\left\{ \begin{array}{cc}iTCP_{1},&\textbf{if}\;N\;\textbf{is}\;1 \\ iTCP_{1}\;\ast\;iTCP_{2},&\textbf{if}\;N\;\textbf{is}\;2\end{array} \right., \tag{6}\]\[iR\ =\left\{ \begin{array}{ll}iR_{1},&\textbf{if}\ N\ \textbf{is}\ 1\\ \text{Equation}\ (\ref{eq:1}),\ \text{where}\ Iw=[iR_{1},iR_{2},iR_{2}]\ \text{and}\ TCP=[iTCP_{1},iTCP_{2},iTCP_{2}],\ \textbf{if}\ N\ \textbf{is}\ 2\\ \text{Equation}\ (\ref{eq:1}),\ \text{where}\ Iw=[iR_{1},iR_{2},iR_{3}]\ \text{and}\ TCP=[iTCP_{1},iTCP_{2},iTCP_{3}],\ \textbf{if}\ N\ \textbf{is}\ 3\\ \end{array} \right. \tag{7}\]  
Finally, Pseudocode 5 performs an inpainting method for the given \(iR\) and \(iTCP\) images. The output image is named as \(iRecovery\).