SpectralData

Struct SpectralData 

Source
pub struct SpectralData {
    pub wavelengths: Vec<f32>,
    pub values: Vec<f32>,
    pub mode: MeasurementMode,
}

Fields§

§wavelengths: Vec<f32>§values: Vec<f32>§mode: MeasurementMode

Measurement mode affects XYZ calculation method

Implementations§

Source§

impl SpectralData

Source

pub fn new(values: Vec<f32>) -> Self

Source

pub fn with_mode(values: Vec<f32>, mode: MeasurementMode) -> Self

Create spectral data with explicit measurement mode

Source

pub fn set_mode(&mut self, mode: MeasurementMode)

Set the measurement mode

Source

pub fn to_xyz(&self) -> XYZ

Convert to XYZ using the standard 2-degree observer and D65. Default method for backward compatibility.

Source

pub fn to_xyz_ext(&self, source: Illuminant, obs: Observer) -> XYZ

Convert to XYZ using specified illuminant and observer.

For reflective measurements, uses ASTM E308 weighting factors when available. Currently supported: D65/2°, D50/2°.

Source

pub fn resample(&self, start: f32, end: f32, step: f32) -> Self

Resample spectral data to a new wavelength range and step. Uses Sprague interpolation for high accuracy, which is recommended by the CIE for spectral data resampling.

Source

pub fn to_xyz_emissive_ext(&self, obs: Observer) -> XYZ

Convert spectral power distribution to XYZ with specified observer.

Source

pub fn get_wavelength_data(&self) -> (Vec<f32>, Vec<f32>)

Get the raw wavelengths and values as references. Used for spectral reconstruction and external processing.

Source

pub fn to_xyz_reflective_2(&self) -> XYZ

Convert reflectance to XYZ using ASTM E308 weighting factors (D65/2°). This is the most accurate method for reflective measurements.

The weighting factors already include:

  • D65 spectral power distribution
  • CIE 1931 2° standard observer CMFs
  • Proper normalization
Source

pub fn to_xyz_emissive_2(&self) -> XYZ

Convert spectral power distribution to XYZ for emissive sources (2° observer). Uses direct integration with CIE CMFs.

§Output Units

The output units depend on how the spectral data was processed:

  • If spectral values are in device-calibrated units (via EEPROM emis_coef), the Y value approximates luminance in cd/m² (after proper device calibration).
  • For raw spectral power in W/sr/m²/nm, multiply Y by Km=683 lm/W for cd/m².

Note: The ColorMunki’s EEPROM emis_coef provides device-specific calibration that should produce results comparable to ArgyllCMS when properly applied.

Source

pub fn to_xyz_2(&self) -> XYZ

👎Deprecated since 0.2.0: Use to_xyz() with appropriate MeasurementMode

Convert to XYZ using the 2-degree observer (CIE 1931). Legacy method - uses CMF integration (suitable for emissive sources)

Source

pub fn to_xyz_10(&self) -> XYZ

Convert to XYZ using the 10-degree observer (CIE 1964). Uses CMF integration (suitable for emissive sources)

Source

pub fn calculate_k(illuminant_spd: &[f32], y_bar: &[f32], step: f32) -> f32

Calculate the normalization constant k for reflectance mode. k = 100 / Σ(S(λ) * ȳ(λ) * Δλ)

This is useful when you have raw illuminant SPD and CMF data and need to compute the normalization factor dynamically.

§Arguments
  • illuminant_spd - Relative spectral power distribution of the illuminant
  • y_bar - Y color matching function values
  • step - Wavelength step in nm
Source

pub fn to_result(&self) -> MeasurementResult

Convert the spectral data into a consolidated MeasurementResult. This performs all standard colorimetric conversions (XYZ, Lab, RGB, CCT) using standard settings (D50 for Lab/Print, D65 for Screen/RGB).

Trait Implementations§

Source§

impl Clone for SpectralData

Source§

fn clone(&self) -> SpectralData

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 SpectralData

Source§

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

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

impl<'de> Deserialize<'de> for SpectralData

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for SpectralData

Source§

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

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

impl Serialize for SpectralData

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. 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> Same for T

Source§

type Output = T

Should always be Self
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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,