Lossless Compression of Dithered Images Basar Koc #1, Ziya Arnavut *2, Huseyin Kocak # 1 Department of Computer Science, University of Miami, Miami, FL 33146 USA (Email id: b.koc@ umiami.edu) 2 Department of Computer Science, SUNY Fredonia, Fredonia, NY 14063, USA Abstract- In order to display high-bit resolution images on low-bit resolution displays, bit resolution needs to be reduced. This problem is vital especially for low-cost or small (mobile) devices. To untangle the bit reduction problem, special color quantization algorithms, called dithering, are employed on high-bit resolution images. The dithering process helps to provide solution the problem, but it does not help much in terms of storage and transmission of images. To reduce storage and to lower data transmission, numerous special compression techniques have been proposed in the last several decades. While the well-known compression algorithms, such as gzip, help lower image file sizes, they are not usually adequate. To improve the compression gain, special compression techniques that take into account structure of image data must be developed. We propose to implement the pseudo-distance technique (PDT) for dithered images which has been reported in the literature earlier [6].The compression result of this approach will be compared with result of graphic interchange format (GIF) and portable network format (PNG). Keywords— Color palette, lossless image compression, dithering, pseudo-distance metric, GIF, PNG I. INTRODUCTION For long term storage and efficient transmission of data, data compression is critical. Over the past decade, several compression techniques have been proposed. Few of the researchers [1,2] focused on general data compression, while others [3,4] designed more specific file compression techniques for movies, sound, and image files. When a file type is known, better compression results can be attained with less effort because better prediction models can be designed. Usually, this set of available colors, called a color palette, may be selected by a user from a wide variety of available colors. Such device restrictions make it particularly difficult to display natural color images since these images usually contain a wide range of colors which must then be quantized by a palette with limited size. This color quantization problem is considered in two parts: the selection of an optimal color palette and the optimal mapping of each pixel of the image to a color from the palette. Color quantization proposed by M.T.Orchard and C.A.Bouman [2] of images develops algorithms for the design of hierarchical tree structured color palettes in cooperating performance criteria which reflect subjective evaluations of image quality. Tree structured color palettes greatly reduce the computational requirements of the palette design and pixel mapping tasks, while allowing colors to be properly allocated to densely populated areas of the color space. The algorithms produce higher quality images and require less computation than earlier non-hierarchical method. A color image quantization is a three-step process: the first step is designing a suitable palette to reduce the number of colors, the second step is coding, and the final step is decoding. A low-cost display device (e.g. mobile) has limited ability for true colors. For example, there are 16.8 million (2^24) possible color combinations in an RGB color image. Since an RGB color image consists of three bytes for each pixel; one byte for each color (red, blue, and green), a color image quantization is applied to map 24 bits to 16, 8, or 4 bits per pixel. For each RGB image, by generating a set of representative colors, a palette is formed. Later, the palette is used in image encoding and decoding. In the encoding process, each color pixel in the RGB image is replaced with the index of the closest color in the palette. In effect, each RGB color pixel is represented by an index, which is mapped to the color palette. If the palette size is 256 or less, each index can be represented with a byte. Hence, effectively, image size is reduced from 3 bytes per color to one byte per index value by applying the quantization. In Page 1 quantization process, we may have quantization errors, e.g., distortion. To overcome quantization errors, dithering algorithms are used. In a dithered image, colors not available in the palette are approximated by a diffusion of colored pixels from within the available palette. In recent years, several dithering algorithms were proposed. The most well-known algorithm was developed in 1976 by Floyd–Steinberg [4], which is known as the Floyd–Steinberg dithering technique. It uses error-diffusion algorithms instead of basic dithering algorithms, such as average, ordered, or random, and produces images which look closer to original form. Error diffusion techniques are commonly used for displaying images which have been quantized to very few levels. The application of error diffusion techniques to the display of color images. A modified error diffusion technique is proposed for resolving the quantized images. The new error diffusion technique has been reported easy for implementation using the tree structured color palettes developed. A re-ordering and re-indexing method utilizes a new context model along with pseudo distance technique in compression of color mapped images. Graphic Interchange Format (GIF) and Portable Network Format (PNG) are two of the well-known and frequently used techniques for the compression of color mapped images. There are several techniques (JPEG) that achieve better compression results than GIF and PNG; however, most of these techniques need two passes on the images data, while others do not run in linear time. The pseudo distance technique runs in linear time and requires only one pass. It has been reported by [10] the proposed context model along with the pseudo distance technique yields better results for compression gain than both GIF and PNG. Sampling the original image for color statistics. Choosing a color map based on those statistics. Mapping the colors to their representative in the color map. Quantizing the image. The quantized image obtained is given as input image to the previous block which implements pseudo distance transformation and encodes the transformed image using Run Length Encoder. Most of the color-mapped image compression techniques, which require two passes, the pseudo-distance compression technique requires one pass and runs in linear time. There are several techniques that yield better compression results than GIF and PNG. Run length encoder is used for them to compress the data. On run length encoded data, arithmetic coding can be done to obtain an output is in the form of binary file and decoded on it. Quantized Images PDT RLE Decoder BAC Original Image II. BLOCK DIAGRAM AND DESCRIPTION The original RGB color image is quantized by using the steps given below. Reconstruction Image Page 2 1) Level 1: Quantization:-Sampling the original image, choosing the color and mapping the color and output is in the form of quantized image. 2) Level 2: Pseudo Distance Transformation (PDT):-Pseudo-distance transformation used for calculating (by calculating Euclidean distance) distance between every pair of indices from a color palette or by applying suitable algorithm in further. 3) Level 3: Run Length Encoder:-The use of run length is vital in entropy coder phase since the output of the PDT on dithered images contains a significant number of zeros.RLE detects long run sequences and regroup the repetitive sequences.RLE along with binary arithmetic coder gives compression output. 4) Level 4 : Decoder:-The encoder output is converted into original form. III. ALGORITHMS A. Encoding Algorithm the error matrix E. Then, this index value, along with the right neighbouring index value (3), is used to determine the error value 0 from the pseudo-distance matrix (P (3, 3) = 0). After that, the error value (0) is written next to the top-left corner element (3) of the matrix E. In each row, this process is repeated similarly, except the error value of the left most element of each row in E is predicted using the pixel immediately above that element in I. B. Decoding Algorithm The decoder part of the application uses a procedure similar to that used by the encoding algorithm. The encoded image file consists of the index table of the original image and the error signals. Hence, the decoder can easily construct the Euclidean distance and the pseudo-distance matrices. The original image is reconstructed as follows: First, the pseudodistance matrix is reconstructed from the index table. Then the index number of the first pixel at the top-left corner, call it a, is encoded with the original index value. Later the process is applied as follows: Receive the error signal e of the next pixel of the encoded image E.In row a of the pseudo-distance matrix, search for the error signal value e. Emit the corresponding column value x as the original index value of the reconstructed image, as shown in Figure 6. Let x be a and repeat the process from 1 until we reach the end of the file. Clearly, in the decoding process, we obtain the original index values without any loss. First, the top-left corner index value (3) is copied to the top-left corner of Page 3 Lossless compression of heading, dithered paragraph images with the pseudo-distance techniqueauthor [11],the pseudo distance technique (PDT) is used toaffiliation achieve better compression 11 author gain namethan the any well-known image 24compression schemes (GIF,PNG & title JPEG2000).The compression gain reported by research is 46.8% for GIF and 14.2% for PNG. It has been reported that further improvement 3.9% was obtained by using PDT technique. This indicates promising feature of PDT for image Images Compression Ratio Lenna 1.09 Man 1.09 Lossless compression of images [1], Chall 1.17 the compression ratio is the size of original image Coral 1.16 to the size of the compressed image and bit rate is the number of bits per pixel required by the Shuttle 1.18 compressed image. For example, a 256*256, 8 bits Sphere 1.25 per pixel image requires 256*256*8 bits=65536*8 bits=65536 bytes form. If the compressed image Brain 1.60 requires 32768 bytes then compression ratio is 2.0. Since the image has 256*256=65,536 pixels, the compression. A survey on palette recording compressed file needs 32768*8/65536=4 bits per methods for improving the compression of color pixel on average bit rate is 4. indexed image [12], the entropy values for original The compression ratio reported by image and recorded image are reported as 7.62. It has been reported that further research on any images by using compression entropy values 7.41 for the original image and 5.21 algorithm such as gizp.It has been reported that further improvement was obtained by using for recorded image was obtained by using Zeng’s Huffman coding method. The compression ratios of method. The compression was 4%-5% worse for JPEG-LS and 3%-5% worse for lossless JPEG2000 any images are given in table as follows: by using Zeng’s method. The following Table gives the quality Color quantization of images [2], PSNR and quantization error by using LBG the PSNR and quantization error reported by algorithm. research as follows: For girl image PSNR is 30.6 dB and quantization error is 15.13 by using Linde Buzo –Gray (LBG) algorithm. For Lena image PSNR is 30.15 dB and quantization error is 5.37 by using LBG algorithm. An efficient re-indexing algorithm for color mapped images [8], the entropy value for 2 to 32 color palette reported as 2.1 and 33 to 256 color palette reported as 3.3. It has been reported that further entropy was decreased; the entropy value 2.0 for 2 to 32 color palette and 2.5 for 33 to 256 was obtained by using Zeng’s method. Images- Girl Lena Pepper PSNR (dB) 30.6 15.13 28.92 Quantization 30.15 5.37 8.72 Error Page 4 IV. CONCLUSIONS The PDT is an efficient lossless image compression method for color-palette images since the PDT runs in linear time and requires only onepass [11]. In our previous work [11], we have shown that, when the PDT is used in conjunction with a context-model BAC, we obtained better compression results than the well-known image compressors such as GIF, PNG, JPEG-LS, and JPEG2000 on dithered images. In this paper, we have shown that further compression gains are possible when we update one more neighbor of the predicted pixel in PDT matrix. Indeed, with this modification, on three sets of dithered images, we have achieved on average 3.9% improvement over our previous work resulting in total gains of 46.8% over GIF and 14.2% over PNG. REFERENCES [1] Lossless compression of dithered images, June 2013. [2] M. T. Orchard and C. A. Bouman, “Color quantization of images”,[ IEEE Trans. Signal Process., vol. 39, no. 12,pp. 2677–2690, Dec. 1991. [3][Online].Available:“http://www.visgraf.impa.br/Courses/ip 00/proj/Dithering1/” [4] R. W. Floyd and L. Steinberg, “An adaptive algorithm for spatial grey scale”,[ in Proc. Soc. Inf. Display, 1976, vol. 17,pp. 75–77. [6] C. Alasseur, A. G. Constantinides, and L. Husson, BColour quantisation through dithering techniques,[ in Proc. ICIP, Sep. 14–17, 2003, vol. 1, pp. I-469–I-472. [7] Z. Yao and Y. Wan, “A high performance dithering method for gray and color image quantization”,[ in Proc. 6th Int. Conf. WiCOM, Sep. 23–25, 2010, pp. 1–4. [8] S. Battiato, G. Gallo, G. Impoco, and F. Stanco, “An efficient re-indexing algorithm for color-mapped images”,[ IEEE . Image Process., vol. 13, no. 11, pp. 1419–1423, Nov. 2004. [9] B. Koc and Z. Arnavut, “Gradient adjusted predictor with pseudo-distance technique for lossless compression of color mapped” images,[ in Proc. FIT, Dec. 19–21, 2011, pp. 275– 280. [10] B. Koc and Z. Arnavut, “A new context-model for the pseudo-distance technique in lossless compression of color mapped Images”,[ in Proc. SPIE Opt. Eng.þ Appl., Appl. Digit. Image Process. XXXV, Aug. 12–16, 2012, p. 84 991O. [11] B. Koc, Z. Arnavut, and H. Kocak, “Lossless compression of dithered images with the pseudo-distance technique”,[ in Proc. 9th Int. Conf. HONET, Dec. 12–14, 2012, pp. 147–151. [12] A. J. Pinho and A. J. R. Neves, BA survey on palette reordering methods for improving the compression of colorindexed images,[ IEEE Trans. Image Process., vol. 13, no. 11, pp. 1411–1418, Nov. 2004. [5] L. Akarun, Y. Yardunci, and A. E. Cetin, “Adaptive methods for dithering color images”,[ IEEE Trans. Image Process.,vol. 6, no. 7, pp. 950–955, Jul. 1997. Page 5