Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to calculate Image compression ratio?

How do I calculate the following : Suppose we want to compress tiny images that are 10x10 pixels and each pixel is represented by four bytes (for Red, Green, Blue and transparency).

Suppose a codebook (centroids of K-Means) of size 1000 provides acceptable distortion.

Assuming that each image is compressed separately, and ignoring the encoding of the codebook, what is the compression ratio (uncompressed bit / compressed bits)?

like image 851
Oliver Avatar asked Nov 02 '25 01:11

Oliver


1 Answers

Ignoring global compression parameters and encoding, and assuming we're keeping all pixels - each cluster (i.e. a color palette value) would be encoded as its cluster index.

For that we'll need 10 bits (covering up to 1024 values) for encoding each pixel in our new 1000 color palette.

Then, compared to our previous representation of 32 bits per pixel (4 bytes, one per color channel) we achieved a compression ratio of:

32 / 10 = 3.2
like image 76
mork Avatar answered Nov 04 '25 10:11

mork



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!