|3.1.0||Mar 20, 2021|
|3.0.1||Mar 19, 2021|
|3.0.0||Feb 8, 2021|
|2.11.5||Jan 12, 2021|
|2.11.3||Aug 24, 2020|
#1 in #metric
363 downloads per month
Used in 2 crates (via dssim)
This tool computes (dis)similarity between two or more images using an algorithm approximating human vision. Comparison is done using a variant of the SSIM algorithm.
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.
- Improved algorithm
- Compares at multiple weighed resolutions, and scaling is done in linear-light RGB. It's sensitive to distortions of various sizes and blends colors correctly to detect e.g. chroma subsampling errors.
- Uses L*a*b* color space for the SSIM algorithm. It measures brightness and color much better than metrics from average of RGB channels.
- Supports alpha channel.
- Supports images with color profiles.
- Takes advantage of multi-core CPUs.
- Can be used as a library in C, Rust, and WASM.
- No OpenCV or MATLAB needed.
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 mindful about color profiles in the images. Different profiles, or lack of support for profiles in other tools, can make images appear different even when the pixels are the same.
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.
When you quote results, please include the DSSIM version. The scale has changed between versions.
The version is printed when you run
Download from releases page. It's also available in Mac Homebrew and Ubuntu Snaps.
You'll need Rust 1.48 or later. Clone the repo and run:
cargo build --release
Will give you
- 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.
- a/b 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 mean absolute deviation. You can get per-pixel SSIM from the API to implement custom pooling.