A systematic comparison of linear algebra-based and state of the art image compression techniques
Course: DSC 210 - Numerical Linear Algebra
Instructor: Dr. Tsui-Wei Weng
Team Members:
Aryan Bansal, Chandrima Das, Keertana Kappuram, Shreejith Suthraye Gokulnath
The aim of this project is to compare SVD-based image compression with the state of the art method, JPEG2000. For this, we used the Kodak Lossless True Color Image Suite, which is a widely used benchmark in image compression research.
For SVD, we used numpy
, and for JPEG2000, we utilized the implementation in Glymur
.
For SVD, the parameter used to control the compression was the explained variance. A higher explained variance leads to lower compression ratios.
SVD based compression achieved poor results, with compression ratios up to 2.2. Even at 97% variance, the PSNR, on average, was below 20 dB, and SSIM was under 0.7, indicating poor quality.
Here we have SVD-based compression at an explained variance of 95%. As evidenced by the difference of images, there was a significant loss of detail. This is why the compressed image does not look anything like the original image.
If we increase the retained variance to 99%, the difference between images is minimal. We achieve a better quality image, but the compression ratio is close to 1.
The JPEG2000 compression was controlled by the compression ratio.
JPEG2000 achieved compression ratios as high as 70, which is a 70 times reduction in file size, with high PSNR and structural similarity, indicating excellent compression quality.
Looking at the JPEG2000 compressed image at a compression ratio of 5, no discernable details were lost. This results in a better compression without loss of visual quality.
Even at a compression ratio of 100, there was no blurring or loss of detail, demonstrating efficient compression without visual degradation.
- Note: Ensure that the network connectivity is good - the build stage will fail if the network speed is low.
-
Download the
Dockerfile
(no need to clone the repository). -
Build the docker image:
docker build --no-cache -t image-compression-team24-notebook .
This step can take 6-7 minutes.
- Run the image:
docker run -it --rm -p 8888:8888 image-compression-team24-notebook:latest
Ensure that no other container is already using port 8888, or use a different port.
-
Navigate to
https://127.0.0.1:8888/tree?
(replace port number, if necessary). Jupyter may take some time to load, and you may need to refresh the browser a few times. -
Run the cells of the image_compression.ipynb notebook.
-
Clone the repository and navigate to the project's root directory.
-
Set up the environment:
# Create the conda environment conda env create -f environment.yaml sudo apt-get update sudo apt-get upgrade -y # Install openJPEG and other dependencies sudo apt install libopenjp2-7 libopenjp2-tools libgl1-mesa-glx # Activate the environment conda activate dsc210-project-team24 # If using VS code, this can be skipped pip install jupyter
-
Set the paths in
.env
. OnlyPROJECT_DIR
needs to be set to the current working directory (repo directory). DO NOT change the other variables. -
Create the directories for storing the compressed images and the metrics
mkdir -p image_data/compressed_jp2 image_data/compressed_svd metrics/jp2 metrics/svd
-
Run the cells of the image_compression.ipynb notebook. (If using VS Code, use the dsc210-project-team24 environment to create a kernel.)