pub struct SpectralData {
pub wavelengths: Vec<f32>,
pub values: Vec<f32>,
pub mode: MeasurementMode,
}Fields§
§wavelengths: Vec<f32>§values: Vec<f32>§mode: MeasurementModeMeasurement mode affects XYZ calculation method
Implementations§
Source§impl SpectralData
impl SpectralData
pub fn new(values: Vec<f32>) -> Self
Sourcepub fn with_mode(values: Vec<f32>, mode: MeasurementMode) -> Self
pub fn with_mode(values: Vec<f32>, mode: MeasurementMode) -> Self
Create spectral data with explicit measurement mode
Sourcepub fn set_mode(&mut self, mode: MeasurementMode)
pub fn set_mode(&mut self, mode: MeasurementMode)
Set the measurement mode
Sourcepub fn to_xyz(&self) -> XYZ
pub fn to_xyz(&self) -> XYZ
Convert to XYZ using the standard 2-degree observer and D65. Default method for backward compatibility.
Sourcepub fn to_xyz_ext(&self, source: Illuminant, obs: Observer) -> XYZ
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°.
Sourcepub fn resample(&self, start: f32, end: f32, step: f32) -> Self
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.
Sourcepub fn to_xyz_emissive_ext(&self, obs: Observer) -> XYZ
pub fn to_xyz_emissive_ext(&self, obs: Observer) -> XYZ
Convert spectral power distribution to XYZ with specified observer.
Sourcepub fn get_wavelength_data(&self) -> (Vec<f32>, Vec<f32>)
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.
Sourcepub fn to_xyz_reflective_2(&self) -> XYZ
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
Sourcepub fn to_xyz_emissive_2(&self) -> XYZ
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.
Sourcepub fn to_xyz_2(&self) -> XYZ
👎Deprecated since 0.2.0: Use to_xyz() with appropriate MeasurementMode
pub fn to_xyz_2(&self) -> XYZ
Convert to XYZ using the 2-degree observer (CIE 1931). Legacy method - uses CMF integration (suitable for emissive sources)
Sourcepub fn to_xyz_10(&self) -> XYZ
pub fn to_xyz_10(&self) -> XYZ
Convert to XYZ using the 10-degree observer (CIE 1964). Uses CMF integration (suitable for emissive sources)
Sourcepub fn calculate_k(illuminant_spd: &[f32], y_bar: &[f32], step: f32) -> f32
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 illuminanty_bar- Y color matching function valuesstep- Wavelength step in nm
Sourcepub fn to_result(&self) -> MeasurementResult
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
impl Clone for SpectralData
Source§fn clone(&self) -> SpectralData
fn clone(&self) -> SpectralData
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more