colour.volume Package

Module Contents

colour.volume.is_within_macadam_limits(xyY, illuminant, tolerance=None)

Returns if given CIE xyY colourspace array is within MacAdam limits of given illuminant.

Parameters:
  • xyY (array_like) – CIE xyY colourspace array.
  • illuminant (unicode) – Illuminant.
  • tolerance (numeric, optional) – Tolerance allowed in the inside-triangle check.
Returns:

Is within MacAdam limits.

Return type:

bool

Notes

  • Input CIE xyY colourspace array is in domain [0, 1].
  • This definition requires scipy to be installed.

Examples

>>> is_within_macadam_limits(np.array([0.3205, 0.4131, 0.51]), 'A')
array(True, dtype=bool)
>>> a = np.array([[0.3205, 0.4131, 0.51],
...               [0.0005, 0.0031, 0.001]])
>>> is_within_macadam_limits(a, 'A')
array([ True, False], dtype=bool)
colour.volume.RGB_colourspace_limits(colourspace, illuminant=(0.34567, 0.3585))

Computes given RGB colourspace volume limits in Lab colourspace.

Parameters:
  • colourspace (RGB_Colourspace) – RGB colourspace to compute the volume of.
  • illuminant_Lab (array_like, optional) – Lab colourspace illuminant chromaticity coordinates.
Returns:

RGB colourspace volume limits.

Return type:

ndarray

Examples

>>> from colour import sRGB_COLOURSPACE as sRGB
>>> RGB_colourspace_limits(sRGB)    
array([[   0...        ,  100...        ],
       [ -79.2263741...,   94.6657491...],
       [-114.7846271...,   96.7135199...]])
RGB_colourspace_volume_MonteCarlo(colourspace, samples=10000000.0, limits=array([[ 0, 100],
[-150, 150],
[-150, 150]]), illuminant_Lab=(0.34567, 0.3585), chromatic_adaptation_method=u'CAT02', random_generator=<function random_triplet_generator at 0x2adc441cdc80>, random_state=None, processes=None)

Performs given RGB colourspace volume computation using Monte Carlo method and multiprocessing.

Parameters:
  • colourspace (RGB_Colourspace) – RGB colourspace to compute the volume of.
  • samples (numeric, optional) – Samples count.
  • limits (array_like, optional) – Lab colourspace volume.
  • illuminant_Lab (array_like, optional) – Lab colourspace illuminant chromaticity coordinates.
  • chromatic_adaptation_method (unicode, optional) – {‘CAT02’, ‘XYZ Scaling’, ‘Von Kries’, ‘Bradford’, ‘Sharp’, ‘Fairchild, ‘CMCCAT97’, ‘CMCCAT2000’, ‘Bianco’, ‘Bianco PC’}, Chromatic adaptation method.
  • random_generator (generator, optional) – Random triplet generator providing the random samples within the Lab colourspace volume.
  • random_state (RandomState, optional) – Mersenne Twister pseudo-random number generator to use in the random number generator.
  • processes (integer, optional) – Processes count, default to multiprocessing.cpu_count() definition.
Returns:

RGB colourspace volume.

Return type:

float

Notes

The doctest is assuming that np.random.RandomState() definition will return the same sequence no matter which OS or Python version is used. There is however no formal promise about the prng sequence reproducibility of either Python or *Numpy implementations: Laurent. (2012). Reproducibility of python pseudo-random numbers across systems and versions? Retrieved January 20, 2015, from http://stackoverflow.com/questions/8786084/reproducibility-of-python-pseudo-random-numbers-across-systems-and-versions

Examples

>>> from colour import sRGB_COLOURSPACE as sRGB
>>> prng = np.random.RandomState(2)
>>> processes = 1
>>> RGB_colourspace_volume_MonteCarlo(sRGB, 10e3, random_state=prng, processes=processes)    
859...