Skip to content

Commit 4e2be9f

Browse files
committed
Polish *Metamerism Index* computation implementation.
1 parent 0f9b42a commit 4e2be9f

File tree

3 files changed

+53
-46
lines changed

3 files changed

+53
-46
lines changed

colour/difference/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
)
6767
from .din99 import delta_E_DIN99
6868
from .huang2015 import power_function_Huang2015
69-
from .metamerism import Lab_to_metamerism_index, XYZ_to_metamerism_index
69+
from .metamerism_index import Lab_to_metamerism_index, XYZ_to_metamerism_index
7070
from .stress import INDEX_STRESS_METHODS, index_stress, index_stress_Garcia2007
7171

7272
__all__ = [

colour/difference/metamerism.py renamed to colour/difference/metamerism_index.py

Lines changed: 46 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22
:math:`M_{t}` - Metamerism Index
33
================================
44
5-
Define the :math:`M_{t}` metamerism computation objects.
5+
Define the :math:`M_{t}` *metamerism index* computation objects:
66
77
- :func:`colour.difference.Lab_to_metamerism_index`
88
- :func:`colour.difference.XYZ_to_metamerism_index`
99
1010
References
1111
----------
12-
- :cite:ISO18314-4_2024 : International Organization for Standardization. (2024).
13-
ISO 18314-4:2024. Analytical colorimetry, Part 4: Metamerism index for pairs
14-
of samples for change of illuminant (2nd ed., 24 pp.).
15-
ISO/TC 256. https://www.iso.org/standard/85116.html
12+
- :cite:`InternationalOrganizationforStandardization2024` : International
13+
Organization for Standardization. (2024). INTERNATIONAL STANDARD ISO
14+
18314-4 - Analytical colorimetry Part 4: Metamerism index for pairs of
15+
samples for change of illuminant. https://www.iso.org/standard/85116.html
1616
"""
1717

1818
from __future__ import annotations
@@ -56,33 +56,38 @@ def Lab_to_metamerism_index(
5656
**kwargs: Any,
5757
) -> NDArrayFloat:
5858
"""
59-
Compute the metamerism index :math:`M_{t}` between four specified
60-
*CIE L\\*a\\*b\\** colourspace arrays. Before computing the metamerism index,
61-
we apply either an additive or multiplicative correction. The correction is
62-
based on the difference between the colour sample and colour standard under
63-
reference illuminant and applied to the colour sample under test illuminant.
64-
The correction is applied in *CIE L\\*a\\*b\\** colourspace.
59+
Compute the *metamerism index* :math:`M_{t}` between four specified
60+
*CIE L\\*a\\*b\\** colourspace arrays.
6561
66-
:cite:ISO18314-4_2024 recommends to use additive correction in *CIE L\\*a\\*b\\**.
62+
Before computing the *metamerism index*, apply either an additive or
63+
multiplicative correction. The correction is based on the difference
64+
between the colour sample and colour standard under the reference
65+
illuminant and is applied to the colour sample under the test illuminant.
66+
The correction is applied in *CIE L\\*a\\*b\\** colourspace, which is then
67+
used to compute the *metamerism index*.
68+
69+
:cite:`InternationalOrganizationforStandardization2024` recommends using
70+
additive correction in *CIE L\\*a\\*b\\**.
6771
6872
Parameters
6973
----------
7074
Lab_spl_t
71-
*CIE L\\*a\\*b\\** colourspace array of colour sample under
72-
test illuminant.
75+
*CIE L\\*a\\*b\\** colourspace array of the colour sample under the test
76+
illuminant.
7377
Lab_std_t
74-
*CIE L\\*a\\*b\\** colourspace array of colour standard under
78+
*CIE L\\*a\\*b\\** colourspace array of the colour standard under the
7579
test illuminant.
7680
Lab_spl_r
77-
*CIE L\\*a\\*b\\** colourspace array of colour sample under
81+
*CIE L\\*a\\*b\\** colourspace array of the colour sample under the
7882
reference illuminant.
7983
Lab_std_r
80-
*CIE L\\*a\\*b\\** colourspace array of colour standard under
84+
*CIE L\\*a\\*b\\** colourspace array of the colour standard under the
8185
reference illuminant.
8286
correction
83-
Correction method to apply, either 'Additive' or 'Multiplicative'.
84-
metric
85-
Colour difference metric to use.
87+
Correction method to apply, either ``'Additive'`` or
88+
``'Multiplicative'``.
89+
method
90+
Colour-difference method.
8691
8792
Other Parameters
8893
----------------
@@ -104,7 +109,7 @@ def Lab_to_metamerism_index(
104109
Returns
105110
-------
106111
:class:`numpy.ndarray`
107-
Metamerism index :math:`M_{t}`.
112+
*Metamerism index* :math:`M_{t}`.
108113
109114
Notes
110115
-----
@@ -122,7 +127,7 @@ def Lab_to_metamerism_index(
122127
123128
References
124129
----------
125-
:cite:ISO18314-4_2024
130+
:cite:`InternationalOrganizationforStandardization2024`
126131
127132
Examples
128133
--------
@@ -177,34 +182,36 @@ def XYZ_to_metamerism_index(
177182
**kwargs: Any,
178183
) -> NDArrayFloat:
179184
"""
180-
Compute the metamerism index :math:`M_{t}` between four specified
181-
*CIE XYZ* colourspace arrays. Before computing the metamerism index,
182-
we apply either an additive or multiplicative correction. The correction is
183-
based on the difference between the colour sample and colour standard under
184-
reference illuminant and applied to the colour sample under test illuminant.
185-
The correction is applied in *CIE XYZ* colourspace. Afterwards, we convert to
186-
*CIE L\\*a\\*b\\** colourspace to compute the metamerism index.
185+
Compute the *metamerism index* :math:`M_{t}` from four specified
186+
*CIE XYZ* colourspace arrays.
187+
188+
Before computing the *metamerism index*, apply either an additive or
189+
multiplicative correction. The correction is based on the difference
190+
between the colour sample and colour standard under the reference
191+
illuminant and is applied to the colour sample under the test illuminant.
192+
The correction is applied in *CIE XYZ* colourspace. Afterwards, convert
193+
to *CIE L\\*a\\*b\\** colourspace to compute the *metamerism index*.
187194
188-
:cite:ISO18314-4_2024 recommends to use multiplicative correction in
189-
*CIE L\\*a\\*b\\**.
195+
:cite:`InternationalOrganizationforStandardization2024` recommends using
196+
multiplicative correction in *CIE L\\*a\\*b\\**.
190197
191198
Parameters
192199
----------
193200
XYZ_spl_t
194-
*CIE XYZ* tristimulus array of the sample under test
201+
*CIE XYZ* tristimulus array of the colour sample under the test
195202
illuminant.
196203
XYZ_std_t
197-
*CIE XYZ* tristimulus array of the standard under test
204+
*CIE XYZ* tristimulus array of the colour standard under the test
198205
illuminant.
199206
XYZ_spl_r
200-
*CIE XYZ* tristimulus array of the sample under reference
207+
*CIE XYZ* tristimulus array of the colour sample under the reference
201208
illuminant.
202209
XYZ_std_r
203-
*CIE XYZ* tristimulus array of the standard under reference
210+
*CIE XYZ* tristimulus array of the colour standard under the reference
204211
illuminant.
205212
correction
206-
Correction method to apply, either 'Additive' or
207-
'Multiplicative'.
213+
Correction method to apply, either ``'Additive'`` or
214+
``'Multiplicative'``.
208215
method
209216
Colour-difference method.
210217
@@ -232,7 +239,7 @@ def XYZ_to_metamerism_index(
232239
Returns
233240
-------
234241
:class:`numpy.ndarray`
235-
Metamerism index :math:`M_{t}`.
242+
*Metamerism index* :math:`M_{t}`.
236243
237244
Notes
238245
-----
@@ -250,7 +257,7 @@ def XYZ_to_metamerism_index(
250257
251258
References
252259
----------
253-
:cite:ISO18314-4_2024
260+
:cite:`InternationalOrganizationforStandardization2024`
254261
255262
Examples
256263
--------

colour/difference/tests/test_metamerism.py renamed to colour/difference/tests/test_metamerism_index.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
"""Define the unit tests for the :mod:`colour.difference.metamerism` module."""
1+
"""Define the unit tests for the :mod:`colour.difference.metamerism_index` module."""
22

33
from __future__ import annotations
44

55
import numpy as np
66

77
from colour.constants import TOLERANCE_ABSOLUTE_TESTS
8-
from colour.difference.metamerism import (
8+
from colour.difference.metamerism_index import (
99
Lab_to_metamerism_index,
1010
XYZ_to_metamerism_index,
1111
)
@@ -26,13 +26,13 @@
2626

2727
class TestLab_to_Metamerism_Index:
2828
"""
29-
Define :func:`colour.difference.metamerism.Lab_to_metamerism_index`
29+
Define :func:`colour.difference.metamerism_index.Lab_to_metamerism_index`
3030
definition unit tests methods.
3131
"""
3232

3333
def test_domain_range_scale_Lab_to_metamerism_index(self) -> None:
3434
"""
35-
Test :func:`colour.difference.metamerism.Lab_to_metamerism_index`
35+
Test :func:`colour.difference.metamerism_index.Lab_to_metamerism_index`
3636
definition domain and range scale support.
3737
"""
3838

@@ -78,13 +78,13 @@ def test_domain_range_scale_Lab_to_metamerism_index(self) -> None:
7878

7979
class TestXYZ_to_Metamerism_Index:
8080
"""
81-
Define :func:`colour.difference.metamerism.XYZ_to_metamerism_index`
81+
Define :func:`colour.difference.metamerism_index.XYZ_to_metamerism_index`
8282
definition unit tests methods.
8383
"""
8484

8585
def test_domain_range_scale_XYZ_to_metamerism_index(self) -> None:
8686
"""
87-
Test :func:`colour.difference.metamerism.XYZ_to_metamerism_index`
87+
Test :func:`colour.difference.metamerism_index.XYZ_to_metamerism_index`
8888
definition domain and range scale support.
8989
"""
9090

0 commit comments

Comments
 (0)