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_oxide::{compute_butteraugli, ButteraugliParams};
// Create two 8x8 RGB images (must be 8x8 minimum)
let width = 8;
let height = 8;
let rgb1: Vec<u8> = (0..width * height * 3).map(|i| (i % 256) as u8).collect();
let rgb2 = rgb1.clone(); // Identical images
let params = ButteraugliParams::default();
let result = compute_butteraugli(&rgb1, &rgb2, width, height, ¶ms).unwrap();
// Identical images should have score ~0
assert!(result.score < 0.01);§Comparing Different Images
use butteraugli_oxide::{compute_butteraugli, ButteraugliParams, BUTTERAUGLI_GOOD, BUTTERAUGLI_BAD};
let width = 16;
let height = 16;
// Original image - gradient
let original: Vec<u8> = (0..width * height)
.flat_map(|i| {
let x = i % width;
[(x * 16) as u8, 128, 128]
})
.collect();
// Distorted image - add noise
let distorted: Vec<u8> = original.iter()
.map(|&v| v.saturating_add(10))
.collect();
let result = compute_butteraugli(&original, &distorted, width, height, &ButteraugliParams::default())
.expect("valid image data");
if result.score < BUTTERAUGLI_GOOD {
println!("Images appear identical to humans");
} else if result.score > BUTTERAUGLI_BAD {
println!("Visible difference detected");
}§References
Re-exports§
Modules§
- blur
- Gaussian blur implementation for butteraugli.
- consts
- Constants for butteraugli and XYB color space.
- image
- Image buffer types for butteraugli.
- malta
- Malta edge-aware filter for butteraugli.
- mask
- Visual masking functions for butteraugli.
- opsin
- Butteraugli OpsinDynamicsImage implementation.
- psycho
- Multi-scale psychovisual decomposition for butteraugli.
- xyb
- XYB color space conversion for butteraugli.
Structs§
- Butteraugli
Params - Butteraugli comparison parameters.
- Butteraugli
Result - Butteraugli image comparison result.
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_
fuzzy_ class - Converts butteraugli score to fuzzy class value.
- compute_
butteraugli - Computes butteraugli score between two sRGB images.
- compute_
butteraugli_ linear - Computes butteraugli score between two linear RGB images.
- score_
to_ quality - Converts butteraugli score to quality percentage (0-100).
- srgb_
to_ linear - Converts sRGB u8 value to linear RGB f32.