International Journal of Science, Engineering and Technology Research (IJSETR) Volume 1, Issue 1, July 2012 An Efficient Encryption and Compression System for Grayscale and Color Images B. Sahaya Jenila1, S. Ashvini2, and Dr. B. Elizabeth Caroline3 Abstract - In this paper, an image encryption and compression system is designed for both grayscale and color images in order to make the image encryption more efficient. The Compression is done along with encryption to improve the security level. The proposed system is operated in error prediction domain and clustering process is done to provide high security. The lossless compression is achieved through Arithmetic coding approach to make an efficient compression. The two predictors namely Gradient Adjusted Predictor (GAP) and Accurate Gradient Selection Predictor (AGSP) are compared and its Peak-to-Signal Noise Ratio for different images are analyzed. This system is implemented using Matlab. Index Terms - Encryption and Compression, GAP, AGSP, Arithmetic coding. I. INTRODUCTION The image can be compressed when the correlation between one pixel and its neighbour pixels is very high, or the values of one pixel and its adjacent pixels are very similar. The data is first compressed and then encrypted in the sender side and to recover the data at the receiver side, the decryption is performed prior to decompression. The encryption then compression system is designed based on the error prediction clustering and random permutation technique [1]. The compression of the data is made for transmission after encrypting the data to make the data to be more efficient [2]-[6]. The Slepian-Wolf decoder is not more efficient for grayscale images so a Resolution Progressive Compression (RPC) is used for lower resolution images mainly [7]. Depending upon the number of images to be encrypted it is scalable [8]. The image encryption is done by pseudorandom permutation followed by the lossy compression which uses the coefficients generated from the orthogonal transform [9]. The lossy compression is performed to make the compression rate more but when compared with lossless compression it is not more worthy [10]. A Context-Based adaptive lossless image coding (CALIC) which comprise of pixel prediction technique, both for encryption and compression process [11]. The compression is done by using the side information that is present in the turbo codes [12]. The Compression is performed of binary sources with side information at the decoder side by using LDPC codes, the process of exploiting spatial correlation in pixel-domain distributed image compression [13], [14]. The encryption process is done by using the block ciphers namely Advanced Encryption Standard (AES) [15] and Data Encryption Standard (DES) [16]. Slepian-Wolf codes are used for decryption. Noiseless coding of correlated information sources can also be performed but the analysis is a very lengthy process [17]. Practical Distributed Source Coding and its application is used to compression the encrypted data [18]. The low-density parity-check (LDPC) [19] is used for compressing the encrypted image. Security is very less lossy compression. The video sequence compression can also be made but the losses occurred is more. The application inferred from the compressed data is used to improve the compression efficiency is performed along with the encrypted data [20]. The SCAN pattern analysis can also be used to compress the data after encryption [21]. Gradient prediction can be done to make the pixel values smoother. The four way prediction is used in Accurate Gradient Selection Prediction [25]. The drawbacks attained in this existing process is overcome by the proposing a Encryption then compression system. In-order to improve the compression efficiency and secrecy of the encrypted image the encryption process is done prior to compression. In the proposed work both the encryption and compression process is designed in the same system and the compression process is done followed by the encryption process. The encryption process is done through error prediction domain where as the compression process is done through Arithmetic Coding approach. II. PROPOSED SYSTEM Manuscript received Oct 15, 2011. B.Sahaya Jenila, Applied Electronics, IFET College of Engineering,(srimathi.oec@gamil.com).Villupuram, India, +919489694892 S. Ashvini, Applied Electronics, IFET College of Engineering, Villupuram, India, +919894304923., (ashvinisugu@gmail.com). Dr.B.Elizabeth Caroline, Electronics and Communication Engineering, IFET College of Engineering, Villupuram, India, +919443249952, (jayabhavaniece@gmail.com). The schematic representation of the image compression along with encryption process is shown in Figure 1. The entire operation starts initially from the error prediction domain and different process are performed later to encrypt and compress the image. 1 All Rights Reserved © 2012 IJSETR International Journal of Science, Engineering and Technology Research (IJSETR) Volume 1, Issue 1, July 2012 I + Encode and compress ∑ 3 6 9 16 Ie 4 7 10 13 1 8 11 14 2 5 12 15 (b)Row shift Prediction Fig 2.(a)(b). Representation of clusters after cyclic shift operation Fig 1. Encryption and compression system A. Image Encryption Procedure There are different steps involved in encryption of a image, namely Step 1: The pixel prediction for each image is done by using the predictor GAP [11] and AGSP [26]. For each pixel in image I, will be denoted as Ii,j so after the pixel prediction is done the predicted values will be given as I͞͞ i,j. Step 2: The difference between the actual pixel value and predicted pixel value is determined and it is replaced on the actual pixel. It is mapped within the range [0,255]. This process is known as mapping. ̅ e = Ii,j − Ii,j The key k value is predicted within the range 0 ≤ k ≤ 15. The concatenation of the encrypted image is based on this range. This process is known as random permutation. Step 5: By using the assembler all the clusters values are obtained in a encrypted bitstream Ie . I AGSP Mapping (1) The value of a pixel can be accurately predicted using a simple predictor of previously observed neighbour pixels. Step 3: After the mapping of errors is done, the error values are clustered into 16 groups, depending upon the error values. This process is known as clustering. Step 4: Each clusters are subjected to cyclic shift operations namely column shift Ck and row shift Rk separately. A fixed key value is given in common to all the clusters respectively. Clustering ……… k C1 C2 C16 Perm utatio n C͞͞1 Permu tation k k …………… C͞͞2 Permu tation C͞͞16 …… 1 5 9 13 2 6 10 14 3 7 11 15 4 8 12 16 Assembler Ie Fig.2 Actual representation of clusters Fig 3. Image encryption operation The initial stage of 16 cluster formation is shown in Fig.2. The Column shift Ck is applied to the clusters initially followed by the Row shift Rk. Fig.3 shows the cluster representation after the cyclic shift operation is performed. In Fig.3 the Schematic diagram for image encryption process is given. A 16 bit data will be obtained as the encrypted image. It is further subjected to compression. B. Image Compression Procedure Ck = [3 1 2 0] 13 1 5 9 14 2 6 10 11 15 3 7 (a) Column shift 4 8 12 16 At the compression stage the clusters C͞͞1 ,C͞͞2 , C͞͞3 ,…., C͞͞16 are segmented from the encrypted image Ie . In order to make a lossless compression an Adaptive Arithmetic Coding approach is followed. Since the random permutation changes only the location the values remain unchanged. So, depending upon the cluster values the bitstream B is generated. The entire bitstream B is denoted as, B = B1 B2 B3………….B16 (2) Rk = [2 3 0 1] 2 All Rights Reserved © 2012 IJSETR International Journal of Science, Engineering and Technology Research (IJSETR) Volume 1, Issue 1, July 2012 The reason for going with lossless compression is that, Lossy compression formats suffer from generation loss, repeatedly compressing and decompressing the file will cause it to progressively lose quality. This is in contrast with lossless data compression, where data will not be lost via the use of such a procedure. Due to this a loss less data can be transferred from one place to other. III . COMPARISON BETWEEN THE PREDICTORS F G H E C B I D A X Fig 5. Causal template for AGSP In AGSP, the pixel prediction is done in four directions namely in horizontal, vertical, 45⁰ and -45⁰ as shown in Figure 6. A. Gradient Adjusted Predictor The Gradient Adjusted Predictor (GAP) [11] is used to achieve smoothness of the pixel values that are present in an image. The pixel scanning is done to predict the pixel values. The raster scanning is done. Vertical -45⁰ . D G H C B I A X Horizontal 45⁰ Fig 4. Causal template for GAP Fig 4. shows the general template for the Gradient Adjusted Predictor. For a particular pixel X given in Fig 4. the pixel prediction is done on both the horizontal and vertical analysis. The dh and dv are the horizontal and vertical pixel values that are predicted respectively. The d h and dv are determined as, dh = │a − d│ + │b − c│ + │b − i│ (3) dv = │a − c│ + │b − g│ + │i − h│ (4) By obtaining the difference between dh and dv using the equation (3) and (4) the edges are predicted. There are three different ranges for weak edge, normal edge and sharp edge in both horizontal and vertical directions [11]. The value obtained is known as the pixel predicted value. The difference between this the actual pixel value and the predicted pixel value is known as the error obtained. B. Accurate Gradient Selection Predictor The Accurate Gradient Selection Predictor (AGSP) [25] is the proposed predictor that is used in the encryption and compression system that is designed. The advantage of AGSP over GAP is that it gives more accurate pixel predicted values so that the rate of loss of the encrypted image will be very less. The scanning of the pixel is done through raster scanning method. The causal template for AGSP is shown in Fig 5. In this X is the current pixel and the remaining variables are the neighboring pixels. Fig 6. Four direction Gradient Selection The pixel prediction is determined by using the variables dh , dv , dp , dn , Ch , Cv , Cp and Cn as shown in equations (5) – (12) , dh = (2x│a-d│+2x│b-c│+2x│b-i│+│g-f│+│g-h│+│c-e│) 9+1 …..(5) dv = (2x│a-c│+2x│b-g│+2x│i-h│+│d-e│+│c-f│) 7+1 (6) dp = (2x│b-a│+2x│b-h│+2x│c-d│+│c-g│) 6+1 (7) dn = (2x│a-e│+2x│b-f│+2x│i-g│) 5+1 (8) Ch = a (9) Cv = b (10) Cp = i (11) Cn = c (12) By using the parameters obtained from the above equations the predicted pixel value X͞ is calculated as, ̅= X (dmin 1 x Cmin 2 ) + (dmin 1 x Cmin 2 ) dmin 1 + dmin2 (13) 3 All Rights Reserved © 2012 IJSETR International Journal of Science, Engineering and Technology Research (IJSETR) Volume 1, Issue 1, July 2012 The equation 13, gives the value of the predicted pixel and the difference between the actual pixel value and the predicted pixel value gives the error value. IV. RESULTS The entire system is implemented through Matlab software. The comparison between the GAP and AGSP predictor is analyzed. A color image is chosen and it is processed through both the predictors. Fig 9. Mapped images of AGSP and GAP The resolution of the image is determined through the Peak-to-Signal Noise Ratio (PSNR). The resolution of the reconstructed image depends upon the PSNR value. The PSNR rate is calculated for both the predictors using the formula, PSNR = 10 x log 255∗255 MSE log 10 (14) The PSNR rate of the image processed through GAP is 5.9569 as analyzed from Fig. 10. But it is less when compared to the PSNR rate that is obtained through AGSP predictor. Fig 7. Original image Fig 7. shows the original image that is to be processed through both the systems. Due to get an efficient processing system color image is converted into grayscale initially and further processing is done. The converted grayscale image of the original image is shown in Fig 8. Fig 10. Features of an image obtained through GAP predictor Fig 8. Converted grayscale image The error values for all the corresponding pixel is calculated and the mapping process is done through both the predictors and the comparison between the two mapped images is shown in Fig 9. From Fig 11. It is proved that the PSNR rate of the image is higher when compared with the image processed through GAP predictor. The PSNR rate obtained through AGSP predictor is 6.4219. 4 All Rights Reserved © 2012 IJSETR International Journal of Science, Engineering and Technology Research (IJSETR) Volume 1, Issue 1, July 2012 ACKNOWLEDGMENT It’s our immense pleasure to express our deep sense of gratitude and indebtedness to our highly respected and esteemed Prof. B. Elizabeth Caroline (ECE) Department IFET College of Engineering, Tamilnadu. Her invaluable guidance, inspiration, constant encouragement sincere criticism and sympathetic attitude could make this paper possible. REFERENCES [1] [2] [3] [4] Fig 11. Features of an image obtained through AGSP predictor [5] [6] The Table 1 shows the entire comparison between the two GAP and AGSP predictor in general. Table I. Comparison between GAP and AGSP [7] [8] Parameters GAP AGSP MSE 1.6496e+04 1.6103e+04 PSNR 5.9569 6.0619 dh 3 2.7778 dv 10 2.2857 dp - 4 dn - 3.4000 Cn - 46 Cp - 44 Ch - 47 [15] Cv - 45 [16] [9] [10] [11] [12] [13] [14] [17] V. CONCLUSION [18] In this paper, an efficient image encryption and compression system is proposed through the error prediction domain and random permutation by using a new Accurate Gradient Selection Predictor. It is also proved that the new proposed predictor is more efficient than the Gradient Adjusted Predictor by calculating its Peak-to-Signal Noise ratio. The security of transmitting the encrypted images can be improved more through this proposed system. [19] [20] [21] [22] [23] Jiantao Zhou, Xianming Liu, Oscar C. Au, and Yuan Yan Tang,”Designing an Efficient Image Encryption-Then-Compression System via Prediction Error Clustering and Random Permutation” IEEE transactions on information forensics and security, vol. 9, no. 1,pp 39-50 January 2014 J. Zhou, X. Liu, and O. C. Au, “On the design of an efficient encryptionthen-compression system,” in Proc. ICASSP, 2013, pp. 2872–2876. M. Johnson, P. Ishwar, V. M. Prabhakaran, D. Schonberg, and K. Ramchandran, “On compressing encrypted data,” IEEE Trans. Signal Process., vol. 52, no. 10, pp. 2992–3006, Oct. 2004. D. Schonberg, S. C. Draper, and K. Ramchandran, “On compression of encrypted images,” in Proc. IEEE Int. Conf. Image Process., Oct. 2006,pp. 269–272. R. Lazzeretti and M. Barni, “Lossless compression of encrypted greylevel and color images,” in Proc. 16th Eur. Signal Process. Conf.,Aug. 2008, pp. 1–5. A. Kumar and A. Makur, “Distributed source coding based encryption and lossless compression of gray scale and color images,” in Proc.MMSP, 2008, pp. 760–764. W. Liu, W. J. Zeng, L. Dong, and Q. M. Yao, “Efficient compression of encrypted grayscale images,” IEEE Trans. Imag. Process., vol. 19,no. 4, pp. 1097–1102, Apr. 2010. X. Zhang, G. Feng, Y. Ren, and Z. Qian, “Scalable coding of encrypted images,” IEEE Trans. Imag. Process., vol. 21, no. 6, pp. 3108–3114,Jun. 2012. A. Kumar and A. Makur, “Lossy compression of encrypted image by compressing sensing technique,” in Proc. IEEE Region 10 Conf.TENCON, Jan. 2009, pp. 1–6. X. Zhang, “Lossy compression and iterative recobstruction for encrypted image,” IEEE Trans. Inf. Forensics Security, vol. 6, no. 1, pp. 53–58,Mar. 2011. X. Wu and N. Memon, “Context-based, adaptive, lossless image codec,” IEEE Trans. Commun., vol. 45, no. 4, pp. 437–444, Apr. 1997. A. Aaron and B. Girod, "Compression with side information using turbo codes," in Proc. IEEE Dala Compression Conj, Snowbird, UT, Apr. 2002, pp. 252-26. A. Liveris, Z. Xiong, and C. Georghiades, "Compression of binary sources with side information at the decoder using LDPC codes," IEEE Commun. Lett. vol. 6, no. 10, pp. 440--442, Oct.2002. D. Varodayan, A. Aaron, and B. Girod, "Exploiting spatial correlation in pixel-domain distributed image compression," in Proc. Picture Coding Symposium, Beijing, China, Apr. 2006. Advanced Encryption Standard (AES), FIPS PUB 197, Gaithersburg, MD, Denmark, Nov., 2001 Data Encryption Standard (DES), FIPS PUB 197, Washington, DC, 1977. D. Slepian and J. Wolf, “Noiseless coding of correlated information sources,” IEEE Trans. Inf. Theory, vol. IT-19, no. 4, pp. 471–480, Jul.1973. D. Schonberg, “Practical Distributed Source Coding and its Application to the Compression of Encrypted Data,” Ph.D. dissertation, Univ. California, Berkeley, 2007. R. G. Gallager, “Low Density Parity Check Codes,” Ph.D. dissertation, Mass. Inst. Technol., Cambridge, MA, 1963. D. Schonberg, S. C. Draper, C. Yeo, and K. Ramchandran, “Toward compression of encrypted images and video sequences,” IEEE Trans. Inf. Forensics Security, vol. 3, no. 4, pp. 749–762, Dec. 2008. N. Bourbakis and C. Alexopoulos, “Picture data encryption using SCAN patterns,” Pattern Recognit., vol. 25, no. 6, pp. 567–581, 1992. A. Moffat, R. Neal, and I. Witten, “Arithmetic coding revisited,” in Proc. Data Compression Conf., J. A. Storer and M. C. Cohn, Eds., 1995, pp.202–211. M. J. Weinberger, J. J. Rissanen, and R. B. Arps, “Applications of universal context modeling to lossless compression of 5 All Rights Reserved © 2012 IJSETR International Journal of Science, Engineering and Technology Research (IJSETR) Volume 1, Issue 1, July 2012 gray-scaleimages,” IEEE Trans. Image Processing, vol. 5, pp. 575–586, Apr. 1996. [24] X. Wu, “Lossless compression of continuous-tone images via context selection, quantization, and modeling,” IEEE Trans. Image Processing,vol. 6, May 1997. [25] Abdolrahman Attar , Reza Moradi Rad and Asadollah Shahbahrami “An Accurate Gradient-Based Predictive Algorithm for Image Compression”, MoMM2010 Proceedings. [26] J. Knezovic and M. Kovac, “Gradient Based Selective Weighting of Neighboring Pixels for Predictive Lossless Image Coding” 25th Int. Conf. on Information Technology Interfaces, June 2003. BIOGRAPHY B.Sahaya Jenila was born in Tamilnadu on 1992. She is a M.E. student of Applied Electronics department in IFET College of Engineering, Villupuram, India. She completed her Bachelor of degree in Electronics and Communication Engineering in Sri Manakula Vinayagar Engineering College, Puducherry, India in the year 2013. S.Ashvini was born in Tamilnadu on 1992. She is a M.E. student of Applied Electronics department in IFET College of Engineering, Villupuram, India. She completed her Bachelor of degree in Electrical and Electronics Engineering in Sri Manakula Vinayagar Engineering College, Puducherry, India in the year 2013. Dr. B. Elizabeth Caroline, M.E., Ph.D., is a Electronics and Communication Engineering graduate of 1992 Batch from Karunya Institute of Technology, Coimbatore .She obtained her Master degree in Communication systems in the year 1999 from Regional Engineering College (NIT), Trichy. She was awarded Ph.D. (Optical signal processing) by Anna University, Chennai, Tamil Nadu, India in 2010. She is having concurrent Teaching, Research and Industrial experience of two decades. She is working as a Professor of ECE department. She has published research papers in International Journals, National and International Conferences. Her areas of interest include digital signal processing, image processing, optical signal processing and optical computing. She is an active member of IEEE and a life member of ISTE and BES (Broad casting Engineers Society) .She is a recognized supervisor under the faculty of Information and Communication Engg, Anna University , Thiruchirapalli. She is guiding 2 research scholars in the area of image processing and wireless sensor network. She is acting as Doctoral Committee members for 2 research scholars. She is reviewer for few reputed international journals .She served as Chair-Person, Resource Person, Key Note Speaker for national and International Conferences. She visited Australia and Singapore. 6 All Rights Reserved © 2012 IJSETR