Home · Lab · Keying Lab

K1 How a keyer works

screen = g − max(r, b), flipped into alpha

Keying Lab · ~7 min · Free

1 The idea

A green screen is pixels greener than they are red or blue. A basic keyer measures "how much extra green" (g − max(r, b)) and flips it into alpha: very green means low alpha, not green means high alpha.

Gain stretches the difference. Clip black pushes a greyish background to 0; clip white pushes a see-through subject to 1. Press "a" on the Viewer to see the matte, and view the Keyer or Premult node.

alpha = 1 − clamp((g − max(r, b)) · gain), then clip black / clip white

2 Hands-on in the mini compositor

Task: tune the Keyer until the matte is close to the true matte (error ≤ 1.1‰)

View alpha on the Premult node: lower the gain, then use clip white to make the robot solid and clip black to clean the background

SkyVFX mini compositor · K1640×360 · float · 1001

3 Deep dive

Walk through it pixel by pixel

screen = g − max(r, b), then alpha = 1 − clamp(screen × gain). The table uses gain 2. The green-screen pixel still has alpha 0.1, not 0, so clip black has to help. Yellow paint has less green than red, so its screen is negative, clamps to 0 and stays fully solid.

Then the clips: alpha = (alpha − clip black) ÷ (clip white − clip black). With clip black 0.15 and clip white 0.9, the screen goes to 0 and the robot’s 0.96 is pushed to 1.

Pixelr, g, bg − max(r, b)alpha (gain 2)
Green screen0.10, 0.60, 0.150.450.10
Grey robot body0.40, 0.42, 0.400.020.96
Yellow paint0.80, 0.70, 0.10−0.10 → 01.00

A key is contrast between channels

If you can see a difference between subject and screen in any channel, you can key it. Start every shot by viewing R, G and B one at a time and noting which one separates best.

Pick a screen colour the subject doesn’t contain: a robot with green parts belongs on a blue screen.

Easy keys start on set

An evenly lit screen with no hotspots or shadows; screen lights separate from subject lights; the subject far enough away to cut spill and shadows on the screen; correct screen exposure; a clean plate (empty screen); and tracking markers that are easy to remove.

An uneven screen costs far more to fix in comp than on set.

Judging a matte properly

Always judge the alpha. Drop the Viewer gamma right down to find holes in solid areas; raise the gain to find grey haze on the screen. Then try it over grey, over a checkerboard and over the real background, and play it at speed.

The plate copy you key from can be treated any way you like (denoise, grade), because only its alpha survives. The colour you deliver still comes from the original plate.

  1. 1View alpha
  2. 2Gamma down: holes
  3. 3Gain up: haze
  4. 4Over grey / real BG
  5. 5Play at speed

4 In real work

In Nuke

  1. Denoise a copy of the plate before keying, for the alpha branch only
  2. Keylight: pick the Screen Colour (Ctrl+Shift drag to average), keep Screen Gain near 1, then adjust Clip Black / Clip White while viewing the Screen Matte
  3. Uneven screen: IBKColour builds a per-frame clean plate, then IBKGizmo keys against it
  4. Copy the alpha into the main pipe → Premult → Merge over the background
  5. In the Viewer: press a for alpha, use the Viewer gain/gamma to check holes and haze

Common mistakes → the fix

  • ✗ Judging the key from the colour image only✓ Look at the alpha with gamma down and gain up
  • ✗ Cranking gain/clips to kill haze far from the subject✓ Use a garbage matte for far areas; keep the key for the edges
  • ✗ Keying a grainy plate, so the matte chatters✓ Denoise the copy used for the key
  • ✗ Combining alphas with plus so alpha goes over 1✓ Use max; alpha must stay within 0–1

Before you send the shot

  • Background alpha is truly 0 (no haze with gain up)
  • Robot body is solid 1 (no holes with gamma down)
  • Alpha stays within 0–1
  • Checked over grey and over the real background
  • Played at speed: no chattering matte

5 Check yourself

One question to check yourself

With the starting key the robot looks see-through: parts of its body show the background, and its edges carry a green tint from spill. What do you adjust first?

What you learned

🔒 Answer the question above and this card opens

More questions

1. Pixel (0.2, 0.5, 0.3). What is screen = g − max(r, b)?

2. Why can you denoise the plate copy before keying without softening the final image?

Where the numbers come from: The keyer here is a simple green-difference keyer (not Keylight or IBK). The despill formulas are the standard limit methods. Scores compare against the true matte rendered in Blender alongside the green-screen plate (the same robot and camera as the plate). The goals are measured on these renders, relative to the best key this Keyer can reach.