Skip to content

KBNLresearch/jpeg-quality-demo

Repository files navigation

About

This repository contains all analysis scripts and data that were used for the following blog posts:

Scripts

Below scripts were tested with Python 3.8.10, with version 10.4.0 of Pillow Imaging Library. Pillow can be installed using:

pip install pillow

Important note on Pillow version: some of these scripts will either not work or give (very!) wrong results when used with older Pillow versions! This is because Pillow changed the order in which the values in the quantization tables are returned around the release of Pillow 8.3 (I think!), see details here. The below scripts are all based on the new/current behaviour!

Also the plot-goodness-fit.py script needs Pandas. Installation:

pip install pandas

The scripts are:

  • jpegquality-im-original.py: computes JPEG quality for one or more files using original ImageMagick heuristic. Option --verbose prints out values of all variables in main loop at each iteration.
  • jpegquality-im-modified.py: computes JPEG quality for one or more files using modified ImageMagick heuristic. Option --verbose prints out values of all variables in main loop at each iteration.
  • jpegquality-lsm.py: computes JPEG quality for one or more files using least squares matching against standard JPEG quantization tables.
  • jpegquality-compare.py: computes JPEG quality for one or more files using all of the above methods, and write results in comma-delimited format.
  • generate-testimages-pillow.py: generates a set of JPEG images at 6 quality levels from a user-defined source image.
  • generate-testimages-im.sh: generates a set of JPEG images at 6 quality levels from a user-defined source image using ImageMagick.
  • generate-testimages-cjpeg.sh: generates 10 thousand images at all possible luminance, chrominance quality combinations using cjpeg.
  • test-quantization.py: reads the quantization tables of one or more files and writes the values to 2 comma separated text files.
  • plot-goodness-fit.py: creates scatterplots of image vs standard quantization tables and adds relevant measures (Q, RMSE, NSE).
  • cjpeg-sensitivity.py: performs simple sensitivity analysis on cjpeg-generated test images and creates scatter plots. This uses the output of generate-testimages-cjpeg.sh.

Both ImageMagick based quality estimation scripts are derived and modified from the Python port of ImageMagick's heuristic by Eddy O (AKA "eddygeek"). In turn this port is based on ImageMagick's original code.

Data

The directory images contains the following folders:

  • im_pil: test images created with Python's Pillow library and and ImageMagick. Each image is compressed at level indicated in filename.
  • source: source images for all Pillow and ImageMagick test images.
  • dbnl: examples of problematic access and master JPEGs from DBNL scans.
  • misc: miscellaneous images, most of these give different quality estimates depending on which tool/method is used.

Image attribution

About

Test scripts and resources for jpeg quality assessment

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published