Color Image Compression Using EZW and SPIHT Algorithm Ms. Swati Pawar 1, Mrs. Adita Nimbalkar 2, Mr. Vivek Ugale 3 swati.pawar@sitrc.org 1, adita.nimbalkar@sitrc.org 2, vivek.ugale@sitrc.org 3 Department of Electronics & Telecommunication Engineering Sindip Institute of Technology & Research Centre, Nasik 1, 2, 3 1, 2, 3 Abstract Image compression is now essential for applications such as transmission and storage in data bases. A fundamental goal of data compression is to reduce the bit rate for transmission or storage while maintaining an acceptable fidelity or image quality. Image compression is used to minimize the amount of memory needed to represent an image. Images often require a large number of bits to represent them, and if the image needs to be transmitted or stored, it is impractical to do so without somehow reducing the number of bits. The problem of transmitting or storing an image affects all of us daily. Embedded zerotree wavelet (EZW) coding, introduced by J. M. Shapiro, is a very effective and computationally simple technique for image compression. Moreover, they present a new and different implementation based on set partitioning in hierarchical trees (SPIHT), which provides even better performance than their previously reported extension of EZW that surpassed the performance of the original EZW. Keywords EZW, SPIHT, Wavelet Decomposition. I. INTRODUCTION Image compression techniques, especially nonreversible or lossy ones, have been known to grow computationally more complex as they grow more efficient, confirming the tenets of source coding theorems in information theory that a code for a (stationary) source approaches optimality in the limit of infinite computation (source length). Notwithstanding, the image coding technique called embedded zerotree wavelet (EZW), introduced by J.M. Shapiro[1], interrupted the simultaneous progression of efficiency and complexity. This technique not only was competitive in performance with the most complex techniques, but was extremely fast in execution and produced an embedded bit stream. With an embedded bit stream, the reception of code bits can be stopped at any point and the image can be decompressed and reconstructed. Following that significant work Said A, and Pearlman W A, proposed an alternative explanation of the principles of its operation, so that the reasons for its excellent performance can be better understood. This has been published in A new fast and efficient image coder based on set partitioning in hierarchical trees, IEEE Trans. Circuits and Systems for Video Technology, VOL. 6, NO. 3, June, 1995: 243-250[2]. In the past decades, the discrete cosine transform (DCT) has been the most popular for compression because it provides optimal performance and can be implemented at a reasonable cost. Several compression algorithms, such as the JPEG standard for still images and the MPEG standard for video images are based on DCT. However, the EZW [1], the SPIHT [2], the SPECK, the EBCOT algorithms and the current JPEG 2000 standard are based on the discrete wavelet transform (DWT) [7].DWT has the ability to solve the blocking effect introduced by DCT, it also reduces the correlation between the neighboring pixels and gives multi scale sparse representation of the image. II. WAVELET TRANSFORMATION OF IMAGES Wavelets are mathematical functions that decompose data into different frequency components, and then study each component with a resolution matched to its scale. They have advantages over traditional Fourier [4] methods in analyzing physical situations where the signal contains discontinuities and sharp spikes. Wavelet transform uses a sub-band coder, to produce a pyramid structure where an image is decomposed sequentially by applying power complementary low pass and high pass filters and then decimating the resulting images. These are one-dimensional filters that are applied in cascade (row then column) to an image whereby creating a four-way decomposition: LL (low-pass then another low pass), LH (low pass then high pass), HL (high and low pass) and finally HH (high pass then another high pass). Fig. 1: Wavelet Transform The resulting LL version is again four-way decomposed as shown in Figure 1. Each level has various bands information IJETT ISSN: 2350 0808 September 2014 Volume 1 Issue 1 164
such as low low, low high, high low, and high high frequency bands. Furthermore, from these DWT coefficients, the original image can be reconstructed. This reconstruction process is called the inverse DWT (IDWT). III. EZW ALGORITHM The EZW algorithm was one of the first algorithms to show the full power of waveletbased image compression. An EZW encoder is an encoder specially designed to use with wavelet transforms. The EZW encoder was originally designed to operate on images (2D-signals) but it can also be used on other dimensional signals [1]. The EZW encoder is based on progressive encoding to compress an image into a bit stream with increasing accuracy. This means that when more bits are added to the stream, the decoded image will contain more detail. Progressive encoding is also known as embedded encoding, which explains the E in EZW. The EZW encoder is based on two important observations: 1. Natural images in general have a low pass spectrum. When an image is wavelet transformed the energy in the sub bands decreases as the scale decreases (low scale means high resolution), so the wavelet coefficients will, on average, be smaller in the higher sub bands than in the lower sub bands. This shows that progressive encoding is a very natural choice for compressing wavelet transformed images, since the higher sub bands only add detail. is also zero and labelled as end-of-block. The EZW algorithm encodes the tree structure so obtained. This results in bits that are generated in order of importance, yielding a fully embedded code. The main advantage of this encoding is that the encoder can terminate the encoding at any point thereby allowing a target bit rate to be met exactly. To arrive at a perfect reconstruction the process is repeated after lowering the threshold until the threshold has become smaller than the smallest coefficient to be transmitted. Similarly, the decoder can also stop decoding at any point resulting in the image that would have been produced at the rate of the truncated bit stream. One important thing is however still missing : the transmission of the coefficient positions. Indeed, without this information the decoder will not be able to reconstruct the encoded signal (although it can perfectly reconstruct the transmitted bit stream). It is in the encoding of the positions where the efficient encoders are separated from the inefficient ones. EZW encoding uses a predefined scan order to encode the position of the wavelet coefficients through the use of zerotrees many positions are encoded implicitly. Several scan orders are possible, as long as the lower sub bands are completely scanned before going on to the higher sub bands. 2. Large wavelet coefficients are more important than small wavelet coefficients. These two observations are exploited by encoding the wavelet coefficients in decreasing order, in several passes. For every pass a threshold is chosen against which all the wavelet coefficients are measured. If a wavelet coefficient is larger than the threshold it is encoded and removed from the image, if it is smaller it is left for the next pass. When all the wavelet coefficients have been visited the threshold is lowered and the image is scanned again to add more detail to the already encoded image. This process is repeated until all the wavelet coefficients have been encoded completely or another criterion has been satisfied (maximum bit rate for instance). A zerotree is a quad-tree of which all nodes are equal to or smaller than the root. The tree is coded with a single symbol and reconstructed by the decoder as a quad-tree filled with zeroes. The root has to be smaller than the threshold against which the wavelet coefficients are currently being measured. The EZW encoder exploits the zerotree based on the observation that wavelet coefficients decrease with scale. The zerotree is based on the hypothesis that if a wavelet coefficient at a coarse scale is insignificant with respect to a given threshold t 0, then all wavelet coefficients of the same orientation in the same spatial location at a finer scales are likely to be insignificant with respect to t 0. The idea is to define a tree of zero symbols which starts at a root which Fig. 2: Scanning Order The scan order, as shown in Figure 2, seems to be of some influence of the final compression result. The algorithm produces excellent results without any pre-stored tables or codebooks, training, or prior knowledge of the image source. The unavoidable artifacts produced at low bit rates using this method are typical of wavelet coding schemes coded to the same PSNR. However, subjectively these are not objectionable as the blocking effects typical of block transform coding schemes. EZW encoder does not really compress anything; it only reorders wavelet coefficients in such a way that they can be compressed very efficiently. An EZW encoder should therefore always be followed by a symbol encoder, for instance an arithmetic encoder because of the above mention reason. The next scheme, called SPIHT, is an improved form of EZW which achieves better compression and performance than EZW. IJETT ISSN: 2350 0808 September 2014 Volume 1 Issue 1 165
IV. SPIHT ALGORITHM (2) One of the most efficient algorithms in the area of image compression is the Set Partitioning in Hierarchical Trees (SPIHT).The SPIHT [3] image coding algorithm was developed in 1996 by Said and Pearlman and is another more efficient implementation of the embedded zerotree wavelet (EZW)[ algorithm by Shapiro. There exists a spatial relationship among the coefficients at different levels and frequency sub-bands in the pyramid structure. A wavelet coefficient at location (i,j) in the pyramid representation has four direct descendants (off-springs) at locations: where Ci,j is the wavelet coefficient at the nth bit plane, at location (i,j)of the,τm subset of pixels, representing a parent node and its descendants. If the result of the significance test is yes an S flag is set to 1 indicating that a particular test is significant. If the answer is no, then the S flag is set to 0, indicating that the particular coefficient is insignificant. This is represented by equation (3). (3) and each of them recursively maintains a spatial similarity to its corresponding four off-spring. This pyramid structure is commonly known as spatial orientation tree. If a given coefficient at location (i,j) is significant in magnitude then some of its descendants will also probably be significant in magnitude. The SPIHT algorithm takes advantage of the spatial similarity present in the wavelet space to optimally find the location of the wavelet coefficient that are significant by means of a binary search algorithm. The SPIHT algorithm sends the top coefficients in the pyramid structure using a progressive transmission scheme. This scheme is a method that allows obtaining a high quality version of the original image from the minimal amount of transmitted data. As illustrated in Figure 3, the pyramid wavelet coefficients are ordered by magnitude and then the most significant bits are transmitted first, followed by the next bit plane and so on until the lowest bit plane is reached. It has been shown that progressive transmission can significantly reduced the Mean Square Error (MSE) distortion for every bit-plane sent. Bit Row Sign s s s s s s s s s MSB 5 1 1 0 0 0 0 0 0 0 4 1 1 0 0 0 0 0 3 1 1 1 0 0 2 0 1 LSB 0 Fig. 3: Bit-plane ordering and transmission scheme To take advantage of the spatial relationship among the coefficients at different levels and frequency bands, the SPIHT coder algorithm orders the wavelets coefficient according to the significance test defined as: After the wavelet transform is applied to an image, the main algorithm works by partitioning the wavelet decomposed image into significant and insignificant partitions. Wavelets coefficients which are not significant at the nth bit-plane level may be significant at (n-1) th bit-plane or lower. This information is arranged, according to its significance, in three separate lists: list of insignificant sets (LIS), the list of insignificant pixels (LIP) and the list of significant pixels (LSP). In the decoder, the SPIHT algorithm replicates the same number of lists. It uses the basic principle that if the execution path of any algorithm is defined by the results on its branching points, and if the encoder and decoder have the same sorting algorithm then the decoder can recover the ordering information easily. 1. Initialization: Output ; set the LSP as empty list and add the coordinates to the LIP and only those with descendents also to the LIS, as type A entries. 1. Sorting Pass: 2.1 for each entry in the LIP do: 1.1.1 Output 1.1.2 If then move to the LSP and output the sign of 2.2 for each entry in the LIS do: 2.2.1 if the entry is of type A then output if then * for each O do : o Output If o If then add to the LSP and output the sign of ; o If then add end of then to the end of LIP * If Output move to the IJETT ISSN: 2350 0808 September 2014 Volume 1 Issue 1 166
the LIS as entry of type, and go to step 2.2.2; otherwise remove entry from the LIS 2.2.2 if the entry is of type B then Output If * add each O to the end of the LIS as entry of type A * remove from the LIS 3. Refinement Pass: For each entry in the LSP except those included in the last sorting pass (i.e. with the same n), output the nth most significant bit of. Fig. 4: Method of Color Image Compression 4. Quantization step update: decrement n by 1 and go to step 2 Notations used in the algorithm are defined as follows: : set of coordinates of the off-spring (i,j) : set of coordinates of all descendants (i,j) : set of coordinates of all tree roots in the highest level of the pyramid = - V. COLOR IMAGE COMPRESSION USING SPIHT ALGORITHM Color image compression is very important in today s communication era because most of the images are in color. Color images take more space for storage. Also without compression it may take long time for transferring images through internet. Figure 4 shows the model used for compressing color images. Lena true color image (RGB 24 bit) is used. Image is converted to YCbCr format. YCbCr or Y CbCr, sometimes written YC B C R or Y C B C R, is a family of color spaces used as a part of the color image pipeline in video and digital photography systems. Y is the luma component and C B and C R are the blue difference and reddifference chroma components. Y (with prime) is distinguished from Y which is luminance, meaning that light intensity is non-linearly encoded using gamma correction. Figure 6 shows YCbCr image. After converting wavelet analysis is done for Y, C B, C R. Then the data is compressed using SPIHT algorithm. Lena image shown below is used for analysis. For calculating PSNR only Y (Luminance) component of original and reconstructed image is used. Lena image is used for analysis [6]. Fig. 5: Original Lena Image (RGB) Fig. 6: RGB to YCbCr IJETT ISSN: 2350 0808 September 2014 Volume 1 Issue 1 167
VI. CONCLUSION Fig. 7: Different Color components of Lena Image RESULT Following are the result for different wavelets for EZW Algorithm and SPIHT Algorithm. TABLE I Wavelets PSNR(dB) PSNR(dB) EZW SPIHT Bior1.5 28.69 db 38.04 db db1 28.70 db 38.83 db coif1 29.57 db 40.40 rbio1.1 28.70 db 38.83 SYM20 30.00 db 41.08 haar 28.70 db 38.83 Initially we studied EZW and SPIHT algorithm for image compression. The SPIHT algorithm uses the principles of partial ordering by magnitude, set partitioning by significance of magnitudes with respect to a sequence of actively decreasing thresholds, ordered bit plane transmission and self- similarity across scale in an image wavelet transform. The realization of these principles in matched coding and decoding algorithm is a new one and is shown to be more effective than in previous implementations of EZW coding. We can see that the recovered image is visually very close to the original image. If all the bit planes are used then the original image is recovered completely (up to rounding errors). The PSNR obtained in case of SPIHT is improved as compared to EZW algorithm from different wavelets. REFERENCES [1] J. M. Shapiro, Embedded image coding using zerotrees of wavelets coefficients, IEEE Trans. Signal Processing, vol. 41, pp. 3445-3462, Dec. 1993. :243-250. [2] A. Said, and W A Pearlman, A new fast and efficient image coder based on set partitioning in hierarchical trees, IEEE Trans. Circuits and Systems for Video Technology, Vol.6,No.3, pp243-250, 1996. [3] Said A, and Pearlman W A, A new fast and efficient image coder based on set partitioning in hierarchical trees, IEEE Trans. Circuits and Systems for Video Technology, VOL. 6, NO. 3, June,1995: 243-250. [4] Rafael C. Gonzalez and Richard E. Woods, Digital Image Processing, Pearson Education, Englewood Cliffs, 2002. [5] K.Sayood, Introduction to Data Compression, 2nd edition, Academic Press, Morgan Kaufman Publishers, 2000. [6] Sadashivappa, Mahesh Jayakar, K.V.S Anand Babu,Dr. Srinivas K, Color Image Compression using SPIHT Algorithm, International Journal of Computer Applications (0975 8887) Volume 16 No.7, February 2011.pp 34-42. [7] M. Antonini, M. Barlaud, and P. Mathieu, etc., Imagecoding using wavelet transform, IEEE Trans. Image Processing, 1992(1): pp205-220. [8] G. Sadashivappa, K. Anandbabu, Performance Analysis OF Image Coding Using Wavelets, IJCSNS International Journal of Computer Sci 144 ence and Network Security, Vol.8, PPN. 144-151, 2008. [9] R. Sudhakar, R. Karthiga and S.Jayaraman, Image compression using Coding of Wavelet Coefficients: A Survey, ICGST-GVIP Journal, Vol. 5, PPN.25-38, 2005. [10] Mallat A Theory for Multi-resolution Signal Decomposition : The wavelet representation, IEEE Pattern Analysis and Machine Intelligence, Vol.11,no.7,pg.674-693,1989. Fig. 8: Reconstructed Lena Image for Bior1.5 by EZW IJETT ISSN: 2350 0808 September 2014 Volume 1 Issue 1 168