Batch Image Encryption Using Generated Deep Features Based on Stacked Autoencoder Network

Chaos-based algorithms have been widely adopted to encrypt images. But previous chaos-based encryption schemes are not secure enough for batch image encryption, for images are usually encrypted using a single sequence. Once an encrypted image is cracked, all the others will be vulnerable. In this paper, we proposed a batch image encryption scheme into which a stacked autoencoder (SAE) network was introduced to generate two chaotic matrices; then one set is used to produce a total shuffling matrix to shuffle the pixel positions on each plain image, and another produces a series of independent sequences of which each is used to confuse the relationship between the permutated image and the encrypted image. The scheme is efficient because of the advantages of parallel computing of SAE, which leads to a significant reduction in the run-time complexity; in addition, the hybrid application of shuffling and confusing enhances the encryption effect. To evaluate the efficiency of our scheme, we compared it with the prevalent “logistic map,” and outperformance was achieved in running time estimation. The experimental results and analysis show that our scheme has good encryption effect and is able to resist brute-force attack, statistical attack, and differential attack.


Introduction
Nowadays, though the communication system has been greatly developed, insecure communication channels such as the Internet are still prevalent and a growing number of digital images are transmitted through them.Nevertheless, as long as the images are transmitted and stored over public networks, they are easy to be intercepted and tampered by unauthorized IPs.If the images have confidential information, specially, they need to be encrypted before exchange across Internet.However, traditional encryption algorithms such as 3DES, AES, and IDEA are typically designed for text encryption and are not suitable for image encryption on account of the intrinsic features of images as high correlation between pixels and redundancy [1].On the other hand, a lot of image encryption schemes have been suggested, for example, DNA cryptography, mathematical concept, compression methodology, and transform domain, but most of them have security vulnerabilities [2].Over the past two decades, chaos-based cryptography has been studied by more and more researchers for the fundamental characteristics of chaos as ergodicity, pseudostochasticity, mixing, and high sensitivity to initial conditions/parameters, and so forth.[3][4][5][6].In 1998, Fridrich firstly proposed permutation-diffusion method which encrypted images using chaos [7].Based on his work, there have been many improvements for a wide variety of image encryption tasks, such as bit permutation [8][9][10][11][12], image pixel confusion [13,14], extensive diffusion operations [15,16], high-quality key-stream generation process [17,18], and applications of plain-image features [19][20][21].
Chaotic cryptography with artificial neural networks (ANNs) has been extensively developed due to the following characteristics: nonlinear computation, associative memory, large-scale parallel processing, and highly fault tolerance.Those characteristics contribute much to enhancing chaos security.For example, in [22], a discrete Hopfield neural network was utilized to make a nonlinear sequential cipher generator, which could generate a pseudostochastic sequence to confuse the plain image given a small amount of stochastic parameters as the cipher codes.And, in [23][24][25], ANN models were also used for image encryption.Among kinds of ANN models, the SAE model provides a baseline method for unsupervised feature learning and additionally extracts a great number of feature parameters simultaneously, which are necessarily helpful for batch image encryption.
With previous chaos-based encryption schemes, a batch of images are usually encrypted using a single chaotic sequence.In this paper, we proposed a batch image encryption scheme that encrypts each image with an independent sequence.Firstly, a SAE based five-layer deep neural network was constructed to produce two chaotic matrices; and then the two matrices were used together for mixing encryption processing, that is, one for a total shuffling matrix generation and another for multiple chaotic sequence generation; finally the shuffling matrix was used to shuffle the pixel positions on each plain image, and each chaotic sequence was used to confuse the relationship between the corresponding shuffled image and the encrypted image.Several security evaluation results proved that the proposed scheme completely met the requirements of image encryption.Compared with traditional image schemes such as the logistic map, the proposed scheme is more powerful.In other words, the scheme is able to generate a large number of chaotic sequences in parallel and then to encrypt a lot of images simultaneously.Our scheme has a better performance in run-time complexity and a significant effect on batch image encryption.

Stacked Autoencoder
Autoencoder (AE) is a single-hidden-layer and unsupervised learning neural network.It is actually generated by two identical Restricted Boltzmann Machine models (RBMs) [26].Several AEs compose the SAE network which is like a multilayer AE.For example, in the SAE network in Figure 1, the hidden layer of the previous AE is the input layer of the next AE; these joined layers are combined to make the encoding section of SAE (see layers [, ℎ1, ℎ2] in Figure 1); then a reversed network of the encoding section makes the decoding section (see layers [ℎ2, ℎ1  ,   ] in Figure 1); in addition,  and   are input and output layers, respectively; the hollow cycles are neurons and the blue solid cycles are offsets.  is like a mirror of , they have the same number of neurons, and so do ℎ1  and ℎ1 (For the sake of convenience, we will denote the input/output value of a certain layer by /ℎ1/ℎ2/ℎ1  /  in the following statement.).The encoding and decoding sections are combined to make the SAE network that has the functions of encoding and decoding.
Greedy training methods such as back propagation (BP) can be directly used to train a monolayer AE to learn weight parameters; however, it is hard to train the SAE network because the multilayer network would consume much more memory and computation time.In order to alleviate the problem, a two-step training method is widely adopted for the SAE network training, that is, pretraining and fine-training.
In the pretraining period, each layer is trained in turn with a lay-wise approach: the SAE network encodes the input data  and produces ℎ1 and immediately decodes ℎ1 and produces   ; then we get the error  =   −  which is utilized to tune the weight parameters between the layers  and ℎ1; the network continues to encode ℎ1 and produce ℎ2 and immediately to decode ℎ2 and produce ℎ1  ; the weights between the layers ℎ1 and ℎ2 are tuned by  = ℎ1  − ℎ1; if there is any more layer, the encoding and decoding operations will be repeated.Now we get the optimized weight set (, ) which will save training time in the following training.In the fine-training period, the network is trained using the BP algorithm and is gradually close to the optimal solution.See detailed fine-tuning procedures as follows [27]: (1) The activation of each hidden layer is computed successively in the feed-forward processing.
(2) Firstly, in the output layer, the grade error is calculated by the following function: (3) The grade error of each hidden layer is as follows: (4) The partial derivatives are where  =  *  + ,  is the set of weights,  is the input,  is the offset value,  is the expected output, (⋅) is the sigmoid function which will be described in the following,   (⋅) is the derivative of (⋅), and the superscript is the number of a certain layer.
Then ∇  and ∇  are used to tune  and .And steps (1) to (4) are repeated until the network is close to the optimal solution.The SAE network can learn levels of features.And given the same hyperparameters, the extracted feature information can be reproduced.Sequences composed of those features satisfy the basic requirements of chaos and can be utilized to encrypt images.In this paper, we extracted two sets of features to encrypt images in batch using a five-layer neural network based on SAE, and experimental results show that our scheme is effective and efficient.

The Batch Image Encryption Scheme
3.1.The Chaotic Matrix Generation Network.In order to obtain practicable chaotic matrices, we modified the SAE model in Figure 1 by removing the offset neurons and constructed a chaotic matrix generation network (Figure 2).As mentioned in Section 2, /ℎ1/ℎ2/ℎ1  /  is the layer name which also denotes the input/output value of the layer. is the input layer with  neurons, ℎ1 is the first hidden layer with  neurons, ℎ2 is the second hidden layer with  neurons, ℎ1  and   are mirror layers of ℎ1 and , respectively,  0 is the weight matrix between  and ℎ1,  1 is the weight matrix between ℎ1 and ℎ2, and the weight matrices between ℎ2, ℎ1  , and   are not marked in the figure; they are transposed matrices of  0 and  1 , respectively.The procedures of the chaotic matrix generation are described as follows.
(1) Parameter Initialization.The pixel components of a given image compose a vector and the values in the vector are normalized as float point numbers in the fixed range of 0 to 1;  0 and  1 are initialized using a cipher code  which is a decimal between 0 and 1;  is the number of the image pixel components;  is the number of images to be encrypted;  is a preappointed number that is not equal to , such as  =  − 1; and the iteration times is predefined as it num; accordingly, these parameters are prepared for the following chaotic matrix generation, where , , and it num are cipher codes.
(2) Chaotic Matrix Generation.Given the set of cipher codes, the network is trained it num times, and two chaotic matrices are obtained which are  1 and  0 ;  1 is used to produce the set of chaotic sequences and  0 is used to produce the total shuffling matrix, which will be used in the following subsection.

Batch Image Encryption.
As we can see in Figure 3,  1 and  0 feed into two generators, respectively, and then a total shuffling matrix and a set of chaotic sequences are obtained; in addition, there are two operations where one with the total shuffling matrix shuffles each image of the image dataset and another with each chaotic sequence confuses the corresponding permutated image; finally, every image is encrypted.The detailed encryption procedures are as follows.
(1) Image Dataset Preparation.We assume that all plain images have the same number of pixels.The assumption conforms to the rules of most image processing tasks such as real-time telemedicine.And each image has  pixels.
(2) Total Shuffling Matrix Generation. 1 is an  by  matrix; that is, it has  *  digital numbers, which is converted to a sequence as { 1 ,  2 ⋅ ⋅ ⋅   *  }.Then let sl = mod (abs (  ) × 10 4 , ) ,  = 1, 2 ⋅ ⋅ ⋅  * .(5) Obviously, sl is an integer in the range of 0 to  − 1, to do iteration of (5) until we get  different integers.If  1 is exhausted before we get  different integers, the updated  1 at previous iteration could be used and it num could be adjusted accordingly.Finally, the  different integers make a matrix that has the same dimension of the plain image.
(3) Chaotic Sequence Generation. 0 is an  by  matrix; that is, it produces  -length sequences which can be used to encrypt  plain images.To confuse each image with an independent chaotic sequence, we set  as the number of images in the image dataset, and each column of  0 makes an -length chaotic sequence; then we get the set of independent chaotic sequences.
(4) Shuffling the Plain Image.With the total shuffling matrix, each plain image is shuffled.Pixel values of the plain image are changed according to the number of the corresponding position in the total shuffling matrix.For example, with respect to a 512 by 512 image, if it is 522 in the position [1,1] of the total shuffling matrix, the pixel value in the position [1,1] of the plain image will be replaced by the pixel value in the position [2,10] of the plain image.
(5) Confusing the Relationship between the Permutated Image and Encrypted Image.With each of the chaotic sequences, the corresponding permutated image is confused.The confusion process is mathematically abstracted as follows, where  is the confused one,  is the permuted one,  is a chaotic sequence, bitxor(⋅) is an element-wise XOR function: Now, we get the encrypted images.
The following pseudocode is presented to depict the process of batch image encryption.

append(confusing(pimage, chaotic sequences[index])) return encrypted images
Here, sl matrix is the total shuffling matrix, chaotic sequences is the set of chaotic sequences, the function shuffling(⋅) is described as step (4), and the function confusing(⋅) is as (6).

Experiments and Results
4.1.Experimental Settings.This encryption scheme was evaluated over a group of gray-level images.Those images have the same dimension of 512 by 512 and are all 256 graylevel.Pixel values were normalized, that is, each image was represented by a 512 * 512 matrix and each element of the matrix had a decimal value in the range of 0 to 1.The iteration number it num is 10 and one of the images was selected as the cipher code.In order to facilitate the presentation, we only discussed the encryption effect of four randomly selected images.Figure 4 lists the plain images and the corresponding encrypted images and decrypted images, and the plain and the decrypted images are almost identical.At the next subsection, the encryption effect was verified through several evaluation methods, and comparative study was performed with other image encryption schemes; besides, we applied the proposed scheme to encrypt four color images, and the plain, encrypted, and decrypted images are listed in the figure.In Section 4.3, a comparative study on running time was performed with the prevalent image encryption scheme-"logistic map."

Performance and Security Analysis
(1) Key Space Analysis.Any encryption scheme should have a large-enough key space to resist brute-force attack.The cipher codes of the proposed scheme are the following: key = {, , it num}, where C-the calculation precision-is 10 16 by default,  is the size of third layer in Figure 2 and it approximates 10 5 in this experimental task, and it num is the iteration times which is 10.Hence, the key space is 10 21 .With so huge a key space, it is extremely hard to crack through a brute-force effort.
(2) Histogram Analysis.The plain image has rich-semantic information and it can be read because of the frequency of each gray-level.Hence, a strong encryption scheme should reduce such statistical information as much as possible.Histograms of the plain and the encrypted images are listed in Figure 5.The histogram of each encrypted image is pretty uniform and does not reveal any statistical information.
(3) Correlation Analysis.Similar to the histogram, the correlation reveals statistical information of the image; besides, it reflects the relationship between adjacent pixels.An encryption scheme should decrease the correlations of the image.The correlation coefficient is a quantitative indicator reflecting the correlation of a pair of adjacent pixels and is mathematically abstracted as follows [28]: where  is the number of selected pixels in the image,  and  are values of two adjacent pixels, cor  is the correlation coefficient of  and , (⋅) is the mean function, (⋅) is the variance function, and cov(⋅) is the covariance function.
We selected ten pairs of adjacent pixels in each plain and encrypted image, and we listed the correlation coefficients of these pairs in Table 1.There is rich-semantic information in the plain image, so adjacent pixels of it are strongly correlated and the coefficient value is high; on the contrary, the correlation between adjacent pixels of the encrypted image is deeply decreased and the coefficient value is very small.The correlation distribution of an image is commonly depicted using a scattered diagram.We randomly selected 1000 pairs of adjacent pixels from each image in vertical, horizontal, and diagonal directions, and the correlation is illustrated in Figure 6.As we can see, the correlation is strong for the plain image in any direction, and the encryption scheme conceals the significant characteristics of the plain image in three directions.
(4) Sensitivity Analysis.The encrypted image would not be decrypted with a tiny change in the cipher code; that is, the encryption scheme is robust.In the experiment, we changed the cipher code  by increasing a very small number, and the changed cipher code   =  + 10 −15 .The plain image was encrypted using  and then decrypted using   .The encrypted images are listed in Figure 4 and the decrypted images are shown in Figure 7.The encrypted ones completely cannot be identified.That is to say, our scheme is very sensitive.
(5) Differential Attack.Differential attack would fail if the encrypted image is significantly different with a tiny change in the plain image.The following measures are usually used to measure this capability: number of pixels change rate (NPCR) and unified average changing intensity (UACI) [29,30].
where  1 and  2 are two encrypted images whose original plain images have only one different pixel,  1 (, ) and  2 (, ) are the pixel values at position (, ) of the encrypted images, respectively, and Hei and Wid are the size of the height and the width of the image, respectively.According to the two measures, our scheme is compared with several other encryption schemes and results are listed in Table 2. Of our scheme, the NPCR is more than 99% and the UACI is more than 33%, which proves that the proposed scheme is sensitive.
In addition to the gray-level images, our scheme is also used to encrypt color images.The color image can be considered to be three channels overlapping together which are Red, Green, and Blue channels.Each channel is like a graylevel image.The three channels are encrypted, respectively, and then merged together to become an encrypted color image.Figure 8 lists four color images and their encrypted and decrypted images.

Comparative Study on Running
Time.The comparative study on running time is performed with "logistic map" [31], which has been widely used to encrypt images.To simplify the comparative process, we just take into account the calculation process of generating the total shuffling matrix and generating the chaotic sequences; and the consumption time of the encryption process is stable, so it is excluded.Table 3 lists the comparative results.As we can see, the running time of the logistic map increases with the increment of the generated sequences; on the contrary, the running time of our scheme decreases slightly when more than 50 sequences are generated.We think it is the following reasons that cause the result: the logistic map generates the shuffling

Conclusions and Future Work
Our scheme has the following advantages: fast batch image encryption and independent chaotic sequence for each image, which ensures the efficiency and security of our scheme.The experimental results prove that our scheme can be used for batch image encryption in variant applications as real-time remote image transmission and image protection.
There is a drawback to our scheme that all plain images must have the same size (512 * 512 pixels in the experiments).
In the future, we would seek to generate multilength shuffling matrices and chaotic sequences for different sizes of images.We would like, specially, to generate a large-enough shuffling matrix, from which the minor size of matrix would be extracted to shuffle the corresponding size of images. of Education (no.KY201522B, no.KY201520B); and Fundamental Research Funds for the Central Universities (no.XDJK2016E068).
(a) The decrypted Gold-hill (b) The decrypted Barbara (c) The decrypted Yacht (d) The decrypted Peppers

Figure 7 :
Figure 7: The decrypted images with a changed cipher code.

Table 2 :
Comparative study of NPCR and UACI of the proposed algorithm to some existing algorithms.

Table 3 :
Comparative study on running time of the proposed scheme and the logistic map.