def vs_colorimetry_data(spd_test, spd_reference, spds_vs, cmfs, chromatic_adaptation=False): XYZ_t = spectral_to_XYZ(spd_test, cmfs) XYZ_t /= XYZ_t[1] XYZ_r = spectral_to_XYZ(spd_reference, cmfs) XYZ_r /= XYZ_r[1] xy_r = XYZ_to_xy(XYZ_r) vs_data = [] for _key, value in sorted(VS_INDEXES_TO_NAMES.items()): spd_vs = spds_vs.get(value) XYZ_vs = spectral_to_XYZ(spd_vs, cmfs, spd_test) XYZ_vs /= 100 if chromatic_adaptation: XYZ_vs = chromatic_adaptation_VonKries(XYZ_vs, XYZ_t, XYZ_r, transform='CMCCAT2000') Lab_vs = XYZ_to_Lab(XYZ_vs, illuminant=xy_r) _L_vs, C_vs, _Hab = Lab_to_LCHab(Lab_vs) vs_data.append(VS_ColorimetryData(spd_vs.name, XYZ_vs, Lab_vs, C_vs)) return vs_data
def vs_colorimetry_data(spd_test, spd_reference, spds_vs, cmfs, chromatic_adaptation=False): """ Returns the *VS test colour samples* colorimetry data. Parameters ---------- spd_test : SpectralPowerDistribution Test spectral power distribution. spd_reference : SpectralPowerDistribution Reference spectral power distribution. spds_vs : dict *VS test colour samples* spectral power distributions. cmfs : XYZ_ColourMatchingFunctions Standard observer colour matching functions. chromatic_adaptation : bool, optional Perform chromatic adaptation. Returns ------- list *VS test colour samples* colorimetry data. """ XYZ_t = spectral_to_XYZ(spd_test, cmfs) XYZ_t /= XYZ_t[1] XYZ_r = spectral_to_XYZ(spd_reference, cmfs) XYZ_r /= XYZ_r[1] xy_r = XYZ_to_xy(XYZ_r) vs_data = [] for _key, value in sorted(VS_INDEXES_TO_NAMES.items()): spd_vs = spds_vs.get(value) XYZ_vs = spectral_to_XYZ(spd_vs, cmfs, spd_test) XYZ_vs /= 100 if chromatic_adaptation: XYZ_vs = chromatic_adaptation_VonKries(XYZ_vs, XYZ_t, XYZ_r, transform='CMCCAT2000') Lab_vs = XYZ_to_Lab(XYZ_vs, illuminant=xy_r) _L_vs, C_vs, _Hab = Lab_to_LCHab(Lab_vs) vs_data.append( VS_ColorimetryData(spd_vs.name, XYZ_vs, Lab_vs, C_vs)) return vs_data
def vs_colorimetry_data(sd_test, sd_reference, sds_vs, cmfs, chromatic_adaptation=False): """ Returns the *VS test colour samples* colorimetry data. Parameters ---------- sd_test : SpectralDistribution Test spectral distribution. sd_reference : SpectralDistribution Reference spectral distribution. sds_vs : dict *VS test colour samples* spectral distributions. cmfs : XYZ_ColourMatchingFunctions Standard observer colour matching functions. chromatic_adaptation : bool, optional Perform chromatic adaptation. Returns ------- list *VS test colour samples* colorimetry data. """ XYZ_t = sd_to_XYZ(sd_test, cmfs) XYZ_t /= XYZ_t[1] XYZ_r = sd_to_XYZ(sd_reference, cmfs) XYZ_r /= XYZ_r[1] xy_r = XYZ_to_xy(XYZ_r) vs_data = [] for _key, value in sorted(VS_INDEXES_TO_NAMES.items()): sd_vs = sds_vs[value] with domain_range_scale('1'): XYZ_vs = sd_to_XYZ(sd_vs, cmfs, sd_test) if chromatic_adaptation: XYZ_vs = chromatic_adaptation_VonKries(XYZ_vs, XYZ_t, XYZ_r, transform='CMCCAT2000') Lab_vs = XYZ_to_Lab(XYZ_vs, illuminant=xy_r) _L_vs, C_vs, _Hab = Lab_to_LCHab(Lab_vs) vs_data.append(VS_ColorimetryData(sd_vs.name, XYZ_vs, Lab_vs, C_vs)) return vs_data