Skip to content

Commit

Permalink
Implement support for "vK20" chromatic adaptation transform.
Browse files Browse the repository at this point in the history
  • Loading branch information
KelSolaar committed Nov 11, 2023
1 parent 497dfd0 commit c9714f2
Show file tree
Hide file tree
Showing 6 changed files with 719 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ Chromatic Adaptation - ``colour.adaptation``
... )
array([ 0.2533053 , 0.13765138, 0.01543307])
>>> sorted(colour.CHROMATIC_ADAPTATION_METHODS)
['CIE 1994', 'CMCCAT2000', 'Fairchild 1990', 'Von Kries', 'Zhai 2018']
['CIE 1994', 'CMCCAT2000', 'Fairchild 1990', 'Von Kries', 'Zhai 2018', 'vK20']
Algebra - ``colour.algebra``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
43 changes: 40 additions & 3 deletions colour/adaptation/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
- :cite:`Fairchild2013t` : Fairchild, M. D. (2013). Chromatic Adaptation
Models. In Color Appearance Models (3rd ed., pp. 4179-4252). Wiley.
ISBN:B00DAYO8E2
- :cite:`Fairchild2020` : Fairchild, M. D. (2020). Von Kries 2020: Evolution
of degree of chromatic adaptation. Color and Imaging Conference, 28(1),
252-257. doi:10.2352/issn.2169-2629.2020.28.40
- :cite:`Li2002a` : Li, C., Luo, M. R., Rigg, B., & Hunt, R. W. G. (2002).
CMC 2000 chromatic adaptation transform: CMCCAT2000. Color Research &
Application, 27(1), 49-58. doi:10.1002/col.10005
Expand Down Expand Up @@ -54,6 +57,11 @@
chromatic_adaptation_VonKries,
)
from .fairchild1990 import chromatic_adaptation_Fairchild1990
from .fairchild2020 import (
CONDITIONS_DEGREE_OF_ADAPTATION_VK20,
matrix_chromatic_adaptation_vk20,
chromatic_adaptation_vK20,
)
from .cmccat2000 import (
InductionFactors_CMCCAT2000,
VIEWING_CONDITIONS_CMCCAT2000,
Expand Down Expand Up @@ -87,6 +95,11 @@
__all__ += [
"chromatic_adaptation_Fairchild1990",
]
__all__ += [
"CONDITIONS_DEGREE_OF_ADAPTATION_VK20",
"matrix_chromatic_adaptation_vk20",
"chromatic_adaptation_vK20",
]
__all__ += [
"InductionFactors_CMCCAT2000",
"VIEWING_CONDITIONS_CMCCAT2000",
Expand All @@ -108,6 +121,7 @@
"Fairchild 1990": chromatic_adaptation_Fairchild1990,
"Von Kries": chromatic_adaptation_VonKries,
"Zhai 2018": chromatic_adaptation_Zhai2018,
"vK20": chromatic_adaptation_vK20,
}
)
CHROMATIC_ADAPTATION_METHODS.__doc__ = """
Expand All @@ -116,8 +130,8 @@
References
----------
:cite:`CIETC1-321994b`, :cite:`Fairchild1991a`, :cite:`Fairchild2013s`,
:cite:`Fairchild2013t`, :cite:`Li2002a`, :cite:`Westland2012k`,
:cite:`Zhai2018`
:cite:`Fairchild2013t`, :cite:`Fairchild2020`, :cite:`Li2002a`,
:cite:`Westland2012k`, :cite:`Zhai2018`
"""


Expand All @@ -126,7 +140,12 @@ def chromatic_adaptation(
XYZ_w: ArrayLike,
XYZ_wr: ArrayLike,
method: Literal[
"CIE 1994", "CMCCAT2000", "Fairchild 1990", "Zhai 2018", "Von Kries"
"CIE 1994",
"CMCCAT2000",
"Fairchild 1990",
"Von Kries",
"Zhai 2018",
"vK20",
]
| str = "Von Kries",
**kwargs: Any,
Expand Down Expand Up @@ -188,8 +207,16 @@ def chromatic_adaptation(
{:func:`colour.adaptation.chromatic_adaptation_Zhai2018`},
Degree of adaptation :math:`D_\\Delta` of output illuminant
:math:`\\Delta`.
XYZ_r
{:func:`colour.adaptation.chromatic_adaptation_vK20`},
Reference viewing conditions *CIE XYZ* tristimulus values of
whitepoint.
coefficients
{:func:`colour.adaptation.chromatic_adaptation_vK20`},
*vK20* degree of adaptation coefficients.
transform
{:func:`colour.adaptation.chromatic_adaptation_VonKries`,
:func:`colour.adaptation.chromatic_adaptation_vK20`,
:func:`colour.adaptation.chromatic_adaptation_Zhai2018`},
Chromatic adaptation transform.
XYZ_wo
Expand Down Expand Up @@ -240,6 +267,14 @@ def chromatic_adaptation(
... # doctest: +ELLIPSIS
array([ 0.2163881..., 0.1257 , 0.0384749...])
*vK2020* chromatic adaptation:
>>> XYZ_w = np.array([0.95045593, 1.00000000, 1.08905775])
>>> XYZ_wr = np.array([0.96429568, 1.00000000, 0.82510460])
>>> chromatic_adaptation(XYZ, XYZ_w, XYZ_wr, method="vK20")
... # doctest: +ELLIPSIS
array([ 0.2146884..., 0.1245616..., 0.0466255...])
*CIE 1994* chromatic adaptation, requires extra *kwargs*:
>>> XYZ = np.array([0.2800, 0.2126, 0.0527])
Expand Down Expand Up @@ -328,6 +363,8 @@ def chromatic_adaptation(
kwargs.update({"XYZ_n": XYZ_w, "XYZ_r": XYZ_wr})
elif function is chromatic_adaptation_Zhai2018:
kwargs.update({"XYZ_wb": XYZ_w, "XYZ_wd": XYZ_wr})
elif function is chromatic_adaptation_vK20:
kwargs.update({"XYZ_p": XYZ_w, "XYZ_n": XYZ_wr})

XYZ_c = function(XYZ, **filter_kwargs(function, **kwargs))

Expand Down
Loading

0 comments on commit c9714f2

Please sign in to comment.