## Wednesday, October 14, 2015

### Saturation in prismatic color model

In my last post I described the prismatic color space Dave Hart and I have developed for the Subjective iPhone photo editing app.   This post is about changing saturation in that model.

An hue C is on some line between a neutral hue N and the most saturated (pure) one P on the triangle boundary.   The saturation is the fraction of the distance along the line (0 for neutral, 1 on the boundary, about 0.25 for the example below):
The lines of constant saturation are just inscribed triangles:
These are also just isolines of the smallest barycentric coordinate, which will always vary from 1/3 at N to 0 on the boundary.  This suggests the saturation s is:

s = 1 - 3*min(rho, beta, gamma)

The pure color P is just at s = 1, and the color C can be expressed:

C = N + s(P-N)

Thus

P = N + (C - N)/s

Now that we know P, we can change s to a new value s' and apply the formula

C = N + s'(P-N)

Let's apply that.   Here's a picture from flikr:

And if we compute s at every pixel and replace it with pow(s, 0.7) keeping it in [0,1] but making it bigger we get a slightly more saturated version: