A Python-based image compression pipeline implemented in a Jupyter Notebook, combining Discrete Wavelet Transform (DWT), K-Means clustering, and Arithmetic Coding for efficient grayscale image compression.
This pipeline allows you to compress images, store them in a lightweight format, and decompress them while preserving visual quality. It also provides metrics like PSNR and SSIM to evaluate compression quality.
- Discrete Wavelet Transform (DWT): Reduces image redundancy in frequency space.
- K-Means Clustering: Reduces color intensity variations, lowering data size.
- Arithmetic Coding: Efficient entropy coding for further compression.
- Quality Metrics: Computes PSNR and SSIM for compressed vs decompressed images.
- Visualization: Displays images at each compression stage (original → DWT → clustered → decompressed).
- Pickle-based Storage: Saves compressed data as
.pklfiles for easy sharing and decompression.
git clone https://github.com/faizmansoor/Image-Compression-Pipeline.git
cd image-compression-pipeline
pip install -r requirements.txt##Usage
Compress and Decompress an Image
from compression_pipeline import compress_and_decompress_imageresult = compress_and_decompress_image("test-images/test1.png")This will:
Save the compressed file as test1_compressed.pkl
Save the decompressed image as test1_decompressed.png
Display images at all stages
Print PSNR, SSIM, and compression ratio
Sample 1: 11.27:1 (91.1% size reduction)
Sample 2: 11.23:1 (91.1% size reduction)
Sample 3: 10.38:1 (90.4% size reduction)
Average Compression Ratio: 10.96:1 (~90.9% size reduction)