A high-performance analysis pipeline for comparing classical image compression techniques: Wavelet Transforms vs. CUDA-Accelerated Fractal Encoding.
This project benchmarks compression performance across standard image datasets, with a highly optimized fractal encoding implementation that leverages both CPU and GPU workers in parallel. It outputs reconstructed images and generates comprehensive metrics (PSNR, SSIM, bitrate) for quantitative comparison.
Image compression is fundamental to digital media, balancing quality and file size. This project implements and compares two classical compression approaches:
- Wavelet-based compression: Multi-resolution decomposition with quantization
- Fractal compression: Self-similarity-based encoding using iterative block matching, now heavily accelerated with a hybrid CPU/GPU parallel pipeline.
The pipeline processes images from multiple datasets, applies both compression methods, reconstructs the images, and exports detailed performance metrics for analysis.
- Batch processing of multiple image datasets
- Complete compression/decompression workflows for both methods
- CUDA-Accelerated Fractal Codec: Core fractal compression and decompression logic is accelerated with CUDA via CuPy for massive performance gains.
- Hybrid CPU/GPU Parallel Processing: For fractal encoding, the system leverages all available CPU cores and multiple GPU workers simultaneously to maximize throughput.
- Dynamic Task Scheduling & Work-Stealing: A global task queue feeds all workers. Idle GPU workers can "steal" and accelerate tasks from busy CPU workers, ensuring high resource utilization and minimizing total runtime.
- GPU Task Prioritization: Larger, more computationally intensive images are automatically sorted and assigned to GPU workers first.
- Automated quality metrics calculation (PSNR, SSIM, bitrate)
- Visual outputs reconstructed images saved for inspection
- CSV export of all metrics for further analysis
- Real-time progress tracking with
tqdmprogress bars - Modular architecture for easy extension.
Project-Compression/
├── data/ # Input image datasets
│ ├── clic_subset/ # CLIC dataset subset
│ ├── kodak/ # Kodak PhotoCD test images
│ └── standard_test/ # Standard test images (Lena, Peppers, etc.)
├── results/ # Output directory
│ ├── fractal_cuda_parallel/ # Fractal-compressed results from the hybrid pipeline
│ │ ├── clic_subset/
│ │ ├── kodak/
│ │ └── standard_test/
│ └── metrics/ # Performance metrics CSV
├── src/ # Compression codec modules
│ ├── fractal_codec_cuda.py # CUDA-accelerated fractal implementation
│ ├── fractal_codec_structured.py# CPU-based fractal implementation
│ │ ├── clic_subset/
│ │ ├── kodak/
│ │ └── standard_test/
│ └── metrics/ # Performance metrics CSV
├── src/ # Compression codec modules
│ ├── fractal_codec.py # Fractal compression implementation
│ └── wavelet_codec.py # Wavelet compression implementation
├── fractal_structured_test.py # Main script for the advanced fractal pipeline
└── README.md # This file
- Python 3.8 or higher
- An NVIDIA GPU with CUDA Toolkit installed (version 11.x or 12.x recommended)
- pip package manager
Note on CuPy: The CUDA-accelerated fractal codec depends on CuPy, which must be installed according to your specific CUDA Toolkit version. It is highly recommended to install it manually before installing the other requirements.
For example, for CUDA 12.x:
pip install cupy-cuda12xSee the CuPy Installation Guide for other versions.
pip install -r requirements.txtThe project supports multiple standard image compression benchmarking datasets:
- 24 high-quality RGB images (768×512 pixels)
- Industry-standard benchmark for lossy compression
- Download: Kodak Lossless True Color Image Suite
- Classic test images: Lena, Peppers, Baboon, Barbara, etc.
- Available in 256×256 and 512×512 resolutions
- Download: USC-SIPI Misc Volume
- Professional and mobile photography datasets
- Use
clic_downloader.pyandclic_saver.pyto obtain a subset - Source: CLIC via TensorFlow Datasets
Place downloaded images in the corresponding folders under data/.
Run the main processing pipeline:
python main.pyThis will:
- Process all images in the configured datasets
- Apply wavelet and fractal compression
- Save reconstructed images
- Export metrics to CSV
Modify the data_dirs dictionary in main.py:
data_dirs = {
"kodak": "data/kodak",
"standard_test": "data/standard_test",
"clic_subset": "data/clic_subset"
}Decompressed images are saved for visual quality inspection:
- Wavelet:
results/wavelet/<dataset_name>/<image_name>_wavelet.png - Fractal:
results/fractal/<dataset_name>/<image_name>_fractal.png
The results/ directory contains all quantitative outputs:
-
Raw Metrics: Separate CSV files for each method are stored in
results/metrics/.wavelet.csvfractal_cuda_parallel.csv- Each file contains
dataset,image,psnr,ssim, andbitrate.
-
Performance Summary:
results/performance_summary.csvprovides a high-level overview.
| Column | Description |
|---|---|
dataset |
Name of the source dataset. |
image |
Original image filename. |
psnr_winner |
Method with the higher PSNR. |
ssim_winner |
Method with the higher SSIM. |
bitrate_winner |
Method with the lower bitrate. |
filesize_winner |
Method with the smaller file size. |
- Comparison Plots: Visualizations are saved in
results/detailed_plots/.[dataset]_[metric]_vs_bitrate.png: PSNR/SSIM vs. bitrate scatter plots.[dataset]_[metric]_vs_filesize.png: PSNR/SSIM vs. file size scatter plots.[image]_metrics_comparison.png: Bar chart comparing all metrics for a single image.
- Measures pixel-level difference between original and reconstructed images
- Higher values indicate better quality (typically 30-50 dB for good quality)
- Formula: PSNR = 10 × log₁₀(MAX²/MSE)
- Perceptual quality metric considering luminance, contrast, and structure
- Range: -1 to 1 (1 = identical images)
- Better correlates with human perception than PSNR
- Compression efficiency measured in bits per pixel
- Lower values indicate better compression
- Calculated from compressed file size divided by pixel count
Edit src/wavelet_codec.py:
# Compression parameters
wavelet='haar' # Wavelet type: 'haar', 'db4', 'sym8', etc.
level=3 # Decomposition levels (higher = finer detail)
quant_step=10 # Quantization step (higher = more compression)Edit src/fractal_codec.py:
# Block matching parameters
range_size=8 # Range block size
domain_size=16 # Domain block size (must be ≥ range_size)
iterations=10 # Decoder iterationsProcessing time varies based on:
- Image count and resolution
- Hardware (CPU, RAM)
- Algorithm complexity
Typical processing times per image:
- Wavelet: 0.5-2 seconds
- Fractal: 5-60 seconds (slower due to iterative block matching)
For full Kodak dataset (24 images):
- Total time: 3-25 minutes depending on implementation and hardware
Tip: Test with 3-5 images first to verify setup before processing full datasets.
- Ensure all dependencies are installed:
pip install -r requirements.txt - Verify
src/folder contains both codec files - Check that codec files define all required functions at module level
- Enable Windows Long Path support: Instructions
- Or use shorter directory paths (e.g.,
C:\clic\)
- Safe to ignore; TensorFlow warns about non-standard color profiles
- Images are processed correctly despite the warning
- Kodak Lossless True Color Image Suite
- USC-SIPI Image Database
- CLIC: Challenge on Learned Image Compression
- Wavelet Transform Image Compression
- Fractal Image Compression (Barnsley, Jacquin)
Contributions are welcome! Areas for improvement:
- Additional compression methods (JPEG, JPEG2000, etc.)
- Color image support for fractal compression
- GPU acceleration for faster processing
- Additional quality metrics (VIF, MS-SSIM, etc.)
- Visualization tools for results
For questions or issues, please open an issue on the GitHub repository.
Project Status: Active Development
Last Updated: November 2025