colour.models.rgb Module¶
RGB Colourspace & Transformations¶
Defines the RGB_Colourspace
class for the RGB colourspaces dataset
from colour.models.dataset.aces_rgb
, etc... and the following RGB
colourspace transformations:
See also
-
class
colour.models.rgb.
RGB_Colourspace
(name, primaries, whitepoint, illuminant=None, RGB_to_XYZ_matrix=None, XYZ_to_RGB_matrix=None, OECF=None, EOCF=None)[source]¶ Bases:
object
Implements support for the RGB colourspaces dataset from
colour.models.dataset.aces_rgb
, etc....Parameters: - name (unicode) – RGB colourspace name.
- primaries (array_like) – RGB colourspace primaries.
- whitepoint (array_like) – RGB colourspace whitepoint.
- illuminant (unicode, optional) – RGB colourspace whitepoint name as illuminant.
- RGB_to_XYZ_matrix (array_like, optional) – Transformation matrix from colourspace to CIE XYZ tristimulus values.
- XYZ_to_RGB_matrix (array_like, optional) – Transformation matrix from CIE XYZ tristimulus values to colourspace.
- OECF (object, optional) – Opto-electronic conversion function (OECF) that maps estimated tristimulus values in a scene to \(R'G'B'\) video component signal value.
- EOCF (object, optional) – Electro-optical conversion function (EOCF) that maps an \(R'G'B'\) video component signal to a tristimulus value at the display.
-
RGB_to_XYZ_matrix
¶ Property for self.__to_XYZ private attribute.
Returns: self.__to_XYZ. Return type: array_like, (3, 3)
-
XYZ_to_RGB_matrix
¶ Property for self.__to_RGB private attribute.
Returns: self.__to_RGB. Return type: array_like, (3, 3)
-
illuminant
¶ Property for self.__illuminant private attribute.
Returns: self.__illuminant. Return type: unicode
-
name
¶ Property for self.__name private attribute.
Returns: self.__name. Return type: unicode
-
primaries
¶ Property for self.__primaries private attribute.
Returns: self.__primaries. Return type: array_like, (3, 2)
-
whitepoint
¶ Property for self.__whitepoint private attribute.
Returns: self.__whitepoint. Return type: array_like
-
colour.models.rgb.
XYZ_to_RGB
(XYZ, illuminant_XYZ, illuminant_RGB, XYZ_to_RGB_matrix, chromatic_adaptation_transform=u'CAT02', OECF=None)[source]¶ Converts from CIE XYZ tristimulus values to given RGB colourspace.
Parameters: - XYZ (array_like) – CIE XYZ tristimulus values.
- illuminant_XYZ (array_like) – CIE XYZ tristimulus values illuminant xy chromaticity coordinates or CIE xyY colourspace array.
- illuminant_RGB (array_like) – RGB colourspace illuminant xy chromaticity coordinates or CIE xyY colourspace array.
- XYZ_to_RGB_matrix (array_like) – Normalised primary matrix.
- chromatic_adaptation_transform (unicode, optional) – {‘CAT02’, ‘XYZ Scaling’, ‘Von Kries’, ‘Bradford’, ‘Sharp’, ‘Fairchild, ‘CMCCAT97’, ‘CMCCAT2000’, ‘CAT02_BRILL_CAT’, ‘Bianco’, ‘Bianco PC’}, Chromatic adaptation transform.
- OECF (object, optional) – Opto-electronic conversion function.
Returns: RGB colourspace array.
Return type: ndarray
Notes
- Input CIE XYZ tristimulus values are in domain [0, 1].
- Input illuminant_XYZ xy chromaticity coordinates or CIE xyY colourspace array are in domain [0, \(\infty\)].
- Input illuminant_RGB xy chromaticity coordinates or CIE xyY colourspace array are in domain [0, \(\infty\)].
- Output RGB colourspace array is in domain [0, 1].
Examples
>>> XYZ = np.array([0.07049534, 0.10080000, 0.09558313]) >>> illuminant_XYZ = np.array([0.34567, 0.35850]) >>> illuminant_RGB = np.array([0.31271, 0.32902]) >>> chromatic_adaptation_transform = 'Bradford' >>> XYZ_to_RGB_matrix = np.array([ ... [3.24100326, -1.53739899, -0.49861587], ... [-0.96922426, 1.87592999, 0.04155422], ... [0.05563942, -0.20401120, 1.05714897]]) >>> XYZ_to_RGB( ... XYZ, ... illuminant_XYZ, ... illuminant_RGB, ... XYZ_to_RGB_matrix, ... chromatic_adaptation_transform) array([ 0.0110360..., 0.1273446..., 0.1163103...])
-
colour.models.rgb.
RGB_to_XYZ
(RGB, illuminant_RGB, illuminant_XYZ, RGB_to_XYZ_matrix, chromatic_adaptation_transform=u'CAT02', EOCF=None)[source]¶ Converts from given RGB colourspace to CIE XYZ tristimulus values.
Parameters: - RGB (array_like) – RGB colourspace array.
- illuminant_RGB (array_like) – RGB colourspace illuminant chromaticity coordinates or CIE xyY colourspace array.
- illuminant_XYZ (array_like) – CIE XYZ tristimulus values illuminant chromaticity coordinates or CIE xyY colourspace array.
- RGB_to_XYZ_matrix (array_like) – Normalised primary matrix.
- chromatic_adaptation_transform (unicode, optional) – {‘CAT02’, ‘XYZ Scaling’, ‘Von Kries’, ‘Bradford’, ‘Sharp’, ‘Fairchild, ‘CMCCAT97’, ‘CMCCAT2000’, ‘CAT02_BRILL_CAT’, ‘Bianco’, ‘Bianco PC’}, Chromatic adaptation transform.
- EOCF (object, optional) – Electro-optical conversion function.
Returns: CIE XYZ tristimulus values.
Return type: ndarray
Notes
- Input RGB colourspace array is in domain [0, 1].
- Input illuminant_RGB xy chromaticity coordinates or CIE xyY colourspace array are in domain [0, \(\infty\)].
- Input illuminant_XYZ xy chromaticity coordinates or CIE xyY colourspace array are in domain [0, \(\infty\)].
- Output CIE XYZ tristimulus values are in domain [0, 1].
Examples
>>> RGB = np.array([0.01103604, 0.12734466, 0.11631037]) >>> illuminant_RGB = np.array([0.31271, 0.32902]) >>> illuminant_XYZ = np.array([0.34567, 0.35850]) >>> chromatic_adaptation_transform = 'Bradford' >>> RGB_to_XYZ_matrix = np.array([ ... [0.41238656, 0.35759149, 0.18045049], ... [0.21263682, 0.71518298, 0.07218020], ... [0.01933062, 0.11919716, 0.95037259]]) >>> RGB_to_XYZ( ... RGB, ... illuminant_RGB, ... illuminant_XYZ, ... RGB_to_XYZ_matrix, ... chromatic_adaptation_transform) array([ 0.0704953..., 0.1008 , 0.0955831...])
-
colour.models.rgb.
RGB_to_RGB
(RGB, input_colourspace, output_colourspace, chromatic_adaptation_transform=u'CAT02')[source]¶ Converts from given input RGB colourspace to output RGB colourspace using given chromatic adaptation method.
Parameters: - RGB (array_like) – RGB colourspace array.
- input_colourspace (RGB_Colourspace) – RGB input colourspace.
- output_colourspace (RGB_Colourspace) – RGB output colourspace.
- chromatic_adaptation_transform (unicode, optional) – {‘CAT02’, ‘XYZ Scaling’, ‘Von Kries’, ‘Bradford’, ‘Sharp’, ‘Fairchild, ‘CMCCAT97’, ‘CMCCAT2000’, ‘CAT02_BRILL_CAT’, ‘Bianco’, ‘Bianco PC’}, Chromatic adaptation transform.
Returns: RGB colourspace array.
Return type: ndarray
Notes
- RGB colourspace arrays are in domain [0, 1].
Examples
>>> from colour import sRGB_COLOURSPACE, PROPHOTO_RGB_COLOURSPACE >>> RGB = np.array([0.01103604, 0.12734466, 0.11631037]) >>> RGB_to_RGB( ... RGB, ... sRGB_COLOURSPACE, ... PROPHOTO_RGB_COLOURSPACE) array([ 0.0643338..., 0.1157362..., 0.1157614...])