Struct lcms2::ToneCurve

source ·
pub struct ToneCurve(/* private fields */);
Expand description

Tone curves are powerful constructs that can contain curves specified in diverse ways.

The curve is stored in segments, where each segment can be sampled or specified by parameters. A 16.bit simplification of the whole curve is kept for optimization purposes. For float operation, each segment is evaluated separately. Plug-ins may be used to define new parametric schemes.

Owned version of ToneCurveRef

Implementations§

source§

impl ToneCurve

source

pub fn new(gamma: f64) -> Self

Simplified wrapper to new_parametric. Builds a parametric curve of type 1.

source

pub fn new_tabulated(values: &[u16]) -> Self

Builds a tone curve based on a table of 16-bit values. Tone curves built with this function are restricted to 0…1.0 domain.

source

pub fn new_tabulated_float(values: &[f32]) -> Self

Builds a tone curve based on a table of floating point values. Tone curves built with this function are not restricted to 0…1.0 domain.

source

pub fn new_parametric(curve_type: i16, params: &[f64]) -> LCMSResult<Self>

See Table 52 in LCMS documentation for descriptino of the types.

  1. Exponential
  2. CIE 122-1966
  3. IEC 61966-3
  4. IEC 61966-2.1 (sRGB)
  5. See PDF
  6. Identical to 5, unbounded.
  7. See PDF
  8. See PDF
  9. (108) S-Shaped sigmoidal

Always use 10-parameter slice for plug-in types.

If curve_type is negative, then the curve is analytically inverted.

Methods from Deref<Target = ToneCurveRef>§

source

pub fn reversed(&self) -> ToneCurve

Creates a tone curve that is the inverse of given tone curve.

source

pub fn reversed_samples(&self, samples: usize) -> ToneCurve

Creates a tone curve that is the inverse of given tone curve. In the case it couldn’t be analytically reversed, a tablulated curve of nResultSamples is created.

source

pub fn join(&self, y: &ToneCurveRef, points: usize) -> ToneCurve

Composites two tone curves in the form Y^-1(X(t)) (self is X, the argument is Y)

source

pub fn is_multisegment(&self) -> bool

Returns TRUE if the tone curve contains more than one segment, FALSE if it has only one segment.

source

pub fn is_linear(&self) -> bool

Returns an estimation of cube being an identity (1:1) in the [0..1] domain. Does not take unbounded parts into account. This is just a coarse approximation, with no mathematical validity.

source

pub fn is_monotonic(&self) -> bool

Returns an estimation of monotonicity of curve in the [0..1] domain. Does not take unbounded parts into account. This is just a coarse approximation, with no mathematical validity.

source

pub fn is_descending(&self) -> bool

Does not take unbounded parts into account.

source

pub fn parametric_type(&self) -> i32

source

pub fn estimated_gamma(&self, precision: f64) -> Option<f64>

Estimates the apparent gamma of the tone curve by using least squares fitting. Precision: The maximum standard deviation allowed on the residuals, 0.01 is a fair value, set it to a big number to fit any curve, mo matter how good is the fit.

source

pub fn smooth(&mut self, lambda: f64) -> bool

Smoothes tone curve according to the lambda parameter. From: Eilers, P.H.C. (1994) Smoothing and interpolation with finite differences. in: Graphic Gems IV, Heckbert, P.S. (ed.), Academic press.

source

pub fn estimated_entries(&self) -> &[u16]

Tone curves do maintain a shadow low-resolution tabulated representation of the curve. This function returns a pointer to this table.

source

pub fn eval<ToneCurveValue: FloatOrU16>( &self, v: ToneCurveValue ) -> ToneCurveValue

Evaluates the given number (u16 or f32) across the given tone curve.

This function is significantly faster for u16, since it uses a pre-computed 16-bit lookup table.

Trait Implementations§

source§

impl AsMut<ToneCurveRef> for ToneCurve

source§

fn as_mut(&mut self) -> &mut ToneCurveRef

Converts this type into a mutable reference of the (usually inferred) input type.
source§

impl AsRef<ToneCurveRef> for ToneCurve

source§

fn as_ref(&self) -> &ToneCurveRef

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl Borrow<ToneCurveRef> for ToneCurve

source§

fn borrow(&self) -> &ToneCurveRef

Immutably borrows from an owned value. Read more
source§

impl BorrowMut<ToneCurveRef> for ToneCurve

source§

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

Mutably borrows from an owned value. Read more
source§

impl Clone for ToneCurve

source§

fn clone(&self) -> ToneCurve

Returns a copy 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 Deref for ToneCurve

§

type Target = ToneCurveRef

The resulting type after dereferencing.
source§

fn deref(&self) -> &ToneCurveRef

Dereferences the value.
source§

impl DerefMut for ToneCurve

source§

fn deref_mut(&mut self) -> &mut ToneCurveRef

Mutably dereferences the value.
source§

impl Drop for ToneCurve

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl ForeignType for ToneCurve

§

type CType = ToneCurve

The raw C type.
§

type Ref = ToneCurveRef

The type representing a reference to this type.
source§

unsafe fn from_ptr(ptr: *mut ToneCurve) -> ToneCurve

Constructs an instance of this type from its raw type. Read more
source§

fn as_ptr(&self) -> *mut ToneCurve

Returns a raw pointer to the wrapped value.
source§

fn into_ptr(self) -> *mut Self::CType

Consumes the wrapper and returns the raw pointer.

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

§

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>,

§

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>,

§

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.