This package provides some tools to work with colour in Python in a way that matches human perception. The adopted colour space is CIELCH, the cylindrical representation of CIELAB, with coordinates L = lightness in [0,100], C = chroma >= 0, H = hue angle in [0, 360]. The package relies on NumPy for array manipulations, Matplotlib for plotting, and optionally other colour packages listed below.
convert provides functions to convert a colour triplet between HCL and sRGB spaces, using either built-in formulas or wrappers to colorspacious or colour packages.
gamut provides functions to compute and visualize the boundary Cmax(L,H) of the sRGB gamut and of the full human gamut. These boundaries can be obtained by two methods: (1) for each point in the LCH plane, convert the colour to the target space (RGB or XYZ) and check whether it falls within the gamut; (2) get the contour points of the gamut in the space where it is naturally defined (RGB or XYZ), and convert them back to LCH space. For the latter method, to resample the function Cmax(L,H) on a regular grid the script relies on scipy.interpolate. Both methods assume knowledge of the gamut in some space, this is trivial for the sRGB gamut, not for the human gamut hence the limits script below.
The pre-computed gamuts at resolutions of 1 and 10 bins per unit L,H are included as Numpy binary files (30 MB).
limits provides functions to compute and visualize the limits of the human gamut (optimal colour stimuli, a.k.a. MacAdam limits). As explained on Bruce Lindbloom's website they are obtained by considering all possible step-functions as spectral distributions. The conversion from light spectrum to XYZ colour is made with colour (the computed limits can be compared with the crude triangulation provided by this package). To triangulate the limit surface in 3D the script relies on scipy.spatial (this is required by method 1 above).
The pre-computed limits at resolutions of 1, 5, 10, 20 nm are included as Numpy binary files (4.5 MB).
slices provides functions to draw slices in the colour space: L-H planes as a function of C (or for the maximum possible C), C-H planes as a function of L, and L-C planes as a function of H.
maps provides functions to generate colour maps for Matplotlib, and/or written as png images. Three kinds of cmaps are implemented, which separate the different perceptual dimensions: equi-luminant (varying only in H, at the max C), diverging (varying only in C between two hues H1 and H2), and mono-hue (varying only in L, at the maximum C). It includes utility functions for testing a cmap on mock data, and for displaying the path taken by a cmap in the colour space.
The package comes with five notebooks, which demonstrate the use of the five scripts.
The notebook files can be copied in the current directory using function colourspace.copy_tutorials() found in script tutorials/copy_tutorials.py.
Static renderings of the notebooks can also be seen on nbviewer:
1. Conversions between colour spaces
2. Mapping the sRGB gamut
3. Mapping the human gamut
4. Slicing the LCH space
5. Making custom colour maps
Additional case study:
5.1 Helix colour scheme
This package is provided "as is", with no warranty of any kind.
The code can be freely used by whoever wants to explore modern colour theory.
Metadata
Release files for colourspace-explorer 1.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| colourspace_explorer-1.5.tar.gz | 21.3 MB | Without provenance | Details for colourspace_explorer-1.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| colourspace_explorer-1.5-py3-none-any.whl | Python 3 | none | any | Details for colourspace_explorer-1.5-py3-none-any.whl |
Total release size: 42.6 MB
Release files / colourspace_explorer-1.5.tar.gz
| Download URL | colourspace_explorer-1.5.tar.gz |
|---|---|
| Size | 21.3 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
aa6fe367aaaedf795661a9349eb6d23200cfae6d83d7b634a8b23cda910ff7e1
|
|
BLAKE2b-256 checksum How to use checksums |
db0021beeb4e5936764afed86cea9e5a4469e8a364e187844f1d92f4ebe77ee4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.8.17
|
Release files / colourspace_explorer-1.5-py3-none-any.whl
| Download URL | colourspace_explorer-1.5-py3-none-any.whl |
|---|---|
| Size | 21.3 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9e66038170305f1fac88a059f133be8838d3731581081df74eeb9114a44884a2
|
|
BLAKE2b-256 checksum How to use checksums |
417cffadb41c6efe3d5946e2da3876710c77784d1042929d8215b711923fbdf6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.8.17
|
Security for colourspace-explorer 1.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.