Keywords

1 Introduction

The development of scientific and technological information bringing computer into family, computer becomes a part of human life audio-visual entertainment. But the current development of software design requires a huge amount of hard disk space. Moreover, with the progress of digital technology and the vigorous development of the Internet, a variety of including image, video, audio and other multimedia application innovation. As multimedia data storage needs increased, the data compression is more important and cannot be avoided. Good compression ability in data compression not only decreases the storage space but also great reduces transmission time. About data transmission security, since the data have been compressed and processed, the information is not the original format, can only restore by decompressed operations while greatly increasing the information security.

Multimedia compression is divided into two categories: one is lossless compression also called reversal compression, which allows the original data to be perfectly reconstructed from the compressed data. This type of compression is generally used for text files, executive files, medical image and important information. The other is lossy compression also called irreversal compression. The reconstructed results of such data are not exactly the same as the data before they are being processed. But most of the information and features of the original data are still included in the results of the recovered data. Lossy compression has a much more compression rate than lossless compression; therefore, lossy compression is often used for image compression (such as VQ compression, JPEG compression and MPEG compression) and sound compression (such as MP3) which require high compression rate and allow partial distortion.

Vector quantization (VQ) is an effective and important compression technique, which can achieve very high compression efficiency; therefore VQ is widely used in many different situations, such as multimedia systems, high-definition television, telex systems, image data base management, and so on. VQ compression is a lossy data compression method based on the principle of block coding and is a fixed-to-fixed length algorithm. We use VQ compression as a basis due to the high compression rate and fast implementation of VQ. Then we employ the Huffman Coding technology to enhance VQ compression rate and get a better compression performance due to the reversibility of the Huffman Coding. The proposed VQ-Huffman method can exactly restore the VQ index table.

VQ compression is often used in multimedia including, sounds, images, text [1] and so on. Also VQ compression can add to the information hiding, for example, combined with Search ordering coding (SOC) [2, 3] or locally adaptive coding (LAC) [4, 5]. If we can have a better compression ratio on the basis of VQ, then we can transmit faster, also there will be more space to hide more secret data. This paper uses the difference between current index and surrounding index [6, 7], and then use Huffman Coding for further compression, hoping to achieve better compression and enhance VQ compression efficacy.

The rest of this paper is organized as follows. Section 2 introduces the related work. The proposed VQ-Huffman method is presented in Sect. 3. The experimental results are shown in Sect. 4. Conclusions make recommendations for applying the results in the last section.

2 The Related Work

Image compression using vector quantization is introduced in Sect. 2.1 and then the principle method of Huffman coding is summarized in Sect. 2.2.

2.1 Vector Quantization

In 1980, Linde, Buzo, and Gray (LBG) proposed a VQ algorithm to design a good codebook for data compression. A vector quantizer is composed of two parts, encoder and decoder. An encoder will compare each input vector with every codevector (also called a codeword) in the codebook and generate the index of best-matched codeword which has the minimum distortion between the input vector and the codevector.

The decoded of VQ is to reconstruct the vector after quantization. A decoder takes the index corresponding to each image block to search the codebook and to locate the codevector in that codebook and generates the output vector. We repeat the decoding steps until every index is processed, and the collection of all the result vectors can be used to recovery an image similar to the original one by the quantization reconstruction.

2.2 Huffman Coding

In 1952, Huffman proposed an encoding algorithm [9] which permits error-free data reconstruction. Huffman coding represents data by variable-length codes, with more frequent data being represented by shorter codes.

We use a simple example to show how a Huffman’s Tree is built. Let the character set Sym = (A, B, C, D, E) for corresponding frequency set of symbol occurrences Freq = (24, 12, 10, 8, 8). The technique works by creating a binary tree of nodes. Initially, all nodes are leaf nodes, which contain the symbol itself and the frequency of appearance of the symbol.

The process essentially begins with a new node whose children are the 2 nodes with smallest frequencies, such that the frequency of new internal node is equal to the sum of the children’s frequency as shown in Fig. 1(a). As a common convention, bit “0” represents following the left child and bit “1” represents following the right child. With the previous 2 nodes merged into one internal node and with the new node being now considered, the procedure is repeated until only one node remains as shown in Fig. 1(b), the Huffman tree. Finally, the symbol A will be encoded by “0”; the symbol B will be encoded by “100”; the symbol C will be encoded by “101”; the symbol D will be encoded by “110”, and the symbol E will be encoded by “111”, respectively.

Fig. 1.
figure 1

The process of a Huffman’s tree

Huffman constructs a binary code tree from the bottom up, that omits unused symbols to produce the most optimal code lengths. Though the codes are of different bit lengths, they can be uniquely decoded.

3 The Proposed Method

Each natural image mostly possesses the local spatial correlation which makes the neighboring positions in image pixels have the similar intensity. When we train a codebook by using VQ technique, we also sort the codewords \( CW_{i} = \left( {{\text{cw}}_{i1} ,{\text{cw}}_{i2} , \ldots ,{\text{cw}}_{ik} } \right) \) according to S i in increasing order, where \( S_{i} = \sum\nolimits_{j = 1}^{k} {cw_{ij} } . \) Afterwards, we encode an input image by the sorted codebook and we can exploit the correlation between neighboring VQ indices with similarity. The similarity draws a large number of small differences from the current index with that of its adjacent neighbors; thereby, increasing the compression rate due to the great quantity of small differences.

The seed blocks are at the first column and the first row and the other blocks are called residual blocks as shown in Fig. 2. Indices of the seed blocks are kept unshorten but the indices for residual blocks are encoded with shorter bit streams. Figure 3 displays the layout of the current to-be-processed block X as well as its upper and left neighbors, U and L respectively. The encoding procedure will encode each residual block by two parts. The first part called leading indicators (LI) and the second part is codes for the difference values between the indices of (X and U) or (X and L). Exploiting Huffman encoding, there will be seven cases generated as shown in Fig. 4. The VQ-Huffman encoding with reversibility can further help how to encode each residual block and enhance the compression efficiency of VQ compression.

Fig. 2.
figure 2

Seed blocks and residual blocks

Fig. 3.
figure 3

Current Block X, upper block U and left block L

Fig. 4.
figure 4

Seven cases of VQ-Huffman Coding

Case 1::

The leading indicator is set as LI = “00” if the indices of upper block U and current block X are the same.

While the indices of upper block U and current block X are different, i.e., the difference value Ue ≠ 0, we will go the following six cases.

Case 2::

The leading indicator is set as LI = “01” when the different value Le = 0 because the left block L and the current block X have same index.

Case 3::

While Ue ≠ 0 and 1 ≤ |Le| ≤ 4, the leading indicator is set as “100”. Since there are eight difference values, we encode each difference with 3 bits such that the difference 1 can be encoded as “001”, 2 as “010”, 3 as “011”, 4 as “100”, −1 as “101”, −2 as “110”, −3 as “111”, −4 as “000”.

Case 4::

While Ue ≠ 0 and 5 ≤ |Le| ≤ 8, the leading indicator is set as “101”. There also exists eight differences so we encode the difference 5 as “001”, 6 as “010”, 7 as “011”, 8 as “100”, −5 as “101”, −6 as “110”, −7 as “111”, −8 as “000”.

Case 5::

While Ue ≠ 0 and 9 ≤ |Le| ≤ 12, we set the leading indicator LI = “110”. With nine difference values in this case, we will encode the difference 9 as “001”, 10 as “010”, and so on.

Case 6:

has the condition Ue ≠ 0 and 13 ≤ |Le|  28 while Case 7 has the condition that Ue ≠ 0 and |Le| ≥ 29. Case 6 sets the leading indicator LI = “1110” while Case 7 has LI = “1111”.

In Case 6, there are 32 difference values, that is to say, the difference values from 13 to 28 and −13 to −28 are encoded by “00001”, “00010”, “00011”, and so on. As for the seventh case, we directly encode the current block X with the leading indicator and its own index value in binary representation.

4 Experimental Results

We used eight standard grayscale test images of size H × W where H and W respectively stand for the height and width of an image; H = W = 512 as shown in Fig. 5 for our experiment. Compression Ratio (CR) [10] is a very logical way of measuring how well a compression algorithm compresses a given digital image. The ratio of the number of bits required to represent the image before compression into the number of bits required to represent the image after compression.

Fig. 5.
figure 5

Eight standard grayscale test images, size 512 × 512 pixels

In the experiment, the CR is computed by dividing the size of the original image block in bits over the size of the compressed image block. Thus Eq. 1 gives the VQ compression ratio because each grayscale image block has h × w pixels and each pixel uses 8 bits to represent it. Therefore, Lx is constant because each image block is encoded by an 8-bit index using VQ compression. So the compression ratio by VQ is (8 × 16)/8 = 16.

$$ CR = \, \left( {8 \times h \times w} \right)/Lx $$
(1)

From Eq. 1, we know that the smaller Lx the larger CR. That is the reason why we exploit Huffman Coding to lower the size of the compressed image block, for creating higher compression ratio. The compression ratio of proposed VQ-Huffman method can be redefined as Eq. 2 below. According to Eq. 2 the CR will become higher and so does the compression effect.

$$ CR = \frac{8 \times h \times w}{Lv}, where \, Lv = \mathop \sum \nolimits_{i = 1}^{{\frac{H}{h} \times \frac{W}{w}}} L_{i} $$
(2)

Table 1 provides the performance measured by VQ compression in comparison with the proposed VQ-Huffman method. Our proposed method has the average compression ratio of up to 24.857 for eight grayscale images. For the smoother pictures such as Tiffany and Toys, the compression gains can reach greater than 100%; even for the complex images such as Lena, Peppers, Gold, Barbara and F-16, the compression gain can be increased more than 25%. The results of Table 1 show that our method has a significant lift in compression gains.

Table 1. Comparisons of different encoding techniques with codebook size 256

Table 2 displays the number of blocks after VQ-Huffman method is conducted to each test image. As mentioned earlier, each image block can be encoded into a 8-bit index by VQ compression. Rather than fixed-length encoding, the proposed method encoded each image block into 2 bits by Cases 1 and 2; 6 bits by Cases 3, 4, and 5; 9 bits by Cases 6 and 12 bits by Cases 7. Therefore, we exploit our method to encode the image block by first, two cases, or else try to make the block encoded in the third, fourth, fifth cases so as to really enhance the compression ratios. From Table 2, most blocks are indeed encoded by Cases 1 or 2, which makes the VQ-Huffman method superior to that of VQ compression.

Table 2. Number of blocks for each case by VQ-Huffman method

5 Conclusions

Our paper proposed a combination of VQ compression with Huffman coding compression for enhancing image compression and exactly restoring to the VQ index table. Experimental results show that the proposed combination technique adaptively provides better compression ratios at high compression gains than that of VQ compression.

The overall superior performance offered by our method encourages the method to be applied directly in some applications such as digital libraries or online multimedia transmission. Moreover, it also can be applied to some interdisciplinary research topics such as information hiding to help prevent unauthorized access, use, disclosure, disruption, modification, or inspection of information. Since the proposed method contributes to completely restore the VQ index table without data loss, the VQ-Huffman method can provide to embed a large amount of data into VQ images for information hiding applications.