## 2 Materials and Methods
### Confusion Stage  
_Moving-Window Shuffling Process_  
One of the important characteristics of an image is the strong correlation between adjacent pixels. Therefore, the main mission of the confusion stage is to destroy the relationship of adjacent pixels by relocating those pixels (bit-level) in the horizontal and vertical directions. However, this consumes much computing time and many resources if all of the relationships of adjacent pixels in a plain image are to be broken at the same time--a huge matrix of new locations has to be generated. As a result, an appropriate size of window \(M\times N\) was selected in this article to shuffle each subimage content at the bit level, where new limited locations for each bit number could more effectively be produced. The schematic diagram is shown in Figure 2a,b. Figure 1: Configuration of the interactive image encryption. Figure 2: \(Cont.\)  
In Figure 2a, an appropriate size of window \(M\times N\) was selected to further divide the plain image into several subimages, where the window size in this article was set to be \(16\times 4\) pixels. In order to operate the shuffling process at the bit level, in Figure 2b, we can see that the gray value of each pixel in the selected window is transformed from a decimal number to a binary number (D to B), i.e., the size of the bit-leveled subimage in the selected window was changed to \(M\times N\times 8\). After finishing the whole shuffling process, the new subimage goes back to the decimal numbers (B to D) and a new gray value for each pixel as well as the low-correlated adjacent pixels could be obtained in the new subimage. For the shuffling process, the first logistic map is applied to further generate necessary new position matrices in rows and columns for bit-level relocations, which can be described in Equation (1):  
\[z_{n+1}=rz_{n}(1-z_{n}), \tag{1}\]  
where \(n=0\), \(1\),..., \(\infty\); \(z_{n}\) refers to the state of the first logistic map in each iteration; \(r\) is the system parameter which was set to be \(r=3.99\); and initial condition \(z_{0}\) must be provided by the user at the beginning. The chaotic behavior is shown in Figure 3.  
Figure 3: Chaotic behavior of the logistic map. Figure 2: (**a**) Selected sliding window \(M\times N\). (**b**) From decimal to binary of gray pixel value. For the shuffling process in the row direction, Equation (2) was applied to further convert the state value of the first logistic map in Equation (1) to a new position in each iteration:  
\[Mz_{i}(j)=mod\Big{(}floor\Big{(}z_{n}\times 10^{14}\Big{)},M\Big{)}+1. \tag{2}\]  
where \(z_{n}\) is the state of the logistic map; \(Mz_{i}(j)\in[1,M]\) is the new position for each binary number; and \(j=1,2,\,\ldots,M\) describes the numbers of elements in each row direction. \(Mz_{i}\) is a row vector representing the new position vector where \(i=1,2,\,\ldots,N\times 8\) refers to the total number of row vectors. As a result, this repetitive process generates a new position matrix \(Mb(i,j)\), which is described in Equation (3). Following the new position matrix \(Mb\) to operate the shuffling process in the row direction, a completely new subimage at the bit level can be obtained. The complete flowchart is given in Figure 4.  
\[Mb=[Mz_{1}\,Mz_{2}\,\ldots\,Mz_{N\times 8}]. \tag{3}\]  
For the shuffling process in the column direction, Equation (4) was applied to further convert the state value of the first logistic map in Equation (1) to a new column position:  
Figure 4: New position matrices of each subimage in row and column directions. Figure 2:0  
where \(Nz_{j}(i)\in[1,\,N\times 8]\) is the new position for each binary number and \(i=1,\,2,\,\ldots\,\,,\,N\times 8\) denotes the number of elements in each column direction. \(Nz_{j}\) is a column vector representing the new position vector and \(j=1,\,2,\,\ldots\,\,,M\) refers to the total number of column vectors. As a consequence, this repetitive process generates a new position matrix, \(Nb(i,j)\), which is described in Equation (5).