Exploring Temperature and Tint

When dealing with footage which was shot at improper white balance, and trying to correct it, I sometimes wished that Premiere had the temperature slider present in Camera Raw or in SpeedGrade. When a friend expressed similar concern, I decided to take my shot at it. After all, it should be relatively simple, right? It’s only moving the pixels towards blue or orange, and in the case of tint, towards magenta or green.

I even found a sample approximate algorithm to calculate the white point at a given temperature, and almost ended up using it. However, after reading on how the proper mixing requires conversion to HSL colorspace due to change in luma value of each pixel, I decided to explore the issue in more detail. It turns out, like with many other issues, that there are differences on what “temperature” exactly means in various software packages. Consider the following images:

original

Original image.

camera-raw-temperature

Camera Raw/Lightroom temperature adjustment set to -100. The image is brighter, and the tint is much stronger, washing out the shadows.

speedgrade-temperature

SpeedGrade’s temperature adjustment at -1.0 (equivalent of -100). The shadows are not washed out, although the image is darker due to clipped blue channel.

Clearly, Camera Raw is brightening the image, and almost looks like it is trying to mix the blue or orange solids with the picture. Perhaps similarly to what Tanner Helland described in the comments to his algorithm, but without the attempt to retain luminance. I find this adjustment not so great, especially for images with rich shadows that get washed out in the process.

On the other hand, the blacks in SpeedGrade are untouched, and it seems that the temperature/tint sliders operate only as gain adjustments, multiplying red and blue (temperature) or all three (tint) channels at the same time by roughly the same amount, and leaving the luma mostly intact except for the places, where the blue channel is clipped.

I even explored playing with gamma on the a and b channels in Photoshop L*ab color space, which directly code the interesting information (a is the tint scale, b is the temperature scale), but these were also not as satisfying as SpeedGrade’s. In the end, I decided to stick with the color correction software.

I experimented for a moment with the formulas and values, but in the end, I turned to Nuke to find how it resolves the issue, because it does provide an immediate numerical output. Finding out the exact adjustments was quite easy. Using grade and expression nodes I was able to mimic what Nuke was doing during temperature or tint adjustments, and came up with very simple formulas.

nuke

A very simple setup in Nuke allows to find the proper formula for handling temperature and tint adjustments to mimic SpeedGrade’s controls.

Implementing them as a plug-in for Premiere was relatively uncomplicated, and took me less time than writing the documentation for it. In fact, I was also able to successfully tackle OpenCL acceleration as well, but this will be incoming in the paid version some time in August.

I stand corrected…

In an excellent recent article on Pro Video Coallition Alexis van Hurkman explained how the terminology which I use in my Power Window filter, and in my Lift, Gamma, Gain tutorial is incorrect. The control called “Lift” should in fact be called “Offset”, based on the way it works.

Similarly, the formula which I used to calculate the resulting pixel value in the filter is also a bit different than the approved ASC CDL standard. In my case I decided to apply the power function (gamma) to the input value of the pixel, and the CDL order applies gamma as the last operation, affecting the result of the offset and gain corrections. Come to think about it, it makes a bit more sense than the way it is implemented now, especially for the footage which was shot in log space. If you set your black (offset) and white (gain) levels, you don’t want them to move, when you change the midtones (gamma).

Perhaps for the compatibility sake I should add another (sigh…) control where the user would be able to choose between color calculations, but after giving it some thought, I will definitely correct the order of operations in the next release of Power Window plugin.

Applying the Power Window effect

I’ve been both terribly busy and sick lately, thus the lack of the tutorial last week. Hopefully, something interesting will come out of my business next week, and I would advise you to follow my blog during NAB, if you are interested on my take on a few things that might come up there.

But until then, here is this week’s tutorial: