Skip to content

Instantly share code, notes, and snippets.

@KelSolaar
Last active February 20, 2022 17:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KelSolaar/df7be0d050a865bb993c to your computer and use it in GitHub Desktop.
Save KelSolaar/df7be0d050a865bb993c to your computer and use it in GitHub Desktop.
Munsell Colour to sRGB
import numpy as np
import colour
xyY = np.asarray(colour.MUNSELL_COLOURS_REAL[2000][1])
# Munsell Renotation System uses C illuminant.
# Luminance is in range [0-100], so we need to scale it
# back to [0-1].
XYZ = colour.xyY_to_XYZ(xyY)
RGB = colour.XYZ_to_sRGB(
XYZ / 100, colour.ILLUMINANTS.get(
'CIE 1931 2 Degree Standard Observer').get('C'),
apply_OECF=False)
# Not all the Munsell colours can be encoded by
# sRGB colourspace, You would have to clip that
# particular one in order to display it.
print(RGB)
# [ 0.97132396 0.31934229 -0.03864044]
# Those values are linear light values, so in
# order to display the colour accurately,
# you would need to apply the sRGB OECF.
# You can do that in the above definition call
# or later as your convenience by doing something
# along those lines:
print(colour.sRGB_COLOURSPACE.OECF(RGB))
# [ 0.98728743 0.60068106 -0.49923444]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment