Image Compression Using VQ for Lossy Compression

1 downloads 0 Views 714KB Size Report
Paul Shelley, Xiaobo Li, Bin Han, “A hybrid quantization scheme for image compression”, University of Alberta, 2003. [7]. Martha R. Quispe-Ayala, Krista ...
Image Compression Using VQ for Lossy Compression Rishav Chatterjee1, Alenrex Maity2, Rajdeep Chatterjee3 1,3

School of Computer Science Engineering, KIIT University, Bhubaneswar School of Computer Science & Engineering, Modern Institute of Technology, Kolkata

2

Abstract The process to minimize the total number of bits required to depict an image is known as Image Compression. The main goal of Image Compression is to minimize the transmission cost and to reduce the storage space. Vector Quantization is a most popular technique for Lossy compression due to its high compression rate and simple decoding algorithm. The key technique of VQ is the codebook design. In this paper, we have compared and found out the compression ratios of jpg and tiff images using VQ for Lossy Compression and K-means Clustering. Keywords Encoding, Decoding, Lossy, K-means, VQ

1

Introduction

Image Compression is the process, where we decrease the entire total number of bits required to display an image. The process of identifying and matching of pixel identity vectors into binary vectors resulting in a lesser number of possible reproductions is known as Vector Quantization and it is one of the major Image Compression algorithms. An image compression method will remove the irrelevant and duplicate information and will encode the part which remains. Image compression is c o n s i d e r e d a s t h e m o s t i m p o r t a n t a s p e c t for quality transmission and for proper storage of images [1]. Vector Quantization is one of the most used techniques which is used for image compression. Image vector quantization (VQ) has following ways- vector formation, training set selection, codebook generation and quantization. The first and foremost among them is vector formation and it involves in dividing the input image into set of multiple vectors. The vector formed, is in bigger form and the subsets of this vector i s u s e d as the training sequence. The codebook of code words is calculated by a randomized continuous clustering algorithm. Lastly, in quantizing a vector among the others, which has been taken as input , the most closer words of the codebook is f o u n d and their corresponding tag line of this found code word is radiated. Data Compression could be possible as the address could be transmitted and at the same time, it requires lesser number of bits than transmitting vector itself. The process of data quantization has been extended from scalar to vector data of any flexible dimension. Vector quantization employs a set of representation vectors a n d matrices as output. The set of vectors is defined as “codebook” and input of those are defined as “code words”. Vector quantization has been found to be an effective coding technique due to its ability to exploit the high correlation between the pixels which are present around it [3].The quality of depiction requires e x h i b i t i o n of a distortion measure. There are many algorithms in form of papers, which has been [1][4–8] published on how to generate a codebook. The commonly used VQ algorithm is the one presented by Linde, Buzo, and Gray, (LBG) [1][9] and generalized by Lloyd [1][10], 1982. The vector quantization puts the input data into cluster of “vectors” based on the distortion measure. V e c t o r s a r e w e l l d e f i n e d b e f o r e t h e y a r e b e i n g a d d e d a s i n p u t . The vector quantization has been widely used, beside the encoding/compression, in applications such as pattern recognition, speech recognition, face detection and neural networks design [ 1 ] [11–12] 1

Figure 1: Acoustic Modelling Flow

2

Lossy Compression

Lossy image compression is one of the popular methods which is used for image compression due to the abrupt increase of chunks of data, which is being employed for Internet and other applications. We have to make sure that it is of great importance just to ensure that the compression part is not degrading the quality of the image in a Lossy Compression. The working principle of a Lossy Compression algorithm is evaluated, as far as conflicting aspects are concerned. PSNR values is used to determine Compression ratio and image quality [2].

3

Vector Quantization and K-means Clustering Algorithms

We will describe how the both algorithms work together. The one being, Acoustic Modelling technique, which involves both VQ and K means. The signal representation produces feature vector sequence. Now, there are few ways to process the multi dimensional sequence. Firstly,the methods which can directly model continuous space or secondly, the methods which involves Quantizing and modelling of discrete symbols. Clustering comes under unsupervised learning . Here, we are not aware of the number and forms of classes and the data is not present in a structured format. Clustering algorithm plays the important role in this.

4

Proposed Work

The proposed method is as follows. 1. Convert the image into gray scale image tif. 2. Then I have to read the image

2

3. Fixed the block size then each block do VQ (Image,parameter bits) using VQ encoder. 4. Then in decoder part take input as encoder output then decode it output will come VQ (original image and Reconstructed image). 5. Apply K means Algorithm in this Lossy compression. 6. Then in final by varying parameters and bits i can plot rate and distortion. 7. Change the Bits and for each block do for rest and plot it We will elucidate the method which we have proposed. We have taken input image in code and the purpose is to compare the size of the grayscale uncompressed tiff image with the length of the encoded sequence that you have stored, which is ’encodedSeq.bin’ and it represents your compressed version of the image. This quantity is what should be less than 1 for your code being effective. We have seen that the input image size and reconstructed image size is same and it is coming out that the compression ratio is less than 1. The encoder takes an image in input and gives in output a binary sequence which is the compressed file and the encoder function must save at the end the encoded sequence as a binary file which is the encode sequence. Secondly, the decoder takes the encoded sequence (.bin file) and reconstruct the image. Then, all the information that the decoder needs for the decoding must be written in the encoded sequence (.bin file): then you should have the decode function calling. We need to keep in mind that the function decoder takes as an input, among the other arguments, the image Img1 itself. In real applications, the decoder would know the original image, then it could throw away all the other information and have a perfect reconstruction. We have specified that the compression ratio you get: CR = (num. bit for encoding without c ompression)/ (number bit of the encoded sequence). (Clearly, num. bit for encoding without compression = size (image) * - in the script distortion. ask to the user ’enter the no. of iteration(n):’ it does not make sense. For the parameters L and K, I suggest to fix L (the smallest one, 4) and iterate on K. Actually you should iterate on the bit rate and not on K. Since VQ is very computationally heavy, you can consider only very low values for the bit rate. (1, 2, 3, maybe no more that this value) After the encoding and the decoding fuctions have been called, our task is converting the Recon- structed tif Image into unsigned 8-bit (1-byte) integers of class uint8 along with its size in the memory. Then, we calculate the Compression ratios after displaying it. File Size*8=no of bit in the binary file; File size is in byte so we are converting into bit. Same goes for the jpg image.

3

Figure 1

Figure 1(a)-Normal Input Image

Figure 1(b) - Reconstructed Image

Figure 2(a)-Input tif Image

Figure 2(b) - Reconstructed tif Image

Figure 3(a)-Input jpg Image

Figure 3(b)-Reconstructed jpg Image

Figure 2. Input and Output Images for the Experiment

4

5

Results

The compression ratios of two types of images could be compared and we plot a graph between Bitrate and Distortion after we have calculated the Euclidean distance and the Bitrate formula for the given inputs. Table 1.Output for JPG and TIF images Input Memory Size

Memory Size Compressed

Compression Ratio

1.

196608

99348

5.053101e-01

2.

196608

100372

5.105184e-01

3.

196608

102420

5.209351e-01

Figure 3. Bitrate v/s Distortion Graph

6

Conclusion

Image Compression algorithms and effective methods plays an important role in the field of Pattern Recognition, Data Mining, Computer Vision and Human Interaction. Image Compression is an effective approach where we can code the digital image in order to minimize the number of bits required in depicting it. Numerous image compression techniques are already present in the literature but they do have certain limitations. This paper could propose a novel approach using VQ for effective Image Compression.

7

References

[1] Rishav Chatterjee. Image Compression and Resizing Using Vector Quantization and Other Efficient Algorithms. IJESC. Volume 7, Issue No. 6. [2] Mohammed Uvaze Ahamed, Eswarran Chikkannan, Kannan Ramakrishan(2017). Lossy Image Compression based on prediction error and vector quantization. EURASIP Journal on Image and Video Processing. [3] Salomon D. Data compression: the complete reference. 3rd ed.New York: Springer; 2004. [4]. LockerGnome(2011), “Real World Application of Image Compression”, [5]. Bhavna Gautam, “A Thesis on Image Compression using Discrete Cosine Transform and Discrete Wavelet Transform”, National Institute of Rourkela. [6]. Paul Shelley, Xiaobo Li, Bin Han, “A hybrid quantization scheme for image compression”, University of Alberta, 2003. [7]. Martha R. Quispe-Ayala, Krista Asalde-Alvarez, Avid Roman-Gonzalez, “Image Classification Using Data Compression Techniques”, Author manuscript, published in 2010 IEEE 26th Convention of Electrical and Electronics Engineers in Israel - IEEEI N2010, Israel 2010. [8]. Nopparat Pantaesaena, M.Sangworaisl, C. Nantajiwakornchai and T. Phanpraist, “Image compression using vector quantization”, ReCCIT, Thialand,2005.1 [9] Pragada, S.; Sivaswamy, J. (2008-12-01). "Image Denoising Using Matched Biorthogonal Wavelets". 2008 Sixth Indian Conference on Computer Vision, Graphics Image Processing: 25–32. doi:10.1109/ICVGIP.2008.95. [10]. "Thresholds for wavelet 1-D using Birgé-Massart strategy - MATLAB wdcbm". www.mathworks.com. Retrieved 2017-05-03. [11] Ergen, Burhan (2012-01-01). Signal and Image Denoising Using Wavelet Transform. InTech. doi:10.5772/36434. [12]. "how to get SNR for 2 images - MATLAB Answers - MATLAB Central". Www.mathworks.com. Retrieved 2017-05-10.