Image compression-encryption method based on two-dimensional sparse recovery and chaotic system

In this paper, we propose an image compression-encryption method based on two-dimensional (2D) sparse representation and chaotic system. In the first step of this method, the input image is extended in a transform domain to obtain a sparse representation. To achieve better performance of image compression by 2D sparse recovery, the sparse representation is scrambled via a chaotic confusion. This step helps the satisfaction of the uniqueness conditions for sparse recovery, and the security level of encryption is increased. Then, two orthogonal measurement matrices are generated using the chaotic time series. The singular value decomposition is used to compress the sparse scrambled representation in two dimensions. Finally, to reduce the correlation between adjacent pixels in the compressed matrix, and obtain a uniform distribution in the encrypted image, a compressed scrambling matrix based on chaotic confusion is used. Then, XOR operation is applied for final encryption. In the decryption process, to improve the compression efficiency, the total variation constraint is added to the 2D sparse recovery problem based on the smoothed norm. The simulation results demonstrate the satisfying performance of the proposed method for different compression ratios. Security analysis describes the effectiveness of the proposed encryption approach.

Kronecker compressed sensing 44 based on two measurement matrices in two directions has been proposed. Hence, some proposed encryption approaches have used two measurement matrices to obtain better compression and reconstruction performance 34,39,45 . Also, designing the measurement matrix is a modification approach to obtain better performance. Usually, CS-based encryption approaches use chaotic systems to generate this matrix. Some approaches construct the measurement matrix based on the combination of the Hadamard transform and chaotic map 22,38,39,45 .
In this paper, an image encryption approach based 2D sparse recovery is proposed. In Ref. 43 , the uniqueness conditions of 2D sparse recovery were investigated based on the spark definition. The main properties of these conditions are that the uniformity of sparse coefficients in rows and columns improves the uniqueness conditions to obtain better compression and sparse reconstruction. Based on this theory, a random permutation using a chaotic Lorenz system is proposed. Random orthogonal measurement matrices are constructed via the Lorenz system and singular value decomposition. Simulation results show that the proposed method has an acceptable performance. In this algorithm, the total variation is proposed in the sparse recovery problem based on smoothed ℓ 0 norm SL0 43,46 . In the decryption process, a sparse recovery approach based on the SL0, total variation, and scrambling of sparse coefficients is proposed. This approach improves the compression and reconstruction performance effectively in comparison with other approaches at the same compression ratio. The results show that the proposed approach is robust in the presence of a cropping attack. To obtain the meaningless image in the encryption process, XOR operation and the Lorenz system are used. Security analyses illustrate the effectiveness of the proposed encryption approach. In the section of preliminaries, the concept of 2D sparse recovery and Lorenz system are described. The main idea and the proposed method are stated in the section of the proposed encryption method. The section of experimental results provides security analyses. Finally, the paper is concluded, and the future work direction is pointed out.

Preliminaries
Sparse representation. An important core of signal processing is signal decomposition representing a signal vector y ∈ R n using a linear combination of some basis functions φ i , 1 ≤ i ≤ m , that is y = s 1 φ 1 + . . . + s m φ m = �s , where = [ 1 , . . . , m ] , and s = [s 1 , . . . , s m ] T . Recently, the sparsity assumption on signal and image representation ( s ) has been used for various applications such as image denoising 47 , blind source separation 48 , compressed sensing 24 , pattern recognition 49 , and image registration 50,51 . It is assumed that the signal is k-sparse, which means it has at most k non-zero entries in a learned dictionary or a transform domain such as discrete cosine transform or wavelet.
Sparsity assumption is the basis of compressed sensing. It has a crucial role in our proposed method of image encryption. The goal of compressed sensing is to recover an unknown sparse signal s ∈ R m from a set of underdetermined measurements y = �s ∈ R n (m < n) where ∈ R n×m is the measurement matrix. Sparse recovery problem can be formulated as: where ||s| | 0 stands for the ℓ 0 norm of s that is the number of non-zero elements of s. In this problem, there are two fundamental questions as follows: 1. Uniqueness: does the problem P 1D 0 have a unique solution? 2. Practical solver: does the optimization problem of the sparsest solution have a practical solver?
In reply to the first question, it has been shown that under some conditions, the sparsest solution is unique. Here, we state the uniqueness theorem based on the spark definition.
Theorem (Uniqueness 52 ): Let spark( ) denote the minimum number of columns of that are linearly dependent. Then if the equation y = s has a solution s 0 for which s 0 < spark( )/2 , it is its unique sparsest solution.
Although the sparsest solution of (1) may be unique, finding it requires a combinatorial search and is generally NP-hard. Several methods have been developed in recent years such as matching pursuit 53 , basis pursuit 54 and smoothed ℓ 0 (SL0) 46 .
In some application, we need to use compressive sensing on two dimensional (2D) signal. To achieve this goal, a trivial approach is to convert the 2D problem to the above one-dimensional (1D) problem. Two disadvantages of this approach are the computational load and the high required memory. To overcome these problems, two measurement matrices 1 ∈ R n 1 ×m 1 and 2 ∈ R n 2 ×m 2 were used to compress a sparse matrix S ∈ R m 1 ×m 2 in the form of Y = 1 S T 2 ∈ R n 1 ×n 243 . The sparse recovery based on two measurement matrices can be obtained by solving the following optimization problem.
The uniqueness of this problem has been shown in some researches 43,55,56 . In Ref. 43 , the uniqueness conditions of this sparse recovery problem based on spark definition were investigated. It has been shown that the necessary (but not sufficient) conditions about the distribution of non-zero entries of S are as follows: www.nature.com/scientificreports/ Some sparse recovery algorithms have been proposed to solve 2D compressed sensing such as 2D orthogonal matching pursuits (2D-OMP) 57 , 2D projected gradient (2DPG) algorithm 58 , and 2D smoothed ℓ 0 (2D-SL0) 43 .
In this paper, a new approach of image encryption based on 2D smoothed ℓ 0 norm is proposed. The idea of SL0 is to replace ℓ 0 norm with a smooth approximation of ℓ 0 norm such as 2DSL0 tries to solve directly P 2D 0 problem. The smoothed ℓ 0 norm is equivalent to ℓ 0 norm when σ → 0 . 2DSL0 minimizes S σ 0 for a small σ , subject to Y = 1 S T 2 . In this paper, to improve the performance of sparse recovery, the 2DSL0 problem is regularized with the total variation (TV).
Lorenz system. Lorenz system is one of the well-known chaotic systems which is highly sensitive to initial conditions 59 . It means that a small change in initial values can cause a considerable change in the final state of the time series. The Lorenz system is presented in Eq. (3). The chaotic attractor of the Lorenz system in parameters σ = 10 , β = 8 3 and ρ = 28 , and initial conditions x 01 , y 01 , z 01 ]=[ − 0.823, 3.423, 0.178 is shown in Fig. 1. www.nature.com/scientificreports/ The proposed encryption method. In this section, we propose a new image encryption algorithm based on two-dimensional compressed sensing and the chaotic Lorenz system. The proposed algorithm consists of two steps: compression via 2D compressed sensing and scrambling based on pixel shuffling and XOR operator. Figure 2 illustrates the block diagram of the image compression-encryption algorithm. In the rest of this section, at first two blocks of confusion based on chaotic and constructing measurement matrix are demonstrated, then the encryption process is described.

Chaotic confusion.
In the previous section, we investigate the uniqueness conditions of 2D sparse representation based on the distribution of non-zero entries of the sparse representation matrix. To achieve these conditions, the sparse coefficient matrix is confused by shuffling based on the chaotic system. This confusion also decreases the correlation among elements of the sparse matrix to increase the security level of image encryption. The steps of chaotic confusion (CC) are described as follows: 1. Generating the sequence X = {x i } of the Lorenz system for an initial condition with a suitable step size in the Runge-Kutta method. The length of X is equal to the number of sparse matrix elements. 2. Transforming the sequence X = {x i } into integer sequence X * = x * i : 3. Sorting the sequence X * : where [. , .] = sort(.) is the sequencing operator, X * s is the sorted sequence. idx X s is the index sequence of X * s containing a sequence of integer numbers with a random perturbation. 4. Shuffling the entries of the sparse matrix according to the sequence idx X s .
We also use this approach in the scrambling step of the image encryption algorithm.
Chaotic measurement matrix generation. The measurement matrix has a crucial task in compressed sensing. In the proposed method, at first, the original image is transformed into a sparse domain via DWT. Then the sparse matrix S ∈ R n 1 ×n 2 is measured and compressed using two measurement matrices 1 ∈ R m 1 ×n 1 and 2 ∈ R m 2 ×n 2 . Here, to generate the measurement matrices, we use a unitary matrix constructed by a random matrix based on the chaotic system. The state variables Y = y i and Z = {z i } of the Lorenz system are used to generate measurement matrices 1 and 2 , respectively. The generation process of the two matrices is similar. Five steps of matrix generation for 1 are describes as follows: 1. Generating the sequence Y = y i of the Lorenz system for an initial condition with a suitable step length in the Runge-Kutta method. The length of Y is equal to n 2 1 . www.nature.com/scientificreports/ 2. Transforming the sequence Y = y i into integer sequence Y * = y * i : 3. Reshaping the sequence Y * to construct the matrix Y M ∈ R n 1 ×n 1 which is a random matrix generated by a chaotic system. 4. Computing the singular value decomposition: where ∈ R n 1 ×n 1 is a diagonal matrix containing singular values. The matrices U ∈ R n 1 ×n 1 and V ∈ R n 1 ×n 1 are unitary in which their columns are singular vectors. 5. Constructing the measurement matrix 1 by selecting the first m 1 rows of matrix U.
Image encryption and compression based on 2D sparse representation. Here, we investigate the proposed encryption process (Fig. 2) as follows: Step 1: The original image I ∈ R n 1 ×n 2 is extended in a transform domain such as DWT, to obtain the sparse representation S: Step 2: The chaotic confusion is used to scramble the sparse matrix S: where CC{.} is a chaotic confusion operator.
Step 3: The sparse matrix S s is measured using two chaotic measurement matrices 1 ∈ R m 1 ×n 1 and 2 ∈ R m 2 ×n 2 : In our simulation, it is assumed that the compression ratio is the same in two dimensions, i.e. m 1 n 1 = m 2 n 2 . Hence total compression ratio (CR) is equal to the square of the CR in each dimension.
Step 4: The measured matrix S M is mapped and quantized in the range of [0,255] using the following formula: where [x] rounds the entry of x to the nearest integer value. In this mapping, each pixel of S Q can be represented by one byte.
Step 5: The chaotic confusion is used to scramble the quantized matrix S Q : This step increases security level by reducing the correlation among the elements of the quantized matrix S Q .
Step 6: In the final step, to obtain a uniform distribution for the encrypted image, the scrambled matrix S QS is XORed with a random sequence generated by the Lorenz system. This step is investigated as follows: Generating the sequences Y = y i and Z = {z i } of Lorenz system for an initial condition with a suitable step length in the Runge-Kutta method. The length of Y and Z is equal to m 1 m 2 . Two sequences Y and Z are transformed into integer number in the range of [0,255]: The matrix S QS and sequences Y * = y * i and Z * = z * i are converted to the binary with 8 bits. Then the encrypted image is obtained by XOR operator: Finally, the image is converted to the decimal. In the proposed image encryption, the Lorenz system with two different sets of initial conditions is used to generate six chaotic sequences.
The decryption process and sparse recovery. The decryption process is the inverse operator of the encryption to recover the original image. Here, we assume that the receiver has the initial conditions and step size of the chaotic system to generate random sequences required for the construction of the measurement matrix and the scrambling operators. This process is described as follows: Step 1: Obtaining S QS from I E by the XOR operator: www.nature.com/scientificreports/ Step 2: After the inverse chaotic confusion of image S QS , the measured matrix S M is obtained by the inverse mapping as follows: where CC −1 { . } is the inverse operator of chaotic confusion. max (S M ) and min (S M ) are also gotten from the sender.
Step 3: The sparse matrix S s is obtained from the measured matrix S M using a sparse reconstruction algorithm based on the 2DSL0 algorithm. In this paper, we improve the performance of sparse recovery by adding total variation (TV) regularization term to the cost function of 2DSL0. This step is investigated in the next subsection.
Step 4: After the inverse chaotic confusion of the sparse matrix S S , the original image I is obtained by the inverse transform (IDWT), and the decryption process is finished.
Sparse recovery based on 2D smoothed ℓ 0 norm and total variation. In this subsection, we propose 2D sparse recovery based on smoothed ℓ 0 norm and total variation. We know that the natural images are usually smooth, hence we add this information to the 2D sparse recovery problem via total variation. To obtain the better performance of sparse reconstruction, the search space of the sparse optimization problem is limited by adding the TV regularization to the cost function of sparse measure. Here, the following definition of TV is used to measure the smoothness of the estimated original image Î : where the image Î is the inverse transform of the estimated sparse matrix Ŝ , i.e. Î = Ŝ T . The absolute function is not differentiable at the origin; hence we replace the absolute function of x with the smoothed function √ x 2 + δ where δ is a small value such as 0.001. The derivative is estimated discretely via forwarding difference. Let the square matrix D be in the following form: The derivative of the estimated original image Î can be written in the following matrix form: where D x ∈ R n 1 ×n 1 and D y ∈ R n 2 ×n 2 have the form of matrix D . Based on the above definition, the regularized 2D sparse recovery using SL0 is proposed in the following form: where > 0 is the Lagrange coefficient to quantify the trade-off between sparsity in the transform domain and TV. In this problem, to recover the original image, two sparsity constraints are used in two different domains of the transform and the image gradient. In this optimization, the final two steps of image decryption (Steps 3 and 4) are combined with the TV regularization. Inspired by Refs. 43,46 , to escape from trapping into local minima, the sparsity measure is optimized iteratively by using a decreasing sequence of σ . The minimizer of J σ (S s ) is used as a starting point to minimize J σ (S s ) for the smaller σ . To optimize J σ (S s ) for a fixed σ subject to the condition S M = 1 S s T 2 , the optimizer is based on the steepest descent approach in which each of its iteration S s ← S s − µ∇ S s J σ (S s ) followed by projection onto the feasible set S s |S M = 1 S s T 2 . The more details about this optimization approach can be found in the literature 43,46 . Required gradient of the TV for this optimization can be computed with simple calculations as follows: arg min is used in the relaxed form S M − � 1 S s � T 2F ≤ ǫ . Inspired by Ref. 60 , this condition is considered by performing the projection process when the constraint S M − � 1 S s � T 2F ≤ ǫ is not satisfied. The parameter ǫ is set dependent on the noise level. The image decryption approach based of 2DSL0 and total variation is illustrated in Algorithm 1. The parameters for the proposed approach are empirically selected as fallows: = 0.01 , L = 5 , µ = 0.5 , δ = 0.001 , ǫ = 0.001 . The parameter σ = σ 1 , . . . , σ J is selected as σ 1 = max Ŝ s0 , and σ j = σ 1 1 − 0.003j which is a geometric decreasing sequence.

Experimental results
In this section, the proposed method is evaluated by different measures. All the experiments are performed on a personal computer with Intel Core i7 2. To evaluate the quality of the decrypted image, we use two measures of the peak signal-to-noise ratio PSNR and the mean square deviation MSE defined as follows: where I ∈ R n 1 ×n 2 and Î ∈ R n 1 ×n 2 are the original image and the decrypted image, respectively. Figure 3 shows the results of image encryption for test images. In these examples, the histogram of the original image and encrypted image is also shown. These results indicate that all images have the same results visually and statistically. The decrypted images also have an acceptable quality. www.nature.com/scientificreports/ www.nature.com/scientificreports/ Compression performance. In this section, the decrypted image quality is evaluated for different compression ratios based on the PSNR measure. In the proposed method, to obtain better performance of the image reconstruction, two techniques are used. The first one is based on the uniqueness analysis. The chaotic confusion is applied to the sparse representation of the original image. Also, TV is added to the cost function of sparse recovery. Here, the effect of these terms on the quality of the decrypted image is investigated. Figure 4 shows the PSNR value for different CRs. Here, the proposed approach is also compared with 2DOMP 57 and 2DPG 58 algorithms. We also evaluate the effect of chaotic confusion on these reconstruction approaches. The reconstruction results demonstrate that the technique of chaotic confusion improves the reconstruction performances of 2DSL0, 2DOMP, and 2DPG methods, especially for small compression ratios. These curves show that the image  www.nature.com/scientificreports/ recovery quality has been enhanced with two applied techniques in 2D sparse representation. The proposed approach outperforms 2D-OMP and 2DPG reconstruction methods. Here, we also present the average computation time to compare the computational complexity of different reconstruction approaches in Table 1. Since the runtime depends on the programming skill and the programming languages, this criterion is not appropriate for a computation cost comparison. Table 2 presents the performance of different schemes based on compressed sensing in comparison with the proposed approach. It can be seen that the proposed encryption approach has a better performance for the same CR. Table 3 shows the performance of the decrypted images for different CRs visually. The qualities are entirely acceptable.
Performance evaluation of the proposed measurement matrix. In this section, we evaluate the effectiveness of the proposed measurement matrix. This matrix is a partial orthogonal matrix generated by the chaotic sequence and SVD. Here, we compare the proposed measurement matrix with the partial Hadamard matrix and the Gaussian random matrix. Partial Hadamard matrix, a famous measurement matrix, has been used in encryption schemes 22,35,38,39,45 . Table 4 shows the effectiveness of these measurement matrices in the proposed encryption process for the different CRs. It can be observed that the proposed measurement matrix has better performance than the Gaussian matrix in this application. Also, this presents similar PSNR values compared with that of the partial Hadamard matrix. Therefore, the proposed measurement matrix achieves good performance and effectiveness in compressed sensing and increases image encryption security.

Security performance analyses.
In this section, the security performance of the proposed approach is analyzed by two measures. The initial value of the chaotic system is keystream used to encrypt different images. To increase the image encryption security level in different attacks, it is appropriate to generate a keystream related to the original image. To obtain this purpose, many approaches can be proposed. For example, inspired by Ref. 30 , we can use the SHA-256 hash value of the original image to generate the chaotic system's initial value. Hence, when different images are encrypted, the corresponding measurement matrices and chaotic confusion operators are different. This can ensure that the proposed approach can resist various attacks, such as the chosenplaintext attack, which is the strongest attack.
Key sensitivity. The key sensitivity analysis shows the effect of a tiny difference between decryption and encryption keys on the quality of the decrypted image. In a secure cryptosystem, a tiny variation in the secret key causes to obtain a decrypted image, which is entirely different from the original image. In the proposed approach, the sensitivity of the chaotic system to the initial conditions results in a secure scheme to the keys x 01 , y 01 , z 01 , x 02 , y 02 , z 02 . Figure 5 shows the decrypted Cameraman images for different wrong keys. In each key set, only one key has a tiny variation of 10 −15 , and the other keys are correct. It is obvious that the decrypted image has been significantly distorted. Figure 6 illustrates the key sensitivity based on the MSE measure for the variation of each key. It can be seen that the minimum of MSE is obtained when the keys are correct. Put it in a nutshell, the proposed method is highly sensitive to the secret keys.
Key space. An essential requirement of a secure cryptosystem is the key space. The larger key space makes the brute force attack infeasible. According to the research 61 , the key space should be larger than 2 100 . The precision of the double-precision number is about 10 −15 . Therefore, the total key space of the proposed encryption approach is 10 15 6 = 10 90 ≈ 2 300 which is large enough. This key space prevents the exhaustive searching. Table. 5 compares the key space of different approaches. Table 2. PSNR (dB) values of the encrypted images with different approaches for the different compression ratios.

Image
Compression ratio Proposed method Ref. 45 Ref. 30 Ref. 40  www.nature.com/scientificreports/ www.nature.com/scientificreports/ Statistical analyses. In this subsection, the effectiveness of the proposed encryption scheme is investigated from the statistical viewpoint.

Histogram.
A histogram is a measure to evaluate the performance of the encryption approach. An appropriate histogram of a secure cryptosystem is a uniform distribution that makes the encryption process resistant to the statistical attack. Figure 3 shows the histograms of original and encrypted images. It can be seen that the pro-  Entropy. Information entropy is another measure to calculate the randomness of the encrypted image. The larger value of entropy means the better performance of encrypted images. For a discrete variable, the Shannon entropy is maximized for the uniform distribution. The maximum value is equal to log 2 M where M is the number of discrete variable states. In the encryption scheme, this value is equal to 8 by considering 8 bits for each pixel. Table 6 shows the entropy of the original and encrypted images for CR = 0.5 . The results describe that the entropy after encryption is approximately equal to the ideal value. x 02 + δ x2 ; (e) y 02 + δ y2 ; (f) z 02 + δ z2 . Table 5. Key space of the proposed method and other approaches.

Algorithm
Proposed method Ref. 45 Ref. 30 Ref. 40 Ref. 26 Key space 2 300 2 276 2 300 2 232 2 398 www.nature.com/scientificreports/ www.nature.com/scientificreports/ Correlation. Two previous measures investigate the uniformity of the distribution while they do not calculate the correlation among pixels. For a natural image, there is a high correlation between adjacent pixels in all directions. The minimum correlation among pixels is appropriate for secure image encryption. Figure 7 shows the joint distribution of adjacent pixels in the horizontal direction for the original and encrypted images. These distributions show that the correlation between pixels of the encrypted images is reduced effectively. A measure to quantify the relation between the adjacent pixels of the image is the correlation coefficient (CC). Table 7 presents the CC values of different schemes in three directions for comparison. The results show that the proposed encryption method reduces the correlation between pixels, and has better performance.
Roustness analysis. Noise attack. Images are usually affected by different noise models in the transmission process. Here, we evaluate the robustness of the proposed approach in the presence of different noise attacks such as Gaussian noise (GN), speckle noise (SN), and salt and pepper noise (SPN). In this simulation, the Cameraman image is used as a test image, and CR = 0.5 . Figure 8 presents decrypted images in the presence of noise attacks with different intensities. The recovery performance of the proposed encryption approach is shown in Fig. 9 for different noise intensities. We can conclude that: (1) Gaussian noise has the largest effect on the recovery performance, (2) there is a certain robustness to the SN attack, (3) the proposed scheme has the strongest robustness to the SPN attack. These results show that the proposed encryption method has a good ability to recover the original image in the presence of the noise attack.
Cropping attack. An essential challenge in image transmission is the cropping attack in which some pixels of the encrypted image are loosed. Since the proposed image encryption is based on compressed sensing, our approach is robust against data loss and can effectively recover the original image. The proposed approach's performance is evaluated for different cropping masks, and results are shown in Fig. 10. The decrypted images and their PSNR demonstrate the robustness of the proposed method in the presence of a cropping attack.

Conclusion
In this paper, an image cryptosystem was proposed based on two-dimensional sparse recovery to simultaneously achieve encryption and compression. Based on the compressed sensing theory, the original image was compressed via two measurement matrices. To improve the performance of image recovery, a chaotic confusion was added before compression. Also, the total variation was used in the sparse recovery problem based smoothed ℓ 0 norm. The security level was increased by chaotic scrambling and XOR operations. Statistical analyses have shown that the proposed cryptosystem has ample key space, high sensitivity to the tiny variation in the key, maximum entropy, uniform distribution of the encrypted image, and week correlation between adjacent pixels. These features have demonstrated the robustness of the proposed approach against the statistical analysis and brute-force attack. The simulation results have illustrated that the proposed cryptosystem has high security and excellent compression performance. The proposed approach was also adequately robust against the noise and cropping attacks because of considering the chaotic confusion and the total variation in the two-dimensional sparse recovery. Future work will focus on improving the compression ratio performance based on the dictionary learning to obtain the sparse representation. www.nature.com/scientificreports/