This test page includes saturation examples of ppmhsy, including the newest version, 1.2, with gamma correction. We compare the results with results from Gimp and Imagemagick, which use variants of the HLS model. Note that Gimp uses much the same algorithms as the popular Photoshop. Saturation by a factor of more than 2 in gimp is done by saturating twice by 100%.
Note: most saturation increases tested here are very heavy, up to a factor of 4. This is to show the effect of the algorithms more clearly. Usually, you'll only want to saturate up to a factor of 1.5 or perhaps 2.
Desaturation. From left to right: original, gimp desaturated, ppmhsy 1.1 (no
gamma correction), ppmhsy 1.2 (gamma correction). Note: this image clearly
demonstrates the desaturation problem with regular HSV or HLS colour spaces.
Results from imagemagick are identical to gimp. The ppmhsy rendering results
in a faithful greyscale image. Note that the Gimp greyscale mode produces an
image similar to the ppmhsy image.
A more blatant example of the HSV/HLS brightness problem can be seen when one takes an image with primary colours. With help of such an image, it is also possible to see differences in different Y formulas. See the page on Y values.
Increasing saturation 4x. From left to right: original, gimp, ppmhsy 1.1,
Note: gimp looks reasonably neat here, but the greens are brightened and the
blues are darkened. Ppmhsy compensates by adding extra red and blue, which
amplifies noise in the dark areas. The newest version of ppmhsy with gamma
correction corrects the noise problem in the dark areas.
The need for gamma correction is apparent here. A much clearer example of this
is found in the image below. From left to right: original, gimp desaturated,
ppmhsy desaturated without gamma correction, ppmhsy desaturated with gamma
correction. Note: Gimp renders the blue and red waves too bright. Ppmhsy
without gamma correction makes the waves disappear completely (gimp greyscale
mode produces a similar result). Ppmhsy with gamma correction produces a more
accurate result. Even the bright bands around the edges of the blue and red
waves are rendered faithfully.
Increasing saturation 4x. From left to right: original, gimp, imagemagick,
ppmhsy 1.1, ppmhsy 1.2. Note: the yellows in the flower's heart are
brightened in gimp and imagemagick, causing ugly contrast in the shadows.
This effect already happens at 2x saturation. At 4x saturation, we also get
terrible noise in the blues, which seems to be a result of the great
brightness differences between small differences of H or S of blue/cyan for
equal L. It is not present in the ppmhsy version. Oddly, the noise in the
Gimp version is worse (see below). There is little difference between ppmhsy
with and without gamma correction here.
To further test my hypotheses about the noise in the blue-cyan areas, I did a
4x saturation on a simple blue-cyan gradient. The results are quite
surprising. From left to right: original, gimp, imagemagick, ppmhsy 1.1,
ppmhsy 1.2. There is terrible banding in the gimp image, indicating some
kind of serious rounding error, which may result from the fact that gimp uses
8-bit integers to represent the HLS values. The imagemagick image looks quite
smooth, but has a steep brightness gradient about 1/3 from the bottom
(strongest at H=192), which is further proof of the theory about the
brightness noise. The difference between ppmhsy with and without gamma
correction is very clear here: without gamma correction it is too bright and
there is a small bright band around H=200.
So, it appears that for H around 190-200, varying H or S with equal L is likely to cause visible brightness differences, resulting in noise. Furthermore, we may conclude that the gimp (version 1.2.3) algorithm is defective, and should be fixed.
Another situation where cyans can easily be shown to be troublesome are hue
shifts. Say, I want to prove that I am an alien by turning a picture of
myself cyan. Left: original. Middle: Gimp, 180 deg. hue shift. Right:
ppmhsy, 180 deg. hue shift. Of all possible hue shifts, this one turns out
worst in Gimp. The ppmhsy rendering shows that the HSY model is also suitable
for hue operations.
Boris van Schooten, firstname.lastname@example.org