Skip to main content

DiffmapOptions

Struct DiffmapOptions 

Source
pub struct DiffmapOptions {
    pub weighting: DiffmapWeighting,
    pub masking_strength: Option<f32>,
    pub sqrt: bool,
    pub include_edge_mse: bool,
    pub include_hf: bool,
}
Expand description

Post-processing options for the diffmap signal.

These are applied after multi-scale fusion to shape the diffmap for specific use cases. All options default to off (raw SSIM error signal).

Fields§

§weighting: DiffmapWeighting

Channel weighting scheme (default: Trained).

§masking_strength: Option<f32>

Apply contrast masking to suppress errors in complex/textured regions.

When enabled, each diffmap value is divided by a local complexity mask derived from the source image’s luminance variance: mask = 1 + strength × local_variance(Y_src).

This matches the perceptual intuition that errors in smooth areas (sky, gradients) are more visible than in textured areas (foliage, hair).

Default: None (no masking). Typical values: 2.0–8.0.

§sqrt: bool

Apply sqrt to diffmap values after masking.

Compresses the dynamic range so that the diffmap is more linearly proportional to perceived distortion intensity. Similar to butteraugli’s sqrt(dc_masked + ac_masked) combination.

Default: false.

§include_edge_mse: bool

Include edge artifact, edge detail loss, and MSE features in the diffmap.

When false (default), the diffmap only includes SSIM error. When true, each pixel also accumulates:

  • Edge artifact: max(0, residual_dst² − residual_src²) — structure added by distortion (ringing, blocking).
  • Edge detail loss: max(0, residual_src² − residual_dst²) — structure removed by distortion (blurring, smoothing).
  • MSE: (src − dst)² — raw per-pixel squared difference.

Feature contributions are weighted by the profile’s trained weights for each feature type and channel. This makes the diffmap a more complete representation of the metric’s per-pixel view.

§include_hf: bool

Include high-frequency energy features in the diffmap.

When true, each pixel also accumulates HF texture loss/gain signals:

  • HF energy loss: max(0, (src−μ)² − (dst−μ)²) — texture energy removed by distortion (smoothing, quantization).
  • HF magnitude loss: max(0, |src−μ| − |dst−μ|) — texture magnitude removed (L1 variant, more robust to outliers).
  • HF energy gain: max(0, (dst−μ)² − (src−μ)²) — texture energy added by distortion (ringing, noise).

These correspond to trained features 10–12 and help encoder quantization loops (especially JXL AC coefficient tuning) see where HF texture is being lost or gained. Requires mu1/mu2 storage (same as include_edge_mse).

Default: false.

Trait Implementations§

Source§

impl Clone for DiffmapOptions

Source§

fn clone(&self) -> DiffmapOptions

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DiffmapOptions

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for DiffmapOptions

Source§

fn default() -> DiffmapOptions

Returns the “default value” for a type. Read more
Source§

impl From<DiffmapWeighting> for DiffmapOptions

Source§

fn from(w: DiffmapWeighting) -> Self

Converts to this type from the input type.
Source§

impl Copy for DiffmapOptions

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.