Image Compression Using Proposed Enhanced Run Length Encoding Algorithm

In this paper, we will present p roposed enhance process of image compression by using RLE algorithm. This proposed yield to decrease the size of compressing image, but the original method used primarily for compressing a binary images [1].Which will yield increasing the size of an original image mostly when used for color images. The test of an enhanced algorithm is performed on sample consists of ten BMP 24-bit true color images, building an application by using visual basic 6.0 to show the size after and before compression process and computing the compression ratio for RLE and for the enhanced RLE algorithm.


Introduction
The size of the compressed stream depends on the complexity of the image [2]. Image compression is minimizing the size in bytes of a graphics file without degrading the quality of the image to an unacceptable level. The reduction in file size allows more images to be stored in a given amount of disk or memory sp ace. It also reduces the time required for images to be sent over the Internet or downloaded from Web pages [3]. Computer graphics applications, particularly those generating digital photographs and other complex color images, can generate very large file sizes. Issues of storage sp ace, and the requirement to rapidly transmit image data across networks and over the Internet, have therefore led to the development of a range of image compression techniques, to reduce the physical size of files. M ost compression techniques are independent of specific file formats -indeed, many formats supp ort a number of different compression types.

Graphics compression algorithms
Graphics compression algorithms fall into two categories: a-Lossy compression achieves its effect at the cost of a loss in image quality, by removing some image information. b-Lossless compression techniques reduce size whilst preserving all of the original image information, and therefore without degrading the quality of the image. Although lossy techniques may be very useful for creating versions of images for day-to-day use or on the Internet, they should be avoided for archival master versions of image [4]

Different formats of images
Digital images can be stored in different formats. JPEG is a form developed by the Joint Photographic Expert Group. Images in this form compressed to a high degree. JPEG's purpose is to achieve high compression ratio with images containing large number of colors.
Graphics Interchange Format (GIF) is an 8-bit p er pixel format. It supp orts animas well. GIF images are compressed using lossless LZW data compression technique. Portable Network Graphics (PNG) is another lossless data compression which is close to GIF but supp orts 24-bit color palette. It can be seen that JPEG can be used whenever the size is a criterion [5]. JPEG: Is a lossy compression scheme for color and gray-scale images. It works on full 24bit color (True Color) which means it can store up to 16 million colors [6]. JPEG is favored because its compression produces a reasonable image with a small file size. JPEG's compression reduces image files to about 5% their normal size with loss due to destructive or "lossy" compression [7]. TIFF: The TIFF (Tagged Image File Format) format, it is a flexible format that normally saves 8 bits or 16 bits p er color (red, green, blue) for 24-bit and 48-bit totals, using the LZW compression algorithm for lossless storage(lossless, but is less effective for 24 bit color images). M ost graphics p rograms that use TIFF do not compression. Consequently, file sizes are quite big [8]. The TIFF file format is ideal for producing and storing high-quality images that are used to produce professional photographic prints, exhibit backgrounds, posters, magazines, etc [7]. GIF: Works best for images with only a few distinct colors, such as line drawings and simple cartoons. GIF is useful for cartoon images that have less than 256-(2^8) colors, grayscale images, and black and white text. The primary limitation of a GIF is that it only works on images with 8 bits per pixel or less, which means 256 or fewer colors. GIF compresses images using LZW compression [9]. GIF achieves compression in two ways. First, it reduces the number of colors of color-rich images, thereby reducing the number of bits needed per pixel, as just described. Second, it replaces commonly occurring patterns (especially large areas of uniform color) with a short abbreviation: instead of storing "white, white, white, white, white," it stores "5 white." Thus, GIF is "lossless" only for images with 256 colors or less. For a rich, true color image, GIF may "lose" 99.998% of the colors [10]. BMP: Windows BM P is the native image format in the M icrosoft Windows operating systems. It supports images with 1, 4, 8, 16, 24, and 32 bits per pixel, although BM P files using 16 and 32 bits per pixel are rare. BMP also supp orts simple run-length compression for 4 and 8 bits per pixel. However, BM P compression is of use only with large blocks with identical colors, making it of very limited value. It is rare for Windows BMP to be in a compressed format. M ulti-byte integers in the Windows BM P format are stored with the least significant bytes first. Data stored in the BMP format consists entirely of complete bytes so bit string ordering is not an issue. The BMP file structure is very simple [12]. It starts with a file header that contains the two bytes BM and the file size. This is followed by an image header with the width, height, and number of bitp lanes [2]. It allows you to make a trade-off between file size and image quality when the image is compressed. Typically, an image in a PNG file can be 10 to 30% more compressed than in a GIF format [4] . PNG uses ZIP compression which is lossless, and slightly more effective than LZW (slightly smaller files) [11].

Run length encoding (RLE)
Run length encoding (RLE) is perhaps the simplest compression technique in common use. RLE algorithms are lossless, and work by searching for runs of bits, bytes, or pixels of the same value, and encoding the length and value of the run. As such, RLE achieves best results with images containing large areas of contiguous color, and especially monochrome images. Complex color images, such as photographs, do not compress well -in some cases, RLE can actually increase the file size. There is a number of RLE variants in common use, which are encountered in the TIFF, PCX and BMP graphics formats [4]. Run-length encoding represents a string by replacing each subsequence of consecutive identical characters with(char; length). The string 11112222333111 would have representation (1; 4)(2; 4)(3; 3)(1; 3). Then compress each (char; length) as a unit using, say, Human coding. Clearly, this technique works best when the characters repeat often. One such situation is in fax transmission, which contains alternating long sequences of 1's and 0's. The distribution of code words is taken over many documents to compute the optimal Human code. [14] Proposed enhanced run length encoding algorithm Each color images consists of the basic three colors (R,G,B), the RLE algorith m represented the image consists on N pixels as follows : But in the new algorithm we compute the differences between the adjacent pixels for each color, if the difference between r 1 and r 2 less than or equal to a threshold value (th<=10) and if the difference between g 1 and g 2 less than or equal to a threshold value (th<=10) and if the difference between b 1 and b 2 less than or equal to a threshold value (th<=10) we add 1 to C 1 , and if the difference is greater than 10 we do this process between next adjacent pixels until we reach the last pixel in the image, and the following example explains the RLE algorithm and the enhanced RLE algorithm : The number of records required to save this image are 16. When compress this image by using RLE algorithm we will generate the following values :

Experimental results
we use ten images to test the above algorithm and the threshold value equal or less than (10), then we get the following results :

VOL.24 (1) 2011
The above table shows the size of true color BMP images and the size after the compression process using RLE and proposed enhanced RLE algorithms. The compression ratio is changing from image to another, but this related to the variety between the values of adjacent p ixels. Decreasing variety between the values of adjacent pixels will yield to increase compression ratio, and vice versa. As shown in the figures (4,5,6,7,8,9,10,11,12,13).
The Conclusions 1-Run length encoding algorithm is a method of compressing images depend on the number of adjacent p ixels value in the image. 2-RLE algorithm is failing mostly when using it for compressing color images, because we need new field to store the number of repeated adjacent pixels. 3-Run length encoding algorithm is an efficient compression method with images have less various between values of adjacent pixels, but fail with images have high difference between adjacent p ixels value. 4-When increasing the values of threshold in the proposed enhanced RLE algorithm this will yield increasing the compression ratio, and vice versa. 5.Controlling the compression ratio depends on the value of the threshold, which depends on the type of domain that image used it .