Keywords

1 Introduction

Image compression is a technique that removes the redundancy present in the image that reduces the amount of memory required to store it in a storage medium and also reduces the required bandwidth to transfer the image through a communication medium [1,2,3,4, 7,8,9]. The image is basically compressed by taking advantage of three types of redundancies [7, 8]. (i) Coding redundancy: Present in the image when less optimal codeword is used. (ii) Inter-pixel redundancy: Causes due to correlation of the neighboring pixels, (iii) Psychxo-visual redundancy-causes due to data ignored by human visual system [8]. Image compression technique broadly classifies into two categories, i. Lossless image compression [8] technique: Visual quality of the decompressed image is the same as original, but the compression ratio achieved is not up to the mark. Normally, this type of compression technique is used where the visual quality of the decompressed image is a major issue rather than compression ratio. Run length encoding (RLE) [7, 8], arithmetic encoding (AE), [7, 8] and Lempel–Ziv–Welch (LZW) [7, 8] are some well-known lossless image compression techniques. ii. Lossy image compression [8]: In the case of lossy image compression, the amount of compression ratio achieved is very high, but at the same time, a huge amount of data is lost due to which the visual quality of the image is degraded. Vector quantization (VQ) [7, 8], color image quantization (CIQ) [7, 8], JPEG [4], and JPEG2000 [4] are some well-known lossy image compression techniques.

The article is organized as follows: Section 2 discusses the literature review. A brief explanation of the proposed method is discussed in Sect. 3. Experimental results are shown in Sects. 4, and 5 concludes the article.

2 Literature Review

In literature study, a sufficient amount of code vector matrix or codebook modification process are found. A few of them are discussed below.

In 2019, Abul Hasnat et al. [4] proposed a method where multiple images of same size can be compressed together by combining code vector matrices or codebook of the chrominance channels of all the images in a three-dimensional matrix. This method improves the compression ratio of the algorithm but at the same time degrade the visual quality of the image. In 2018, Rui Li et al. [5] proposed a new general codebook (GCB) design method based on bit rate and distortion which improves the performance of VQ significantly. Pradeep Kumar Shah et al. [6] in 2016 generate codebook by two steps i. The training set is sorted based on the magnitudes of the training vectors. ii. From the sorted list, training vector from every nth position is selected to form the codevectors. The method reduces the amount of memory required to store the codebook, but at the same time, it degrades the visual quality of the decompressed image.

3 Proposed Method

The size of the codebook of vector quantization plays a vital role for measuring the amount of space required to store the compressed image. The aim of this work is to reduce the number of bits required to store the codebook. The proposed method works in two steps (i) Compression: Reduce the size of each value of the codebook to 5 bits from 8 bits. (ii) Decompression: Just reverse process of compression.

3.1 Compression

Input: Codebook of vector quantization Output: Compressed codebook.

Step 1: Let \(CB\) be a codebook of size \({\text{p}}*{\text{q}}\), generated by a normal vector quantization algorithm. The number of elements in the codebook is \(n = {\text{p}}*{\text{q}}\).

Step 2: Divide each value of \(CB\) by 64, the one fourth value of the maximum value that can be represented by 8 bits, i.e., 255/4 = 64, and generate the first quotient matrix \(Q\) which contains 0,1, 2, and 3 which can be represented by 2 bits and a remainder matrix \(R\) which contains values between 0 to 63 (Fig. 1).

$$ Q_{i,j} = CB_{i,j} /64 R_{i,j} = {\text{MOD}}\left( {CB_{i,j} ,64} \right) $$
(1)
Fig. 1
figure 1

Quotient matrix \(Q\) and remainder matrix \(R\) formation

Step 3: Divide each value of remainder matrix \(R\) by second threshold value 8 and store the nearest integer value in \(Q^{^{\prime} }\) (Fig. 2).

$$ Q_{i,j}^{^{\prime} } \cong R_{i,j} /8 $$
(2)
Fig. 2
figure 2

Second quotient matrix \(Q^{^{\prime} }\) formation

3.2 Decompression

Input: Compressed codebook Output: Decompressed codebook.

Step 1: Multiply each value of \(Q^{^{\prime} }\) by second threshold value 8 and generate \(Q^{\prime \prime }\) (Fig. 3).

$$ Q_{i,j}^{\prime \prime } = Q_{i,j}^{^{\prime} } *8 $$
(3)
Fig. 3
figure 3

Creation of \(Q^{\prime \prime }\) by multiplying \(Q^{^{\prime} }\) by threshold value 8

Step 2: Multiply each value of Quotient matrix \(Q\) of equation no 1 by first threshold value 64 and then add matrix \(Q^{\prime \prime }\) to generate decompressed codebook \(CB^{^{\prime} }\) (Fig. 4).

$$ CB_{i,j}^{^{\prime} } = Q_{i,j} *64 + Q_{i,j}^{\prime \prime } $$
(4)
Fig. 4
figure 4

Decompressed codebook \(CB^{^{\prime} }\) formation from \(Q\) and \(Q^{\prime \prime }\)

3.3 Memory Requirements for Proposed Method

Decompressed codebook \(CB^{^{\prime} }\) can be recovered by quotient matrices \(Q\) and \(Q^{^{\prime} }\). The number of bits required to store the uncompressed codebook \(CB\) is 12 * 8 = 96 bits. The maximum value of \(Q\) is 3 and requires 2 bits to represent it, whereas the maximum value of \(Q^{^{\prime} }\) is 6, i.e., maximum 3 bits are required to store it. So, memory required for Q = n* no of bits require to represent \({\text{MAX}}\) element, i.e. = 12 * 2 = 24 bits. Similarly, the number of bits required to store \(Q^{^{\prime} }\) is 12*3 = 36 bits. Total number of bits require to recover decompressed codebook \(CB^{^{\prime} }\) = 24 + 36 = 60 bits. So, it saves (96–60)/96% = 37.50% memory.

4 Experimental Results

The proposed method is implemented using MATLAB2018 and tested on standard color images found in literature and images from UCIDv.2 [4, 7,8,9] database. The performance of the proposed method is measured by three metrics, compression ratio (CR) [10], peak signal-to-noise ratio (PSNR) [10] and structural similarity index measure (SSIM) [10, 11].

Figure 5a–c shows the original pepper image, decompressed pepper images using vector quantization algorithm and the proposed method, respectively.

Fig. 5
figure 5

a Original ımage, b decompressed image using vector quantization, c decompressed image using proposed method

From Fig. 5, ıt can be easily observed that the visual quality of decompressed image using vector quantization and proposed method are almost same. Comparative result of space reduction between vector quantization and proposed method is given in Table 1.

Table 1 Space reduction using vector quantization and proposed method

From Table 1, it is observed that space reduction using proposed method lies between 90.81 and 93.81% which is much higher than 88.47–93.23% of VQ.

Table 2 shows computed PSNR [10] between original image and decompressed image using vector quantization and proposed method.

Table 2 PSNR between original image and decompressed image using vector quantization and proposed method

From Table 2, it is observed that visual quality of decompressed image using the proposed method is almost same or slightly lower than VQ in terms of PSNR [10].

From Table 3, it can be seen that the quality of the decompressed image using the proposed method slightly lower than vector quantization algorithm in terms of structural similarity index measure (SSIM) [10, 11].

Table 3 SSIM between original image and decompressed image using vector quantization and proposed method

5 Conclusion

This study proposes a method which is used to reduce the number of bits require to store the codebook of a vector quantization algorithm. The proposed method represents each value of the codebook by 5 bits instead of 8 bits that mean it reduces the memory required to store the codebook by 37.50% which increases the compression ratio (CR) of the overall algorithm significantly keeping the visual quality of the decompressed image almost same or slightly lower. Future work may be focused on improving the compression ratio more, keeping the visual quality of the image exactly the same as the original.