Skip to content

Python images scalar quantizer lossy compressor and decompressor.

Notifications You must be signed in to change notification settings

bernatmarcilla/image-scalar-quantizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

image-scalar-quantizer

The whole compression process only consist of a single quantization stage: no transform or predictor, nor entropy encoding, just a quantizer. Obviously the compression process is lossy. The objective is to the get the lowest Mean Squared Error (MSE) possible between the original and the reconstructed image. Since there are more than one image, the objective is to minimize the average MSE when encoding and decoding all of them.

Quantizer

This is a scalar quantizer that generate compresseds .bin files with rate of (at most) 3 bps. The encoder implements the Lloyd's algorithm to get a representative value for each subgroup of values and will iterate until there is no changes between iteration and iteration.

Usage

python3 scalar_cat_encoder.py cat_image.png quantized_image.bin
python3 scalar_cat_decoder.py quantized_image.bin recovered_cat_image.png

Results

After encode and decode 193 images, the final average Mean Squared Error (MSE) is 52.761987462.