Skip to main content

SpectralContext

Struct SpectralContext 

Source
pub struct SpectralContext { /* private fields */ }
Expand description

Everything the spectral exposure needs, built once per render.

Implementations§

Source§

impl SpectralContext

Source

pub fn new() -> Self

Build the context on the internal grid, with the default camera profile and the default film’s layers.

The film’s layers are measured from the manufacturer’s data sheet; the camera is CameraProfile::default, the input’s own definition. Both are ordered R, G, B, and getting that order wrong is invisible until a red patch comes out blue.

This is the context for whichever stock crate::RenderParams::default uses. A render of any other film wants Self::for_stock, or the exposure is computed with VISION3’s spectral response and only the curve changes.

§Panics

Cannot panic: the grid is a compile-time constant with a valid step.

Source

pub fn for_stock(stock: &FilmStock) -> Self

The context for a particular film stock: its own layer sensitivities.

This is the difference between “a film with a different curve” and “a different film”: which wavelengths each layer records decides how the scene separates into dyes, and no curve can stand in for it.

Source

pub fn with_atoms(self, atoms: &[Spectrum]) -> Self

Use a dictionary prior, with the polynomial as the fallback.

Atoms are resampled onto the internal grid, so callers can pass spectra measured on any uniform grid.

Source

pub fn with_camera(self, camera: CameraProfile) -> Self

Replace the camera assumption.

The grey anchor is recomputed, because it is the film’s response to the spectrum this camera reconstructs for mid grey. Changing the camera without that would silently re-balance every print.

Source

pub fn with_threshold(self, threshold: f64) -> Self

Relative camera-response residual above which the hybrid falls back.

Source

pub fn has_dictionary(&self) -> bool

Whether a dictionary prior is active.

Source

pub fn identity(&self) -> String

A stable description of the model this context implements.

Recorded in baked tables so that loading a table baked for a different camera or film fails loudly instead of silently producing wrong colour.

Source

pub fn grid(&self) -> &Spectrum

The wavelength grid.

Source

pub fn camera(&self) -> &Sensor

The camera assumption this context was built with.

Source

pub fn film(&self) -> &Sensor

The film’s three layer sensitivities.

Source

pub fn reference(&self) -> [f64; 3]

The film’s response to a reconstructed 18 % grey, per layer.

The anchor Self::expose divides by: an integrator that wants the same anchor needs this number rather than a second reconstruction.

Source

pub fn model(&self) -> Option<ExposureModel>

The constants this context integrates with, flattened for another backend.

None when a dictionary prior is active, or when a table is not on the model’s grid. Both mean the closed form below is not what this context computes, and a backend that rendered anyway would be rendering a different model without saying so.

Source

pub fn expose(&self, linear: [f64; 3]) -> Option<[f64; 3]>

Per-layer log10 exposure for a linear-light pixel.

Returns None if the reconstruction fails, which can only happen on a grid mismatch that Self::new rules out.

Source

pub fn expose_with_extra( &self, linear: [f64; 3], ) -> Option<([f64; 3], Option<f64>)>

The same exposure, plus the fourth layer when the film has one.

One reconstruction feeds all four integrals: the second cyan emulsion sits in the same stack and sees the same light, so rebuilding the spectrum for it would be the same arithmetic twice.

The fourth layer is normalised on the blue layer’s grey response, not on its own. The data sheet plots every emulsion on one log H axis, so the distance between the blue-sensitive curve and the cyan-sensitive one is a speed difference; anchoring each on its own grey would divide that difference out and make the fourth layer a copy of the third.

Trait Implementations§

Source§

impl Clone for SpectralContext

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for SpectralContext

Source§

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

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

impl Default for SpectralContext

Source§

fn default() -> Self

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

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.