18template<
typename T, CSpectralSampleProps SampleProps>
21 return static_cast<T
>(SampleProps::MAX_WAVELENGTH_NM - SampleProps::MIN_WAVELENGTH_NM) /
22 static_cast<T
>(SampleProps::NUM_SAMPLES);
25template<
typename T, CSpectralSampleProps SampleProps>
33 static_cast<T
>(SampleProps::MIN_WAVELENGTH_NM) +
static_cast<T
>(sampleIndex + 0) * INTERVAL_NM,
34 static_cast<T
>(SampleProps::MIN_WAVELENGTH_NM) +
static_cast<T
>(sampleIndex + 1) * INTERVAL_NM
38template<
typename T, CSpectralSampleProps SampleProps>
42 return sum > 0 ? sum : 0;
45template<
typename T, CSpectralSampleProps SampleProps>
59template<
typename T, CSpectralSampleProps SampleProps>
63 samples.fill(constant);
67template<
typename T,
typename U, CSpectralSampleProps SampleProps>
69 const U*
const wavelengthsNM,
70 const U*
const values,
71 const std::size_t numPoints,
74 PH_ASSERT(wavelengthsNM);
87 for(std::size_t i = 0; i < numPoints; i++)
89 const U wavelengthNm = wavelengthsNM[i];
90 const U value = values[i];
92 curve.
addPoint({wavelengthNm, value});
100 for(std::size_t i = 0; i < SampleProps::NUM_SAMPLES; ++i)
106 const U area = areaCalculator.
integrate(curve);
107 const U avgValue = area / (range.second - range.first);
108 sampled[i] =
static_cast<T
>(avgValue);
113 PH_ASSERT_UNREACHABLE_SECTION();
119template<
typename T, CSpectralSampleProps SampleProps>
128template<
typename T, CSpectralSampleProps SampleProps>
134 std::tuple_size_v<spectral_data::ArrayD65>);
139template<
typename T, CSpectralSampleProps SampleProps>
149template<
typename T, CSpectralSampleProps SampleProps>
161 constexpr auto wavelengthIntervalInMeter =
165 radianceSamples.
mulLocal(
static_cast<T
>(wavelengthIntervalInMeter));
166 return radianceSamples.
toArray();
169template<
typename T, CSpectralSampleProps SampleProps>
172 using ComputeT = double;
174 std::vector<ComputeT> spectralRadianceLambdas;
177 SampleProps::MIN_WAVELENGTH_NM,
178 SampleProps::MAX_WAVELENGTH_NM,
179 SampleProps::NUM_SAMPLES,
180 &spectralRadianceLambdas);
183 spectralRadianceLambdas.data(),
184 spectralRadianceValues.data(),
185 spectralRadianceValues.size());
193template<
typename T, CSpectralSampleProps SampleProps>
210 using XYZCMFValueType = spectral_data::ArrayD65::value_type;
211 constexpr auto NMU_XYZ_CMF_POINTS = std::tuple_size_v<spectral_data::ArrayXYZCMF>;
228 weights[0].set(sampledCmfValuesX);
229 weights[1].set(sampledCmfValuesY);
230 weights[2].set(sampledCmfValuesZ);
237 const T integratedCmfY = (
weights[1] * wavelengthIntervalNM).sum();
239 const auto uniformUnitSamples =
ArrayType(1);
245 for(std::size_t ci = 0; ci < 3; ++ci)
248 weights[ci] = (
weights[ci] * wavelengthIntervalNM) / integratedCmfY;
269template<
typename T, CSpectralSampleProps SampleProps, EReferenceWhite NORMALIZER>
277 for(std::size_t ci = 0; ci < 3; ++ci)
279 CIEXYZColor[ci] = copiedSrcSamples.
dot(kernel.
weights[ci]);
302 "Currently normalizer supports only D65 and E.");
323 "A color usage must be specified when converting spectral color samples.");
Error on the color-related functionalities.
Definition math_exceptions.h:24
Definition TAnalyticalIntegrator1D.h:10
T integrate(const TPiecewiseLinear1D< T > &func) const
Definition TAnalyticalIntegrator1D.ipp:23
void setIntegrationDomain(T x0, T x1)
Definition TAnalyticalIntegrator1D.ipp:66
T sum() const
Definition TArithmeticArrayBase.ipp:336
std::array< T, N > toArray() const
Definition TArithmeticArrayBase.ipp:855
Derived & divLocal(const Derived &rhs)
Definition TArithmeticArrayBase.ipp:148
Derived & mulLocal(const Derived &rhs)
Definition TArithmeticArrayBase.ipp:112
Derived & clampLocal(T lowerBound, T upperBound)
Definition TArithmeticArrayBase.ipp:271
Definition TArithmeticArray.h:13
Definition TPiecewiseLinear1D.h:26
void addPoint(const TVector2< T > &point)
Definition TPiecewiseLinear1D.h:96
void update()
Definition TPiecewiseLinear1D.h:89
T dot(const Derived &rhs) const
Definition TVectorNBase.ipp:14
const ArrayD65 & CIE_D65_wavelengths_nm()
Definition spectral_data.cpp:771
const ArrayXYZCMF & XYZ_CMF_CIE_1931_2_degree_X()
Definition spectral_data.cpp:756
const ArrayXYZCMF & XYZ_CMF_CIE_1931_2_degree_Z()
Definition spectral_data.cpp:766
const ArrayXYZCMF & XYZ_CMF_CIE_1931_2_degree_wavelengths_nm()
Definition spectral_data.cpp:751
const ArrayXYZCMF & XYZ_CMF_CIE_1931_2_degree_Y()
Definition spectral_data.cpp:761
const ArrayD65 & CIE_D65_values()
Definition spectral_data.cpp:776
Math functions and utilities.
Definition TransformInfo.h:10
constexpr TSpectralSampleValues< T, SampleProps > constant_spectral_samples(T constant)
Definition spectral_samples.ipp:60
TRawColorValues< T, SampleProps::NUM_SAMPLES > TSpectralSampleValues
Definition color_basics.h:54
std::vector< T > black_body_spectral_radiance_curve(const T temperatureK, const T lambdaMinNM, const T lambdaMaxNM, const std::size_t numCurvePoints, std::vector< T > *const out_lambdaValues=nullptr)
Get a curve for Black-body radiation. Note that this function is not returning radiance but spectral ...
Definition black_body.h:58
TSpectralSampleValues< T, SampleProps > resample_illuminant_E()
SPD of standard illuminants. Any light source which statistically has the same relative SPD as a stan...
Definition spectral_samples.ipp:120
TSpectralSampleValues< T, SampleProps > normalize_samples_energy(const TSpectralSampleValues< T, SampleProps > &srcSamples)
Normalize spectral samples as if they carry energy. Normalized spectral samples, together,...
Definition spectral_samples.ipp:46
TTristimulusValues< T > CIEXYZ_of(const EReferenceWhite refWhite)
Definition color_basics.h:243
TTristimulusValues< T > spectral_samples_to_CIE_XYZ(const TSpectralSampleValues< T, SampleProps > &srcSamples, EColorUsage usage)
Converting spectral samples to CIE-XYZ using standard CMFs.
Definition spectral_samples.ipp:270
ESpectralResample
Definition color_enums.h:161
EColorUsage
Definition color_enums.h:140
TSpectralSampleValues< T, SampleProps > resample_spectral_samples(const U *wavelengthsNM, const U *values, std::size_t numPoints, ESpectralResample algorithm=ESpectralResample::Default)
Definition spectral_samples.ipp:68
TRawColorValues< T, 3 > TTristimulusValues
Definition color_basics.h:48
TSpectralSampleValues< T, SampleProps > resample_black_body_radiance(T temperatureK)
SPD of black-body radiation in radiance. If a normalized energy distribution is desired,...
Definition spectral_samples.ipp:150
T estimate_samples_energy(const TSpectralSampleValues< T, SampleProps > &srcSamples)
Definition spectral_samples.ipp:39
TSpectralSampleValues< T, SampleProps > resample_black_body_spectral_radiance(T temperatureK)
SPD of black-body radiation in spectral radiance. Note that this function is not returning radiance b...
Definition spectral_samples.ipp:170
TSpectralSampleValues< T, SampleProps > resample_illuminant_D65()
SPD of standard illuminants D65, with total energy = 1.
Definition spectral_samples.ipp:129
constexpr std::pair< T, T > wavelength_range_of(std::size_t sampleIndex) noexcept
Definition spectral_samples.ipp:26
constexpr T wavelength_interval_of() noexcept
Definition spectral_samples.ipp:19
TSpectralSampleValues< T, SampleProps > resample_black_body(T temperatureK)
SPD of black-body radiation, with total energy = 1.
Definition spectral_samples.ipp:140
Definition spectral_samples.ipp:195
TArithmeticArray< T, 3 > illuminantENormalizer
Definition spectral_samples.ipp:200
std::array< ArrayType, 3 > weights
Definition spectral_samples.ipp:198
TCIEXYZCmfKernel()
Definition spectral_samples.ipp:202
TArithmeticArray< T, 3 > illuminantD65Normalizer
Definition spectral_samples.ipp:199
TVectorN< T, SampleProps::NUM_SAMPLES > ArrayType
Definition spectral_samples.ipp:196