Skip to content

Conversation

@lassefschmidt
Copy link

@lassefschmidt lassefschmidt commented Nov 6, 2025

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_Lab
  • colour.difference.metamerism_index_from_XYZ

Both 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)

    Lab_corr,t = Lab_spl,t - (Lab_spl,r - Lab_std,r)
    
  • Multiplicative correction (recommended in CIEXYZ domain by ISO 18314-4)

    XYZ_corr,t = XYZ_spl,t * (XYZ_std,r / XYZ_spl,r)
    

After correction, the metamerism index is computed as a colour-difference metric between the corrected sample and the standard under test illuminant:

M_t = ΔE(Lab_std,t, Lab_corr,t)

The metric can be any supported ΔE implementation (e.g. CIE1976, CIE2000, CMC, etc.) available in colour.difference.

Preflight

Code Style and Quality

  • Unit tests have been implemented and passed.
  • Pyright static checking has been run and passed.
  • Pre-commit hooks have been run and passed.
  • New transformations have been added to the Automatic Colour Conversion Graph.
  • New transformations have been exported to the relevant namespaces, e.g. 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

  • New features are documented along with examples if relevant.
  • The documentation is Sphinx and numpydoc compliant.

Best,
Lasse

Copy link
Member

@KelSolaar KelSolaar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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":
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked CIE 015:2018 Colorimetry, funnily enough, the only method mentioned for tristimulus values is multiplicative:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants