# Joint Image Compression and Encryption Using IWT with SPIHT, Kd-Tree and Chaotic Maps
## 4 Proposed Image Compression and Encryption Algorithm
### 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})\hskip 56.905512 ptn=0,1,2,\ldots N \tag{6}\]  
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\leq 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})\hskip 56.905512 ptk=1,2,\ldots,M\hskip 56.905512 ptn =0,1,2,\ldots N_{k} \tag{7}\]  
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. \begin{tabular}{|c|c|c|c|c|c|c|c|} \hline X\({}_{1,1}\); X\({}_{1,2}\);.....; X\({}_{1,N1}\) & X\({}_{2,1}\); X\({}_{2,2}\);.....; X\({}_{2,N2}\) &........... & X\({}_{1,i}\); X\({}_{i,2}\);.....; X\({}_{i,N1}\) &........... & X\({}_{M,1}\); X\({}_{M,2}\);....; X\({}_{M,Nk}\) \\ \hline k=1 & \multicolumn{3}{c|}{k=2} & k=i & k=M \\ \hline \end{tabular}   
The chaotic binary sequence was generated by the following Equation (8). \[b_{i}=\left\{ \begin{array}{ll}0&x_{i}\leq 0.5\\ 0&x_{i}>0.5\end{array} \right.\qquad\qquad i=0,\;1,\ldots,n \tag{8}\]  
The quadratic map is another fundamental type of chaotic system. The classical quadratic map can be represented as follows in Equation (9). \[X_{n+1}=r-(X_{n})^{2} \tag{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 \(\lambda\), 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):  
\[\lambda(x_{0})=\lim_{x\rightarrow\infty}\frac{1}{n}\ln\left|f^{\prime}(x_{i})\right| \tag{10}\]  
Here, \(f^{\prime}\) is the derivative of the function \(f^{\prime}\). From the above equation, we can calculate the value of \(\lambda\), which can be positive, negative or zero. The value \(\lambda\) gives us important information about the state of the system. If the value of \(\lambda\) is negative, the system shows non-chaotic behavior; in contrast, if the value of \(\lambda\) is zero, then the system is in a steady state and cannot be used for a cryptosystem. Only if the value of \(\lambda\) 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 \(\lambda\). The more positive the value of \(\lambda\) is, the more sensitive the system is to initial conditions and the closer to zero that \(\lambda\) 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.