Study Of Various Lossless Image Compression Technique Mrs.Bhumika Gupta Computer Science Engg. Deptt. G.B.Pant Engg. College Pauri Garhwal,Uttrakhand Abstract This paper addresses the area of image compression as it is applicable to various fields of image processing. On the basis of evaluating and analyzing the current image compression techniques this paper presents the SIMPLE COMPRESSION TECHNIQUE (SCZ) approach applied to image compression. It also includes various benefits of using image compression techniques Keywords- Fractal, Self-similarity, IteratedFunction System(IFS) Newton Raphson Method, Newton Raphson Fractals. 1. INTRODUCTION TO IMAGE COMPRESSION Image compression can be defined as minimizing the size in bytes of a graphics file without degrading the quality of the image to an unacceptable level. This reduction allows more images to be stored in a given amount of memory space but the major benefit is the reduction of the time required for images to be sent over the Internet or downloaded from Web pages[1]. There are several different ways in which image files can be compressed like JPEG, GIF, PNG, fractals and wavelets.for Internet use, the two most common compressed graphic image formats are the JPEG format and the GIF format. The JPEG method is more often used for photographs, while the GIF method is commonly used for line art and other images in which geometric shapes are relatively simple[2]. Other method like fractals and wavelets offer higher compression ratios than the JPEG or GIF methods for some types of images. In near future PNG format will replace GIF format. 2. ERROR METRICS 2.1 Introduction Two of the error metrics used to compare the various image compression techniques are the 1.Mean Square Error (MSE) 2.Peak Signal to Noise Ratio (PSNR) The MSE is the cumulative squared error between the compressed and the original image the mathematical formula is- M N 2 1 ' (, ) (, ) MN y 1 x 1 MSE I x y I x y The PSNR is a measure of the peak error between the compressed and the original image the mathematical formula is- PSNR = 20 * log10 (255 / sqrt(mse)) where I(x,y) is the original image, I'(x,y) is the approximated version (which is actually the decompressed image) and M,N are the dimensions of the images. A lower value for MSE means lesser error, and as seen from the inverse relation between the MSE and PSNR, this translates to a high value of PSNR. 3. TYPE OF COMPRESSION There are two broad category of image compression: 1.Lossless compression 2.Lossy compression 4. LOSSY COMPRESSION It allows constructing an approximation of the original data, in exchange for better compression ratio. Methods for lossy compression: Color space: Reducing the color space to the most common colors in the image. The selected colors are specified in the color palette in the header of the compressed image. Each pixel just references the index of a color in the color palette, this method can be combined with dithering to avoid posterization[3]. Chroma subsampling: This takes advantage of the fact that the human eye perceives spatial changes of brightness more sharply than those of color, by averaging or dropping some of the chrominance information in the image[3]. Transform coding: This is the most commonly used method. In particular, a Fourier-related transform such as the Discrete Cosine Transform (DCT) is widely used. The more recently developed wavelet transform is also used extensively, followed by quantization and entropy coding[4]. Volume 2, Issue 4 July August 2013 Page 253
Fractal Compression: Fractal Image Compression technique identify possible self similarity within the image and used to reduce the amount of data required to reproduce the image. Traditionally these methods have been time consuming, but some latest methods promise to speed up the process[4]. 5. LOSSLESS COMPRESSION Lossless data compression is a class of data compression algorithm that allows the exact original data to be reconstructed from the compressed data. Lossless data compression is used in many applications. For example, it is used in the ZIP file format[2]. Lossless compression is used in cases where it is important that the original and the decompressed data be identical, or where deviations from the original data could be deleterious. Typical examples are executable programs, text documents, and source code. Some image file formats, like PNG or GIF, use only lossless compression, while others like TIFF and MNG may use either lossless or lossy methods[4]. Methods for lossless compression[1]: 1. Runlength encoding 2. Huffman encoding 3. LZW coding 4.SCZ coding 1.Run length encoding Run-length encoding (RLE) is a very simple form of data compression in which runs of data (that is, sequences in which the same data value occurs in many consecutive data elements) are stored as a single data value and count, rather than as the original run. This is most useful on data that contains many such runs: for example, simple graphic images such as icons, line drawings, and animations. It is not useful with files that don't have many runs as it could greatly increase the file size[4]. Run-length encoding performs lossless data compression and is well suited to palette-based iconic images. It does not work well at all on continuous-tone images such as photographs, although JPEG uses it quite effectively on the coefficients that remain after transforming and quantizing image blocks. 2.Huffman Encoding Huffman encoding, an algorithm for the lossless compression of files based on the frequency of occurrence of a symbol in the file that is being compressed. The Huffman algorithm is based on statistical coding, which means that the probability of a symbol has a direct bearing on the length of its representation. The more probable the occurrence of a symbol is, the shorter will be its bit-size representation. In any file, certain characters are used more than others. Using binary representation, the number of bits required to represent each character depends upon the number of characters that have to be represented. Using one bit we can represent two characters, i.e., 0 represents the first character and 1 represents the second character. Using two bits we can represent four characters, and so on. Unlike ASCII code, which is a fixed-length code using seven bits per character, Huffman compression is a variable-length coding system that assigns smaller codes for more frequently used characters and larger codes for less frequently used characters in order to reduce the size of files being compressed and transferred. For example, in a file with the following data: XXXXXXYYYYZZ the frequency of "X" is 6, the frequency of "Y" is 4, and the frequency of "Z" is 2. If each character is represented using a fixed-length code of two bits, then the number of bits required to store this file would be 24, i.e., (2 x 6) + (2x 4) + (2x 2) = 24. If the above data were compressed using Huffman compression, the more frequently occurring numbers would be represented by smaller bits, such as: X by the code 0 (1 bit) Y by the code 10 (2 bits) Z by the code 11 (2 bits) therefore the size of the file becomes 18, i.e., (1x 6) + (2 x 4) + (2 x 2) = 18. In the above example, more frequently occurring characters are assigned smaller codes, resulting in a smaller number of bits in the final compressed file[4]. 3.LZW Compression LZW compression is named after its developers, A. Lempel and J. Ziv, with later modifications by Terry A. Welch. It is the foremost technique for general purpose data compression due to its simplicity and versatility. Typically, you can expect LZW to compress text, executable code, and similar data files to about one-half their original size. LZW also performs well when presented with extremely redundant data files, such as tabulated numbers, computer source code, and acquired signals. Compression ratios of 5:1 are common for these cases. LZW is the basis of several personal computer utilities that claim to "double the capacity of your hard drive." LZW compression is always used in GIF image files, and offered as an option in TIFF and PostScript. LZW compression uses a code table. A common choice is to provide 4096 entries in the table. In this case, the LZW Volume 2, Issue 4 July August 2013 Page 254
encoded data consists entirely of 12 bit codes, each referring to one of the entries in the code table. Uncompression is achieved by taking each code from the compressed file, and translating it through the code table to find what character or characters it represents. Codes 0-255 in the code table are always assigned to represent single bytes from the input file. pair of routines has been added to SCZ for efficient photo-image compression. The scz compression and scz decompression programs implement simple image compression/decompression, respectively. They reduce space required to store photographic images, are based on the SCZ core compression algorithm, and can be included within other applications. The scz compression and scz decompression programs are released as companions to the SCZ (Simple Compression) routines. The LZW method achieves compression by using codes 256 through 4095 to represent sequences of bytes[3]. 6. SCZ CODING 6.1 SCZ - Simple Compression Utilities and Library[7]. SCZ is a simple set of compression routines for compressing and decompressing arbitrary data. The initial set of routines implement new loss-less compression algorithms with perfect decompression. The library is called SCZ, for simple compression format. SCZ is intended as subroutines for calling within your own applications without legal or technical encumbrances. It was developed because the standard compression routines, such as gzip, Zlib, JPEG, GIF, etc., are fairly large, complex, and difficult to integrate-with, maintain, understand, have external dependencies. SCZ is simple lightweight, self-contained, datacompress/decompress routines that can be included within other applications, and that permit the applications to compress or decompress data on-the-fly, during read-in or write-out by simple calls. SCZ typically achieves 3:1 compression. On binary PPM diagram image files it often achieves a 10:1 compression. On text files such as XML, it often compresses by 25:1. On difficult files, it may achieve less than 2:1 reduction. Although the scz routines are intended for compiling (or linking) into your applications, the package also includes two self-contained (example) application programs that are stand-alone compress/decompress utilities. 6.2 Photo-Image SCZ compression SCZ routines are useful for compressing text, XML, linedrawing/diagram images, scans of text pages, or other types of binary computer data. However, they are unable to compress photographic images very much because they implement loss-less methods that can only reduce exactly repeated patterns within data which are common in the above file types but not in photographic images. A new scz compression program accepts PPM/bmp image files and preprocesses them into a form that is more compressible, and then applies the normal SCZ compression. Specifically, it quantizes the differences between pixels in adjacent columns. The differences are quantized in a mu-law-like distribution so that small changes can be resolved. The quantization causes a small loss in image information, but increases the number of exact patterns that can be exploited by the normal compression algorithm. On decompression with scz decompression program, the process is reversed. The processed image data is decompressed with the regular SCZ algorithm, and then the preprocessing is reversed by integrating the columndifferences. I have applied scz compression and scz decompression algorithm on some standard images to determine the compression ratio. The results are following: 6.2.1 Original image-angry.bmp Writing output to file angry.bmp.scz Initial size = 5862, Final size = 2259 Compression ratio = 2.59495 : 1 Writing output to file angry.bmp Decompression ratio = 2.60071 6.2.2 Original image- darts.bmp Volume 2, Issue 4 July August 2013 Page 255
Writing output to file darts.bmp.scz Initial size = 5374, Final size = 2091 Compression ratio = 2.57006 : 1 Writing output to file darts.bmp Decompression ratio = 2.57622 6.2.3 Original image- fgrpoint.bmp Writing output to file lady.bmp.scz Initial size = 5822, Final size = 3291 Compression ratio = 1.76907 : 1 Writing output to file lady.bmp Decompression ratio = 1.77176 6.2.6 Original image- man.bmp Writing output to file fgrpoint.bmp.scz Initial size = 1086, Final size = 581 Compression ratio = 1.86919 : 1 Writing output to file fgrpoint.bmp Decompression ratio = 1.88542 6.2.4 Original image- horse.bmp Writing output to file horse.bmp.scz Initial size = 8702, Final size = 3236 Compression ratio = 2.68912 : 1 Writing output to file horse.bmp Decompression ratio = 2.69328 6.2.5 Original image- lady.bmp Writing output to file man.bmp.scz Initial size = 10862, Final size = 2764 Compression ratio = 3.92981 : 1 Writing output to file man.bmp Decompression ratio = 3.93693 7. CONCLUSION This paper presents various types of image compression techniques. There are basically two types of compression techniques first one is Lossless Compression and other is Lossy Compression Technique. Comparison between these techniques can be done accurately when comparison is done on same data, with same performance measures. We also apply SCZ(Simple Compression Technique) for image compression.for compression and decompression we have separate routines in scz known s scz compression routines and scz decompression routines. It leads to better compression and decompression ratio. References [1] Digital Image Processing by R. C. Gonzales and R. E. Woods, Addison-Wesley Publishing Company, 1992. Volume 2, Issue 4 July August 2013 Page 256
[2] Two-Dimensional Signal and Image Processing by J. S. Lim, Prentice Hall, 1990. [3] Subramanya A, Image Compression Technique, Potentials IEEE, Vol. 20, Issue 1, pp 19-23, Feb- March,2001. [4] David Jeff Jackson & Sidney Joel Hannah, Comparative Analysis of image CompressionTechniques, System Theory 1993, Proceedings SSST 93, 25th Southeastern Symposium,pp 513-517, 7 9March 1993. [5] Hong Zhang, Xiaofei Zhang & Shun Cao, Analysis & Evaluation of Some Image Compression Techniques, High Performance Computing in AsiaPacific Region, 2000 Proceedings, 4th Int. Conference, vol. 2, pp 799-803,14-17 May, 2000 [6] Ming Yang & Nikolaos Bourbakis, An Overview of Lossless Digital Image Compression Techniques, Circuits & Systems, 2005 48th Midwest Symposium,vol. 2 IEEE,pp 1099-1102,7 10 Aug, 2005. [7] scz-compress.sourceforge.net [8] M. Nelson, The Data Compression Book, San Mako, CA: M & T Publishing, Inc., 1992 [9] Lossless Data Compression, Report Concerning Space Data Systems Standards, CCSDS 120.0-G-2. Green Book. Issue 2. Washington, D.C.: CCSDS, December 2006. [10] Gray, R. M. Fundamentals of Data Compression,International Conference on Information, Communications, and Signal Processing, Singapore, September 1997. IEEE Publication, New York. [11] Sayood, Khalid, Lossless Compression Handbook, Elsevier Science, San Diego, CA, 2003. Volume 2, Issue 4 July August 2013 Page 257