#### Abstract

This paper is intended to present a lossless image compression method based on multiple-tables arithmetic coding (MTAC) method to encode a gray-level image . First, the MTAC method employs a median edge detector (MED) to reduce the entropy rate of . The gray levels of two adjacent pixels in an image are usually similar. A base-switching transformation approach is then used to reduce the spatial redundancy of the image. The gray levels of some pixels in an image are more common than those of others. Finally, the arithmetic encoding method is applied to reduce the coding redundancy of the image. To promote high performance of the arithmetic encoding method, the MTAC method first classifies the data and then encodes each cluster of data using a distinct code table. The experimental results show that, in most cases, the MTAC method provides a higher efficiency in use of storage space than the lossless JPEG2000 does.

#### 1. Introduction

With the rapid development of image processing and Internet technologies, a great number of digital images are being created every moment. Therefore, it is necessary to develop an effective image-compression method to reduce the storage space required to hold image data and to speed the image transmission over the Internet [1–16].

Image compression reduces the amount of data required to describe a digital image by removing the redundant data in the image. Lossless image compression deals with reducing coding redundancy and spatial redundancy. Coding redundancy consists in using variable-length codewords selected to match the statistics of the original source. The gray levels of some pixels in an image are more common than those of others–-that is, different gray levels occur with different probabilities–-so coding redundancy reduction uses shorter codewords for the more common gray levels and longer codewords for the less common gray levels. We call this process variable-length coding. This type of coding is always reversible and is usually implemented using look-up tables. Examples of image coding schemes that explore coding redundancy are the Huffman coding [4, 5, 7] and arithmetic coding techniques [8, 9].

There exists a significant correlation among the neighbor pixels in an image, which may result spatial redundancy in data. Spatial redundancy reduction exploits the fact that the gray levels of the pixels in an image region are usually the same or almost the same. Methods, such as the LZ77, LZ88, and LZW methods, exploit the spatial redundancy in several ways, one of which is to predict the gray level of a pixel through the gray levels of its neighboring pixels [14].

To encode an image effectively, a statistical-model-based compression method needs precisely to predict the occurrence probabilities of the data patterns in the image. This paper proposes a lossless image compression method based on multiple-tables arithmetic coding (MTAC) method to encode a gray-level image.

A statistical-model-based compression method generally creates a code table to hold the probabilities of occurrence of all data patterns. The type of data pattern significantly affects the encoding efficiency when minimizing storage space. When the data come from different sources, it is difficult to find an appropriate code table to describe all the data. Therefore, this MTAC method categorizes the data and adopts distinct code tables that record the frequencies which the data patterns occur in different clusters.

#### 2. The MTAC Method

The proposed MTAC method contains three approaches: median edge detector (MED) processing, base-switching transformation, and statistical-model-based compressing. This section introduces these three approaches.

##### 2.1. MED Processing Approach

Shannon's entropy equation can estimate the average minimum number of bits needed to encode a data pattern based on the frequency which the data pattern occurs in a data set [11, 12]. Let *l* be the total number of different data patterns in a data set and the probability of the th data pattern's occurring in the data set. The entropy rate *E* of the data set is defined as

It is impossible to encode the data set, in a lossless manner, with a bit rate higher than or equal to *E*. The bit rate is defined as the ratio of the number of bits holding the compression data to the number of pixels in the compressed image. The higher the entropy rate, the less one can compress it using a statistical-model-based compression method.

Let be the encoded image consisting of pixels, where *H* and *W* are the height and the width of *f*, respectively. MED [10] estimates the gray level of a pixel by detecting whether there is an edge passing through the pixel. MED scans each pixel in *f*, starting from the left-top pixel of *f*, in the order shown in Figure 1. While scanning a pixel , MED estimates the gray level of via the gray-levels , , and of the pixels , , and , where *P*(*i, j*) is the pixel located at the coordinates (*i, j*) in *f*. Figure 2 shows the spatial relationships of , , , and .

For or , the estimated gray level of is defined as

In addition, for to , and to :

Here, and are the maximum and the minimum between and , respectively. If , MED considers that a horizontal edge passes through or some pixels above . When , MED perceives that one vertical edge passes through or some pixel on the left of .

Let be the difference between and ; we call the estimated error of . Similarly, in the decompressing phrase, based on , , and , the MTAC method can compute through formulas (2.2) or (2.3); then it can get . To recover *f* without loss, the MTAC method needs to save and the estimated errors of all other pixels in .

The estimated error is within the interval between and . Each can be represented by an 8-bit memory space that describes the absolution value of and one bit *b* that records the sign of . All the s compose a gray-level image , and all the sign bits *b*s make up a binary image . We call the error image and the sign bit image of .

Figure 3 shows two gray-level images Airplane and Baboon, and their gray-level histograms. Let , and

**(a) Airplane**

**(b) Baboon**

According to formula (2.1), the entropy rates of Airplane and Baboon, in theory, reach and bits/pixel, respectively. From Shannon's limit [11, 12], with such an entropy rate, the minimum number of bits required to describe a pixel in Airplane (resp., Baboon) is (resp., ) bits/pixel. Since the numbers of bits are over the acceptable maximum, the MTAC method utilizes MED [10] to decrease the entropy rate of *f* before encoding *f*. Figure 4 demonstrates the error images of Airplane and Baboon shown in Figure 3, and the gray-level histograms of the error images. The gray levels of most pixels in the error images are close to 0; the entropy rates of the error images of Airplane and Baboon are and bits/pixel, respectively, which are far lower than the entropy rates of the original Airplane and Baboon.

**(a) Airplane**

**(b) Baboon**

Figure 5 shows the sign bit images of Airplane and Baboon. It is clear that both sign bit images are messy, so it is difficult to find a method effectively with which to encode them effectively. To deal with this problem, the MTAC method transforms the error image and sign bit image into a difference image and an MSB (most significant bit) image, respectively. The MTAC method pulls out the MSB of all the s to create an binary image , where the MSB of is given to the pixel located at the coordinates of . We call the binary image the MSB image of *f*. Meanwhile, the MTAC method concatenates the sign bit *b* of and the remaining , whose MSB has been drawn out, by appending *b* to the rightmost bit of the remaining in order to generate another gray-level image. We name the gray-level image the difference image of *f*. Figure 6 illustrates these actions.

**(a) Airplane**

**(b) Baboon**

Figure 7 shows the MSB images of Airplane and Baboon. Almost all the pixels on the MSB images are 0. Figure 8 displays the difference images of Airplane and Baboon and their gray-level histograms. Clearly, the gray levels of most pixels in the difference images are equal to 0. The entropy rates of the difference images of Airplane and Baboon are 4.4 and 6.2 bits/pixel, respectively. These entropy rates are higher than the entropy rates of their error images but are much lower than those of the original Airplane and Baboon.

**(a) Airplane**

**(b) Baboon**

**(a) Airplane**

**(b) Baboon**

##### 2.2. Base-Switching Transformation Approach

The gray level of a pixel in a gray-level image is generally represented by an 8-bit memory space. However, it is uneconomical if the gray levels of the pixels in a gray-level image are similar. Hence, the MTAC method adopts the base-switching transformation (BST) algorithm [1, 2] to compress a difference image.

The BST algorithm partitions a difference image into small nonoverlapping image blocks, each consisting of pixels. Let and be the minimal and maximal gray levels of the pixels in an image block *B*. The difference between and the gray level *g* of each pixel in *B* can be depicted by bits. The MTAC method uses a 3-bit memory space *S* to describe , where

For each image block, the BST algorithm needs to hold only , , and the gray-level differences between and the gray levels of all the pixels in *B*. We call the difference between the gray level of a pixel *P* and the gray-level difference of *P*. Figure 9 is a image block *B*. The bits of memory space are required to store *B*. However, in the BST algorithm, , , and *S* of *B* are 137, 122, and 3, respectively. The BST algorithm uses 8 bits, 3 bits, and bits to hold , *S*, and the gray-level differences of all the pixels in *B*; hence, the BST algorithm requires only a total of 75 bits to store .

##### 2.3. Statistical-Model-Based Compressing Approach

After the MED processing approach, image is transformed into an MSB image and a difference image. In the base-switching transformation approach, the difference image is segmented into nonoverlapping small image blocks. The MTAC method then writes down , *S*, and the gray-level differences of all the pixels in each image block. However, a few pixels may have big gray-level differences in an image block, so each gray-level difference in this image block requires large number of bits to hold it. For example, the maximal gray-level difference of the image block in Figure 9 is 15; therefore, each gray-level difference can be expressed by at least 4 bits. To remedy this problem, the MTAC method takes arithmetic coding algorithm continuously to compress the data obtained in the MED processing and BST approaches.

The arithmetic coding algorithm [8, 15] is one of the statistical-model-based compressing methods that decide the bit length of a code according to the occurrence frequencies of data patterns. These methods give longer codes to the data patterns that occur more frequently and shorter codes to those that occur less often. Hence, the type of data pattern significantly affects the encoding's efficiency in minimizing storage space. The MTAC method will adopt the arithmetic coding algorithm to compress the MSB image, all the s, and all s. Since the MSB image, all the s, and all s have different statistics, the MTAC method will require distinct code tables to record the data patterns of the MSB image, all the s, and all s. Each data pattern of the MSB image, all the s, and all s are described by 8-bits, 8-bits, and 3-bits in length, respectively.

Next, the MTAC method concatenates the gray-level differences of all the image blocks into a binary string , where the bit length of each gray-level difference in the image blocks is *S*. For example, the gray-level differences in all the image blocks with are concatenated into . The MTAC method then uses an arithmetic coding algorithm to encode each , where the bit length of each data pattern in encoding is *S*. Finally, the MTAC method needs to hold only the height *H* and the width *W* of *f*, all the code tables, and all the compression data generated by the arithmetic coding algorithm.

After the statistical-model-based compressing approach has been employed, the MTAC method concatenates *W*, *H*, , , , , and into the compression data. Here, represents all the code tables; , , , and are the compression data of the MSB image, all s, *S*s, and s, respectively.

##### 2.4. Image Decompression

In the decompression phrase, the MTAC method first draws *W*, *H*, and from the compression data. The bit length of each data pattern in the MSB image is 8*.* Hence, the MTAC method can reconstruct the MSB image based on by using the arithmetic decoding method. Since *f* consists of image blocks, the MTAC method will decompress the s from using the arithmetical decoding method, where the bit length of a data pattern is 8. Similarly, it can decode *S*s from , where each data pattern is described by 3 bits. How many data patterns are in each can be easily computed via *S*s. Hence, each can be decoded as well.

#### 3. Experiments

The purpose of this section is to investigate the performance of the MTAC method by experiments. In these experiments, ten gray-level images Airplane, Lena, Baboon, Gold, Sailboat, Boat, Toy, Barb, Pepper, and Girl, shown in Figure 10, are used as test images. The first experiment explores the effect of the MED processing approach on reducing the entropy rate of the compressed image. Table 1 lists the entropy rates of the ten original test images and the entropy rates of their error images. The experimental results show that most of the entropy rates of the error images are close to half those of the original test images.

**(a) Airplane**

**(b) Lena**

**(c) Baboon**

**(d) Gold**

**(e) Sailboat**

**(f) Boat**

**(g) Toy**

**(h) Barb**

**(i) Pepper**

**(j) Girl**

In experiment 2, the arithmetic coding method is used to encode the sign bit images of the ten test images, where the bit length of each data pattern is 8 bits. Table 2 shows the sizes of the original sign bit images and their compression data obtained by the arithmetic coding method where the bit length of each data pattern is 8 bits. The experimental results illustrate the difficulty of obtaining a good performance in compressing the sign bit images. Since the sign bit images are very messy, the arithmetic coding method cannot effectively encode it; even for most error images, the sizes of their compression data are larger than the sizes of their original images; that is, there hardly exist the coding and spatial redundancies in the error images. Table 3 lists the entropy rates of the difference images of the ten test images where are set to . Although the entropy rates of the difference images are higher than those of the error images, they are much lower than those of the original images are.

The last experiment compares the performance of the MTAC method with that of the lossless JPEG2000 [3, 6, 13]. Table 4 displays the bit rates obtained by the MTAC method and the lossless JPEG2000 in encoding the test images. Table 4 reveals that the MTAC method is more efficient in storage space use than the lossless JPEG2000, except image Barb. Figure 11 shows that huge gray-level variations among most adjacent pixels in the partial magnified difference image of Barb. The MTAC method obtains better performance in terms of storage space use than that of the lossless JPEG2000 in encoding an image with small gray-level variations among adjacent pixels but performs worse in compressing an image with great gray-level variations among adjacent pixels. Hence, the MTAC method performs worse in terms of storage space use than the lossless JPEG2000 does when encoding Barb.

#### 4. Conclusions

This paper proposes the MTAC method to encode a gray-level image *f*. The MTAC method contains the MED processing, BST, and statistical-model-based compressing approaches. The MED processing approach reduces the entropy rate of *f*. The BST approach decreases the spatial redundancy of the difference image of *f* based on the similarity among adjacent pixels. The statistical-model-based compressing approach further compresses the data generated in the MED processing and BST approaches, based on their coding redundancy. The data patterns of the data produced by the MED processing approach and the BST approach have different bit lengths and distinct occurrence frequencies. Hence, the MTAC method first classifies the data into clusters before compressing the data in each cluster using the arithmetic coding algorithm via separated code tables.

The experimental results reveal that the MTAC method usually gives a better bit rate than the lossless JPEG2000 does, particularly for the images with small gray-level variations among adjacent pixels. However, when the gray-level variations among adjacent pixels in an image are very large, the MTAC method performs worse in terms of bit rate.