This repository contains two projects related to image compression techniques:
- JPEG Compression Engine: A custom implementation inspired by the JPEG compression algorithm.
- Edge-Based Image Compression: An implementation of a research paper that employs edge detection and homogeneous diffusion for image compression.
Click here for the detailed project report summarizing the methods, experiments, and results.
JPEG_compression_engine.ipynb: Implements a JPEG-like compression algorithm.Research_Paper_Implementation.ipynb: Implements edge-based image compression from a research paper (link to paper).CS663_Project_Report.pdf: Comprehensive report detailing methodologies, experiments, and results of both projects.
- Techniques Used:
- Discrete Cosine Transform (DCT): Converts image data from spatial to frequency domain.
where:
-
$I(x, y)$ represents the intensity value of the pixel at position$(x, y)$ in the image block. -
$C(u, v)$ is the DCT coefficient at position$(u, v)$ in the frequency domain. -
$N$ is the size of the block ($N=8$ in JPEG compression). -
The
$u$ and$v$ indices correspond to frequencies in the horizontal and vertical directions, respectively.- Quantization: Reduces precision for compression.
where:
-
$C(u, v)$ represents the DCT coefficient at position$(u, v)$ , -
$Q_{\text{table}}(u, v)$ is the corresponding value in the quantization matrix, -
$Q(u, v)$ is the quantized coefficient. -
Objectives:
- Implement core JPEG compression steps for grayscale images.
- Evaluate compression with metrics such as Bits Per Pixel (BPP) and Root Mean Squared Error (RMSE).
- Simulate varying quality factors and plot RMSE vs. BPP curves.
| Quality Factor | File Size (bytes) | Compression Rate | Compression Ratio |
|---|---|---|---|
| Original | 186368 | - | - |
| 10 | 3116.50 | 59.80 | 0.017 |
| 40 | 3932.88 | 47.39 | 0.021 |
| 80 | 4967.62 | 37.52 | 0.027 |
Table 1: File Size, Compression Rate, and Compression Ratio at different Quality Factors
- Stages:
- Edge Detection and Mask Generation: Identifies edges for efficient compression.
- Subsampling: Reduces redundant data storage near edges.
- Supersampling: Improves reconstruction near edges.
- Reconstruction: Uses homogeneous diffusion to fill missing data.
- Sample Results:


- Python 3.8 or above
- Required libraries:
numpyopencv-pythonscipymatplotlibjupyterlab
Install dependencies using:
pip install numpy opencv-python scipy matplotlib jupyterlabClone the repository:
git clone https://github.com/SRAVAN-IITB/Image-Compression-Algorithms.git
cd Image-Compression-AlgorithmsRun the notebooks:
- Open
JPEG_compression_engine.ipynborResearch_Paper_Implementation.ipynbin Jupyter Lab/Notebook. - Execute cells sequentially to see results and visualizations.
- Significant compression achieved with minimal loss in visual quality.
- Observed inverse exponential decay of RMSE with increasing BPP.
- Moderate compression rates with limitations in Peak Signal-to-Noise Ratio (PSNR) for detailed images.
- For detailed analysis, refer to
CS663_Project_Report.pdf.
Feel free to contribute by opening issues or submitting pull requests. Feedback is highly appreciated!
- Prof. Ajit Rajwade, Indian Institute of Technology Bombay.
- Research paper authors for their innovative methods in image compression.
- Libraries: NumPy, OpenCV, SciPy, and Matplotlib.
This project is licensed under the MIT License. See the LICENSE file for details.



