Joint Image Compression and Encryption Using IWT with SPIHT, Kd-Tree and Chaotic Maps

: Conﬁdentiality and efﬁcient bandwidth utilization require a combination of compression and encryption of digital images. In this paper, a new method for joint image compression and encryption based on set partitioning in hierarchical trees (SPIHT) with optimized Kd-tree and multiple chaotic maps was proposed. First, the lossless compression and encryption of the original images were performed based on integer wavelet transform (IWT) with SPIHT. Wavelet coefﬁcients undergo diffusions and permutations before encoded through SPIHT. Second, maximum confusion, diffusion and compression of the SPIHT output were performed via the modiﬁed Kd-tree, wavelet tree and Huffman coding. Finally, the compressed output was further encrypted with varying parameter logistic maps and modiﬁed quadratic chaotic maps. The performance of the proposed technique was evaluated through compression ratio (CR) and peak-signal-to-noise ratio (PSNR), key space and histogram analyses. Moreover, this scheme passes several security tests, such as sensitivity, entropy and differential analysis tests. According to the theoretical analysis and experimental results, the proposed method is more secure and decreases the redundant information of the image more than the existing techniques for hybrid compression and encryption.


Introduction
In the current era, with the availability of inexpensive capturing devices with high resolution, the rapid growth of image transmission over public networks has raised substantial concern in the fields of secure transmission and the compression of images [1,2].
The compression of data is the main thrust in multimedia applications due to high redundancy. Without compression, storage and communication resources are used inefficiently. In particular, low-bandwidth communication channels and power-limited devices require low-bit-rate compression due to bandwidth and power constraints.
In addition, encryption is required for confidentiality and integrity of the information, particularly for open-access networks. Encryption algorithms are typically optimized for a specific type of data due to several factors, such as encryption speed, processing power and sensitivity to bit changes. Encryption algorithms that are specially designed for text data encryptions, such as data encryption standard (DES), advance encryption standard (AES), and Blowfish, are not suitable for image data encryption. Image data have various built-in features, such as redundancy and strong correlation less computations (up to 50%) compared to the convolution-based approach. The Lifting wavelet transform is highly suitable for implementation on the hardware and reduces the computational complexity. During the lifting implementation, no extra memory buffer is required because of the in-place computation feature of lifting. Lifting wavelet transform (LWT) has attracted increased interest in image compression as it has low computational complexity due to the utilization of an ordinary wavelet filter in the lifting steps [18]. The lifting-based approach offers an integer-to-integer transformation that is suitable for lossless image compression.
LWT is derived from a polyphase matrix representation that can distinguish between even and odd samples. A polyphase matrix is a matrix in which the elements are filter masks. To derive the lifting wavelet transform, the original filter is divided into a series of shorter filters using the filter-factoring algorithm. Those filters are designed as low-pass and high-pass filters with lifting steps. A polyphase matrix is used for matrix decomposition, which leads to additional matrices in the form of a lifting scheme.
There are three stages in the LWT (see Figure 1): splitting, prediction and update. x n+ (2) In the prediction stage, the even signal is used to estimate the odd signal via multiplication by a forecasting parameter P. The difference between the odd and predicted signals is the high-frequency coefficients, as expressed in Equation (3). Then, in the update stage, the even signal is updated, and it results in low-frequency coefficients by Equation (4).
( ) ( ) ( ) ( ) e c n = x n -U d n (4) SPIHT is one of the most widely used, powerful and efficient image compression techniques, with extremely low computational complexity, especially with lifting-based IWT. With SPIHT, the image is first decomposed into a series of wavelet coefficients via the wavelet transform. These wavelet coefficients are grouped into sets that are known as spatial orientation trees (SOT), as shown in Figure 2a and scanning sequence in Figure 2b. After that, the coefficients in each SOT are encoded progressively from the most significant bit planes to the least significant bit planes, starting with the coefficients with the highest magnitude. The SPIHT algorithm involves two coding passes: the sorting pass and the refinement pass. The sorting pass looks for zero trees and sorts significant and insignificant coefficients with respect to a specified threshold, as shown in Equation (5). The refinement pass sends the precision bits of the significant coefficients. After one sorting pass and one refinement pass, which can be considered one scan pass, the threshold T is halved, and the coding process is repeated until the expected bit rate is achieved. At the end, the compressed bit stream for all the coefficients is obtained. It provides In the splitting stage, the input signal is divided into two sets: odd (Equation (1)) and even (Equation (2)) signals, which can be described as: x o (n) = x(2n + 1) (1) x e (n) = x(n + 1) In the prediction stage, the even signal is used to estimate the odd signal via multiplication by a forecasting parameter P. The difference between the odd and predicted signals is the high-frequency coefficients, as expressed in Equation (3).
Then, in the update stage, the even signal is updated, and it results in low-frequency coefficients by Equation (4).
SPIHT is one of the most widely used, powerful and efficient image compression techniques, with extremely low computational complexity, especially with lifting-based IWT. With SPIHT, the image is first decomposed into a series of wavelet coefficients via the wavelet transform. These wavelet coefficients are grouped into sets that are known as spatial orientation trees (SOT), as shown in Figure 2a and scanning sequence in Figure 2b. After that, the coefficients in each SOT are encoded progressively from the most significant bit planes to the least significant bit planes, starting with the coefficients with the highest magnitude. satisfactory image quality, high PSNR, and optimization for progressive image transmission. SPIHT is highly vulnerable to bit corruption since a single bit error can introduce major image distortion, depending on its location.

Image Encryption with Chaotic Maps
Many encryption algorithms, specifically for digital images, have been proposed to meet the requirements of robust image encryption applications. Among them, the chaos-based encryption algorithms are popular due to several excellent properties, such as ergodicity, randomness, unpredictability, and high sensitivity to initial conditions and various parameters [5][6][7].
However, most of these schemes encounter various problems that limit their robustness and security [19][20][21][22][23][24]. It is well known that some chaotic maps completely lose their chaotic behavior and become periodic when they are discretized [25]. In addition, the security of chaotic systems depends on control parameters and shows specific behavior on these values, which can be determined in some cases. Therefore, one of the main problems in chaos-based cryptography is the selection of the chaotic system [21].
Various types of chaotic maps have been proposed, such as the Logistic map, Sine map, Cubic map, Tent map, Baker map, Arnold map, Chen map and many more. Among these, the most primitive and complex is the logistic map, which arises from a nonlinear dynamical equation [24]. However, all these maps suffer from security deficiencies. The security of chaotic maps depends upon the number of parameters that are used in these chaotic cryptosystems. To increase the number of these parameters, multi-dimensional and multiple iterative chaotic maps have been used [26]. However, security deficiencies remain [27]. The control parameters in chaotic systems act as a key on which security of the system is based. It is well known that the secret key is of fundamental importance in the security of all cryptosystems. There exist several tools and methods for estimating the initial values of chaotic systems by determining the behavior of the systems [28]. Therefore, some researchers used chaotic and non-chaotic encryption schemes together [29].
Recently, another type of chaotic system was reported, namely, the hyper-chaotic system, which has superior properties compared to general chaotic systems. It has two or more Lyapunov exponents and more-complex structures. These characteristics are considered to provide a strong entropy source. However, cryptanalysis studies demonstrate that hyper chaotic schemes can be broken by chosen-plaintext attack; thus, these are also insecure and not suitable for secure image communication [30]. The SPIHT algorithm involves two coding passes: the sorting pass and the refinement pass. The sorting pass looks for zero trees and sorts significant and insignificant coefficients with respect to a specified threshold, as shown in Equation (5). The refinement pass sends the precision bits of the significant coefficients. After one sorting pass and one refinement pass, which can be considered one scan pass, the threshold T is halved, and the coding process is repeated until the expected bit rate is achieved. At the end, the compressed bit stream for all the coefficients is obtained. It provides satisfactory image quality, high PSNR, and optimization for progressive image transmission. SPIHT is highly vulnerable to bit corruption since a single bit error can introduce major image distortion, depending on its location.

Image Encryption with Chaotic Maps
Many encryption algorithms, specifically for digital images, have been proposed to meet the requirements of robust image encryption applications. Among them, the chaos-based encryption algorithms are popular due to several excellent properties, such as ergodicity, randomness, unpredictability, and high sensitivity to initial conditions and various parameters [5][6][7].
However, most of these schemes encounter various problems that limit their robustness and security [19][20][21][22][23][24]. It is well known that some chaotic maps completely lose their chaotic behavior and become periodic when they are discretized [25]. In addition, the security of chaotic systems depends on control parameters and shows specific behavior on these values, which can be determined in some cases. Therefore, one of the main problems in chaos-based cryptography is the selection of the chaotic system [21].
Various types of chaotic maps have been proposed, such as the Logistic map, Sine map, Cubic map, Tent map, Baker map, Arnold map, Chen map and many more. Among these, the most primitive and complex is the logistic map, which arises from a nonlinear dynamical equation [24]. However, all these maps suffer from security deficiencies. The security of chaotic maps depends upon the number of parameters that are used in these chaotic cryptosystems. To increase the number of these parameters, multi-dimensional and multiple iterative chaotic maps have been used [26]. However, security deficiencies remain [27]. The control parameters in chaotic systems act as a key on which security of the system is based. It is well known that the secret key is of fundamental importance in the security of all cryptosystems. There exist several tools and methods for estimating the initial values of Appl. Sci. 2018, 8, 1963 5 of 22 chaotic systems by determining the behavior of the systems [28]. Therefore, some researchers used chaotic and non-chaotic encryption schemes together [29].
Recently, another type of chaotic system was reported, namely, the hyper-chaotic system, which has superior properties compared to general chaotic systems. It has two or more Lyapunov exponents and more-complex structures. These characteristics are considered to provide a strong entropy source. However, cryptanalysis studies demonstrate that hyper chaotic schemes can be broken by chosen-plaintext attack; thus, these are also insecure and not suitable for secure image communication [30].
For a fixed chaotic system, with the development of chaos theory, the chaotic orbits may be estimated, and their parameters or initial values may be predicted [31]. Therefore, it is not secure to use a fixed chaotic system in the encryption algorithm. Compared with fixed chaotic maps, time-varying chaotic maps are more complex and the output sequences are non-stationary, which makes them much more difficult to predict and analyze [31]. The varying parameters disrupt the phase space of the system; hence, the system can resist phase-space reconstruction attacks and chaotic signal estimation technologies effectively [32]. Thus, an image encryption algorithm that is based on a time-varying chaotic system is more secure. A direct and effective method for constructing a time-varying chaotic system is through varying parameters of the chaotic system. Recently, several chaotic image encryption algorithms that are based on varying parameters have been proposed [31,32]. In [32], a parameter-varying logistic map, which can overcome the weaknesses of the logistic map and resist phase-space reconstruction attacks, is used to shuffle the plain image.

Joint Image Compression and Encryption
Several joint image compression and encryption algorithms have been proposed in the literature that achieves robust security in the compressed domain. Maqbool et al. [33] proposed a secure JPEG algorithm for simultaneous compression and encryption. During JPEG compression, encryption is introduced by scrambling the DCT coefficients in the quantization step. Xiaoyong et al. [34] proposed a hybrid compression and encryption algorithm that is based on the generalized knight's tour, DCT and the Chen chaotic map. In this method, the nested generalized knight's tour was used to scramble the plain image, and DCT and quantization coding were utilized to compress the image with a high compression ratio. Diffusion was performed by encrypting some of the DCT coefficients by using the Chen chaotic system. Tong et al. [35] proposed joint compression and encryption using integer wavelet transform, SPIHT and multiple chaotic maps. First, integer wavelet coefficients are scrambled with the Lorenz map and the Henon map and compressed using SPIHT. At the end, the SPIHT bit stream is encrypted with a logistic map sequence. Zhang et al. [36] proposed a hybrid technique by combining compression using SPIHT and a chaos-based cryptosystem to yield a crypto-compression scheme that is based on a modified logistic map. In [37], joint compression and encryption of image data through cross-coupled chaotic maps and Non-uniform Discrete Cosine Transform was proposed. The compression of data is performed on blocks and permutation of these blocks and diffusion are carried out simultaneously. In [14], a joint lossless image encryption and compression scheme that is based on integer wavelet transform (IWT), set partitioning in hierarchical trees (SPIHT) with a hyper-chaotic system, a nonlinear inverse operation, and Secure Hash Algorithm-256 (SHA-256) was proposed. A JPEG based compression encryption algorithm is presented in [38]. This scheme is known as content adaptive because of the encryption key for altering the discrete cosine transform (DCT) orthogonal transformation and the encryption of the AC and DC coefficients performed through the key generated via BLAKE2 hashing algorithm applying to the plain image.

Compact Data Structures
Compact data structures offer a fascinating approach in substitution, data compression and efficient retrieval of information. In this paper, we used two well-known compact data structures

Kd-Tree
Initially, Kd-tree was used for the representation of web graphs. Here, we used Kd-tree for the compression of binary sparse matrices with permutations and substitution operations. The Kd-tree structure uses various matrix properties, such as sparseness and large homogeneous areas of zeros and ones. Kd-tree efficiently compresses the large areas of zeros and ones and provides efficient navigation over these compressed values. The simplest variant of Kd-tree is K 2 -tree, where; K = 2; K 2 -tree is similar to a compact Quad tree [39].
In K 2 -tree, a binary matrix is divided recursively from left to right and from top to bottom. A conceptual tree is built from this recursive division; a 1-bit is added to the sub-tree T (root tree) of the conceptual tree if the sub-matrix contains at least a single 1-bit and 0-bits otherwise. At each partitioning level, each matrix is divided into K 2 sub-matrices of equal size. During this recursive division of the binary matrix, two sub-trees (T and L) are built:  Figure 3 shows an example of a K 2 -tree in which the matrix was divided into four sub-matrices and for each sub-matrix, the root node has a bit. Each bit indicates whether the sub-matrix has at least one 1 or all zeros. Therefore, the root node of Figure 3 is 1011, since the first sub-matrix has 1 s, the second does not have 1 s, and so on. The sub-matrices that have 1 s are divided again, following the same method, until the subdivision reaches the cell level. navigation over these compressed values. The simplest variant of Kd-tree is K 2 -tree, where; K = 2 ; K 2 -tree is similar to a compact Quad tree [39]. In K 2 -tree, a binary matrix is divided recursively from left to right and from top to bottom. A conceptual tree is built from this recursive division; a 1-bit is added to the sub-tree T (root tree) of the conceptual tree if the sub-matrix contains at least a single 1-bit and 0-bits otherwise. At each partitioning level, each matrix is divided into K 2 sub-matrices of equal size. During this recursive division of the binary matrix, two sub-trees (T and L) are built:  Figure 3 shows an example of a K 2 -tree in which the matrix was divided into four sub-matrices and for each sub-matrix, the root node has a bit. Each bit indicates whether the sub-matrix has at least one 1 or all zeros. Therefore, the root node of Figure 3 is 1011, since the first sub-matrix has 1 s, the second does not have 1 s, and so on. The sub-matrices that have 1 s are divided again, following the same method, until the subdivision reaches the cell level.
The original binary matrix can be constructed by navigating these trees. For this, we must construct a rank structure with sub-tree T. The rank structure counts the number of ones in the root sub-tree T. Each 1-bit in T represents a sub-matrix, depending upon its position, and each 0-bit represents a zero matrix. If we know the position of slightly in root tree T, we can determine the position of its children via pos0 = rank1 (T, pos) × K 2 of T: L. In this way, navigate the conceptual tree using trees T and L. Variants of the K 2 -tree can be used to compress contiguous zeros and ones, or any other specific pattern, together. With these variants of kd-tree, we can compress binary images that contain large areas of homogeneous values. In these variants, the strategy is to check for specific contiguous values and remove these contagious values from the original matrix via a specific bit representation in the root tree. The sizes of these homogeneous areas vary with the level. If we remove homogenous regions of multiple values from the original matrix, then we need more bits in the root tree to represent the values in the original matrix. In our case, we compress homogenous regions of zeros and ones. Conceptually, these values are represented by nodes of different colors. The variants of the K 2 -tree for compression of zeros and ones can be traversed in the same way as the original K 2 -tree. With modified navigation rules, we can easily implement the compression of ones with K 2 -trees.
Depending upon the size and distribution of the values in the binary matrix, we can change the number of division levels by changing the value of K. Usually, for a very large matrix, higher values of K at the start and smaller values at lower levels improve compression. To further improve the compression efficiency, we have used different values of K for ones and zeros, which also improve The original binary matrix can be constructed by navigating these trees. For this, we must construct a rank structure with sub-tree T. The rank structure counts the number of ones in the root sub-tree T. Each 1-bit in T represents a sub-matrix, depending upon its position, and each 0-bit represents a zero matrix. If we know the position of slightly in root tree T, we can determine the position of its children via pos0 = rank1 (T, pos) × K 2 of T: L. In this way, navigate the conceptual tree using trees T and L.
Variants of the K 2 -tree can be used to compress contiguous zeros and ones, or any other specific pattern, together. With these variants of kd-tree, we can compress binary images that contain large areas of homogeneous values. In these variants, the strategy is to check for specific contiguous values and remove these contagious values from the original matrix via a specific bit representation in the root tree. The sizes of these homogeneous areas vary with the level. If we remove homogenous regions of multiple values from the original matrix, then we need more bits in the root tree to represent the values in the original matrix. In our case, we compress homogenous regions of zeros and ones. Conceptually, these values are represented by nodes of different colors. The variants of the K 2 -tree for compression of zeros and ones can be traversed in the same way as the original K 2 -tree. With modified navigation rules, we can easily implement the compression of ones with K 2 -trees.
Depending upon the size and distribution of the values in the binary matrix, we can change the number of division levels by changing the value of K. Usually, for a very large matrix, higher values of K at the start and smaller values at lower levels improve compression. To further improve the compression efficiency, we have used different values of K for ones and zeros, which also improve the security level by introducing more uncertainty in the data size. These variants of K 2 -tree can be used efficiently for the compression of binary raster images.

Wavelet Tree
The wavelet tree is a very useful data structure that serves several purposes. It can be used to adaptively change the entropy measures of the data when it encodes, thereby enabling compressed data representations. It is considered useful for three tasks: (i) adaptive representation of a sequence, (ii) reordering of data elements, and (iii) for the grid of a point's representation [40].
A wavelet tree is constructed by assigning 0 to half of the symbol and 1 to the other half of the symbol. The same process for symbol assignment is performed recursively on each half of the children, splitting the αbets at each level. The splitting and symbol assignment process stops when each 03B1bet set consists of only two symbols.
In Figure 4, we demonstrate a simple wavelet tree as an example. The representation shows how to assign binary values to the 03B1bets by dividing them into lower and upper halves. In practical implementations, we only store the assigned binary values; the symbols are shown here only to facilitate understanding of the wavelet tree decomposition process. the security level by introducing more uncertainty in the data size. These variants of K 2 -tree can be used efficiently for the compression of binary raster images.

Wavelet Tree
The wavelet tree is a very useful data structure that serves several purposes. It can be used to adaptively change the entropy measures of the data when it encodes, thereby enabling compressed data representations. It is considered useful for three tasks: (i) adaptive representation of a sequence, (ii) reordering of data elements, and (iii) for the grid of a point's representation [40].
A wavelet tree is constructed by assigning 0 to half of the symbol and 1 to the other half of the symbol. The same process for symbol assignment is performed recursively on each half of the children, splitting the αbets at each level. The splitting and symbol assignment process stops when each 03B1bet set consists of only two symbols.
In Figure 4, we demonstrate a simple wavelet tree as an example. The representation shows how to assign binary values to the 03B1bets by dividing them into lower and upper halves. In practical implementations, we only store the assigned binary values; the symbols are shown here only to facilitate understanding of the wavelet tree decomposition process.
To adaptively change the entropy measure during encoding, different variants can be used to obtain satisfactory compression and space results. The symbol assignment strategy can be changed to obtain better compression results. The wavelet tree is useful in many ways for data compression, especially with Huffman coding. By using a wavelet tree, we can obtain the desired bit pattern by using a specific encoding that change the tree shape.
Inserting or removing 03B1bet symbols in the original sequence requires changing the shape of the wavelet tree and the bitmaps that are stored at each level. This dynamism can be achieved when we combine the K 2 -tree with the wavelet tree and it is very helpful for data security and compression.  Figure 5 illustrates the process of image compression and encryption by the proposed method. The whole process of compression and encryption was divided into three stages: At the first stage, compression and encryption were performed via lifting IWT and the SPIHT algorithm. In the second stage, compression of SPIHT output along with permutations and substitution operations was performed via a modified Kd-tree and a wavelet tree. Further compression was achieved through Huffman coding. Finally, at the third stage, encryption was performed on the output of the second stage by varying parameters in the logistic map and modified quadratic chaotic maps. To adaptively change the entropy measure during encoding, different variants can be used to obtain satisfactory compression and space results. The symbol assignment strategy can be changed to obtain better compression results. The wavelet tree is useful in many ways for data compression, especially with Huffman coding. By using a wavelet tree, we can obtain the desired bit pattern by using a specific encoding that change the tree shape.

Proposed Image Compression and Encryption Algorithm
Inserting or removing 03B1bet symbols in the original sequence requires changing the shape of the wavelet tree and the bitmaps that are stored at each level. This dynamism can be achieved when we combine the K 2 -tree with the wavelet tree and it is very helpful for data security and compression. Figure 5 illustrates the process of image compression and encryption by the proposed method. The whole process of compression and encryption was divided into three stages: At the first stage, compression and encryption were performed via lifting IWT and the SPIHT algorithm. In the second stage, compression of SPIHT output along with permutations and substitution operations was performed via a modified Kd-tree and a wavelet tree. Further compression was achieved through Huffman coding. Finally, at the third stage, encryption was performed on the output of the second stage by varying parameters in the logistic map and modified quadratic chaotic maps.

Compression and Encryption Based on IWT and SPIHT
LWT with SPIHT yields the best results in terms of compression ratio and computational complexity with very good image quality for medical and natural images. The plain image is transformed into integer wavelet coefficients through LWT. The wavelet transform has the capability of placing a large percentage of the total signal energy in the low sub-band of the image. Therefore, the nonlinear inverse diffusion operations in

Compression and Encryption Based on IWT and SPIHT
LWT with SPIHT yields the best results in terms of compression ratio and computational complexity with very good image quality for medical and natural images. The plain image is transformed into integer wavelet coefficients through LWT. The wavelet transform has the capability of placing a large percentage of the total signal energy in the low sub-band of the image. Therefore, the nonlinear inverse diffusion operations in Z p on lower-band wavelet coefficients provide sufficient security and linear diffusion operations on the remaining coefficients to increase the 0 counts during SPIHT encoding. In this case, we only select the coefficient values in the 64 × 64 upper-left corner. Among them, we transformed two-byte positive (0 − 65535) values through nonlinear inverse operations. However, unfortunately, 65536 is not a prime number. Hence, Z 65536 is not a field and does not have a multiplicative inverse. Therefore, we choose the next prime, which is Z 65537 , for taking the inverse. For the two bytes of the wavelet coefficient that is represented by m, the inverse operation can be defined as I = m −1 mod 2 16 + 1 . After the diffusion process, these coefficients were permuted via a high-dimensional Kd-tree. These permuted and diffused coefficients were subjected to SPIHT for encoding.

Compression with Confusion-Diffusion through Kd-Tree, Wavelet Tree and Huffman Coding
In the second stage, we performed joint compression and encryption via Kd-tree, wavelet tree and Huffman coding. A detailed explanation is given below.

Confusion-Diffusion and Compression with K 2 -Tree
Usually, SPIHT encoding produces a sparse bit stream. The sparseness can be increased by the linear diffusion of small wavelet coefficients with small negative value. Several cyclic shifts were performed on the SPIHT bit stream and reshaped into small blocks (2 × 2), packed to form large blocks (8 × 8) and combined into a large matrix (512 × 512). Then, this matrix was subjected to K 2 -tree for further compression with confusion and diffusion operations. At different levels of K 2 -tree, we can achieve permutations of sub-level matrices with the help of a pseudo-random permutation sequence (which is obtained via Matlab function randperm with rng(seed) with a specified seed value). In a modified K 2 -tree, we achieved compression of homogeneous regions of zeros and ones at multiple levels. The matrix vocabulary was used to achieve diffusion at lower levels of the conceptual tree.

Diffusion and Compression with Wavelet Tree
Further compression along with confusion-diffusion was achieved via a modified wavelet tree by reordering L-array elements. We convert the L-array bits to symbols (2-bit symbols) and rearrange these symbols via the wavelet tree to achieve additional compression and diffusion.

Huffman Coding
Huffman encoding is the most widely used encoding technique and is the best known among the most popular techniques. In this technique, first, we calculate the frequency of each symbol with a probability distribution. Then, we assign code words based on the occurrence probability of each symbol. Huffman encoding is similar to a tree in which each node has either 0 or 2 children [41].

Chaotic-Map-Based Encryption
Logistic maps are one-dimensional maps, as expressed in Equation (6) and have been widely used in image encryption.
x n+1 = ax n (1 − x n ) n = 0, 1, 2, . . . N where a is the parameter of the logistic map, and x n is the sequence generated with Equation (6) with initial value x 0 (0 < x 0 < 1). For 3.56999 < a ≤ 4, Equation (6) becomes chaotic. From this chaotic function, real numbers can be obtained that form a pseudo-random sequence.
Research shows that logistic map sequences are not secure due to well-known weaknesses, such as small key size, short chaotic orbit and lack of resistance to phase-space reconstruction attacks. Therefore, to overcome these weaknesses, a logistic map with varying parameters (in Equation (7)) was proposed to expand the key space and improve resistance to phase-space construction attacks.
x k,n+1 = a k x k,n (1 − x k,n ) k = 1, 2, . . . , M n = 0, 1, 2, . . . N k Here, the value of k represents the specific parameter set and N k represent the number of values in each set. X k,n+1 is the output of the chaotic map at specific parameter value k. The a k is the varying coefficients from [3.5699, 4] that can be vary either through other chaotic maps or with the periodic perturbation of the parameters like a k = 3.9 + 0.01 * k. M is the cardinality of parameter set. The logistic chaotic map output with varying parameter sets can be represented as follows.
Here, the value of k represents the specific parameter set and k N represent the number of values in each set. k,n+1 X is the output of the chaotic map at specific parameter value k. The k a is the varying coefficients from [3.5699, 4] that can be vary either through other chaotic maps or with the periodic perturbation of the parameters like = 3.9 + 0.01* k a k . M is the cardinality of parameter set. The logistic chaotic map output with varying parameter sets can be represented as follows.
The chaotic binary sequence was generated by the following Equation (8).
The quadratic map is another fundamental type of chaotic system. The classical quadratic map can be represented as follows in Equation (9).
Here, r is the chaotic parameter and n is the number of iterations. The quadratic map is a nonlinear chaotic system. It depends upon a mathematical equation; therefore, it is deterministic.
However, it is highly sensitive to the initial conditions: a slight change in initial value 0 x can produce a significant change in the output of the map.
The chaotic binary sequence was generated by the following Equation (8).
The quadratic map is another fundamental type of chaotic system. The classical quadratic map can be represented as follows in Equation (9).
Here, r is the chaotic parameter and n is the number of iterations. The quadratic map is a nonlinear chaotic system. It depends upon a mathematical equation; therefore, it is deterministic. However, it is highly sensitive to the initial conditions: a slight change in initial value x 0 can produce a significant change in the output of the map.
The Lyapunov exponent, which is denoted as λ, is a performance-measuring parameter of chaotic map systems. The value of the Lyapunov exponent indicates the sensitivity of the chaotic system to the initial condition quantitatively. For a discrete system and a chaotic orbit that starts with x 0 , the Lyapunov exponent can be defined as follows in Equation (10): Here, f is the derivative of the function f . From the above equation, we can calculate the value of λ, which can be positive, negative or zero. The value λ gives us important information about the state of the system. If the value of λ is negative, the system shows non-chaotic behavior; in contrast, if the value of λ is zero, then the system is in a steady state and cannot be used for a cryptosystem. Only if the value of λ is positive does the system show chaotic behavior and is sensitive to the initial conditions; however, the degree of sensitivity depends on the value of λ. The more positive the value of λ is, the more sensitive the system is to initial conditions and the closer to zero that λ is, the less sensitive the system will be to the initial conditions. Equations (11) and (12) are the modified quadratic maps that are proposed in.
A larger Lyapunov exponent indicates more-chaotic behavior. The above-modified quadratic chaotic map has Lyapunov exponent 3.4709, which is a very good value compared to other chaotic maps; thus, this map yields a chaotic sequence with desired properties.

Reverse Process of Compression and Encryption
The complete reverse process of compression and encryption is illustrated in Figure 6. This is the opposite process of the compression and encryption algorithm. Appl. Sci. 2018, 8, x FOR PEER REVIEW 11 of 21 Figure 6. Reverse encryption and compression process.

Experimental Results
The experiment was performed on six standard 512 × 512 grayscale images with 256 gray levels. The images are titled Baboon, Lena, Peppers, Airplane, House, and Lake. First, compression and encryption of these images were performed with IWT-based SPIHT. Then, this bit stream was further compressed along with maximum confusion diffusion operations via Kd-tree. Finally, an additional level of security was achieved via encryption through a varying parameter logistic map and modified quadratic chaotic maps. Experimental results demonstrate that our method provides maximum compression with a high level of security, which are the two core objectives in this research. Figure 7 shows Lena's encrypted results for the wavelet coefficients under various sizes of diffusion.

Compression Performance
In this paper, lossless image compressions have been achieved. Table 1 lists the compression ratios (CRs) of six images when the permutation and diffusion operations were performed on the upper-left 64 × 64 wavelet coefficients and SPIHT bit-stream compression with permutations at block sizes of greater than 8×8. The compression performance is represented by the compression ratio (CR) or bits per pixel (bpp). Larger values of CR indicate more compression, whereas lower values of bpp indicate more compression. CR and bpp are defined as follows.

Number -of -bits-of -plain -image CR = Number -of -bits-of -cipher -image
Total -bits-in -compression -image bpp = Total -number -of -image -pixels Here, we used both the CR and bpp for comparison. The compression comparison of the proposed method with the most relevant methods [14,35,37,38] indicate that our method has achieved much more compression performance in joint image compression and encryption domain as compared to the existing methods. It indicates that the algorithm has a better compression ratio and the impact of encryption on compression is not substantial; thus, the proposed approach achieves a good balance between compression and encryption.

Experimental Results and Discussion
For the proposed hybrid compression and encryption algorithm, security tests and compression performance tests were performed. The experiments were implemented in the MATLAB R2016b programming environment developed by mathworks is an American privately held corporation, which was running on a personal computer with an Intel Corei3 3.5-GHz processor and 8-GB memory.

Experimental Results
The experiment was performed on six standard 512 × 512 grayscale images with 256 gray levels. The images are titled Baboon, Lena, Peppers, Airplane, House, and Lake. First, compression and encryption of these images were performed with IWT-based SPIHT. Then, this bit stream was further compressed along with maximum confusion diffusion operations via Kd-tree. Finally, an additional level of security was achieved via encryption through a varying parameter logistic map and modified quadratic chaotic maps. Experimental results demonstrate that our method provides maximum compression with a high level of security, which are the two core objectives in this research. Figure 7 shows Lena's encrypted results for the wavelet coefficients under various sizes of diffusion.

Resistance to Statistical Attacks
Resistance to statistical attacks is the most basic objective of an image encryption algorithm. Shannon suggested that maximum confusion and diffusion should be employed in a cryptosystem to remove the correlation characteristics of image pixels to frustrate powerful statistical analysis. In the proposed compression and encryption algorithm, we achieve maximum confusion and diffusion

Compression Performance
In this paper, lossless image compressions have been achieved. Table 1 lists the compression ratios (CRs) of six images when the permutation and diffusion operations were performed on the upper-left 64 × 64 wavelet coefficients and SPIHT bit-stream compression with permutations at block sizes of greater than 8×8. The compression performance is represented by the compression ratio (CR) or bits per pixel (bpp). Larger values of CR indicate more compression, whereas lower values of bpp indicate more compression. CR and bpp are defined as follows.
Here, we used both the CR and bpp for comparison. The compression comparison of the proposed method with the most relevant methods [14,35,37,38] indicate that our method has achieved much more compression performance in joint image compression and encryption domain as compared to the existing methods. It indicates that the algorithm has a better compression ratio and the impact of encryption on compression is not substantial; thus, the proposed approach achieves a good balance between compression and encryption.
The commonly used criteria for image quality assessment after compression are mean square error (MSE), which is defined in Equation (13), and peak signal-to-noise ratio (PSNR), which is defined in Equation (14).
Here, I (i, j) denotes the original image and I(i, j) is the testing image, i.e., the compressed image. M and N represent the height and width, respectively, of the image. PSNR = 10 × log 10 Here, x peak represents the peak signal value. The results in Table 1 demonstrate that the proposed method yields very good compression results compared to other related joint image compression and encryption methods with high-quality images.

Key-Space Analysis
Sufficiently large key size is necessary for any good encryption algorithm. In the proposed method, we have used four keys: wavelet coefficient permutation and diffusion keys, SPIHT bit-stream cyclic shift with permutation and matrix vocabulary keys, logistic chaotic map keys and quadratic chaotic map keys. At each stage, we have used 4-real-number keys of double data type. In these four stages, keys that are composed of a minimum of 16 real numbers are used. These 16 double real numbers provide a key size of 1024 bits. Thus, the size of the key space is 2 1024 , which is large enough to resist any brute-force attack. Table 2 shows the comparison among key sizes of the proposed and pseudorandom number based encryption schemes.

Key Sensitivity
Key sensitivity analysis determine the affect of small change in the encryption key on the ciphered data. The encryption scheme in which small change in the encryption key leads to considerable difference in cipher text considered to be a good encryption scheme. The proposed joint image compression and encryption scheme used at least four keys. For the diffusion and permutations of the lower band 64 × 64 integer wavelet coefficients. A tiny change in the permutation key affects the whole SPIHT encoding. Similarly a one bit change in the permutations sequence at any level of Kd-tree applied on the SPIHT output changed completely the bit stream. The other two keys are varying parameters logistic and quadratic chaotic maps keys which are also very sensitive to the change. Here, the key sensitivity results are presented in the form of PSNR and mean structural similarity index (MSSIM) after apply tiny changes at different levels of keys. The PSNR of the wrong key deciphered image was calculated thorugh Equation (14), SSIM and MSSIM were obtained with Equations (15) and (16) respectively. Here µ and σ are the mean and variance respectively. Table 3 shows the key sensitivity test results of the proposed scheme.

Resistance to Statistical Attacks
Resistance to statistical attacks is the most basic objective of an image encryption algorithm. Shannon suggested that maximum confusion and diffusion should be employed in a cryptosystem to remove the correlation characteristics of image pixels to frustrate powerful statistical analysis. In the proposed compression and encryption algorithm, we achieve maximum confusion and diffusion at various levels via nonlinear inverse operations, K 2 -tree and multiple chaotic maps in the last stage. After many confusion and diffusion operations were performed through the joint compression and encryption operations, the cipher image shows a truly random distribution. This random distribution of the cipher image was evaluated using histograms, adjacent-pixel correlations, and the information entropy of the cipher image. Figure 8 shows the "Lena" image histograms and, on the right, the corresponding "Lena" cipher image. Figure 8 shows that the histogram of the corresponding cipher image is almost uniformly distributed; therefore, this technique can withstand all types of statistical attacks. We also analyze the distribution of the pixel values of encrypted images through the chi-square test. The chi-square value was calculate using Equation (17).

Histogram Analysis
Appl. Sci. 2018, 8,1963 15 of 22 Here, Oi is the observed frequency of the ith pixel i (0 ≤ i ≤ 255), E is the expected frequency of pixel value i, and 256 . The results of the χ 2 −test for the 6 pairs of plain/encrypted test images are presented in Table 4:  Here, O i is the observed frequency of the ith pixel i (0 ≤ i ≤ 255), E is the expected frequency of pixel value i, and v 0 = (m × n)/256. The results of the χ 2 -test for the 6 pairs of plain/encrypted test images are presented in Table 4: From Table 4, for the six images, the values of the χ 2 -test are all lower than the critical value. Thus, we conclude that the distribution of pixel values in the encrypted image is uniform. That means that the proposed scheme can resist statistical attacks.

Correlation of Two Adjacent Pixels
In image data, adjacent pixels show very strong correlations with each other. Good encryption algorithms must remove this strong correlation to resist statistical attacks. The correlation among adjacent pixels calculated via Equation (18).
The results that were obtained from the above relation demonstrate that the proposed algorithm efficiently destroys the correlation among adjacent pixels, as shown in Table 5 and Figure 9. Therefore, no information can be obtained through the correlation of the pixels.

Information Entropy Analysis
The information entropy is a measure of the data distribution after encryption, which is defined by Equation (19). If each symbol has almost the same entropy as a random distribution, then the system has high random complexity and each pixel is treated as a random event.
Here, ( ) i P S represents the probability of each symbol i S . According to Equation (19), for a uniform distribution, the ideal entropy for each symbol is 8 for an image in which each pixel consists of 8 bits. Table 6 shows the entropy analysis results for encrypted images. Table 6 shows global entropies of the encrypted images. The results indicates that the entropy values are very close to the ideal value 8 for grayscale images. Encrypted image randomness measured with traditional methods only provide quantitative measure rather than qualitative extent. Ref. [42] developed a new test to measure the randomness of an encrypted image over local blocks that is known as local Shannon entropy test. The local Shannon entropy is defined as follows.

Information Entropy Analysis
The information entropy is a measure of the data distribution after encryption, which is defined by Equation (19). If each symbol has almost the same entropy as a random distribution, then the system has high random complexity and each pixel is treated as a random event.
Here, P(S i ) represents the probability of each symbol S i . According to Equation (19), for a uniform distribution, the ideal entropy for each symbol is 8 for an image in which each pixel consists of 8 bits. Table 6 shows the entropy analysis results for encrypted images. Table 6 shows global entropies of the encrypted images. The results indicates that the entropy values are very close to the ideal value 8 for grayscale images. Encrypted image randomness measured with traditional methods only provide quantitative measure rather than qualitative extent. Ref. [42] developed a new test to measure the randomness of an encrypted image over local blocks that is known as local Shannon entropy test. The local Shannon entropy is defined as follows.
Here, H (K,T B ) (S) represents the local entropy with K blocks of TB number of pixels in each block and S1, S2, . . . ., Sk are randomly chosen non-overlapping encrypted image blocks. We have selected 30 blocks (k = 30) from six test images randomly with T B = 1936 and calculate local entropy test results, which are shown in Table 7.  [43]. This test works on binary data by converting it in the form of ±1 and calculate the absolute sum. The test statistic is obtained as follows by Equation (21).
The value of P determine the randomness of a sequence. If the value of P is less than 0.01 the sequence is considered to be non-random otherwise random. The test results on the encrypted bit stream are shown in Table 8.

Resistance to Linear and Differential Attacks
The proposed compression and encryption scheme have multiple levels of securities in series. First, integer wavelet coefficients permutations and substitutions were performed by which the SPIHT encoding generates completely different bit stream, after that the produced bit stream under goes extensive permutations and substitutions with Kd-tree. Finally, multiple chaotic maps-based encryptions achieved randomness in the bit stream. The proposed joint image compression and encryption algorithm destroy the relationship between the original image and the encrypted image. The experimental results demonstrate that the scheme is sufficiently secure against all known types of attacks, such as brute-force attack, differential attack, chosen plaintext attack, known-plaintext attack and statistical attack. Resistant to differential attacks can be checked through following two security tests. The values of number of pixels change rate (NPCR) and unified average change intensity (UACI) values used to evaluate these test results. The NPCR is defined as follows in Equation (23).
Here, D(i, j) is the difference value of the two corresponding pixels of two images and W × H size of the image. The value of NPCR gets closer to 100% then it became more sensitive to the change in the plain image. The comparison between the corresponding pixels of the two encrypted images is done as follows Here, C 1 is the original encrypted image and C 2 is the encrypted image after changing one pixel value in the original image.
The UACI measure the change between original image and the corresponding encrypted image. Large values of UACI strongly resist to the differential attacks. UACI is defined as follow by Equation (25). Table 9 shows the results of NPCR and UACI tests. For good encryption algorithms that can resist differential attacks the values of NPCR and UACI tests are around 99.6094% and 33.4635% respectively [44].

Computational Compexity and Encryption Speed
The computational complexity of the proposed scheme for an image with n number of pixels is depicted in the Table 10. The lifting integer wavelet transform reduces the computational time by almost 50% compared to the traditional wavelet transform and the SPIHT encoding algorithm is the most computationally efficient compression algorithm. Only Kd-tree takes more time when applied on the whole data set, compared to other compression and encryption schemes. However, many researchers have proposed fully parallel Kd-tree implementations in other big-data applications; hence, the processing time can be reduced in the future by implementing a fully parallel Kd-tree for this scheme. The chaotic map encryption is computationally very light weight as like XOR operations mostly. Table 11 lists the compression and encryption speeds of the proposed scheme.

Joint Compression and Encryption for the Worst Case Images
The proposed scheme was evaluated with complete white and black images. As the complete white and black images have no information and in the trnsform domain appear only as a dot. Therefore, wavelet coefficients only have few information in the form of only four values. However, if these values passed to SPIHT encoding, it generates almost the same number of ones and zeros as for the other iamges. The rest of the procedure have no difference for worst case and other images.

Performance Comparison with Related Methods
We have compared our proposed method with most of the related joint compression and encryption methods. The experimental results demonstrate that our method outperforms the existing methods in terms of compression, as shown in Table 1, and security, according to the statistical results. Joint compression and encryption of a SPIHT bit stream with modified Kd-tree and varying parameters chaotic maps provide efficient security with compressed data.

Conclusions
In this paper, a joint image compression and encryption algorithm that is based on IWT with SPIHT, Kd-tree and multiple chaotic maps was proposed. First, compression is performed via lifting-based IWT and SPIHT. The diffusion of the major coefficients of IWT is carried out through nonlinear inverse operations. Permutations of the lower-frequency-band coefficients are performed via Kd-tree. Then, this SPIHT bit stream is subjected to Kd-tree for further compression, permutations and diffusions. In Kd-tree, permutations are performed with pseudo-random sequences. The diffusion of leaf nodes is achieved through matrix vocabulary. The Kd-tree output is further compressed via a modified wavelet tree and Huffman coding. Using this method, we achieved a high compression ratio and maximum confusion and diffusion operations. The main advantage of this scheme is that, with a robust security level, the compression performance is not degraded, as is the case with most joint compression and encryptions schemes. Finally, this bit stream is encrypted via varying parameter logistic maps and modified quadratic maps. Multi-level security is achieved that can withstand cryptanalysis and all types of known attacks. Moreover, the key space is very large, which makes the scheme resistant to brute-force attacks. The test results demonstrate that the system is sufficiently secure with satisfactory lossless compression performance.