Skip to main content

DiffmapResult

Struct DiffmapResult 

Source
#[non_exhaustive]
pub struct DiffmapResult { /* private fields */ }
Expand description

Result containing both a zensim score and a per-pixel error map.

The diffmap is a multi-scale spatial error map using modified SSIM across all three XYB channels. SSIM error maps are computed at each pyramid scale (4 scales by default), then coarser scales are upsampled to full resolution and blended with the profile’s trained scale weights. This captures both fine-grained detail loss (scale 0) and structural/low-frequency distortions (scales 1-3).

It tells you WHERE perceptual error is concentrated, while the zensim score tells you HOW MUCH total error there is.

§Diffmap signal

Each value is a weighted blend of per-scale SSIM errors:

per_channel_s = (1 − mean_term × structure_term).max(0)   [at scale s]
  mean_term      = 1 − (μ_src − μ_dst)²
  structure_term  = (2·σ_src_dst + C₂) / (σ²_src + σ²_dst + C₂)
  C₂ = 0.0009

scale_error_s[i] = Σ_c w_c_s × per_channel_s_c   (channel-weighted)
diffmap[i] = Σ_s blend_s × upsample(scale_error_s)[i]   (scale-blended)

With trained weights: scale 0 gets ~6%, scales 1-3 get ~28-35% each (matching the trained model’s emphasis on structural features).

  • Range: [0, +∞). Zero means perceptually identical at that location. Values above ~0.5 indicate severe local distortion. On typical photo pairs, most values fall in [0, 0.3].
  • Spatial smoothing: scale 0 reflects 11×11 neighborhoods, coarser scales reflect progressively larger areas (22×22, 44×44, 88×88).
  • Color space: computed in XYB (perceptual luma + chroma). Channel combination weights are controlled by DiffmapWeighting.
  • Not butteraugli distance: the values are unitless SSIM error, not butteraugli distance units. Use the global zensim score for overall quality.

§Layout

Row-major, width × height elements: diffmap[y * width + x]. No padding — actual image dimensions, not SIMD-padded.

Implementations§

Source§

impl DiffmapResult

Source

pub fn result(&self) -> &ZensimResult

The full zensim comparison result (score, features, etc.).

Source

pub fn score(&self) -> f64

The zensim score (convenience shorthand for result().score()).

Source

pub fn diffmap(&self) -> &[f32]

Per-pixel perceptual error map. See DiffmapResult for signal definition, range, and layout.

Source

pub fn into_parts(self) -> (ZensimResult, Vec<f32>, usize, usize)

Consume this result and return the diffmap as an owned Vec<f32>, along with the zensim result and dimensions.

Source

pub fn width(&self) -> usize

Image width (actual, not SIMD-padded).

Source

pub fn height(&self) -> usize

Image height.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.