Skip to content


Repository files navigation

Build Status Coverage Status Coverity Scan Build Status

MCL: a Minimalistic Color Library

The MCL is a small collection of color related tools. It features:

  • lightweight color classes (RGB, HSV, XYZ...),
  • color spaces conversion algorithms,
  • color distance computations (delta e),
  • color interpolation functions,
  • command line utilities,
  • a (limited) C API...


To build, MCL currently requires g++ 4.8, boost 1.54, and the NPL.

make install # PREFIX=/usr/local
  • Headers will be installed in $PREFIX/include/nauths/mcl/.
  • Binaries (clcc, clcd, clct) will be installed in $PREFIX/bin/.
  • The .a file (libmcl.a) will be installed in $PREFIX/lib/.

To use, simply include <nauths/mcl/mcl.hh>, add -std=c++11 to your compilation flags, and add -l mcl to your link flags.


Here's a file named that uses and demonstrates some of the mentioned features.

#include <nauths/mcl/mcl.hh>
#include <iostream>

using namespace mcl;

int main(int argc, char const* const* argv)
  typedef Endomorphism<Color> ColorTransform; // Color -> Color

  ColorTransform t1 = opaque<Color>();        // sets alpha to maximum
  ColorTransform t2 = grey<Color>();          // converts to grayscale
  ColorTransform t3 = to<RGBub>();            // converts to unsigned byte RGB
  ColorTransform tr = (t3 , t2 , t1);         // (,) composes endomorphisms

  for (int i = 1; i < argc; ++i)
    Color c = read<Color>(argv[i]);
    std::cout << tr(c) << std::endl;          // equivalent to t3(t2(t1(c)))

Simply compile it with g++ -std=c++11 -lmcl -o test. This program expects colors as arguments, and outputs an opaque, greyscaled, RGBified version of them. For instance:

$ ./test red

$ ./test "HSV(30, 0.1, 0.6, 0.1)"


The MCL builds and installs three small binaries: clcc, clcd, and clct. Run any of each with "-h" to display a summary of options and usage.

CLCC: Command Line Color Convert
$ clcc -f "red" -t XYZ
CLCD: Command Line Color Distance
$ clcd --cie94 "RGB(1.0, 0.4, 1.0)" "RGB(1.0, 0.5, 1.0)"
CLCT: Command Line Color Transform
$ echo red | clct grey | clct "to xyz"


All the documentation can be found on the Wiki.