Color Theory: How to convert Munsell HVC to RGB/HSB/HSL

后端 未结 8 1642
时光说笑
时光说笑 2020-12-23 10:08

I\'m looking at at document that describes the standard colors used in dentistry to describe the color of a tooth. They quote hue, value, chroma v

8条回答
  •  萌比男神i
    2020-12-23 10:53

    Munsell Renotation System to sRGB Colourspace Conversion

    Colour, our open source Python colour science package allows to perform that conversion.

    From Munsell Renotation System to CIE xyY Colourspace

    The following two definitions based on Centore (2012) method converts between Munsell Renotation System and CIE xyY colourspace:

    • munsell_colour_to_xyY
    • xyY_to_munsell_colour

    From CIE xyY Colourspace to sRGB Colourspace

    Converting from CIE xyY colourspace to sRGB colourspace is done by first converting to CIE XYZ tristimulus values and then to sRGB colourspace using the following definitions:

    • xyY_to_XYZ
    • XYZ_to_sRGB

    Implementation

    Here is an annotated complete example using the above definitions:

    import colour
    
    # The *Munsell Renotation System* colour we would like to convert
    # to *sRGB* colourspace.
    MRS_c = '4.2YR 8.1/5.3'
    
    # The first step is to convert the *MRS* colour to *CIE xyY* 
    # colourspace.
    xyY = colour.munsell_colour_to_xyY(MRS_c)
    
    # We then perform conversion to *CIE xyY* tristimulus values.
    XYZ = colour.xyY_to_XYZ(xyY)
    
    # The last step will involve using the *Munsell Renotation System*
    # illuminant which is *CIE Illuminant C*:
    # http://nbviewer.ipython.org/github/colour-science/colour-ipython/blob/master/notebooks/colorimetry/illuminants.ipynb#CIE-Illuminant-C
    # It is necessary in order to ensure white stays white when
    # converting to *sRGB* colourspace and its different whitepoint 
    # (*CIE Standard Illuminant D65*) by performing chromatic 
    # adaptation between the two different illuminant.
    C = colour.ILLUMINANTS['CIE 1931 2 Degree Standard Observer']['C']
    RGB = colour.XYZ_to_sRGB(XYZ, C)
    
    print(RGB)
    

    [ 0.96820063 0.74966853 0.60617991]

    You can also perform the reverse conversion from sRGB colourspace to Munsell Renotation System:

    import colour
    
    C = colour.ILLUMINANTS['CIE 1931 2 Degree Standard Observer']['C']
    
    RGB = (0.96820063, 0.74966853, 0.60617991)
    
    print(colour.xyY_to_munsell_colour(colour.XYZ_to_xyY(colour.sRGB_to_XYZ(RGB, C))))
    

    4.2YR 8.1/5.3

    References

    • Centore, P. (2012). An open-source inversion algorithm for the Munsell renotation. Color Research & Application, 37(6), 455–464. doi:10.1002/col.20715

提交回复
热议问题