# [Gimp-developer] Softlight blend mode formulas [was: Image processing algorithms resources]

• From: yahvuu <yahvuu gmail com>
• To: Calculemus <calculemus1988 gmail com>
• Cc: gimp-developer <gimp-developer-list gnome org>
• Subject: [Gimp-developer] Softlight blend mode formulas [was: Image processing algorithms resources]
• Date: Tue, 31 Jul 2012 00:00:22 +0200

```hi again and sorry for the ultra-late answer. I'm putting this back on the list so it can be found in the archives.

Am 08.07.2012 17:14, schrieb Calculemus:
> I am still confused though, how do I make a decision on which
> formula to use for soft-light for example? Can I pick the "best" one,
> or there is no best one and it does not matter which one I pick?

In short: it doesn't matter much, the various softlight modes produce quite similar results.

In bullet points:
- It is a good idea to adhere to the      industry standard photoshop [3]
- It is a good idea to adhere to the open industry standard SVG [8]
- GIMP does neither, it uses the 'pegtop' formula [4,9] -- and does so whithout problems
- The best formula is the illusions.hu one [5] -- in theory, for some sense of 'best'

In full glory: the subtle differences in the softlight modes can be explained by looking at the
ideas behind the formulas. In my regard this is an exercise of mere academic interest since
the artistic needs for a softlight blend mode are satisfied by any of the formulas. I'm happy to
be proved wrong here, though.

Regarding notation, i'll follow the conventions given in [1]: the variables a and b represent the values
of the base layer and the blend layer, in that order. The values are in the range [0..1].

The original motivation behind the photoshop formula [3] is presumably to allow for local gamma correction:
where the blendlayer value b is a mid gray of b=0.5, the result is identical to the base layer's value a.
Lower values of b result in darking the image, up to b=0 which corresponds to a gamma correction with gamma=0.5.
Brighter values of b give brighter results, up to b=1 which corresponds to gamma correction with gamma=2.

The photoshop formula has a downside:
The way the formula switches between the brightening and the darkening case results in a certain kind
of discontinuity in the graphs which has been illustrated in the pegtop article [6].
The corresponding 'gradient angle' diagram in [2] also displays a discontinuity around b=0.5.
In theory, this discontinuity results in suboptimal properties regarding the
transfer of blend layer midtone texture to base layer highlights and shadows.

The pegtop formula [4] successfully avoids this discontinuity and improves
local contrast transfer properties (in theory). However, it breaks the symmetry between darkening
and brightening curves: b=1 does not result in gamma correction anymore, while b=0 still
corresponds to gamma=0.5. This can best be seen by comparing the 'curves' diagrams in [2].

The ilhu formula [7] resolves the discontinuity in the photoshop formula in a more elegant way,
keeping the symmetric gamma correction properties.  Another difference from the photoshop formula
is that ilhu provides a gamma curve for any value of b, not just for the extrema b=0 and b=1
as the photoshop formula does (not counting the neutral case for b=0.5)

Now interestingly, the SVG formula [8] (which has not been examined in the blog article)
follows the photoshop math but introduces a special case when brightening the shadows of the base layer:
for b>0.5 (blending effect is brightening) and a<0.25 (shadows of the base layer),
a different formula is used which provides less intense brightening than the photoshop formula.

I'm short on references for the motivation of this modification. On a general
note, i think that blend mode formulas are not a good place to compensate for
any weaknesses of a given color representation.

-yahvuu

[1] http://yahvuu.wordpress.com/2009/09/27/blendmodes1/
[2] http://yahvuu.files.wordpress.com/2009/09/table-contrast-2100b.png
[3] softlight_ps in table [2]
[4] softlight_pt in table [2]; formula taken from [6]
[5] softlight_ilhu in table [2]; formula taken from [7]
[6] http://www.pegtop.net/delphi/articles/blendmodes/softlight.htm
[7] http://illusions.hu/effectwiki/doku.php?id=list_of_blendings
[8] http://dev.w3.org/SVG/modules/compositing/master/SVGCompositingPrimer.html
[9] http://docs.gimp.org/2.6/en/gimp-concepts-layer-modes.html

```

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]