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(), ¶ms).unwrap();
// Identical images should have score ~0
assert!(result.score < 0.01);§Features
simd(default): Enable SIMD optimizations via thewidecrate
§References
Re-exports§
pub use precompute::ButteraugliReference;
Modules§
- precompute
- Precomputed reference data for fast repeated butteraugli comparisons.
Structs§
- Butteraugli
Params - Butteraugli comparison parameters.
- Butteraugli
Result - Butteraugli image comparison result.
- Img
- Basic struct used for both owned (alias
ImgVec) and borrowed (aliasImgRef) image fragments. - RGB
- A
Red + Green + Bluepixel.
Enums§
- Butteraugli
Error - 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_
butteraugli Deprecated - Legacy function for backward compatibility.
- compute_
butteraugli_ linear Deprecated - Legacy function for backward compatibility (linear RGB).
- srgb_
to_ linear - Converts sRGB u8 value to linear RGB f32.