#image #compare #rms #ssim #rgb #comparison #hybrid #grayscale


Image comparison library based upon the image crate. Currently it provides SSIM and RMS for comparing grayscale and rgb images, a cool hybrid compare as well as several grayscale histogram distance metrics. All with a friendly license.

6 releases

Uses new Rust 2021

new 0.2.2 May 14, 2022
0.2.1 May 6, 2022
0.2.0-RC2 Apr 24, 2022
0.1.1 Apr 6, 2022

#95 in Images

Download history 20/week @ 2022-03-31 114/week @ 2022-04-07 38/week @ 2022-04-14 51/week @ 2022-04-21 141/week @ 2022-04-28 118/week @ 2022-05-05 177/week @ 2022-05-12

487 downloads per month

MIT license

802 lines


Documentation CI

Simple image comparison in rust based on the image crate

Note that this crate is heavily work in progress. Algorithms are neither cross-checked not particularly fast yet. Everything is implemented in plain CPU with rayon multithreading. SIMD is under investigation on a feature branch (simd-experimental).

Supported now:

  • Comparing grayscale and rgb images by structure
    • By RMS - score is calculated by:
    • By MSSIM
      • SSIM is implemented as described on wikipedia:
      • MSSIM is calculated by using 8x8 pixel windows for SSIM and averaging over the results
    • RGB type images are split to R,G and B channels and processed separately.
      • The worst of the color results is propagated as score but a float-typed RGB image provides access to all values.
      • As you can see in the gherkin tests this result is not worth it currently, as it takes a lot more time
      • It could be improved, by not just propagating the individual color-score results but using the worst for each pixel
      • This approach is implemented in hybrid-mode, see below
    • "hybrid comparison"
      • Splitting the image to YUV colorspace according to T.871
      • Processing the Y channel with MSSIM
      • Comparing U and V channels via RMS
      • Recombining the differences to a nice visualization image
      • Score is calculated as:
      • This allows for a good separation of color differences and structure differences
  • Comparing grayscale images by histogram
    • Several distance metrics implemented see OpenCV docs:
      • Correlation
      • Chi-Square
      • Intersection
      • Hellinger distance


~114K SLoC