paint-brush
What is an Image Compression Module?by@remotedesktop

What is an Image Compression Module?

by Remote Desktop4mFebruary 28th, 2025
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

In this paper, we describe a practical clustering procedure that is designed specifically for the compression of 2D images.

People Mentioned

Mention Thumbnail

Companies Mentioned

Mention Thumbnail
Mention Thumbnail
featured image - What is an Image Compression Module?
Remote Desktop HackerNoon profile picture
0-item

Abstract and 1 Introduction

2 Related Work

3 Image Compression Module

4 System Architecture

5 Experimental Results

6 Conclusions

A Compression Results

References

3 Image Compression Module

Clustering methods are widely used in pattern recognition, data compression, data mining, but the problem of using them in real-time systems has not been a focus of most algorithm designers. In this paper, we describe a practical clustering procedure that is designed specifically for compression of 2D images.


3.1 K-means Clustering



Algorithm 1: Conventional K-Means Algorithm


3.2 Proposed Image Compression Algorithm using k-Means


2D images typically use either 8-bit or 24-bit color. When using 8-bit color, there is a definition of up to 256 colors forming a palette for this image, each color denoted by an 8-bit value. A 24-bit color scheme, as the term suggests,


Fig. 2: Image compression module, following the procedure given in Algorithm 2.


Input : Real image, µ number


Output: Reconstructed image


1. Load the color image A(m × n);


2. Read every pixel in the original image as sample data;


3. Apply k-Means algorithm to find the µ colors (clusters) that best group the pixels in the 3-dimensional RGB space;.


4. Compute the cluster centroids again;


5. Assign each pixel position to its closest centroid;


6. Compute the mean of all the centroid;


7. Replace each pixel location with the mean of the assigned centroid;


Algorithm 2: Image Compression Algorithm using k-Means Clustering


uses 24 bits per pixel and provides a much better set of colors. For our purposes we’ll consider 24 bit RGB (R’G’B’) to be uncompressed color. The number 24 refers to the total number of bpp (bits per pixel) used to describe color. A 24 bit number has a range of 0 (no color or black) to 16,777,215 for a total of 16,777,216 different colors. Since Red, Green, and Blue are each described by 8 bits (24/3), which gives a range of 0 (no Red, no Green, or no Blue) to 255 for a total of 256 possible variations of each primary color. From this we can start to get an idea that the real-image contains thousands of colors and reduce the number of colors as a suitable number of colors. It can be 8, 16 or 32 colors, depend on the user demand and the network condition which is present in the next section. Procedure of image compression algorithm is shown in Figure 2.


By making this reduction, it is possible to represent (compress) the photo in an efficient way. For example, suppose we want to reduce the number of colors to 16 of 256×256 image . Specifically, we need to store the RGB values of the 16 selected colors, and for each pixel in the images we now need to only store the index of the color at that location (where only 4 bits are necessary to represent 16 possibilities). Concretely, we will treat every pixel in the original image as a data example and use the k-means algorithm to find the 16 colors that best group (cluster) the pixels in the 3 dimensional RGB space. Figure 3 shows that there are 16 groups of colors be created after applying the K-means clustering algorithm. First we have computed the cluster centroids on the image and then assigned each pixel position to its closest centroid. After that, we can view the effects of the compression by reconstructing the image based on the centroid assignments. Specifically, replace each pixel location with the mean of centroid assigned. Eventually, notice that after these steps we have significantly reduced the number of bits that are required to describe the image. The results can be summarized as follows: The original image required 24 bits for each one of the 256×256 pixel locations, so total size of 256 ×256×24 = 1, 572, 864 bits. The new representation requires some overhead storage in form of a dictionary of 16 colors, each of which require 24 bits, but the image itself then only requires 4 bits per pixel location. The final number of bits used is therefore 16 × 24 + 256 × 256 × 4 = 262, 528 bits, which corresponds to compressing the original image by about a factor of 6.


Fig. 3: Applying K-means clustering with a 2D image: the centroids stopped moving at the 10th iteration, meeting the convergence termination criterion. 16 colors (cluster) that best group be created


This paper is available on arxiv under CC BY 4.0 DEED license.

Authors:

(1) Huu-Quoc Nguyen, Department of Computer Engineering, Kyung Hee University, 1 Seocheon, Giheung, Yongin, Gyeonggi, South Korea and quoc@khu.ac.kr;

(2) Tien-Dung Nguyen, Department of Computer Engineering, Kyung Hee University, 1 Seocheon, Giheung, Yongin, Gyeonggi, South Korea and ntiendung@khu.ac.kr;

(3) Van-Nam Pham, Department of Computer Engineering, Kyung Hee University, 1 Seocheon, Giheung, Yongin, Gyeonggi, South Korea and nampv@khu.ac.kr;

(4) Xuan-Qui Pham, Department of Computer Engineering, Kyung Hee University, 1 Seocheon, Giheung, Yongin, Gyeonggi, South Korea and pxuanqui@khu.ac.kr;

(5) Quang-Thai Ngo, Department of Computer Engineering, Kyung Hee University, 1 Seocheon, Giheung, Yongin, Gyeonggi, South Korea and nqthai@khu.ac.kr;

(6) Eui-Nam Huh, Department of Computer Engineering, Kyung Hee University, 1 Seocheon, Giheung, Yongin, Gyeonggi, South Korea and johnhuh@khu.ac.kr.