6 releases

0.1.5 Oct 27, 2022
0.1.4 Oct 26, 2022

#1 in #sad

MIT license

3MB
110 lines

image-similarity at crates.io image-similarity at docs.rs

A Rust library for calculating the similarity between two images.

List of metrics

  • Sum of Absolute Differences (SAD)
  • Mean of Absolute Differences (MAD)
  • Sum of Squared Differences (SSD)
  • Mean of Squared Error (MSE)
  • Normalized Cross Correlation (NCC)
  • Peak Signal to Noise Ratio (PSNR)
  • Structural Similarity (SSIM)
  • Multi-Scale Structural Similarity (MS-SSIM)
  • Gradient Magnitude Similarity (GMSD)
  • ...

Usage

[dependencies]
image = "0.23.4"
let image_a = image::open("image_a.png").unwrap();
let image_b = image::open("image_b.png").unwrap();
let difference = similarity_sad(&image_a, &image_b);

Examples of results

Image A Image B
SAD¹: 0
MAD¹: 0.0
SSD¹: 0
MSE¹: 0.0
SAD¹: 13500834
MAD¹: 51.501595
SSD¹: 1179189332
MSE¹: 4498.2505
SAD¹: 16662881
MAD¹: 63.563847
SSD¹: 1680929909
MSE¹: 6412.239
SAD¹: 19903895
MAD¹: 75.92734
SSD¹: 1681425109
MSE¹: 6414.128
SAD¹: 46021705
MAD¹: 175.55887
SSD¹: 9046268163
MSE¹: 34508.773
SAD¹: 69718295
MAD¹: 265.9542
SSD¹: 20780685733
MSE¹: 79272.02

¹: The smaller the value, the more similar the images are.


Made with 💜 by AE Studio

Dependencies

~13MB
~57K SLoC