Crate butteraugli

Crate butteraugli 

Source
Expand description

§Butteraugli

Butteraugli is a perceptual image quality metric developed by Google. This is a Rust port of the butteraugli algorithm from libjxl.

The metric is based on:

  • Opsin: dynamics of photosensitive chemicals in the retina
  • XYB: hybrid opponent/trichromatic color space
  • Visual masking: how features hide other features
  • Multi-scale analysis: UHF, HF, MF, LF frequency components

§Quality Thresholds

  • Score < 1.0: Images are perceived as identical
  • Score 1.0-2.0: Subtle differences may be noticeable
  • Score > 2.0: Visible difference between images

§Example

use butteraugli::{butteraugli, ButteraugliParams};
use imgref::Img;
use rgb::RGB8;

// Create two 8x8 RGB images (must be 8x8 minimum)
let width = 8;
let height = 8;
let pixels: Vec<RGB8> = (0..width * height)
    .map(|i| RGB8::new((i % 256) as u8, ((i * 2) % 256) as u8, ((i * 3) % 256) as u8))
    .collect();

let img1 = Img::new(pixels.clone(), width, height);
let img2 = Img::new(pixels, width, height); // Identical images

let params = ButteraugliParams::default();
let result = butteraugli(img1.as_ref(), img2.as_ref(), &params).unwrap();

// Identical images should have score ~0
assert!(result.score < 0.01);

§Features

  • simd (default): Enable SIMD optimizations via the wide crate

§References

Re-exports§

pub use precompute::ButteraugliReference;

Modules§

precompute
Precomputed reference data for fast repeated butteraugli comparisons.

Structs§

ButteraugliParams
Butteraugli comparison parameters.
ButteraugliResult
Butteraugli image comparison result.
Img
Basic struct used for both owned (alias ImgVec) and borrowed (alias ImgRef) image fragments.
RGB
A Red + Green + Blue pixel.

Enums§

ButteraugliError
Error type for butteraugli operations.

Constants§

BUTTERAUGLI_BAD
Quality threshold for “bad” (visible difference).
BUTTERAUGLI_GOOD
Quality threshold for “good” (images look the same).

Functions§

butteraugli
Computes butteraugli score between two sRGB images.
butteraugli_linear
Computes butteraugli score between two linear RGB images.
compute_butteraugliDeprecated
Legacy function for backward compatibility.
compute_butteraugli_linearDeprecated
Legacy function for backward compatibility (linear RGB).
srgb_to_linear
Converts sRGB u8 value to linear RGB f32.

Type Aliases§

ImgRef
Reference to pixels inside another image. Pass this structure by value (i.e. ImgRef, not &ImgRef).
ImgVec
Image owning its pixels.
RGB8
8-bit RGB