088: ChromaKey component

This helps you build an alpha channel from video with a blue-screen or green-screen (or other) background color by interactively selecting colors from an image and refining the key. It also smooths alpha edges and eliminates color spill.

NOTE: Get the latest chromeKey component from the palette in 088 builds 52000 or later. An older version is found below.

It is a pure TouchDesigner compositing network underneath that uses methods employing the ChromaKey, Blur and Lookup TOPs together with DATs and small python scripts.

Unzip the ChromaKey.3.zip file and drag-drop chromakey.tox to any network.

Then connect a video stream (can be a movie) to Input 1 of the chromakey component, such as the video that’s included with the ChromaKey.1.zip file, and select Input 1 in the UI.

Or you can select the source to be Movie File and drag-drop a movie in the movie player, then scrub the movie to various frames.

Then you can hook a background video stream or still image to input 2 to see your result composited.

Next you want to select the key color. In the large middle image of the UI, select Input 1 and then left-click the mouse over a part of the key color, and drag the mouse around to gather more pixels that are the key color.

Then you can middle-click or Ctrl-click or Alt-click to add to the key color selection. The key color selection is a min-to-max of hue, a min-to-max of saturation and a min-to-max of luminance.

If you mess up, press Undo or start again by left-clicking on the image. And there’s Undo to go back up to 10 steps ago.

It may be tricky to select key color when the input video is rapidly changing. Instead you can press Sample Image a number of times, then drag the Samples slider below the sampled images to pick one of the images. You can then add to the key color selection. You can sample up to 8 images and use the sample slider to go between them.

Above the middle large image you can select what to put in the background of the preview: Black, Red, Input 2 or a standard background still.

You can also adjust the key color selection by moving the handles on the hue, saturation or level bars.

Bottom small image shows the spill mask on red. Spill is adjusted with the stack of 4 sliders beside it.

There’s also the alpha-smoothing slider to round-out and slightly soften the edges.

You can select 4 ways to output on the right - raw RGBA, composited over red, input2, etc.

It is created in TouchDesigner 088 build 8460. The .tox file is standalone (use it as-is in other files). In the Toe folder is the .toe version that is independent of /uig: ChromaKeyForTox.toe (from which the .tox was created), versus ChromaKey.toe that has its gadgets cloned from /uig.

I left some room in the UI so you can add your own extensions and re-post! Contact me if you need guidance.

And a big thanks to Hal Lovemelt of Playatta (playatta.com) for the tips and the use of the sample video.

(version 2 reorganized files vs version 1)
(version 3 has better history/undo mechanism vs version 2)
(version 5 works with Builds 10300 and later)
( Version 10 is in the palette of 088 builds 52000 or later )


No challenge is too great’

this is awesome

Thanks Greg. Finally get to have a play with this one!

got it too, thanks! there’s a lot to learn before I fully understand this though :confused:

This has better color spill control (which turns pixels to grey around the edge where the key color spills onto the subject).

It also improves Sample Source which samples the input while it’s playing, and now gives you 1/4 second to click the button after you see a frame you want to sample. (What it should do is sample a sequence of 5 frames so you can choose the best one!)

< new version below>

Thanks for the component Zeotime and Greg! Super useful… Can’t seem to download version 6 either?


This fixes some bugs in the color spill control and is faster.

NOTE: This component is replaced by the more optimized chromaKey component in the palette of 088 build 52000 or later.

chromakey.7.tox (110 KB)

1 Like

This component is super useful !
Should be a built-in optimized node in TouchDesigner.

thanks! works brilliantly

This chromeKey.tox component has been replaced by the chromaKey component found in the palette in 088 builds 52000 (currently experimental) and later.

One significant speed-up is that when you take it out of Test Mode after you set your levels up, it runs 2x faster. See its help popup on the ? button.

Hello all, I am looking to build on this awesome Keyer in the edge correction and cleaning
/ Tools to help improve the edges of the matte.

Does anyone have any research tips, or shaders that may help in the dev of tools like :

Matte Choking ( with geometric smoothing between pixels )

Noise / artifact reducing

better smoothing / aliasing

Thank you!

Has anyone gotten this pallet to work with an M1 Mac? I have a feeling that’s my issue but anted to check