# Joint Image Compression and Encryption Using IWT with SPIHT, Kd-Tree and Chaotic Maps
## 5 Experimental Results and Discussion
### 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).  
\[NPCR=\frac{\sum_{i,j}D(i,j)}{W\times H}\times 100\% \tag{23}\]  
Here, \(D(i,j)\) is the difference value of the two corresponding pixels of two images and \(W\times 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  
\[D(i,j)=\left\{\begin{array}{ll}1&C_{1}(i,j)\
eq C_{2}(i,j)\\ 0&C_{1}(i,j)=C_{2}(i,j)\end{array}\right. \tag{24}\]  
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).  
\[UACI=\frac{1}{W\times H}\bigg{[}\frac{C_{1}(i,j)-C_{2}(i,j)}{255}\bigg{]} \times 100\% \tag{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].  
\begin{table}
\begin{tabular}{c c c} \hline \hline
**Test** & _p-Value_ & **Pass Rate** \\ \hline Monobit test & 0.231475 & Pass \\ Frequency within block test & 0.754126 & Pass \\ Runs test & 0.632514 & Pass \\ Longest run ones in a block test & 0.641258 & Pass \\ Binary matrix rank test & 0.412572 & Pass \\ DFT test & 0.754163 & Pass \\ Non overlapping template matching test & 0.425712 & Pass \\ Overlapping template matching test & 0.912458 & Pass \\ Universal test & 0.952413 & Pass \\ Linear complexity test & 0.342587 & Pass \\ Serial test & 0.765812 & Pass \\ Approximate entropy test & 0.672541 & Pass \\ Cumulative sum test & 0.192745 & Pass \\ Random excursion test & 0.256312 & Pass \\ Random excursion variant test & 0.028735 & Pass \\ \hline \hline \end{tabular}
\end{table}
Table 8: NIST SP800-22 tests of encrypted bit stream.