Home · Lab · Keying Lab

K3 Despill: average vs max

Green light bounced onto the robot

Keying Lab · ~6 min · Free

1 The idea

The bright green screen bounces green light onto the robot (spill). Even with a good matte, the robot still looks green. Despill caps the green channel at a limit built from red and blue.

Average (compare with the mean of red and blue) removes more green than max (compare with the larger of the two). Max is gentler on skin and yellows but leaves more green behind.

average: g′ = min(g, (r + b)/2 · L) · max: g′ = min(g, max(r, b) · L)

2 Hands-on in the mini compositor

Task: switch the Despill on and pick a method that leaves ≤ 0.0079 spill on the robot

Enable the Despill node first (untick "Disable"), then try both methods

SkyVFX mini compositor · K3640×360 · float · 1001

3 Deep dive

Two formulas, four colours

Average: g′ = min(g, (r+b)/2). Max: g′ = min(g, max(r, b)). (The table uses L = 1.) Both fix a spilled grey about equally, but on yellow and cyan, average cuts green that really belongs there, so the colour shifts.

Colourr, g, baverage g′max g′
Grey robot with spill0.40, 0.55, 0.420.410.42
Yellow paint0.80, 0.70, 0.100.45 (turns orange)0.70 (unchanged)
Skin tone0.70, 0.50, 0.400.50 (unchanged)0.50 (unchanged)
Cyan0.10, 0.60, 0.700.40 (shifts)0.60 (unchanged)

Despill darkens

Green carries most of the brightness (Rec.709 weights G at 0.7152). The grey robot above loses 0.14 of green with average despill, about 0.1 of luminance, so its edges turn dull and grey.

Restore luminance: take plate minus despilled (the spill that was removed), desaturate it and add it back. Use it when the background is about as bright as the screen. Over a background darker than the screen, turn it off, or respill with the background colour instead.

plate − despilled is a free mask of where the spill was.

Despill lives on its own branch

Keying is three separate jobs: alpha, despill and merge. Despill on its own branch from the original plate, Copy the finished alpha in, Premult once, then Merge over. When you combine several keys, don’t use each keyer’s built-in despill: they differ and leave seams.

Real shots often use two despills: a strong one for the edge, pushed toward the background colour, and a gentle one for the core that keeps the original colours, Keymixed through a blurred core matte.

  1. 1Plate
  2. 2Despill (RGB)
  3. 3Copy alpha
  4. 4Premult
  5. 5Merge over BG

Choose the target from the background

Put the real background in before despilling, then ask two questions: how bright is the background behind this edge, and what colour is the subject here? Neutral grey only suits a mid-grey background; a warm desert background wants warm edges.

On set: keep the subject as far from the screen as you can, so there is less spill to begin with.

4 In real work

In Nuke

  1. Expression node: g = min(g, max(r,b)) for the core, or min(g, (r+b)/2) for edges
  2. HueCorrect: pull the g_sup curve down over the green hues only, stopping before non-green colours
  3. Restore luminance: Merge (minus) plate − despilled → Saturation 0 → Merge (plus) onto the despilled image
  4. Two despills (edge/core) combined with Keymix through a blurred core matte
  5. Any despill after the Copy must write RGB only, or it overwrites the alpha; then Premult → Merge over

Common mistakes → the fix

  • ✗ Using each keyer’s built-in despill when combining keys✓ Despill on a separate branch from the original plate
  • ✗ Average everywhere: the yellow shirt turns orange✓ Max for the core; keep average for the edge
  • ✗ Forgetting that despill darkens: dull grey edges✓ Restore luminance, or respill with the background colour
  • ✗ Eroding the matte to remove a green fringe✓ A green fringe is a despill job, not an alpha job. Erode only cuts the edge off; it does not fix the colour (see K4)
  • ✗ A despill node overwriting alpha after the Copy✓ Set it to output RGB only

Before you send the shot

  • No green fringe with the saturation pushed up for checking
  • Yellows, skin and cyans on the subject haven’t shifted
  • Edge brightness suits the real background
  • The alpha wasn’t overwritten by the despill
  • Premult happens once, before the Merge over

5 Check yourself

One question to check yourself

A character wears yellow. Which despill shifts the shirt less?

What you learned

🔒 Answer the question above and this card opens

More questions

1. Pixel (0.30, 0.60, 0.50). What does max despill give for g′?

2. The robot is over a dark night street. With restore luminance on, its edges glow. Why?

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.