#ssim #image #comparison #metric #objective


Library that measures structural similarity between images using a multi-scale variant of the SSIM algorithm

3 stable releases

new 2.11.5 Jan 12, 2021
2.11.4 Oct 11, 2020
2.11.3 Aug 24, 2020

#1 in #metric

Download history 58/week @ 2020-09-25 48/week @ 2020-10-02 254/week @ 2020-10-09 311/week @ 2020-10-16 340/week @ 2020-10-23 82/week @ 2020-10-30 89/week @ 2020-11-06 39/week @ 2020-11-13 56/week @ 2020-11-20 93/week @ 2020-11-27 449/week @ 2020-12-04 385/week @ 2020-12-11 323/week @ 2020-12-18 142/week @ 2020-12-25 55/week @ 2021-01-01 70/week @ 2021-01-08

824 downloads per month
Used in 2 crates (via dssim)


1.5K SLoC

RGBA Structural Similarity

This tool computes (dis)similarity between two or more PNG images using an algorithm approximating human vision.

Comparison is done using the SSIM algorithm at multiple weighed resolutions.

The value returned is 1/SSIM-1, where 0 means identical image, and >0 (unbounded) is amount of difference. Values are not directly comparable with other tools. See below on interpreting the values.


  • Comparison is done in L*a*b* color space (D65 white point, sRGB gamma). Other implementations use "RGB" or grayscale without gamma correction.
  • Supports alpha channel.
  • No OpenCV or MATLAB needed.
    • DSSIM version 1.x uses C (C99) and libpng or Cocoa on macOS.
    • DSSIM version 2.x is easy to build with Rust.


dssim file-original.png file-modified.png

Will output something like "0.02341" (smaller is better) followed by a filename.

You can supply multiple filenames to compare them all with the first file:

dssim file.png modified1.png modified2.png modified3.png

You can save an image visualising the difference between the files:

dssim -o difference.png file.png file-modified.png

It's also usable as a library.

Please be careful about color profiles in the images. Different profiles, or lack of support for profiles, can make images appear different even when the pixels are the same.

Interpreting the values

The amount of difference goes from 0 to infinity. It's not a percentage.

If you're comparing two different image compression codecs, then ensure you either:

  • compress images to the same file size, and then use DSSIM to compare which one is closests to the original, or
  • compress images to the same DSSIM value, and compare file sizes to see how much file size gain each option gives.

More about benchmarking image compression.

When you quote results, please include DSSIM version, since the scale has changed between versions. The version is printed when you run dssim -h.

Build or Download

You need Rust 1.48 or later.

cargo build --release

Will give you ./target/release/dssim.


Scores for version 2.11 measured against TID2013 database:

TID2013 Spearman Kendall
Noise -0.9336 -0.7670
Actual -0.9405 -0.7803
Simple -0.9479 -0.7980
Exotic -0.8510 -0.6628
New -0.8408 -0.6619
Color -0.8537 -0.6761
Full -0.8724 -0.6953


DSSIM is dual-licensed under AGPL or commercial license.

The algorithm improvements in DSSIM

  • The comparison is done on multiple weighed scales (based on IWSSIM) to measure features of different sizes. A single-scale SSIM is biased towards differences smaller than its gaussian kernel.
  • Scaling is done in linear-light RGB to model physical effects of viewing distance/lenses. Scaling in sRGB or Lab would have incorrect gamma and mask distortions caused by chroma subsampling.
  • ab channels of Lab are compared with lower spatial precision to simulate eyes' higher sensitivity to brightness than color changes.
  • The lightness component of SSIM is ignored when comparing color channels.
  • SSIM score is pooled using a combination of local maximums and global averages. You can get per-pixel SSIM from the API to implement custom pooling.


~34K SLoC