An Image Compresson Algorthm based on Wavelet Transform and LZW Png Luo a, Janyong Yu b School of Chongqng Unversty of Posts and Telecommuncatons, Chongqng, 400065, Chna Abstract a cylpng@63.com, b y27769864@sna.cn In mage compresson, the compresson rate of the tradtonal wavelet transform s low, and the tme of both compresson and decompresson s too long whle tradtonal compresson codng method s used. In order to solve problems above, a compresson algorthm for mage combne wavelet transform wth LZW was proposed. In ths algorthm, a low frequency component and three hgh-frequency components of a mage are obtaned by usng wavelet transform method. Then the low-frequency component that has been quantfed wth dfferent degrees was converted to a one-dmensonal vector as well as every hgh-frequency component, and the coeffcents wll be dfferentated three tmes to be compressed wth LZW compresson algorthm. The results of test prove that the algorthm proposed n ths paper can combne the advantages of both wavelet transform and LZW and optmze t. The method wll facltate the mage transmsson and mage storage. Keywords Wavelet Transform, Image Compresson, LZW Compresson Algorthm, Quantzaton, Encodng.. Introducton Wth the rapd development of computer technology, electronc nformaton technology and communcaton technology, the mage nformaton can be used everywhere. However, the large amount of nformaton contaned n the mage nformaton brngs great dffcultes to the storage, processng and transmsson. Therefore, mage compresson s very mportant and necessary []. To explore more effcent and better compresson performance of mage compresson codng technology for mage data storage and transmsson s of great sgnfcance. Dscrete wavelet transform has been wdely used n the feld of mage processng [2], such as font recognton, mage denosng, etc.. Wavelet transform of the mage sgnal s decomposed nto low and hgh frequency component, and pxel value n low frequency component s approxmate value, the other three sub sgnal dsplay vertcal, horzontal and dagonal [3] mage detals. LZW s a dctonary-based compresson algorthm that does not need to statstc the source when t s used. It can generate the encodng dctonary and the decodng dctonary adaptvely, and t s especally sutable for encodng the repetton character or character strng [4]. In [5], a Huffman-based vector quantzaton mage compresson algorthm s used to effectvely mprove the data compresson rato. However, snce the same status codebook s generated n the same sze as the man codebook and Blocks must generate dfferent status codebooks, the process wll requre very long tme to encode. An mproved LZW algorthm s used n [6] and a parallel wavelet tree codng method based on CUDA s proposed and n [7], whch acheves the lossless compresson of mages. But n many applcatons, a certan degree of lossy compresson of the mage s allowed. In ths paper, accordng to the characterstcs of wavelet decomposton mage, the hgh-frequency sgnals are quantzed n dfferent degrees, and the dfference between adjacent pxel values s obtaned three tmes. A large number of zero coeffcents are obtaned for compresson wth LZW algorthm. The method can mprove the compresson effcency, as well as shorten the compresson 76
tme. The method proposed n ths paper can mprove the mage transmsson rate and reduce the storage memory. 2. Algorthm prncple 2. Dscrete Wavelet Transform If we set an mage sgnal whose sze s Nx Ny to be f ( x, y ), the two-dmensonal dscrete wavelet transform formula of the sgnal s as follows: Where j 0 Nx Ny W ( j, m, n) f ( x, y) ( x, y) () 0 j0, m, n NxNy x0 y0 Nx Ny W ( j, m, n) f ( x, y) j, m, n( x, y) NxNy H, V, D 77 x0 y0 (2) s an arbtrary startng scale, W ( j0, m, n) coeffcents defne an approxmaton at scale, and W ( j, m, n) coeffcents add detals of horzontal (H), vertcal (V) and dagonal (D) drectons to j j 0. J =, 2,..., J- and m, n = 0,, 2,..., correspondng wavelet functon. Two dmensonal dscrete wavelet transform s shown below: j 2 H, V, D jj0 m n - are always selected. ( xy, ), j0, m, n,,( xy j m n, ) s f ( x, y) W ( j0, m, n) j0, m, n( x, y) NxNy NxNy m n W ( j, m, n) ( x, y) 2.2 Selecton of wavelet bases. How to choose a sutable wavelet base s an mportant and dffcult problem n the applcaton of wavelet [8]. Comparson of the characterstcs of commonly used wavelet bass s shown n Table [9]. These features are related to how to select the approprate wavelet base. Table Wavelet base and ts characterstcs Wavelet bass Vanshng moment Orthogonalty Tght support Symmetry haar Orthogonal Symmetry db N Orthogonal 2N- Approxmate symmetry bor Nr- Orthogonal 2Nr+ Asymmetry cof 2N Orthogonal 6N- Approxmate symmetry sym N Orthogonal 2N- Approxmate symmetry haar Orthogonal Symmetry Haar wavelet structure s smple [2], and can be fast decomposton and reconstructon. In the compresson of mage data, the mage s decomposed and reconstructed drectly by haar (or db, bor.) wavelet. The obtaned mage s almost completely nvarable but other wavelet bases wll brng some error. In order to facltate the observaton of the effect of ths algorthm, ths paper chooses haar wavelet bass as the wavelet base of mage data compresson. 2.3 LZW compresson and decompresson algorthm LZW (Lempel Zv Welch) s the earlest wdely used general data compresson method on computers [0]. LZW s a dctonary encodng, s to use the repeatablty n the date to acheve compresson. The specfc mplementaton steps of LZW codng algorthm are as follows []: () Intalzng the dctonary, clearng the prefx P; j, m, n (3)
(2)Readng the next character as the current character C, and then format entry <P, C>; (3) To determne whether the entry <P, C> s n the dctonary; If the entry s n, then we assgn the number of the entry <P, C> to P; 2 If entry s not n, we need add the entry <P, C> nto the dctonary, and let P = C, then output P; (4)To determne whether the strng table s full or has been completed codng; If the code s full or complete, we clear the dctonary, loop steps () to (4). 2 Otherwse, we set the end code. (2) If not, we output the encoded data stream Related to P. End of encodng. LZW decodng s the nverse of LZW codng. When we execute the LZW decodng, we need loop read the code, and output the strng correspondng to the code n the strng table, and add a new tem to the table. LZW algorthm has the advantage of smple logc and fast achevng. The dsadvantage s that generaton and search of dctonary s based on sequental nsert and retreval mode, f we need to deal wth a large amount of data, the algorthm wll reduce the effcency of the search. 3. Algorthm Flow n the paper Ths paper presents a wavelet transform and LZW algorthm combned mage compresson algorthm flow shown n Fgure. The orgnal mage(2m*2n) Wavelet transform Low frequency coeffcent(m*n) Convertng to one dmenson vector Dfferencng three tmes Hgh frequency coeffcent(m*n) Respectvely quantfed LZW encodng Reconstructed mage(2m*2n) Inverse wavelet transform Convertng to M*N matrx Summatng three tmes LZW decodng Fgure : Algorthm Flowchart Specfc steps are as follows: () The mage s decomposed by wavelet to get the low frequency coeffcents and the 3 hgh frequency coeffcents of horzontal, vertcal and dagonal drectons. (2)The hgh-frequency coeffcents were quantfed. The mage nformaton s transformed and encoded to obtan a seres of transform coeffcents. These coeffcents have a large coverage area. To reduce the number of bts ndcatng the coeffcent, the values wthn a certan range are classfed and represented by the same data. The process s called quantfcaton. In ths paper, the process of reducng the sze of the pxel value n the mage to an nteger near /n of the orgnal value s referred to smply as /n quantzaton. The quantzaton process wll nevtably produce a large amount of same data. In ths paper, we use the method of /2 quantzaton to quantze the horzontal and vertcal components and /4 quantzaton to quantze the dagonal component for the feature of wavelet transform decomposton mage (3) The low-frequency coeffcent matrx and the quantzed hgh-frequency coeffcent matrx are subjected to the followng processng: Frst, convertng the matrx to a one-dmensonal vector, and then obtanng the dfference between the adjacent two numbers of the one-dmensonal vector (the next number s subtracted from the prevous number) to form a new one-dmensonal vector. And then repeat ths step on the new one-dmensonal vector after 3 tmes we get a one-dmensonal 78
vector, the vector contans a large number of 0 value. The value of the vector wll be compressed by LZW encodng to get bt stream. The frst number of each new vector s retaned to use n subsequent nverse operatons. Because the tme we use normal LZW algorthm to compress a mage s too long, the LZW compresson algorthm used n ths paper s the algorthm that the data s dfference processed three tmes the then usng normal LZW algorthm to compress t. The LZW decompresson algorthm contans three summaton processes. (4) Decompresson process s the nverse process of (3). The coeffcents obtaned by decompresson wll be used to rebuld the mage. 4. Result and Dscusson 4. Evaluaton Crtera for Compresson 4.. Subjectve evaluaton crtera Subjectve evaluaton s a knd of test to determne the system performance drectly usng the subjectve response of the vewer to the system mage of the test system [2]. Subjectve evaluaton crtera are shown n Table 2 [3]. Table 2 Subjectve evaluaton crtera score Evaluaton level Evaluaton scale 5 excellent Very hgh qualty mage 4 good Hgh qualty mages that do not affect the vewng 3 medum Image dstorton less, slghtly affect the vewng 2 poor Image dstorton, affect the vewng bad Image dstorton too much, serously affectng the vewng 4..2 Objectve evaluaton crtera Ths paper takes fve ndcators (T, T2, compresson rate, PSNR and MSE) to measure the compresson effect. In the experment, the tme T ndcates the tme between the orgnal mage and the LZW codng s completed. (If there s only the wavelet transform, T represents the tme of usng wavelet transform to decompose the orgnal mage. Other thngs later n the text lke ths). The tme T2 represents the tme from the begnnng of LZW decodng to the mage reconstructon s completed (Stuaton s lke above). The compresson rato, MSE (Mean Square Error), PSNR (Peak Sgnal to Nose Rato) are defned as follows: ()Compresson rato (Rt, Rm) Compresson rato of reconstructed mage: Rt= s s Compresson rato of codng: Rm= l (5) l 2 Where s represents the number of reconstructed mage bts and s 2 represents the orgnal mage bt number. And l represents the length after LZW compresson, l 2 represents the codng length before compresson The smaller the Rt, the greater the degree of mage compresson. If Rt=, the mage s lossless compresson. The smaller the Rm, the greater the degree of encodng and compresson, and the compresson effect s better. (2)Mean Square Error (MSE) If a gray mage contans Nx Ny pxel, then 2 (4) 79
Where ( j), MSE f fˆ j NxNy Nx Ny 2 [ (, j) (, )] (6) 0 j 0 s the coordnate value of each pxel of the mage, [0, Nx ], j [0, Ny ], f ˆ(, j) f(, j) s the value of each coordnate pxel of the orgnal mage, and s the coordnate pxel value of the reconstructed mage. Obvously, the larger the MSE, the greater the mage dstorton. (3) Peak Sgnal to Nose Rato (PSNR) 255255 PSNR 0lg( ) (7) MSE The hgher the peak sgnal to nose rato s, the smaller the loss of the reconstructed mage, that s, the better the qualty of the reconstructed mage. 4.2 Expermental results and analyss Wth a sze of 256*256 Lena n the experment, the orgnal mage s shown n Fgure 2, after wavelet decomposton of the mage s shown n Fgure 3.Can be found on behalf of low-frequency mage decomposton n the mage on the upper-left secton of the mage s the most close to the orgnal. And the lower-rght secton whch represent the dagonal component has the largest gap between the orgnal. Ths quanttatve method proposed n the paper s based on ths feature. Fgure 2: Orgnal mage Fgure 3:Wavelet decomposton of a layer Fgure 4:Wavelet decomposton and Reconstructon Fgure 5:LZW compresson and decompresson 80
Fgure 6: Wavelet +LZW Fgure 7: Wavelet + /2 quantzaton Fgure 8: Wavelet + quantfcaton of ths artcle Fgure 9: Wavelet + /2 quantzaton + LZW Fgure 0: Wavelet + quantfcaton of ths paper + LZW Fgure 4 s reconstructed by decomposed pxel value matrx whch decomposed by wavelet n a layer from orgnal mage. (Correspondng to Method of Table 3 and the followng method omts the term "Table 3"). Fgure 5 s decompressed from vector from the orgnal mage s compressed wth the LZW algorthm n the paper (Method 2).We can obtan four coeffcent matrces after decomposton of the mage wth wavelet, whch wll be compressed to a vector wth the LZW algorthm. Then the vector wll be decompressed and reconstruct to mage shown n Fgure 6 (method 3). After wavelet decomposton, the hgh frequency coeffcents wll be respectvely /2 quantfed to three new coeffcent matrces whch wll be reconstructed to mage n Fgure 7 wth low frequency coeffcent together(method 4). Compare to method 4, f only the dagonal partal coeffcent s /4 quantfed, 8
fnally we wll obtan mage n Fgure 6. On the bass of method 4 and method 5, the quantzed coeffcents are compressed by the LZW algorthm to three vectors. The vectors wll be decompressed and reconstructed to mage n Fgure 9 and Fgure 0 wth low frequency coeffcent (Methods 6 and 7).Compare wth orgnal mage n Fgure 2, mages n Fgure 4, Fgure 5, Fgure 6 are very hgh qualty mages. Based on subjectve evaluaton crtera, evaluaton level of the mages s excellent and can get 5 ponts. Compared wth the orgnal fgure Image n Fgure 7, Fgure 8, Fgure 9, Fgure 0 s a bt fuzzy, but the evaluaton level s good. The mages are stll hgh-qualty mages, and do not affect the vewng, can get 4 ponts. In order to facltate the objectve evaluaton, the above methods are tested to obtan the objectve evaluaton ndex data whch we base on establsh a table as shown n table 3. As can be seen from Table 3, mean square error between decompressed map and the orgnal mage s 0 n method and method 2, the mage s not dstorton. From the data obtaned by methods, 4, and 5, even f the quanttatve process s added, the total tme of wavelet decomposton and reconstructon s less than 0. second, whch s almost neglgble. If only the use of LZW algorthm, the compresson tme wll reach 547.6986 seconds, but the LZW algorthm has the advantage of data compresson and lossless recovery. In method 3, compresson and decompresson tme s greatly reduced by combnng wavelet and LZW algorthm, but Rm s hgher than that of LZW algorthm only, and the compresson effect s worse. Because the mage s decomposed wth wavelet and then s compressed wth the LZW algorthm respectvely, the same data between the varous parts of the mage can no longer be compressed together. In order to solve the problem of over-tme n method 2 and the problem that the compresson rate of method 3 s ncreased compare to method 3, n ths paper we adopts the method of addng quantzaton process to mprove the method 3. In contrast to method 4 and method 5 (or method 6 and method 7), t can be seen that the quantzaton method used n ths paper s more advantageous than the hgh-frequency quantzaton n all aspects. The compresson rato (Rm) of the method 6 and method 7 s lower than that of the method 2, and the requred tme (T, T2) are shorter. Method 7 s the method proposed n ths paper for the above analyss results. From the expermental results, we know ths method can compress the wavelet decomposton data of the mage to 0.45 tmes of orgnal mage, and the compresson tme s shorter than LZW algorthm, only 0.26 tmes of the latter, the decompresson tme s also only 0.45 tmes of the latter. In all lossy compresson methods, the mean square error (MSE) of method 7 s the smallest and the peak sgnal-to-nose rato (PSNR) s the hghest. And the effectveness of the proposed algorthm n the paper s verfed. Table 3 Comparson of compresson effects of several methods Method MSE PSNR Rt Rm T T2 0.00 35.90.00 0.0 0.03 2 0.00.00 0.47 547.70 2.29 3 0.00 52.94.00 0.63 234.24.52 4 0.05 27.72 0.88 0.0 0.03 5 08.3 27.79 0.85 0.0 0.03 6 0.6 27.7 0.89 0.47 49.04.6 7 08.3 27.79 0.85 0.45 42.32.06 5. Concluson The mage compresson algorthm n ths paper combne the wavelet transform and LZW has the advantages of small reconstructon error, short compresson tme, low compresson rato and so on, whch can make up the defcency of tradtonal mage compresson algorthm. In ths paper, the mage s decomposed by wavelet transform, the hgh frequency data s processed by dfferent quantzaton, and then the quantzaton coeffcent wll be compressed wth the LZW algorthm.ths algorthm can effectvely mprove the compresson effcency compare to tradtonal mage 82
compresson algorthm. The algorthm proposed n ths paper can help to reduce the mage memory and mprove the mage transmsson speed. References [] Tan Y M, Cao H, Tan J B, et al. A Study of Image Compresson Technque Based on Wavelet Transform [C] // Internatonal Conference on Genetc & Evolutonary Computng. IEEE Computer Socety, 200: 826-828. [2] Tabassum F, Islam MI, Amn M R. A smplfed mage compresson technque based on Haar Wavelet Transform [C] // Electrcal Engneerng and Informaton Communcaton Technology (ICEEICT), 205 Internatonal Conference on. IEEE, 205: -9. [3] Rajasekhar V, Vashnav V, Koushk J, et al. An effcent mage compresson technque usng dscrete wavelet transform (DWT) [C] // Electroncs and Communcaton Systems (ICECS), 204 Internatonal Conference on. IEEE, 204: -4. [4] BI Yong-cheng.Comparson of several lossless compresson algorthms n multmeda data processng [J]. Keyu, 200 (0): 9-20.(n Chnese) [5] DENG Hong-gu, GUO Sheng-we, LI Zh-jan.Vector-based mage compresson algorthm based on Huffman codng [J]. Computer Engneerng, 200, 36 (4). (n Chnese) [6] Xa Png, Ma Qanru, Pan Hongxa. Lossless Compresson Converson of BMP Image Based on Improved LZW Algorthm [J].Technology and Management of Machnery Management, 200, 25 (3): 78-79. (n Chnese) [7] Ao J, Mtra S, Nutter B. Fast and effcent lossless mage compresson based on cuda parallel wavelet tree encodng [C] // Image Analyss and Interpretaton (SSIAI), 204 IEEE Southwest Symposum on. IEEE, 204: 2- twenty four. [8] Cu H, Song G. Study of the Wavelet Bass Selectons [M] // Computatonal Intellgence and Securty. Sprnger Berln Hedelberg, 2006: 009-07. [9] Zhang Fengyuan, Lan L, Zou Ja, et al. Study of wavelet transform combned wth LZW compresson algorthm [J]. JOURNAL OF BEIJING UNIVERSITY OF CHEMICAL TECHNOLOGY, NATURAL SCIENCE EDITION, 203, 40 (2): 00-05. (n Chnese) [0] Pm. N, Chezan R M. Behavoral Study of Data Structures on Lempel Zv Welch (LZW) Data Compresson Algorthm and ITS Computatonal Complexty [C] // Internatonal Conference on Intellgent Computng Applcatons. 204: 268-274. [] Zhuo Je, Zhang Y, Lu Xonghou, et al. A Compresson Method of Underwater Acoustc Data Based on Threshold Improved Integer Wavelet and LZW Algorthm [J] Acoustcs Technology, 205, 34 (2): 5-20. (n Chnese) [2] LI Qong, SHI Jun-sheng, MAO Xao-qun.Expermental study on subjectve evaluaton of optmal compresson rato of JPEG and JPEG2000 color mages [J].Journal of Image and Graphcs, 200, 5 (7): 042-046. (n Chnese) [3] WU Yun-ze. Wavelet transform based on mult-level tree set splttng mage compresson algorthm research [D]. Shenyang Unversty of Technology, 205. (n Chnese) 83