pythoncolorscielabcolormath

what is the interval of the return values of Delta E functions for comparing Cielab colours?


I am trying to turn comparison values of Cielab colours using Delta E functions from python colormath (delta_e_cie2000, etc.) into a probability distribution. The problem is, that I could not find any reference on the Delta E functions telling me what interval [min, max], the return value is element of.

The result of e.g two SRGB colors red and blue:

c1 = convert_color(convert_color(sRGBColor(1,0,0), XYZColor), LabColor)
c2 = convert_color(convert_color(sRGBColor(0,0,1), XYZColor), LabColor)
print(delta_e_cie2000(c1, c2))

is 52.880.

If the interval was [0,100], I could just divide by 100 to normalize it to numbers between [0,1].

Does anybody know a reference or has an idea how to determine the min and max value? I do not want to iteratively test it by randomizing colours and trying to find the thresholds.


Solution

  • CIE Lab ΔE does not have a defined working range, the maximum theoretical range is also dependent upon the chose RGB colourspace in your case.

    However, something critical to keep in mind is that CIE Lab ΔE was not designed to measure colour difference beyond a certain CIE Lab ΔE magnitude. 10-20 ΔE is considered large and likely the usable maximum after which it is meaningless trying to quantify the difference. You might end up with a pair more spatially separated than another having a smaller ΔE than the latter.

    Here are a few relevant publications:

    As per your comments, it seems like you are not interested so much by whether the quasi-metric yield a meaningful result. What you could do then for the general case is as follows:

    Here is an example of how to do that with Colour:

    import colour
    import itertools
    import numpy as np
    
    XYZ = colour.volume.XYZ_outer_surface()
    
    combinations = colour.XYZ_to_Lab(np.array(list(itertools.combinations(XYZ, 2))))
    
    delta_E = colour.delta_E(combinations[:, 0, :], combinations[:, 1, :])
    
    print(np.max(delta_E))
    
    # 144.998329679
    

    For the particular sRGB case you could just sample the sRGB cube transformed to CIE XYZ colourspace coordinates as follows:

    import colour
    import colour.plotting
    import itertools
    import numpy as np
    
    RGB = colour.plotting.volume.cube(
        width_segments=10, height_segments=10, depth_segments=10)
    XYZ = colour.sRGB_to_XYZ(RGB, apply_decoding_cctf=False)
    
    combinations = colour.XYZ_to_Lab(np.array(list(itertools.combinations(XYZ, 2))))
    
    delta_E = colour.delta_E(combinations[:, 0, :], combinations[:, 1, :])
    
    print(np.max(delta_E))
    
    # 119.022907418
    

    Here is a Google Colab notebook if you want to try live: https://colab.research.google.com/drive/1nxlq-QIhByrGiF24oZHFX7dNymG79BYg#scrollTo=IkdwsUvzob6h