help 'reverse engineer' a filter / what is Nik Color Efex doing here?

This one has been on my mind for some time, and I guess if it keeps gnawing somewhere in my brain I need to figure it out :slight_smile: .

Can some of you help me on my way - or help me, period - to figure out what Nik Color Efex ‘Skylight’ filter is doing?

I use if often on series of batch images that have a bit of ‘dirty’ warmth to them. By fixing the yellow cast but then adding this ‘skylight’ filter (which doesn’t just add yellow everywhere the same amount) it seems to clean up the colors a lot while still keeping warm tone.

I thought I was close lately by using a ‘Reflect’ blend-mode with a luma-mask and the color of a warming gel/filter, but it’s not as clean as this filter does :slight_smile: .

Of course, there are a lot of people that might not use Nik’s suite or even the Skylight filter in it, and have no interest in it. I thought I add three hald cluts, in not too big a resolution. One with the effect applied for the full 100%, one at 50% and one at the (default usage) 20%. The effect is applied / meant for regular sRGB pictures.

100%
hald_4_skylight100

50:
hald_4_skylight50

20:
hald_4_skylight20

From playing with a color sampler in before/after shots, I don’t see a real pattern yet in RGB / CMYK modes. I also tried in lab, but apart from an increase in the L channel I don’t see much repeatable (sometimes the a channel increases, sometimes it doesn’t, same for b channel, etc…).

The best I can think of is that it’s working in some HSB / HCL / HSV space, it scales/boosts the L a bit, it scales/boosts the saturation a bit, and it seems to push colors ‘toward red’ a bit. Like, the more red in a color, the more it’s pushed towards red, the more ‘blueish’ a color is, the smaller the hue shift. But I’m only guessing here.

Does someone have some tricks, methods or insights in how to figure out what is being done here?

Does it do something other than swap colours? If so, then LUTs won’t completely address the processing.

Oh, good point. From looking at it, it’s just color/lightness. I see no changes to local contrast or anything like that.

Also, trying the lut out on pictures and comparing the same picture with the Nik filter seem identical (at least so far).

Maybe ignore the filter then, and just change the question to ‘help me figure out what this lut does’. Because I think there is a formula to it (Well, more than one probably).

hi @jorismak ,

Filter shifts red towards orange and adds a little orange to the highlights. The slider controls the saturation and a little brightening of highlights.

Tried on the fly with the darktable:

20% CEP4:

darktable:

50% CEP4:

darktable:

80% CEP4:

darktable:

In darktable I used color balance (highlights gain) for coloring the highlights with orange and for color shift color zones module.

3 Likes

From what I’ve seen the slider just is a ‘overal effect strength’.
As in, if I add the filter with the slider at 100% on a separate layer, then set that layer to 20% opacity, it has the same effect as directly applying the filter with 20%.

From looking at the differences between the 3 hald luts (and the baseline version with magick hald:4) it seems red stays red, but just saturated. At 100% even so much that it ‘clips’ the saturation in HSL.

But I see parts where the L (of HSL) part increases, but other parts where it decreases. ??

I also used imagemagick to convert the 100% lut to HSB, extract the ‘S’ channel and display it, compared to the baseline hald. The block in the complete top-left, is pure black, has 0% saturation and stays 0% saturation. But there are other blocks which start at 0% saturation but end up with a bit of saturation.

If I look at some of the more ‘pure’ ramps in the lut (for example, a ramp that goes from RGB 0,0,0 to RGB 255,0,0) it stays ‘pure’ with 100% of the filter. (The ramp still goes from RGB 0,0,0 to RGB 255,0,0. It just hits 255,0,0 much earlier).
The same on a green-to-yellow ramp (RGB 0,255,0 towards RGB 255,255,0) it still stays pretty ‘pure’. The green stays at 255, the blue always stays 0, it’s just the R value changing, just more quickly towards 255.

This seems ‘to perfect’ for me to think they’re doing something with >H<SL, or with L>ab<. Maybe they’re doing something way more simple in (linear?) RGB.

But then, I have a ramp with a bit of blue mixed in (RGB 0,255,17 to RGB 255,255,17) and the resulting blue ends up being 0. Only on a ramp with RGB 0,255,68 to RGB 255,255,68 do I end up with something in the blue (20). So ok, maybe they subtract a bit from the blue channel…

… but another ramp goes from RGB 0,51,68 to 255,51,68 but the resulting blue channel is 82 there. More! So ok, no simple RGB adjustment then…

Or maybe I’ve been measures the patches wrong … it’s late, I should get some sleep :slight_smile:

I forget but shouldn’t it be at least hald:8?

Hald:4 is a cube with 16 elements along each edge, so it is enough to get an idea of the overall effect.

Naming the 100% effect as nik100.png, “magick nik100.png -verbose info:” tells us:

  Channel statistics:
    Pixels: 4096
    Red:
      min: 0  (0)
      max: 255 (1)
      mean: 152.914 (0.599664)
      standard deviation: 95.8091 (0.375722)
      kurtosis: -1.44781
      skewness: -0.339344
      entropy: 0.775838
    Green:
      min: 0  (0)
      max: 255 (1)
      mean: 133.92 (0.525177)
      standard deviation: 95.928 (0.376188)
      kurtosis: -1.53221
      skewness: -0.0776577
      entropy: 0.81511
    Blue:
      min: 0  (0)
      max: 255 (1)
      mean: 120.802 (0.473731)
      standard deviation: 100.42 (0.393806)

Look at the means and standard deviations (SD), the numbers in parentheses which are on a scale 0 to 1. Compare those with unprocessed hald:4, which has mean 0.5 and SD 0.307356.

So all channels have larger SD, which suggests an increased contrast. The red channel mean is much larger (lighter). Green is slightly larger, and blue is slightly lower.

Hald cluts are absolute transformations. We can convert them to relative transformations like this:

magick nik100.png hald:4 -compose Mathematics -define compose:args=0,-1,1,0.5 -composite x.png

x.png has relative colours. Where it is gray(50%), there is no change. Where it is red, nik100.png makes colours redder, and so on. When we display both images expanded to fill the screen, flickering between them, x.png shows what changes and hald:4 shows where it changes. I see two overall effects: (1) increased saturation and (2) a small shift towards red.

EDIT to add: if you want to simplify nik100.png to a simple formula, I suggest you look at G’MIC which has processing for (almost exactly) that.

1 Like

The haldcluts add a warm tint to grayscale images so there is at least one rgb adjustment, raised saturation , less in reds and more in blues/greens and a hue shift, mostly in blue hues

I made linear gradient images on which I did the filter / hald. This makes my head still scratch on what it is exactly they are doing. ‘Pushing towards red in the highlights and adding saturation + brightness’ gets very close, but it still doesn’t match when looking at test images :slight_smile: .

For instance, making a linear gradient from black to full red (0,0,0 - 255,0,0). And then also for green, blue, yellow, cyan, magenta, and gray.

  1. All gradients get boosted in saturation and brightness a bit.

  2. The blue, cyan, green and - d’uh - red gradients are not affected in the hue.

  3. The magenta, yellow and - d’uh - gray gradients ARE affected in the hue.

  4. The gray gradient shows this clearly, but in the cases where the hue is affected, it are the highlights which are NOT affected.

image

  1. if you look at the blue gradient, it is boosted in saturation and brightness. If you look at the RGB values, which go in from 0,0,0 to 0,0,255: What happens is they now reach 0,0,255 earlier. What I’m trying to say here is that ‘blue RGB values’ here are not lowered. If anything, they’re boosted.

But, if you look at a gray value of 127,127,127 for example. That comes out as more red, a bit more green but less blue. So here blue is lowered.

So a simple equation that ‘adds red, removes blue’ doesn’t seem to be the way here. Because then pure-blue colors would also be affected, which the filter is not doing.

What I think now, is that everything gets a bit of saturation, everything gets a bit of brightness.

But then only in the shadows + midtones, the hues are pushed towards red.
And, the further away the color is from red, the less the hue-shift is.
As in, only the colors on the right side of this color-wheel seem to be hue-shifted:
image

Because yellow and orange are clearly affected, magenta is a bit, but blue/cyan/green are not or hardly at all.

I haven’t looked at this… Still haven’t found a series of formulas or explanations on what it is doing exactly. Yes, a lot of things come close, but they are never 100% the same :slight_smile: .

I am content with using the hald clut now though (I never thought about using that before :s, I wanted to clone the filter but for automating purposes applying a hald-clut works just as well).

I use imagemagic for it, but I take the strong 100% clut and with imagemagick apply it at 15, 20, 25 or 30% depending on what the image-series needs. This works for, and that’s why I stopped trying to recreate it.

I’m still curious about what it really does though.

(I still think something like 'saturates everything, raises shadows + mids brightness/lightness a bit, and in the shadows+mids pushes all colors towards red, but the further away from red the color is the least it is affected).

The fact that it has no effect on fully saturated colors but has some effect on partially saturated colors/greys makes me think it may be in some way related to a vibrance filter with some additional hue-shifting tweaks?