Volume 4, Issue 2, February 2014 ISSN: 2277 128X International Journal of Advanced Research in Computer Science and Software Engineering Research Paper Available online at: www.ijarcsse.com Special Issue: Advanced Developments in Engineering and Technology Conference Held in Lord Krishna College of Engineering Ghaziabad, India An Advanced Comparison Approach with RLE for Image Compression Amrita Jyoti Gopal Gupta Kanchan Lata Gupta ABES Engg. College,GZB ABES Engg. College, GZB RKGEC, GZB India India India Abstract The research trends that are available in the area of image compression for various imaging applications are not adequate for some of the applications. These applications require good visual quality in processing. In general the tradeoff between compression efficiency and picture quality is the most important parameter to validate the work. The existing algorithms for still image compression were developed by considering the compression efficiency parameter by giving least importance to the visual quality in processing. Hence, we proposed a lossless image compression algorithm based on RLE coding which was efficiently suited for various types of digital images. We considered medical images, satellite extracted images, and natural images, cartoon images for the inspection and proposed a technique to increase the visual quality of the reconstructed image. Keywords image compression, lossless compression, run length coding, comparison technique, entropy coding I. INTRODUCTION This Image compression is the process of encoding image data into lesser number of symbols such that after decoding, the original image information can be retrieved. The compression procedure facilitates optimized space utilization for storage purposes and also enhances network utilization by using lesser bandwidth [1, 8]. With the ever-increasing growth of multimedia applications over a network, on-line compression has become a necessity. Lossless image compression utilizes statistical redundancy in the uncompressed image. Repetitive groups of same pixel are encoded in Run Length Encoding algorithm [1, 8, 15]. In Huffman Encoding [1,8] the frequency of occurrence of a particular pixel value is used to encode the image pixel information using variable size bit-words. This process is also known as entropy encoding. The dictionary maintenance procedure postulates that image pixel information should be stored in a dictionary, and each entry will be represented using a key. These keys are later utilized for image encoding. Lempel-Ziv-Welch or LZW algorithm [1, 5, 6, 8] is the most famous algorithm of this genre. But the dictionary method had an inherent disadvantage because it had to store the dictionary which was an additional overhead. Many advanced research had been conducted in this context for achieving better compression efficiency without increasing resource requirement. The SCRCA technique [10, 11] proposed to compress gray-scale images by maintaining a dictionary of repetitive character set in the image matrix. The FELICS [3, 5] technique proposes to encode each pixel value by a variable size bit-code depending on the neighborhood of the pixels. The CALIC [7, 9] algorithm uses three steps to produce a context among neighboring pixels and then use quantization to reduce context difference in the neighborhood. The implementation of hardware level compression [2, 4] of raw image information in the run time is also being heavily researched for medical image processing. II. RELATED WORKS Image compression may be lossy or lossless. Lossless compression is preferred for archival purposes and often for medical imaging, technical drawings, clip art, or comics. This is because lossy compression methods, especially when used at low bit rates, introduce compression artifacts. Lossy methods are especially suitable for natural images such as photographs in applications where minor (sometimes imperceptible) loss of fidelity is acceptable to achieve a substantial reduction in bit rate ([12], [13]). The lossy compression that produces imperceptible differences may be called visually lossless. Methods for lossless image compression are: A. Prediction based methods An image is often viewed as a two dimensional array of intensity values, digitized to some number of bits. In 8 bit system the intensity value of a gray scale image can vary from 0 to 255.These intensity values are also known as pixel values. In predictive coding, the compression procedure is often composed of two separate steps: (1) Prediction of pixels: In an image, pixels are highly correlated to each other. Because of this correlation, the pixels can be predicted with a good accuracy from their neighbourhood pixels. (2) Entropy coding of error image: These predicted values are subtracted from the actual value of the corresponding pixels and this process results into prediction error image, which is also called as residual image. Now we do entropy coding of the residual image. 2014, Lord Krishna College of Engineering Ghaziabad, India Page 95
We are giving some name of the important prediction techniques as follows: Median edge detection(med) predictor Gradient Adaptive Predictor (GAP) Activity Level Classification Model (ALCM) Predictor Adaptive Linear Prediction and Classification (ALPC) Variable Block-size prediction (VBS) Edge Directed Prediction (EDP) B. Transform based methods Image compression is an important application that has benefited from the wavelet theory. Discrete Wavelet Transform (DWT) decomposes a given image in different levels. These decomposition levels contain a number of sub bands, which consist of coefficients that describe the horizontal and vertical spatial frequency characteristics of the original image. In JPEG 2000 standard [14] only power of 2 decompositions are allowed in the form of dyadic decomposition. DWT can be irreversible or reversible. Reversible transform rounds-off float coefficients to integer. If wavelet basis is float type, we must overcome obstacles of boundary error and precision error if we apply it in lossless transform directly. When the image data of integer type is transformed, the results are of float type. Quantization will cause quantization error. Lossless image compression should construct a transform that maps integer to integer. So the conventional wavelet transforms are not suitable for lossless image compression. The second generation integer wavelet transform based on lifting scheme [15] can map integer to integer and the reconstructed image quality is independent of extend type and boundary transform uses. Now we discuss some lifting scheme based techniques applied to lossless image compression. The important transform based techniques as follows: Embedded Zero tree Wavelet (EZW) Set Partitioning Hierarchical Trees (SPIHT) algorithm Embedded Block Coding with Optimized Truncation (EBCOT) Burrows- Wheeler Transform (BWT) Tuned Degree K Zero tree Wavelet (TDKZW) C. Entropy coding Entropy encoding is a term referring to lossless coding technique that replaces data elements with coded representations. It is a coding scheme that involves assigning codes to symbols (pixels) so as to match code lengths with the probabilities of the symbols. The data stream to be compressed is considered to be a simple digital sequence. The important entropy techniques as follows: Run length Coding Huffman Coding Golomb- Rice Coding Arithmetic Coding III. OUR WORK The main philosophy behind selecting comparison technique along with run length encoding technique is based on the intrinsic property of most images, that they have similar patterns in a localized area of image, more specifically the adjacent pixels row differ in very less number of pixels. This property of image is exploited to design a very effective image compression technique. Testing on a wide variety of images has provided satisfactory results. The technique used in this compression methodology and run length coding are described in this section. A. Comparison Technique The comparison technique does a comparison between two strings of equal length and represent the second string with respect to the first only with the information of the literal position where the string mismatches. This operation is expressed as (p; char) which means replacing the character at position p by character char. suppose there are two strings: First Row 1 1 0 1 0 0 0 1 0 1 1 1 0 1 0 1 0 Second Row 1 1 0 1 0 0 0 1 1 1 1 0 0 1 0 1 0 In this case first row can be encoded, using comparison technique, as (9; 1), (12; 1). This technique is very useful in image compression because of the inherent property of an image because two consecutive rows of an image has almost same string of pixel values. Only a few pixels vary. Experimental results prove this hypothesis. Apart from the concept of comparison technique, the concept of run length is also used because using run length a row of image can be represented using much less literals than the original. B. Run Length Coding This is a very simple compression method used for sequential data. It is very useful in case of repetitive data. This technique replaces sequences of identical symbols (pixels), called runs by shorter symbols. The run length code for 2014, Lord Krishna College of Engineering Ghaziabad, India Page 96
image is represented by a sequence {Vi, Ri} where Vi is the intensity of pixel and Ri refers to the number of consecutive pixels with the intensity Vi. AAAAAAAAAAACCCCC is stored as (11, A),(5, B). With RLE, this would only require four bytes to store instead of 16 bytes. In this proposed compression technique, we have used the comparison technique in unison with run length. Starting from the left uppermost row of image, every five rows are considered at a time. Of these, the middle row is represented using run length, and the two rows above and two below it are matched with the middle row using comparison technique. This method is continued iteratively until the whole image is scanned and compressed. The algorithms as per our technique are as follows: C. Compress This is the main algorithm for compression. This algorithm will be used to compress the data part of the Source Image File. Output: It will output the Compressed-Image file. Input: This function will take Source Image file as input. Step1. Read the Source Image file as input. Obtains its size (say r*c). Step2. Divide the image into groups and each group having 5 rows. If r is not divisible by 5, then duplicate last row 1, 2, 3 or 4 time in the last such that the number of rows becomes divisible by 5. Step3. Starting with the 1 st Row, choose 5 rows at a time (say, we have chosen row (n-2), (n-1), n, (n+1), (n+2)) and perform the following operation in each iteration: (a) Firstly encode the (n-2) th row using comparison technique with respect to (n-1) th row. For every mismatch, (b) Then encode the (n-1) th row using comparison technique with respect to (n) th row. For every mismatch, two values are stored in compress file. (c) Then encode the (n) th row using run length coding. Every set of values and its run length is stored in a compress file. (d) Then encode the (n+1) th row using comparison technique with respect to (n) th row. For every mismatch, (e) Then encode the (n+2) th row using comparison technique with respect to (n+1) th row. For every mismatch, Step4. Repeat step 3 until all the all rows are compressed. A marker should be used to distinguish between the encrypted version of each row. D. Decompress This is the main algorithm for decompression or decoding the image. Output: It will output the Decompressed or Decoded Image file. Input: This function will take the Compressed-Image file as input Step1. Read the compress array. Obtain the size of the image (say, r * c) Step2. Consider the compressed value of consecutive 5 rows (say, we have chosen row (n-2), (n-1),n,(n+1), (n+2)) from compress file and perform the following operations in each iteration: (a) Firstly construct the n th row with pixel value runlength value in the compress value, by putting the same pixel value in runlength number of consecutive places in the same row. (b) Then the construct the (n-1) th row. For this copy the n th row with replacing those pixel value whose (c) Then the construct the (n-2) th row. For this copy the (n-1) th row with replacing those pixel value whose (d) Then the construct the (n+1) th row. For this copy the n th row with replacing those pixel value whose (e) Then the construct the (n+2) th row. For this copy the (n+1) th row with replacing those pixel value whose Step 3. Step 2 is repeated until we get the complete decompressed file. 2014, Lord Krishna College of Engineering Ghaziabad, India Page 97
E. Test Result Suppose we taken hypothetical data of an binary image as shown in the Fig. 1. Fig. 1 Hypothetical data for a binary image Firstly we divide this data into groups of 5 row. Starting with the first row of first group, we compressed this row using comparison technique with respect to second row. In this case we found only pixel value on 8 th and 19 th position are different in the first row as compare to second row. So compressed the first row by storing (8,1) and (19,0) as pixel value 1 is on 8 th position and pixel value 0 is on 19 th position as shown in the Fig. 2. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 1 st Row 1 1 1 1 0 0 0 1 1 1 1 0 0 0 1 1 1 1 0 0 0 1 1 1 2 st Row 1 1 1 1 0 0 0 0 1 1 1 0 0 0 1 1 1 1 1 0 0 1 1 1 Comparison Tech. in 1 st Row : (8,1), (19,0) Fig. 2 Compressed first row using comparison technique Then we used comparison technique in second row with respect to first row, used run length coding in third row, used comparison technique in fourth row as compare to third row, and used comparison technique for fifth row with respect to fourth row for compression. This procedure repeated for each group, result of the proposed algorithm for the hypothetical data (as shown in Fig.1) is shown in the Fig. 3. Comparison Tech. in 1 st Row (8,1) (19,0) Comparison Tech. in 2 nd Row (8,0) Run Length Coding in 3 rd Row (4,1) (3,0) (4,1) (3,0) (5,1) (3,0) (3,1) Comparison Tech. in 4 th Row (4,0) (14,1) Comparison Tech. in 5 th Row (3,0) Comparison Tech. in 6 th Row (3,1) (8,0) (15,1) Comparison Tech. in 7 th Row (4,1) (3,1) Run Length Coding in 8 th Row (4,0) (4,1) (3,0) (3,1) (4,0) (6,1) Comparison Tech. in 9 th Row (5,0) Data in Compressed File Comparison Tech. in 10 th Row (4,1) (5,1) (15,1) Fig.3 Result of the proposed algo for hypothetical data (as shown in Fig. 1) For binary image one pixel value taken 1 bit storage. For this hypothetical data of a binary image (as shown in Fig. 1): 2014, Lord Krishna College of Engineering Ghaziabad, India Page 98
Before Compression (size): 10X 24=240 bit After Compression (size) : 54 bit Compression percentage : 77.5% IV. CONCLUSIONS The algorithm proposed here is for lossless image compression as it is evident from the algorithm, that the exact image data (pixel values) are extracted from the compressed data stream without any loss. This is possible because the compression algorithm does not ignore or discards any original pixel value. Moreover the techniques such as comparison technique and run length encoding technique are intrinsically lossless. This compression technique proves to be highly effective for images with large similar locality of pixel lay out. This technique will find extensive use in medical imaging sector because of its lossless characteristics and the medical images has large area of similar pixel layout pattern, and cartoon images. REFERENCES [1] Sami Khuri and Hsiu-Chin Hsu Interactive Packages for Learning Image Compression Algorithms lists, requires prior specific permission and/or a fee. ITiCSE 2000, Helsinki, Finland [2] S. Bhattacharjee, S,. Das, D. Roy Choudhury and P. Pal Chouduri, A Pipelined Architecture Algorithm for Image Compression, Proc. Data Compression Conference, Saltlake City, USA, March 1997. [3] Jorg Ritter and Paul Molitor, A pipelined architecture for partitioned DWT based lossy image compression using FPGA's, International Symposium on FPGA, pages 201-206,2001. [4] Amiya Halder, Dipak Kumar Kole and Subarna Bhattacharjee, On-line Colour Image Compression based on PipelinedArchitecture ICCEE- 2009, Dubai, UAE, Dec 28 30. [5] Pratt, William K. Digital Image Processing. [6] G. K. Wallace, The JPEG still picture compression standard, Commun. ACM, vol. 34, pp. 31-44, April 1991. [7] W. B. Pennebaker and J. L. Mitchell, JPEG: Still Image DataCompression Standard, Van Nostrand Reinhold, New York, 1993. [8] Rafael C. Gonzalez, Richard E. Woods, Digital Image Processing, Pearson Education, 2002 [9] Tinku Acharya, Ping-Sing Tsai. JPEG2000 Standard for Image Compression [10] Debashish Chakroborty, Amiya Halder An Efficient Lossless Image Compression Using Special Character Replacement, IEEE ICCET-2010, 13-14 November pp E-62 E-67, Jodhpur, Rajasthan, India [11] Debashis Chakraborty, Sutirtha Ghosh and Joydeep Mukherjee Efficient Text Compression using Special Character Replacement andspace Removal, International Journal of Computer Engineering &Technology(IJCET), ISSN 0976-6367(Print), ISSN 0976-6375(Online), Volume1, Number 2, Sept-Oct (2010), pp. 323-331. [12] S. A. Martucci, Reversible compression of HDTV images using median adaptive prediction and arithmetic coding, Proc. of IEEE ISCAS, pp. 1301-1313, 1990 [13] Wu. X., Memon, N.D and Sayood, K., A Context-based, Adaptive, Lossless/Nearly-Lossless Coding Scheme for Continuous-tone Images, A proposal submitted in response to the Call for Contributions for ISO/IEC JTC1.29.12, 1995. [14] C. Christopoulos, A. Skodras and Touradj Ebrahimi, The JPEG2000 Still Image Coding System: An Overview, IEEE Transactions onconsumer Electronics, Vol. 46, No. 4, Nov. 2000, pp. 1103-1127. [15] J. Kovacevic and W. Sweldens, Wavelet Families of increasing order in arbitrary dimensions, IEEE Trans. Image Processing, Vol. 9, No. 3, pp-480-496, March 2000. 2014, Lord Krishna College of Engineering Ghaziabad, India Page 99