colour.models.derivation Module

RGB Colourspace Derivation

Defines objects related to RGB colourspace derivation, essentially calculating the normalised primary matrix for given RGB colourspace primaries and whitepoint.

References

[1]RP 177-1993 SMPTE RECOMMENDED PRACTICE - Television Color Equations, DOI: https://doi.org/10.5594/S9781614821915 (Last accessed 24 February 2014)
colour.models.derivation.xy_to_z(xy)[source]

Returns the z coordinate using given xy chromaticity coordinates.

Parameters:xy (array_like) – xy chromaticity coordinates.
Returns:z coordinate.
Return type:numeric

References

[2]RP 177-1993 SMPTE RECOMMENDED PRACTICE - Television Color Equations: 3.3.2, DOI: https://doi.org/10.5594/S9781614821915

Examples

>>> xy_to_z((0.25, 0.25))
0.5
colour.models.derivation.normalised_primary_matrix(primaries, whitepoint)[source]

Returns the normalised primary matrix using given primaries and whitepoint matrices.

Parameters:
  • primaries (array_like) – Primaries chromaticity coordinate matrix, (3, 2).
  • whitepoint (array_like) – Illuminant / whitepoint chromaticity coordinates.
Returns:

Normalised primary matrix.

Return type:

ndarray, (3, 3)

References

[3]RP 177-1993 SMPTE RECOMMENDED PRACTICE - Television Color Equations: 3.3.2 - 3.3.6, DOI: https://doi.org/10.5594/S9781614821915

Examples

>>> pms = np.array([0.73470, 0.26530, 0.00000, 1.00000, 0.00010, -0.07700])
>>> whitepoint = (0.32168, 0.33767)
>>> normalised_primary_matrix(pms, whitepoint)  
array([[  9.5255239...e-01,   0.0000000...e+00,   9.3678631...e-05],
       [  3.4396645...e-01,   7.2816609...e-01,  -7.2132546...e-02],
       [  0.0000000...e+00,   0.0000000...e+00,   1.0088251...e+00]])
colour.models.derivation.RGB_luminance_equation(primaries, whitepoint)[source]

Returns the luminance equation from given primaries and whitepoint matrices.

Parameters:
  • primaries (array_like, (3, 2)) – Primaries chromaticity coordinate matrix.
  • whitepoint (array_like) – Illuminant / whitepoint chromaticity coordinates.
Returns:

Luminance equation.

Return type:

unicode

References

[4]RP 177-1993 SMPTE RECOMMENDED PRACTICE - Television Color Equations: 3.3.8, DOI: https://doi.org/10.5594/S9781614821915

Examples

>>> pms = np.array([0.73470, 0.26530, 0.00000, 1.00000, 0.00010, -0.07700])
>>> whitepoint = (0.32168, 0.33767)
>>> # Doctests skip for Python 2.x compatibility.
>>> RGB_luminance_equation(pms, whitepoint)  
'Y = 0.3439664...(R) + 0.7281660...(G) + -0.0721325...(B)'
colour.models.derivation.RGB_luminance(RGB, primaries, whitepoint)[source]

Returns the luminance \(y\) of given RGB components from given primaries and whitepoint matrices.

Parameters:
  • RGB (array_like, (3,)) – RGB chromaticity coordinate matrix.
  • primaries (array_like, (3, 2)) – Primaries chromaticity coordinate matrix.
  • whitepoint (array_like) – Illuminant / whitepoint chromaticity coordinates.
Returns:

Luminance \(y\).

Return type:

numeric

References

[5]RP 177-1993 SMPTE RECOMMENDED PRACTICE - Television Color Equations: 3.3.3 - 3.3.6, DOI: https://doi.org/10.5594/S9781614821915

Examples

>>> RGB = np.array([40.6, 4.2, 67.4])
>>> pms = np.array([0.73470, 0.26530, 0.00000, 1.00000, 0.00010, -0.07700])
>>> whitepoint = (0.32168, 0.33767)
>>> RGB_luminance(RGB, pms, whitepoint)  
12.1616018...