Learn R Programming

spacesXYZ (version 1.5-1)

spacesXYZ-package: CIE XYZ and some of Its Derived Color Spaces

Description

This package covers the basic CIE 1931 space, and derived spaces CIE xyY, Lab, and Luv. The equations are taken from Bruce Lindbloom's CIE Color Calculator. Color areas that are *not* covered are:

  • spectral color data

  • device color spaces, e.g. RGB and CMYK

  • color order systems, e.g. Munsell, DIN, NCS, Ostwald, ...

Arguments

The API

The API is small. There are functions to

  • convert between CIE XYZ and other CIE spaces

  • create and perform some standard chromatic adaptation transforms (CATs)

  • compute 3 standard color difference \(\Delta\)E metrics

  • retrieve XYZ and xy of some standard illuminants

Other Packages

Package colorscience is a superset of this one.
Packages colorspace and farver have similar functionality, and are faster because they are in compiled C/C++.
Package grDevices also has similar functionality (in the function convertColor()), but is missing chromaticities xy, uv, and u'v'.

Logging

Logging is performed using the package logger. This is a powerful package that allows a separate configuration for logging from within spacesXYZ, and that is what I have done. When spacesXYZ is loaded, the logging threshold is changed from INFO to WARN. To change it back again, one can execute:

logger::log_threshold( logger::INFO, namespace="spacesXYZ" ) # preferred
or
library( logger )
log_threshold( INFO, namespace="spacesXYZ" ) # not preferred

The layout callback function is customized; it adds the name of the calling function to the message. To change it back again, one can execute:
log_layout( layout_simple, namespace="spacesXYZ" )
or to install ones own layout function, one can execute:
log_layout( <your function>, namespace="spacesXYZ" ).

The appender callback functions is also customized; it comes to an immediate stop if the log event level is FATAL or ERROR. To continue execution after such a log event, one can execute:
log_appender( appender_console, namespace="spacesXYZ" )

The formatter callback function is initialized to be formatter_sprintf(); this should not be changed.

Author

Glenn Davis <gdavis@gluonics.com>

References

Lindbloom, Bruce. CIE Color Calculator. http://brucelindbloom.com/index.html?ColorCalculator.html

Lindbloom, Bruce. Color Difference Calculator. http://brucelindbloom.com/index.html?ColorDifferenceCalc.html