PR: Implement support for *Metamerism Index* computation.#1374
PR: Implement support for *Metamerism Index* computation.#1374KelSolaar merged 3 commits intocolour-science:developfrom
Conversation
KelSolaar
left a comment
There was a problem hiding this comment.
Thanks a lot @lassefschmidt, I left a few minor comments!
What about the spectral correction method. Have you looked at it? Not implying that you should implement it here or ever, was just curious!
| if correction == "additive": | ||
| Lab_corr_t = as_array(Lab_spl_t) - (as_array(Lab_spl_r) - as_array(Lab_std_r)) | ||
|
|
||
| elif correction == "multiplicative": |
There was a problem hiding this comment.
Wondering if it make sense to perform multiplicative correction with CIE Lab values as they can be negative. The standard does not forbid it but in section 8.3.2 Multiplicative correction it only mentions trististimulus values whereas for additive both CIE XYZ and CIE Lab are mentioned.
@tjdcs : What do you think?
There was a problem hiding this comment.
This correction looks like it's trying to do chromatic adaptation from a "new" source to a reference source... in which case...
Hm.
I don't really understand what's going on here... but if that's the case, then probably the multiplicative corrections only "validated" for tristimulus inputs. This additive correction is based on a pretty gross misunderstanding of chromatic adaptation, but if that's what's in the reference papers then it should be kept.
There was a problem hiding this comment.
To clarify, how do we want to proceed ? As @KelSolaar pointed out, the standard mentions
- additive correction for both CIE Lab and CIE XYZ
- multiplicative correction only for CIE XYZ
I would remove the correction argument from the XYZ_to_metamerism_index function and we will always perform multiplicative correction for XYZ inputs.
…or correction method function argument
8a82944 to
4a83187
Compare
|
Let's merge this one, thanks @lassefschmidt! I might rename the module to "metamerism_index.py". |

Summary
This PR introduces the implementation of the Metamerism Index
M_{t}according to ISO 18314-4:2024 (Analytical Colorimetry, Part 4).We implement additive and multiplicative correction. The norm also defines spectral correction using remission data as input. I would like to implement this as well, but first want to get feedback as spectral correction will likely be a bigger change !
💡 Quick Overview
We define two new computation functions:
colour.difference.metamerism_index_from_Labcolour.difference.metamerism_index_from_XYZBoth follow the ISO procedure for calculating the metamerism index between a sample and a standard under two illuminants (test and reference).
The key idea is that the sample colour under test illuminant is corrected using its behavior under reference illuminant compared to the standard under reference illuminant. (Thus, if sample is too blue under reference illuminant, and too yellow under test illuminant, metamerism will be higher than a simple delta E between sample and standard under test illuminant as the sample changes inversely to the standard under the different illuminations)
Two correction models are supported:
Additive correction (recommended in CIELab domain by ISO 18314-4)
Multiplicative correction (recommended in CIEXYZ domain by ISO 18314-4)
After correction, the metamerism index is computed as a colour-difference metric between the corrected sample and the standard under test illuminant:
The metric can be any supported ΔE implementation (e.g.
CIE1976,CIE2000,CMC, etc.) available incolour.difference.Preflight
Code Style and Quality
colour,colour.models.3 tests failed, all related to image.io -- which was not touched / modified in this PR at all. See below output
=========================== short test summary info ===========================
FAILED colour/io/image.py::colour.io.image.read_image_Imageio
FAILED colour/io/tests/test_image.py::TestWriteImageImageio::test_write_image_Imageio_exr
FAILED colour/io/tests/test_image.py::TestReadImageImageio::test_read_image_Imageio
========== 3 failed, 3635 passed, 17 skipped, 205 warnings in 40.50s ==========
Documentation
Best,
Lasse