colour.volume.rgb Module

RGB Colourspace Volume Computation

Defines various RGB colourspace volume computation objects:

sample_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 0x2b437a204500>, random_state=None)

Randomly samples the Lab colourspace volume and returns the ratio of samples within the given RGB colourspace volume.

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.
Returns:

Within RGB colourspace volume samples count.

Return type:

integer

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)
>>> sample_RGB_colourspace_volume_MonteCarlo(sRGB, 10e3, random_state=prng)    
9...
colour.volume.rgb.RGB_colourspace_limits(colourspace, illuminant=(0.34567, 0.3585))[source]

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 0x2b437a204500>, 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...