Curve adjusted saturation addition

When originally  implementing the saturation adjustment in Rawstudio, we did it pretty simple. We do the transformation in HSV-space, so it is pretty easy to adjust saturation here. Up until now we simply multiplied the saturation value of the pixel with the selected saturation.

If we look at it visually, here is an unadjusted image:

We apply some saturation, and here is the result:

When switching between two images, you will probably notice that some areas are becoming fully saturated, while other parts of the image are hardly affected.¬† So we started out by looking for a new algorithm, that would not give these artefacts.¬† Let’s look at a graph displaying input (x-axis) and output (y-axis):

Blue: Unadjusted saturation.
Red: Old saturation adjustment.
Black: New saturation adjustment.

The blue line is unadjusted saturation. If we raise the saturation value, the red line shows what happens if you use the old algorithm, with a saturation value of 1.4. Raising saturation more will simply make the line steeper. What we see is that values are quite easily saturated. In this example, all input values higher than 0.7 are fully saturated.

The new algorithm applies saturation much gentler and avoids saturating areas that already have a high saturation value. If we look at the image above with the new algorithm applied, it looks like this:

Hopefully you will agree that this is a much more optimal result – the reds are not completely burnt out, while the same amount of saturation is applied to the rest of the image. In my experience the new algorithm is also much better at handling skin-tones, which had a tendency to easily burn out. But try it out yourself, and post your feedback below.

Comments (4)

4 responses to “Curve adjusted saturation addition”

  1. This is very good.

    My first thought when I saw the headline was that it dealt with how the curve tool affects image saturation. My thought is that maybe the curve tool should affect only luminance. While I occasionally use it to create funky colours, I can’t help but feel that it’s primary function should be as a tool for fine tuning contrast.

    • Klaus Post says:

      Actually the curve tool only deals with the ‘V’ part of the HSV colorspace, so it is actually only dealing with luminance, in contrast to contrast (excuse the pun), that does adjustment on individual RGB components.

      But in any colorspace dealing with luminance, that being HSV, HSL, Lab, YCbCr, etc, you cannot completely separate the luminance value. Meaning, tweaking one part (luma) will not always be perceived as the “natural” result when you combine it with the chroma part. This is especially true when you are at the end of the luma ranges, near black or white. I guess this is because black/white aren’t really a real “color”, but rather all or none of them.

      But if you have any specific, funky, colors, you are very welcome to share them :)

  2. Royi says:

    Looks great.
    What kind of function did you use?


    • Klaus Post says:

      Saturation in HSV space is ‘s’.
      ‘saturation’ is the adjustment, where 1 is neutral, 0 = complete desaturation.

      /* Saturation */
      if (saturation > 1.0)
      	/* Apply curved saturation, when we add saturation */
      	float sat_val = saturation - 1.0f;
      	s = (sat_val * (s * 2.0f - (s * s))) + ((1.0f - sat_val) * s);
      	s = MIN(s, 1.0);
      	s *= saturation;
      	s = MIN(s, 1.0);

Leave a Reply

Klaus Post on August 29, 2010

RSS feed