Skip to content

Commit 2b3a6a0

Browse files
committed
Vegan and Solar white points
1 parent 8dbd764 commit 2b3a6a0

File tree

2 files changed

+20
-13
lines changed

2 files changed

+20
-13
lines changed

src/core.py

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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
18171833
supported_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'))
18891903
xyz_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

18971906
class ColorObject:
18981907
"""

src/gui.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,10 +180,8 @@ def frame(num: int, filtersDB: tuple, lang: str):
180180
sg.Input(enable_events=True, size=1, key='tab2_path'+n, expand_x=True, visible=False),
181181
# size=1 is VERY important to make column be depended on the max length of filter file names
182182
# Depending on the radio box, FileBrowse or label is displayed below
183-
sg.FileBrowse(
184-
button_text=tr.gui_browse[lang], size=browse_size,
185-
initial_folder='..', key='tab2_pathText'+n, visible=False
186-
),
183+
sg.FileBrowse(button_text=tr.gui_browse[lang], size=browse_size, key='tab2_pathText'+n, visible=False),
184+
# No need to use initial_folder='..' in the FileBrowse to make the path dynamic between the frames
187185
rgb_text,
188186
],
189187
[

0 commit comments

Comments
 (0)