![](img-similarity.svg) [![image-similarity at crates.io](https://badgen.net/crates/v/image-similarity)](https://crates.io/crates/image-similarity) [![image-similarity at docs.rs](https://docs.rs/image-similarity/badge.svg)](https://docs.rs/image-similarity/0.1.5/image-similarity/) A Rust library for calculating the similarity between two images. ## List of metrics - [x] Sum of Absolute Differences (SAD) - [x] Mean of Absolute Differences (MAD) - [x] Sum of Squared Differences (SSD) - [x] 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 ```toml [dependencies] image = "0.23.4" ``` ``` rust 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 | | --- | --- | ![](test/test_image.png) | ![](test/test_image.png) | | SAD¹: | 0 | MAD¹: | 0.0 | SSD¹: | 0 | MSE¹: | 0.0 ![](test/test_image.png) | ![](test/test_image_blur2.png) | | --- | --- | | SAD¹: | 13500834 | MAD¹: | 51.501595 | SSD¹: | 1179189332 | MSE¹: | 4498.2505 ![](test/test_image.png) | ![](test/test_image_blur5.png) | | --- | --- | | SAD¹: | 16662881 | MAD¹: | 63.563847 | SSD¹: | 1680929909 | MSE¹: | 6412.239 ![](test/test_image.png) | ![](test/test_image_noise20.png) | | --- | --- | | SAD¹: | 19903895 | MAD¹: | 75.92734 | SSD¹: | 1681425109 | MSE¹: | 6414.128 ![](test/test_image.png) | ![](test/test_image_noise50.png) | | --- | --- | | SAD¹: | 46021705 | MAD¹: | 175.55887 | SSD¹: | 9046268163 | MSE¹: | 34508.773 ![](test/test_image.png) | ![](test/test_image_noise100.png) | | --- | --- | | 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