Fred's ImageMagick Scripts



    Licensing:

    Copyright © Fred Weinhaus

    My scripts are available free of charge for non-commercial use, ONLY.

    For use of my scripts in commercial (for-profit) environments or non-free applications, please contact me (Fred Weinhaus) for licensing arrangements. My email address is fmw at alink dot net.

    If you: 1) redistribute, 2) incorporate any of these scripts into other free applications or 3) reprogram them in another scripting language, then you must contact me for permission, especially if the result might be used in a commercial or for-profit environment.

    Usage, whether stated or not in the script, is restricted to the above licensing arrangements. It is also subject, in a subordinate manner, to the ImageMagick license, which can be found at: http://www.imagemagick.org/script/license.php

SSIM


Computes the structural similarity metric between two equal sized images and its complement structural dissimilarity metric.

Download Script

last modified: January 14, 2016



USAGE: ssim [-f format] infile1 infile2 [outfile]
USAGE: ssim [-h or -help]

-f ... format ...... FORMAT is the output image format, if the outfile is
.................... specified; choices are: ssim or dssim; default=ssim
-p ... precision ... PRECISION is the number of decimal figures in the
.................... metric to show; default=3

PURPOSE: To compute the structural similarity metric between two equal sized images.

DESCRIPTION: SSIM computes the structural similarity metric between two equal sized images and its complement structural dissimilarity metric (DSSIM). The DSSIM=(1-SSIM). An optional output image may be specified which can show the SSIM or DSSIM image. The latter is just the -negate of the former. The SSIM process first converts the images to Luma space and then computes the ssim metric within 11x11 local regions at every pixel with Gaussian weighting. Then it computes the average ssim value across the resulting ssim image and reports that value.

ARGUMENTS:

-f format ... FORMAT is the output image format, if the outfile is specified. The choices are: ssim (s) or dssim (d). The default=ssim

-p precision ... PRECISION is the number of decimal figures in the metric to show. The default=3

REFERENCES:
http://en.m.wikipedia.org/wiki/SSIM
https://en.wikipedia.org/wiki/Covariance
http://www.cns.nyu.edu/pub/eero/wang03-reprint.pdf
http://www.cns.nyu.edu/~lcv/ssim/

NOTE: This script will process only the first frame/page of a multiframe or multipage image.

NOTE: Without HDRI enabled, there may be some rounding errors so that the SSIM metric on the image against itself may not be an exact 1, especially if precision is higher than the default.

CAVEAT: No guarantee that this script will work on all platforms, nor that trapping of inconsistent parameters is complete and foolproof. Use At Your Own Risk.


EXAMPLES


Input Image 1

Input Image 2

SSIM Image

SSIM / DSSIM Metrics

ssim=1 dssim=0

ssim=0.807 dssim=0.193

ssim=0.617 dssim=0.383

ssim=0.47 dssim=0.53

ssim=0.463 dssim=0.537



What the script does is as follows:

  • Computes the SSIM Metric according to the references
  • Returns the SSIM metric and optional SSIM image

See the script for actual code details.