colour.volume.rgb Module¶
RGB Colourspace Volume Computation¶
Defines various RGB colourspace volume computation objects:
RGB_colourspace_limits()
RGB_colourspace_volume_MonteCarlo()
RGB_colourspace_pointer_gamut_coverage_MonteCarlo()
RGB_colourspace_visible_spectrum_coverage_MonteCarlo()
-
colour.volume.rgb.
sample_RGB_colourspace_volume_MonteCarlo
(colourspace, samples=10000000.0, limits=array([[ 0, 100], [-150, 150], [-150, 150]]), illuminant_Lab=(0.3457, 0.3585), chromatic_adaptation_method=u'CAT02', random_generator=<function random_triplet_generator>, random_state=None)[source]¶ 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’, ‘CAT02_BRILL_CAT’, ‘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-versionsExamples
>>> 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.3457, 0.3585))[source]¶ Computes given RGB colourspace volume limits in Lab colourspace.
Parameters: - colourspace (RGB_Colourspace) – RGB colourspace to compute the volume of.
- illuminant (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.0000848...], [ -79.2197012..., 94.6760011...], [-114.7814393..., 96.7261797...]])
-
colour.volume.rgb.
RGB_colourspace_volume_MonteCarlo
(colourspace, samples=10000000.0, limits=array([[ 0, 100], [-150, 150], [-150, 150]]), illuminant_Lab=(0.3457, 0.3585), chromatic_adaptation_method=u'CAT02', random_generator=<function random_triplet_generator>, random_state=None, processes=None)[source]¶ 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’, ‘CAT02_BRILL_CAT’, ‘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: 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-versionsExamples
>>> 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) 858...
-
colour.volume.rgb.
RGB_colourspace_pointer_gamut_coverage_MonteCarlo
(colourspace, samples=10000000.0, random_generator=<function random_triplet_generator>, random_state=None)[source]¶ Returns given RGB colourspace percentage coverage of Pointer’s Gamut volume using Monte Carlo method.
Parameters: - colourspace (RGB_Colourspace) – RGB colourspace to compute the Pointer’s Gamut coverage percentage.
- samples (numeric, optional) – Samples count.
- random_generator (generator, optional) – Random triplet generator providing the random samples.
- random_state (RandomState, optional) – Mersenne Twister pseudo-random number generator to use in the random number generator.
Returns: Percentage coverage of Pointer’s Gamut volume.
Return type: Examples
>>> from colour import sRGB_COLOURSPACE as sRGB >>> prng = np.random.RandomState(2) >>> RGB_colourspace_pointer_gamut_coverage_MonteCarlo( ... sRGB, ... 10e3, ... random_state=prng) 83...
-
colour.volume.rgb.
RGB_colourspace_visible_spectrum_coverage_MonteCarlo
(colourspace, samples=10000000.0, random_generator=<function random_triplet_generator>, random_state=None)[source]¶ Returns given RGB colourspace percentage coverage of visible spectrum volume using Monte Carlo method.
Parameters: - colourspace (RGB_Colourspace) – RGB colourspace to compute the visible spectrum coverage percentage.
- samples (numeric, optional) – Samples count.
- random_generator (generator, optional) – Random triplet generator providing the random samples.
- random_state (RandomState, optional) – Mersenne Twister pseudo-random number generator to use in the random number generator.
Returns: Percentage coverage of visible spectrum volume.
Return type: Examples
>>> from colour import sRGB_COLOURSPACE as sRGB >>> prng = np.random.RandomState(2) >>> RGB_colourspace_visible_spectrum_coverage_MonteCarlo( ... sRGB, ... 10e3, ... random_state=prng) 36...