### 1. Introduction

Nowadays, one can observe the massive amount of digital data generated by advanced technology and applications. This large amount of data is due mainly to image data. To handle this amount of data, many image compression techniques have been devised in the research. These techniques are classified as lossy and lossless, and it is known that lossy compression techniques might achieve high compression ratios [1]. However, this achievement usually affects the original image recreation process. On the other hand, lossless compression techniques retrieve the original image with acceptable compression ratios (CRs).

In general, there are three different approaches to compress image files. It is known that some pixel values are more common than others and the repetition of some information (redundancy) can be reduced. The first approach can reduce the coding redundancy based on the pixel values, such as Huffman coding and Lempel-Ziv-Welch (LZW) coding [2–4]. Coding redundancy reduces the number of source symbols by applying a source-mapping scheme. Furthermore, compression algorithms, such as Huffman, LZW, etc., are applied to achieve higher compression. Compared to other algorithms, Huffman algorithm generates minimum redundancy codes [5–7]. Huffman coding has been effectively used in images, video compression, and conferencing systems. The second approach is called psychovisual redundancy, which is used when some color differences are imperceptible [8].

The last approach, reduce interpixel redundancy [8], deals with images based on neighboring pixel values. This brings up the question of ‘how can the noise be tolerated?’. Three spatial methods have been developed to tolerate noise. The first method predicts the next pixel based on the previous one, which is called predictive coding. The second method describes the image in terms of recursive affine transformations. The last method transforms pixels to another domain, such as a frequency domain, in which the correlation between neighboring pixels is lower. Examples of these transforms are the discrete cosine transform, discrete Fourier transform, and the Karhunen-Loeve Transform [9].

Bit-level compression techniques have been proposed in several studies to accomplish enhanced text compression. In [10], the authors proposed a compression technique based on the bi-level technique to produce a dynamic and secure Arabic text compression using the bitwise Lempel-Ziv algorithm. In this research, the text file was prepossessed to produce a binary file by mapping a codeword to each character according to its appearance in the input file in order to reduce the number of the symbols in the file. The bitwise Lempel-Ziv algorithm then compressed the binary file in order to achieve a high CR. In [11,12], a modified compression technique is proposed for being applied to English text files. In [11], each character in the original file is assigned a weighted fix-length code to produce a binary file as an input to the LZ-78 algorithm for compression in order to produce a high CR with less complexity and less memory usage. In [12], an intermediate mapping scheme is used in which the original English text is first transformed to the decimal domain and then to the binary domain. Moreover, an efficient bitwise Huffman coding technique based on source mapping is proposed in [13].

On the other hand, some research has adopted a bit-level compression technique for image compression. A combination method for lossless image compression by applying the LZW code on the image and then processing the outputs using BCH error detection and correction algorithm in a loop ending with inflation detection in order to improve the CR without losing data [14]. In [15], the authors introduced a modification to the BCH encoder when converting an image, by dividing each part of the image into 7-block sizes divided into two parts—one for the image and one for the keys. These blocks are faded to the Huffman code in order to increase the CR without losing data. The authors in [16] proposed a mapping technique that is based on a new fixed-length code, instead of the ASCII code, before applying binary run-length compression techniques.

In this work, an efficient bit-level lossless gray-scale image compression technique is proposed. This proposed technique achieves a higher CR based on mapping the original image into a binary domain. Thus, the number of source symbols is significantly reduced. The mapping process (see Fig. 1) is achieved as follows: first, a pre-analysis of the original image is performed to count the frequency of occurrence of each symbol. Second, symbols are sorted in descending order based on this analysis. In turn, each symbol is replaced by an 8-bit unique weighted fixed-length code. Finally, the well-known compression algorithm, LZW, is applied to the generated binary source. This results in an improvement in CR while also recreating the exact original file.

The rest of the paper is organized as follows: in Section 2, an adaptive mapping scheme of images is presented in Sections 3 and 4 present the compression and decompression processes, which are mainly based on the bit-level LZW algorithm. Experimental results and the evaluation of compressing images based on an adaptive mapping scheme are discussed in Section 5. Finally, the conclusions are provided in Section 6.

### 2. Adaptive Mapping Scheme of Images

In general, symbol occurrences differ from one image to another [17]. In the source-mapping scheme, a statistical analysis is performed on a given image to determine the frequency of occurrence of each available symbol. In light of this analysis, all symbols are arranged from largest to smallest according to the number of times they appear in the image. Subsequently, each symbol is given an 8-bit weighted code in lieu of an arbitrary one (e.g., ASCII code). The weighted codes are assigned and ordered as follows: The code word with a Hamming weight of 8 (all ones 8-bit code) is assigned to the symbol that occurs the most frequently. In the same way, codes with a Hamming weight of 7 are assigned to the next eight symbols that are most probable. The assignment process is iterated until the code with a minimum Hamming weight is given to the symbol that occurs the least often.

According to the aforementioned assignment rule, a binary file

*B*with a large number of ones compared to zeros is generated. As a result, the entropy of the generated binary file multiplied by the code length (*N*) is as close as possible to that of the original image I. Eq. (1) gives the difference in the entropy,*ΔH*. Therefore, the dynamic scheme will enhance the compression performance in comparison with other mapping schemes.
Fig. 2 shows the matrices 1-a and 1-b of a given image. In the first matrix, one can see that a code ‘00001000’ is given to symbol 8. This code is yielded from converting the symbol 8 from the decimal format to an equivalent binary format. However, if the dynamic mapping scheme is used, the code ‘11111111,’ seen in matrix 1-b, is given to the symbol 8 as it appears the most often (i.e., six times). Fig. 2 shows the frequency of both symbol one and symbol zero in both cases. From this figure, one can observe that symbol one has a higher probability of occurrence when a dynamic mapping scheme is used. Fig. 3 displays a complete adaptive source mapping scheme example.

A further step that goes beyond the source-mapping scheme is to apply the lossless compression techniques, LZW, to the resulting binary file. This binary file and the header file, which stores the symbols existing in the original source sorted in descending order, are sent to the receiver side. The binary file is used for the entire decoding process. Whereas, the header file is a key input to the demapping process, which is applied to the file that results from the decoding process. The demapping process works in the opposite way to the mapping one. The next section presents the encoding and decoding tasks of the proposed algorithm.

### 3. Compression Process

Further to the source-mapping scheme, the LZW algorithm has to apply Step 4 (shown in Fig. 4) onto the generated binary file. There are variants of compression algorithms presented in the literature. These algorithms rely on data type to achieve optimal compression performance metrics, such as speed, compression ratio, complexity, etc. It is worth mentioning that Lempel-Ziv compression variants, such as LZ-77, LZ-78, LZW, etc., achieve high compression performance for a wide range of data types. In a fixed-length coding variant, the data stream is processed and stored in a dictionary.

In this study, we apply LZW to the nth-order extension of the generated binary file. Needless to say, the number of symbols of the generated binary file is far less than that of the original image file. This eases the software and hardware implementations of the bit-level LZW algorithm.

The bitwise LZW algorithm processes the input binary stream to find a match between the strings in the file and the strings exist in a string-based dictionary, which has been previously constructed by the algorithm. This dictionary is filled with common subsequences based on the extension-order at which the binary file will be manipulated. For instance, the dictionary is pre-filled with 11, 10, 01, and 00 if an extension-order of two is used for manipulating a file.

### 4. Decompression Process

The decompression process is basically a reverse operation of the compression one (see Fig. 5). To successfully recreate the original image file, some parameters used in the compression process must be readily available. These parameters include all of the symbols found in the image sorted in the descending order of extension order (n), uniform block length (L), and the symbol-mapping table.

A bit-level LZW algorithm along with an image-mapping scheme escalates the compression/decompression complexity. This complexity arises by sharing the header file, which includes the symbols available in the original source sorted in descending order, between the compression and decompression processes. However, this extra complexity is ignored over the compression savings along with the simple implementation processes. Furthermore, one of the steganography techniques can be used to hide the key parameters. Thus, the compressed data is secured from malicious activities [18,19].

On the decompression side, a dictionary is also populated with the same subsequences used in the compression process. Subsequently, the binary data stream stored in the compressed file is parsed into a uniform block of L-length bits. The least n bits of each uniform block are put away. The remaining L-n bits provide the equivalent binary representation of the index of the root subsequence that matches the subsequence under consideration, excluding the innovation bits. Thus, the decoder simply appends the innovation bits to the obtained root subsequence. The simplicity in decoding the task is due to the fixed-length coding attribute of the bit-level LZW encoder.

Once the bit-level LZW decoding process is completed, the original generated binary file retrieves back. Consequently, the retrieved binary data are divided into 8-bit binary words. These binary words are then remapped into their corresponding symbols according to the received key parameters (i.e., symbol mapping table).

### 5. Experimental Results and Discussion

For evaluating the performance of the proposed algorithm, six different well-known grayscale test images were used (see Fig. 6). Furthermore, a MATLAB code was written to transform the original image file into a binary file based on an adaptive mapping scheme. In addition, another code was written to implement the byte-level and bit-level LZW algorithms.

To illustrate the idea of the adaptive mapping scheme, the original image was transformed into binary files. These binary files were generated based on adaptive mapping schemes and the conventional ASCII encoding scheme. The number of ‘ones’ and ‘zeros’ were then computed and compared, as shown in Fig. 7. It is obvious that using the adaptive scheme generated a binary file with a large number of ones compared to zeros.

For evaluating the performance of the source adaptive scheme on a compression algorithm, binary files were generated based on adaptive mapping schemes and the conventional ASCII encoding scheme, which was compressed using the byte-level LZW algorithm. These files were then compressed using the bit-level LZW algorithm. Fig. 8 shows the compression ratio (e.g., CR = compressed image size / original image size) from which one can observe that compressing the image based on using an adaptive mapping scheme acquires some dramatic improvements in CRs.

### 6. Conclusions

In this paper, we have presented an efficient bit-level lossless image compression method that utilizes the adaptive source mapping process before applying the LZW compression algorithm. The purpose of this mapping process was to convert an image file to a binary one, and at the same time, increase the number of occurrences of symbols (i.e., ones) in the resulting binary file. Afterward, this binary file was compressed using the LZW algorithm. Experimental results showed that the CR for the bit-level compression technique that utilizes the adaptive encoding scheme outperformed the byte-level compression technique. It is worth mentioning that the required memory size, execution time, and hardware and software complications for compression/decompression techniques can be greatly reduced by using this type of equivalent binary source.