@@ -1812,6 +1812,22 @@ def database_parser(name: ObjectName, content: dict) -> EmittingBody | Reflectin
18121812
18131813# ------------ Color Processing Section ------------
18141814
1815+ # CIE XYZ (1931) color matching functions, 2-deg
1816+ # https://cie.co.at/datatable/cie-1931-colour-matching-functions-2-degree-observer
1817+ # http://www.cvrl.org/cie.htm
1818+ xyz_cmf = FilterSystem .from_list (('CIE_1931_2deg.x' , 'CIE_1931_2deg.y' , 'CIE_1931_2deg.z' ))
1819+
1820+ # There are CMFs transformed from the CIE (2006) LMS functions, 2-deg
1821+ # (https://cie.co.at/datatable/cie-2006-lms-cone-fundamentals-2-field-size-terms-energy)
1822+ # here: http://www.cvrl.org/database/text/cienewxyz/cie2012xyz2.htm, http://www.cvrl.org/ciexyzpr.htm
1823+ # However, the CIE XYZ (1931) standard is still widely used.
1824+
1825+ def spectrum_to_white_point (spectrum : Spectrum ):
1826+ """ Returns (x, y) coordinates of the spectrum on the chromaticity diagram """
1827+ xyz = (spectrum @ xyz_cmf ).br
1828+ return xyz [:2 ] / xyz .sum ()
1829+
1830+
18151831# Values are Color Primaries: (red, green, blue)
18161832# See https://en.wikipedia.org/wiki/RGB_color_spaces
18171833supported_color_spaces = {
@@ -1838,6 +1854,8 @@ def database_parser(name: ObjectName, content: dict) -> EmittingBody | Reflectin
18381854 'Illuminant D75' : (0.29902 , 0.31485 ),
18391855 'Illuminant D93' : (0.28315 , 0.29711 ),
18401856 'Illuminant E' : (1 / 3 , 1 / 3 ),
1857+ 'Vega' : spectrum_to_white_point (vega_SI ),
1858+ 'Sun' : spectrum_to_white_point (sun_SI ),
18411859}
18421860
18431861
@@ -1882,17 +1900,8 @@ def rgb_to_xyz(self, arr: np.ndarray) -> np.ndarray:
18821900 return np .tensordot (self .inv_matrix , arr , axes = (1 , 0 ))
18831901
18841902
1885- # CIE XYZ (1931) color matching functions, 2-deg
1886- # https://cie.co.at/datatable/cie-1931-colour-matching-functions-2-degree-observer
1887- # http://www.cvrl.org/cie.htm
1888- xyz_cmf = FilterSystem .from_list (('CIE_1931_2deg.x' , 'CIE_1931_2deg.y' , 'CIE_1931_2deg.z' ))
18891903xyz_color_system = ColorSystem ('CIE XYZ' , 'Illuminant E' )
18901904
1891- # There are CMFs transformed from the CIE (2006) LMS functions, 2-deg
1892- # (https://cie.co.at/datatable/cie-2006-lms-cone-fundamentals-2-field-size-terms-energy)
1893- # here: http://www.cvrl.org/database/text/cienewxyz/cie2012xyz2.htm, http://www.cvrl.org/ciexyzpr.htm
1894- # However, the CIE XYZ (1931) standard is still widely used.
1895-
18961905
18971906class ColorObject :
18981907 """
0 commit comments