ComfyUI Node

Keyer

Old-school VFX matte pulling, no ML model required

By spacepxl·Created 3 years ago·Updated 8 months ago· 293
Keyer
  • images
  • image
  • alpha
  • mask
operation
low0.000
high1.000
gamma1.000
premulttrue

Before AI segmentation models existed, VFX compositors pulled mattes with deterministic math: pick a property of the image - brightness, saturation, a color channel, or distance from a known screen color - set a range, and anything inside that range becomes opaque while everything outside fades to transparent. That's a "keyer," the same core operation behind every greenscreen effect ever shot on video. This node brings that classic technique into ComfyUI, and its README description undersells how genuinely useful it is: "Basic image keyer with luma/sat/channel/greenscreen/etc options."

Why reach for this instead of a segmentation model

Tools like BiRefNet or rembg are the right call for arbitrary photos with real, complex backgrounds - they've learned what "foreground" generally looks like. But when your background is known and clean - actual green/blue screen footage, a flat studio backdrop, or a synthetic render with genuinely separated colors - a keyer is faster (no model, no VRAM, instant), more predictable (you control the exact cutoff, not a network's guess), and often cleaner at fine edges like hair, since it's working directly off the color math rather than a learned segmentation boundary. It's the right tool when you can guarantee a clean color separation between subject and background; it's the wrong tool the moment that separation isn't there.

Inputs and outputs

  • images (IMAGE) - the source.
  • operation - what property to key on: luminance, saturation, max, min, individual red/green/blue channels, or the chroma-key modes redscreen/greenscreen/bluescreen for actual colored-backdrop footage.
  • low / high (default 0 and 1) - the range that gets mapped to fully transparent through fully opaque. Values below low key out completely; above high, fully in; it ramps between.
  • gamma (default 1) - reshapes the falloff curve of that ramp, letting you push the transition softer or harder without moving the low/high cutoffs themselves.
  • premult (default on) - whether the output RGB gets multiplied by the resulting alpha, which is standard compositing practice to avoid a colored fringe (green spill, for instance) surviving at the edges once you composite onto a new background.

Three outputs: image (the keyed, optionally premultiplied RGB), alpha (the same information rendered as a grayscale IMAGE), and mask (the MASK-typed version, ready to wire straight into anything in ComfyUI that expects a mask - compositing nodes, inpainting, whatever).

Installing it

ComfyUI Manager: search "ComfyUI-Image-Filters," install, restart. Manually:

cd ComfyUI/custom_nodes
git clone https://github.com/spacepxl/ComfyUI-Image-Filters

pip install -r requirements.txt (or install.bat on Windows), restart. No model weights - this is pure math, unlike a segmentation-based background remover, so it's essentially instant to add and to run.

This pack's one real dependency wrinkle is OpenCV: it needs opencv-contrib-python, and a conflicting cv2 build pulled in by another node pack can throw import errors across the whole repo on startup. Run import_error_install.bat to reinstall the single correct opencv variant if that happens.

Where people get burned

The classic keyer trap: a subject wearing something close to the key color (a greenish shirt against a green screen) gets partially keyed out along with the background - there's no fix for that in the node itself, it's a shoot/asset problem, only avoidable by picking a different operation if another channel separates better, or by accepting you need to matte-paint or garbage-mask that region separately. Second, forgetting premult is on by default and then compositing the image output again through a separate premultiply step - that double-applies the multiply and darkens your edges. And if your background isn't actually a clean, consistent color (real-world photos, busy scenes), don't expect this node to compete with a trained matting model - it wasn't built for that job, and low/high/gamma tuning will only get you so far before you're fighting noise in the source image itself.

CategoryImage-Filters/image

Inputs (6)

NameTypeDefaultDescription
imagesIMAGE
operationCOMBO10 options: luminance, saturation, max, min, red, green, +4
lowFLOAT0.000
highFLOAT1.000
gammaFLOAT1.000
premultBOOLEANtrue

Outputs (3)

NameTypeDescription
imageIMAGE
alphaIMAGE
maskMASK