## Wednesday, October 14, 2015

### Prismatic color model

Note: this model has taken over all of my code.  We decided we should share it.   I love it!  Try it!

In our Subjective photo processing iPhone app (please buy it and rate it!), we have to manipulate color in all the classic ways (and a few others).   For example, increase saturation.   I was very dissatisfied with all the color models commonly used in graphics.

One candidate was some general space like the CIE diagram.   But like many applications we have an RGB space that starts and ends in RGB, so a simple gamut is good.    The classic one is a cylinder of some kind such as HSV :

 The two most common cone RGB spaces (from an excellent wikipedia article)

The practical problems with these spaces for my purposes are 1) intermediate colors such as yellow are not along a line from two colors that make them (red and green), and 2) computationally getting to and from the RGB cube is not that simple.

I hired Dave Hart as a consultant (who with Grue DeBry has founded a cool company Limnu developing collaborative white boards) to help my find the right space.   Dave really liked this barycentic space for the hue part.    Turns out this hue space is often used in computer vision because it factors out illumination and is good for getting a crude albedo transform.   Here's a figure with that space on the right from a paper draft Dave and I may submit someday:
The barycentric Maxwell space has the nice linearity properties of the also barycentric CIE space.   The good news is barycentrics are something graphics people are comfortable with.    They coordinates map nicely to the intuition of RGB mixing:
Here neutral is (1/3, 1/3, 1/3).   Red is (1, 0, 0).    The greek letters we use for the barycentrics are (rho, gamma, beta).   A basic issue is what do we use for the lightness channel.   For example, HSL and HSV above have different ideas.   We go with the HSV approach so that pure colors have a lightness of 1.0.   There are endless debates on this, and we like the pure colors are "light" approach because the computation and intuition are nice, and because lightness is a hard concept anyway once things get colorful as I discuss in a previous post.

The computation for getting to and from this space is awesomely simple (and KISS is good!!!):

I will post some of the ways I use it in a later post.