Nodes/CRT-Nodes/Chroma Key Overlay (CRT)
ComfyUI Node

Chroma Key Overlay (CRT)

Green screen keying that lives in your node graph

By PGCRT·Created 2 years ago·Updated a day ago· 132
Chroma Key Overlay (CRT)
  • images
  • ClickOnMe
  • background_images
  • image_with_alpha
  • blended_image
tolerance10.0
expand_pixels0
blur_radius0.0

Chroma keying - pulling a subject off a green (or any solid) background - is one of those things everyone eventually needs in ComfyUI and nobody wants to leave the graph for. Chroma Key Overlay (CRT) does it natively: pick the background color, set a tolerance, and it cuts the subject out and optionally composites it onto a new background, all inside your workflow.

It's the CRT pack's take on the "remove the green screen" problem. Where the ecosystem's serious background removal lives in segmentation models (BiRefNet and friends, per the KB), this node is the fast, deterministic, no-model alternative: it keys on raw color distance, which is instant and needs no weights, and it's the right tool whenever your source is a real chroma screen rather than an arbitrary photo background.

How it works

Feed it images (a batch tensor) and it computes the distance between every pixel and the key color, using ClickOnMe (a color picker, default green #00FF00) and tolerance (0–100) as the threshold. Pixels farther than the tolerance are kept; closer ones become transparent. Then:

  • expand_pixels - grows the cutout (dilates the background side of the mask) to eat fringe, or conversely trims it. Small values clean the edges.
  • blur_radius - softens the alpha mask with a Gaussian. This is the secret to not looking like a sticker on the new background: a blur of 1–3px feathered edges hide the keying jaggies.

Two outputs come out. image_with_alpha is your cutout as a 4-channel RGBA image - the thing to save for later compositing. blended_image is the subject already composited onto background_images if you connected one (it resizes the background to match and repeats it if it has fewer frames than your subject batch). No background connected → blended_image is just the cutout.

There's a clever default in the source: if you feed it an RGBA image that already has an alpha channel, it skips chroma keying entirely and uses the existing alpha. So the node doubles as a "make sure this image has alpha" utility.

When it's the right tool

The KB's background-removal guide is worth reading on this exact decision. If your source is a genuine green screen - AI-generated keyed footage, a studio shot - color distance is fast, free, and deterministic, and this node handles it in one pass. If your source is a photo with a complex background, you want a segmentation model (BiRefNet), not chroma keying; this node will bleed all over the place on an uncontrolled background. Match the tool to the shot.

Install

cd ComfyUI/custom_nodes
git clone https://github.com/PGCRT/CRT-Nodes.git
pip install -r requirements.txt

or ComfyUI Manager → search "CRT-Nodes". Requires scipy (for the mask dilation/blur), which is in the pack's requirements - no extra downloads.

Gotchas

The tolerance is a percentage of max RGB distance, and it's easy to over-shoot: too high and you key holes in bright highlights on the subject; too low and you keep green fringe. Start at the default 10 and nudge. The mask math happens on CPU through SciPy, so very large batches are slower than you'd hope but fine for normal use. And the one that trips people: ClickOnMe defaults to green, so if you fed it a blue-screen shot and wondered why nothing keyed - that's why.

CategoryCRT/Image

Inputs (6)

NameTypeDefaultDescription
imagesIMAGE
ClickOnMeCOLOR#00FF00
toleranceFLOAT10.00–100
expand_pixelsINT00–128
blur_radiusFLOAT0.00–64
background_imagesoptIMAGE

Outputs (2)

NameTypeDescription
image_with_alphaIMAGE
blended_imageIMAGE