Skip to main content

tools for color models

Project description

Tools for color models.

CircleCI codecov Codacy grade colorful PyPi Version DOI GitHub stars

All methods in colorio are fully vectorized.

Color spaces

All color spaces implement the two methods

vals = colorspace.from_xyz100(xyz)
xyz = colorspace.to_xyz100(vals)

for conversion from and to XYZ100. Adding new color spaces is as easy as writing a class that provides those two methods.

The following color spaces are implemented:

  • XYZ (colorio.XYZ())
  • xyY (colorio.XYY())
  • Linear SRGB (colorio.SrgbLinear()) This class has the two additional methods from_srgb1()    to_srgb1() for conversion from and to standard RGB.
  • CIELAB (colorio.CIELAB())
  • CIELUV (colorio.CIELUV())
  • ICtCp (colorio.ICtCp())
  • IPT (colorio.IPT())
  • CIECAM02 / CAM02-UCS ```python import colorio

L_A = 64 / numpy.pi / 5 ciecam02 = colorio.CIECAM02(0.69, 20, L_A) cam02 = colorio.CAM02(‘UCS’, 0.69, 20, L_A) The implementation contains a few improvements over the CIECAM02    specification (see [here](https://arxiv.org/abs/1802.06067)).  * [CAM16 / CAM16-UCS](https://doi.org/10.1002/col.22131)python L_A = 64 / numpy.pi / 5 cam16 = colorio.CAM16(0.69, 20, L_A) cam16ucs = colorio.CAM16UCS(0.69, 20, L_A) ``The implementation contains a few improvements over the CAM16    specification (see [here](https://arxiv.org/abs/1802.06067)).  * [J<sub>z</sub>a<sub>z</sub>b<sub>z</sub>](https://doi.org/10.1364/OE.25.015131)    (colorio.JzAzBz()`)

Tools

colorio provides a number of useful tools for analyzing and visualizing color spaces.

Visualizing the SRGB gamut

The SRGB gamut is a perfect cube in SRGB space, and takes curious shapes when translated into other color spaces. The above image shows the SRGB gamut in XYZ space. The image data was created with

colorspace = colorio.CIELAB()
colorio.show_srgb_gamut(colorspace, 'out.vtu', n=50, cut_000=False)

The VTU file can then be opened in, e.g., ParaView. To see the coloring, select the srgb data and disable Map Scalars. You might also want to disable the Light Kit.

More images are in the gh-pages branch.

The data can be written in all formats supported by meshio.

Visualizing the visible gamut

Same as above, but with the gamut visible under a given illuminant.

colorspace = colorio.XYZ()
illuminant = colorio.illuminants.d65()
observer = colorio.observers.cie_1931_2()
colorio.show_visible_gamut(colorspace, observer, illuminant, 'visible.vtu')

The gamut is shown in grey since SRGB screens are not able to display the colors.

The xy-gamut

Show the classical visible gamut in xy with Planckian locus and the SRGB colors (at maximum luminosity).

colorio.show_gamut_diagram()

Show experimental data

colorio contains lots of experimental data sets some of which can be used to assess certain properties of color spaces.

Ebner-Fairchild

For example

colorspace = colorio.JzAzBz()
colorio.show_ebner_fairchild(colorspace)

shows constant-hue data from the Ebner-Fairchild experiments in the azbz-plane of the Jzazbz color space. (Ideally, all colors in one set sit on a line.)

MacAdam

The famous MacAdam ellipses (from this article) can be plotted with

colorio.show_macadam(
    scaling=10,
    plot_filter_positions=False,
    plot_standard_deviations=False
    )

Hung-Berns

Likewise for Hung-Berns:

colorspace = colorio.JzAzBz()
colorio.show_hung_berns(colorspace)

Munsell

Munsell color data is visualized with

colorspace = colorio.CIELUV()
colorio.show_munsell(colorspace, V=5)

Color differences

Color differences in any space can be computed with colorio.delta(a, b).

The images below all show the SRGB gamut in the respective color space.

Installation

colorio is available from the Python Package Index, so with

pip install -U colorio

you can install/upgrade.

Testing

To run the tests, simply check out this repository and run

pytest

Distribution

To create a new release

  1. bump the __version__ number,

  2. publish to PyPi and GitHub:

    $ make publish
    

License

colorio is published under the MIT license.

Project details


Release history Release notifications

This version
History Node

0.2.1

History Node

0.2.0

History Node

0.1.0

History Node

0.0.3

History Node

0.0.2

History Node

0.0.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
colorio-0.2.1-py2.py3-none-any.whl (79.9 kB) Copy SHA256 hash SHA256 Wheel py2.py3 Feb 28, 2018

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page