Skip to main content

Crate iqa

Crate iqa 

Source
Expand description

iqa provides a single, ergonomic API over the patchwork of visual quality assessment metrics available in the Rust ecosystem.

Every metric consumes the same Image<F> type, parameterized by a PixelFormat marker. The format fixes an image’s color space, channel layout, and bit depth at the type level, and a metric requires its two inputs to share one format. Comparing images that differ in any of those properties — a classic source of meaningless scores — is therefore a compile error, not a silent surprise. Only a dimension mismatch, which cannot be known at compile time, remains a runtime error.

Decoding external image formats into an Image is out of scope: callers build one directly from a sample buffer via Image::srgb8 and friends.

§Features

Each metric is gated behind a Cargo feature:

  • psnr (default) — peak signal-to-noise ratio, a native implementation.
  • ssim (default) — structural similarity index (SSIM), a native implementation.
  • dssim (default) — structural dissimilarity, (1 - SSIM) / 2, a native implementation layered on ssim (which it enables).
  • ms-ssim (default) — multi-scale SSIM (MS-SSIM), a native implementation that evaluates ssim over an image pyramid (and so enables ssim).
  • iw-ssim (default) — information content weighted SSIM (IW-SSIM, Wang & Li 2011), a native Laplacian-pyramid extension of MS-SSIM that pools ssim’s contrast-structure maps by a Gaussian-Scale-Mixture information weight (and so enables ssim).
  • psnr-hvs-m (default) — PSNR-HVS-M (Ponomarenko et al. 2007), a native DCT-domain PSNR with a contrast-sensitivity function and contrast masking.
  • ciede2000 (default) — CIEDE2000 (ΔE₀₀), a native implementation of the CIE’s perceptual color difference: per-pixel sRGB→CIELAB (D65), mean-pooled.
  • ssimulacra2 (default) — SSIMULACRA2, bound via FFI to the vendored C++ reference. Enabling it requires the third_party/ git submodules and a C++ toolchain; see the project README.
  • butteraugli (default) — Butteraugli, bound via FFI to libjxl’s vendored C++. Shares the same native build as ssimulacra2.

Structs§

ButteraugliOptions
Tuning parameters for butteraugli.
Ciede2000Options
Options controlling a CIEDE2000 computation.
DssimOptions
Options controlling a DSSIM computation.
Gray8
8-bit grayscale, one channel per pixel.
Gray16
16-bit grayscale, one channel per pixel.
Image
A decoded image of pixel format F.
IwssimOptions
Options controlling an IW-SSIM computation.
MsssimOptions
Options controlling an MS-SSIM computation.
PsnrHvsOptions
Options controlling a PSNR-HVS-M computation.
PsnrOptions
Options controlling a PSNR computation.
Rgba8
8-bit sRGB with an alpha channel, four channels per pixel (R, G, B, A).
Rgba16
16-bit sRGB with an alpha channel, four channels per pixel (R, G, B, A).
Srgb8
8-bit sRGB, three channels per pixel (R, G, B).
Srgb16
16-bit sRGB, three channels per pixel (R, G, B).
SsimOptions
Options controlling an SSIM computation.

Enums§

BitDepth
Bits per sample of an Image.
Channels
Channel layout of an Image.
ColorSpace
Color space the pixel values are encoded in.
Error
Errors produced when constructing images or computing metrics.
PsnrHvsMode
Which signal PSNR-HVS-M is computed over.
PsnrMode
Which signal PSNR is computed over.
SsimMode
Which signal SSIM is computed over.

Traits§

ButteraugliInput
A pixel format that butteraugli can score.
PixelFormat
A compile-time description of how an Image’s pixels are laid out and interpreted.
Sample
A raw image sample type: either u8 or u16.
Ssimulacra2Input
A pixel format that ssimulacra2 can score.

Functions§

butteraugli
Computes the Butteraugli distance between reference and distorted.
ciede2000
Computes the mean CIEDE2000 (ΔE₀₀) color difference between reference and distorted.
dssim
Computes the structural dissimilarity (DSSIM) between reference and distorted as (1 - SSIM) / 2.
iwssim
Computes the IW-SSIM between reference and distorted.
msssim
Computes the MS-SSIM between reference and distorted.
psnr
Computes the PSNR (in decibels) between reference and distorted.
psnr_hvs_m
Computes the PSNR-HVS-M (in decibels) between reference and distorted.
ssim
Computes the mean SSIM between reference and distorted.
ssimulacra2
Computes the SSIMULACRA2 score between reference and distorted.

Type Aliases§

Result
Convenience alias for results returned by this crate.