Tutorial 3.3: Keylight, Masking, and Color Correcting

This tutorial discusses how to best take advantage of the Keylight plugin and shows you a few masking and color correcting tricks that can be applied to other nodes as well.

 

Merlin: The Basic Gist

The composite used in the first section is from "Merlin," and demonstrates the basic steps to using Keylight (effects by CFC).

merlin_fg.jpg
merlin_bg.jpg

Keylight has several Color Pickers. In this lesson, the important color picker is screenColour. (Guess in what country CFC is based.)



How good is your mask?

The quality of your mask cannot always be gauged visually. Depending on your monitor gamma, the results of this tutorial differ. The default settings differ from system to system, or, if you are in a large film facility, you may be using custom lookups (check out Cinespace from Rising Sun) to hammer the display to look like film output. (If it appears this issue is being brushed quickly by, you're right. It's far too complicated to treat in a tutorial.) Shake allows you to apply a custom gamma lookup on the Viewer to examine your images.

 

 
Nothing happens, right? The g/o/log stands for Gamma/Offset/Log conversion. You can do all three conversions, but none are activated by default.

viewerGamma = 1
viewerGamma = 2

The heightened gamma reveals noise in the image. If you lower the viewerGamma holes are revealed in the mask. You probably don't see much until you drop below .5, so don't worry about the holes for this composite. However, try to correct the background noise. Keep in mind this image is going to be projected on a very large screen in front of millions of science fiction geeks who later take your film and advance frame-by-frame on their DVD player to reveal the multitude of errors. Perfectionism pays. You have been warned.

Unlike Primatte, which allows you to do several picks to allocate foreground and background color, Keylight relies on sliders and masking to tune the relationship between foreground and background. In this example, there are two parameters to help you. (The possibility exists your mask is fine, by the way.)

The first parameter to adjust the mask is screenRange. Raising this value increases the contrast in the mask. This slider is typically used for garbage masks that are later fed into other masks, as it tends to remove fine detail. Test the effect of adjusting the screenRange values:

See the Keying Overview for screenRange strategies.

The second set of mask opacity controls are the Gain parameters found in the fineControl subtree. Raise or lower the Gain parameters to increase or decrease the mask in the low, midtone, or highlight areas.

highlightGain = .4
highlightGain = 0

 

Note: To toggle the Viewer between alpha and color, position the cursor in the Viewer and press C or A.

So right about now, you may be thinking these parameters are useless and to never touch them and maybe there's something on TV worth watching at the moment that is for more interesting than dreary tutorials. These parameters are often useful, but this example reveals problems you must consider when keying—noise and edge detail. In this case, another approach should be taken, which is the use of masks.

Merlin: Masking the Basic Gist

Draw a garbage matte to get rid of the noise (as well as the line on the left side of the image).

As soon as the blur is activated, the top of the head gets clipped off. What's up with that? The RotoShape is a puny and weak 486 pixels high by default and the other images are a mighty 540 pixels. So, right about now, you are screaming at us because we lied about that whole Infinite Workspace thingy. Before you jump to the phone, be aware that Blur is the only function that gives you the option to work with the Infinite Workspace on or off. By default, it is deactivated so you can blur full-frame images without a black edge on the border.


spread = In Frame Only
spread = Outside Frame

 

Merlin: Color-Correcting the Basic Gist

To venture away from keying for a moment, this section discusses color correcting the foreground. Since the woman is composited into a red room, cast the woman with a red hue. You don't want to color correct after the Keylight composite, because that would change the already Amazingly Perfect Background. You also can't color correct before the Keylight node, because that would change the Amazingly Perfect Green Screen. You seem to be in a pickle (If you don't speak English as your first language, feel free to drop a line for technical descriptions of any of the completely obsolete slang used in these tutorials.). Fortunately, the kids at CFC have taken this problem into account in two ways.

First, Keylight has color correction tools built into the keyer, for exposure (the Shake Mult node), gamma and saturation. Feel free to use these tools if they are sufficient for your color correction. An advantage of the built-in tools is that they are calculated into the keying lookup table, so you have a slight speed advantage over using extra nodes. However, to do other operations like transformations or color-correction curves, you need to do something different.

It is very rare that you read in your elements, key, and composite with only one node. To apply other effects to the foreground, you must break the compositing out of the keying operations and use Over nodes instead. In the Keylight parameters, notice several unimaginative buttons for the output.

The fourth button from the left is called unpremult —an unpremultiplied image. The key is knocked out of the foreground, but is then again divided by its mask. You can then apply color corrections before compositing over the background. This setting is to prepare your foreground for color corrections. If you are only applying filters or transforms, set it to on Black.

With the output switched to unpremult, the composite looks terrible. This unpremultiplied state is temporary until you composite with an Over command.

This still leaves you with a horrid looking image that you definitely would not invite over to tea, but at least the background isn't in the comp, so you are good so far.

Here is the crucial trick:

For the color correction:

For High Color, scrub on a bright part of the background.

 

Note: In the Color Picker tab, note that Use Source Buffer is off. This is good, since you want to scrub color from the comp rather than from the unpremultiplied image coming out of Keylight.

This is, of course, an extreme color-correction used for illustration purposes.

The principal concept here is that you spit out an unpremultiplied image, do your color corrections or transformations, and then composite with preMultiply enabled. You can alternatively use On Black for your output from Keylight, apply a Color - MDiv, do your color corrections, and then apply a Color - MMult to get the same result, but this complicates the tree.

Testing a Color Correction

This is a handy trick learned between random beatings on the playground... Use the VLUT to gauge the color correction. If it is a good correction, the foreground blacks should be somewhat similar to the background blacks when the gamma is boosted, and the brights should be similar when the gamma is brought down below 1.

A bad correction
Highlights are good
Lows are good

 

If things look good, deactivate the VLUT and continue with your happy life.

The Saint: Setting Up

The Saint images used courtesy of CFC and Paramount British Pictures Ltd.

The composite used in the following section was created by CFC for the film The Saint (ahem, not using Shake. Cineon, it is believed). For this lesson, use the five foreground and background images (at video resolution) in the pix/keylight directory.

The Joy of JPEG Never use JPEG images for any footage you have to key. The compression seriously messes you up, as you will find in this tutorial. Also, don't use JPEG images for video interlaced footage, as the fields become corrupted.

The first thing you notice is that these are anamorphic frames, so everything is squeezed. Additionally, the element is originally a scanned Cineon plate, so it is in logarithmic color space. Don't sweat that for the moment, but instead focus on the aspect ratio.

This squeezes the images by half in Y:

proxyRatio = 1
proxyRatio = .5

 

This squeezing can be turned on and off very quickly with the proxy button at the top of the interface. "Other" indicates you are using a custom proxy setting rather than a preset (P1, P2, P3). The scaling is just temporary while you work with the script. When finished with the composite, reset the proxyRatio to 1. For more information, check the About Aspect Ratio page in the Overview.

Now, one thing that may be stressing you out is that you are working on logarithmic (that is, filmic, rather than linear digital or video) color space images. Don't fret—at the bottom of Keylight, you can indicate in what color space Keylight is working.


Note: All masking data is dependent on your monitor gamma. Use the VLUT to ensure you have an accurate key as you proceed with the tutorial.

The Saint: Using fgBias to Remove Blue Spill

Before you get too excited about this, there is some blue spill on her hair on the right side (her left side).

It's real subtle. To see it better, you may want to pull down the original 2K plates. No, wait. That's not right. You can linearize the log plates to return it to something resembling the real world:

To help get rid of the blue spill:

Scrub for blue spill on the hair
With spill suppression

The blue is removed. (A ringing effect may occur due to the JPEG compression on the foreground element. Nothing you can do about that for this tutorial. Sorry.)

To minimize any yellowness that may occur in the image, you can decrease the fgBias saturation. The stronger the saturation of the fgBias color, the stronger the yellow tint.

You can also set the balance parameters to 1 to reduce the yellow tint. It does not reduce all of the yellow—her scarf and map may still retain some yellow—but it helps.

The yellow color correction is further adjusted in the "The Saint: Using the replaceColour" section.

The Saint: Using the HoldOutMatte

Show the alpha channel in the Viewer (press A with the cursor in the Viewer), and you are no doubt appalled at what fgBias has done to the matte. Return to the composite view, (press C over the Viewer) and notice the snow on the road is visible behind the seatbelt. This blows.

To correct this, pull a simple rough second key and connect the key to the Keylight node's HoldOutMatte (third image input).

When the hold out matte is plugged in, it acts as a mask for the foreground. You are, of course, not obliged to use Keylight. Feel free to use roto, Primatte, Chroma/LumaKeys, etc., as well. The following illustrations show the HoldKey alpha and the Keylight1 alpha. HoldKey contains no grey tones, Keylight1 retains the window reflections.

HoldKey
Keylight1

 

The holdout matte has destroyed the edge quality of Keylight1. To correct the edge quality, chew into the edge of the holdout matte.

 

Blur1
Keylight1

 

The hold matte strengthens the normal key pulled by Keylight.

Test the effect of the holdout matte:

Without holdout matte
With holdout matte

The Saint: Using the replaceColour

You can use the holdout matte with the Keylight replaceColour parameter to help get rid of the yellowish tint. This is for areas that are keyed out by mistake because they are lit with more blue light than white light, and are also included in the holdout matte area. The replaceColour can help to correct that lighting.

As an end note, like all keyers, Keylight is not a magic bullet—a key rarely works with a single pixel scrub. Feel free to use Keylight in conjunction with other mask techniques and keyers, and combine the keys through the use of the KeyMix function, or through the adding/subtracting of mattes with tools like IMult, IAdd, ISub, Max, LayerMacro, etc.