Expand description
A pure-Rust port of ColorVideoVDP, a full-reference visual difference predictor for images and video.
ColorVideoVDP (the authors call it cvvdp) compares a test image or video
with a reference, as seen on a specified display, and predicts the visible
difference in Just-Objectionable-Difference (JOD) units. 10 JOD means no
visible difference, and lower values mean stronger distortion; very strong
distortions can give negative values. A difference of 1 JOD between two
conditions means that 75% of observers would choose the one with the higher
score. This crate implements the calibrated base model v0.5.7
(Cvvdp::MODEL_VERSION) of the official PyTorch implementation.
use colorvideovdp::{Color, Cvvdp, DisplayModel, Image, Options};
let reference = Image::new(16, 16, 3, vec![0.5; 16 * 16 * 3])?;
let mut test = reference.clone();
test.data_mut()[0] = 0.6;
let metric = Cvvdp::new(DisplayModel::from_name("standard_4k")?, Options::default())?;
let prediction = metric.predict_image(&test, &reference, Color::Srgb)?;
assert!(prediction.jod < 10.0);§Algorithm
- The display model maps encoded or linear input to absolute luminance (EOTF, peak luminance, black level, reflected ambient light), then to the DKL opponent space: achromatic, red–green, and yellow–violet.
- For video, temporal filters split each frame into sustained channels and an achromatic transient channel.
- Each channel is decomposed into a Laplacian pyramid and converted to contrast relative to the local background luminance.
- Contrast is weighted by castleCSF sensitivity for each band’s spatial frequency and the local luminance.
- Test–reference differences are reduced by cross-channel masking, with a blur that models phase uncertainty, and soft-clamped.
- Differences are pooled with Lp norms over space, bands, channels, and frames, and the pooled value is mapped to JOD.
§Inputs and displays
Image holds one f32 frame. Encoded inputs (sRGB, PQ, HLG, gamma) are
clamped to [0, 1]; linear inputs are absolute luminance in cd/m². The
DisplayModel sets resolution, viewing geometry, and photometry; the 26
reference displays are embedded and listed by DisplayModel::names.
§Features
parallel(default):Execution::Parallelsplits independent spatial rows across the Rayon thread pool. Results are identical toExecution::SingleThread.
§Reference
Rafał K. Mantiuk, Param Hanji, Maliha Ashraf, Yuta Asano, and Alexandre Chapiro. ColorVideoVDP: A visual difference predictor for image, video and display distortions. In SIGGRAPH 2024 Technical Papers, Article 129. https://doi.org/10.1145/3658144
The official implementation is https://github.com/gfxdisp/ColorVideoVDP.
Structs§
- Cvvdp
- A reusable, immutable ColorVideoVDP evaluator for one display.
- Display
Model - A photometric and geometric display model.
- Distortion
Map - A raw distortion map in contiguous frame, row, column order.
- Geometry
- Display geometry used to determine central pixels per visual degree.
- Image
- An owned f32 image in row-major, interleaved RGB or single-channel layout.
- Options
- Prediction options.
- Photometry
- Display luminance, contrast, ambient light, and exposure.
- Prediction
- A quality score, an optional raw distortion map, and pooled features.
Enums§
- Color
- Input colour encoding and primaries.
- Error
- An invalid input, display configuration, or numerical result.
- Execution
- CPU execution policy. Pooling order is deterministic in both modes.
- Temporal
Padding - Padding before the first video frame during temporal filtering.
Type Aliases§
- Result
- Result type returned by this crate.