Chroma Key Prepass
The quick, dirty key that makes the neural keyer look good
- image
- alpha_hint
Chroma Key Prepass is the unglamorous node that makes CorridorKey's neural keyer shine. It's a plain chroma difference-key that eats your green (or blue) screen footage and spits out one thing: a rough alpha_hint mask. The entire trick is that the hint shouldn't be good. CorridorKey was trained on coarse, blurry, eroded masks, and the model's whole job is to fill in the fine detail a human or a dumb keyer would get wrong. The hint is just a map of "roughly where's the subject" so the network doesn't have to hunt the entire frame.
That flips the mindset from every keying session you've had before. If you're used to wrestling a Keylight or a luminance key toward a perfect edge, stop. This node is meant to be a fast, sloppy first pass, and the defaults (threshold 0.3, erode 2, blur 5) are already tuned to produce exactly the kind of hint the model wants. Don't fight it.
How it works
Under the hood it's a classic difference key with three extra stages, all per-frame in numpy/OpenCV:
- Take the screen channel (green or blue) and subtract the maximum of the other two -
g - max(r, b). That's your "how green is this pixel" score. - Soft-threshold it: above
threshold, treat the pixel as background.softnessturns the hard cut into a ramp so the hint has soft edges instead of a cliff. - Erode the mask to pull it away from the subject's edges, then blur it so it's properly coarse.
Erode and blur sound like damage, and for a final key they would be. Here they're the point: pulling the mask off the edges tells the neural keyer "don't trust the boundary, you figure it out," and blurring kills the pixel noise the model would otherwise latch onto.
Inputs and outputs
Only image (the IMAGE input) is required. The rest are optional, and each carries the author's own tooltip - trust those:
- screen_color (
green/blue): match your actual screen. Getting this wrong keys the background instead of the subject. - threshold (0.3): "How much the screen channel must exceed the others to be considered background. Lower = more aggressive keying." If green fringes leak through, drop it toward 0.2.
- softness (0.1): width of the soft falloff between foreground and background; 0 gives a hard edge.
- erode (2): shrinks the foreground mask by that many pixels, pulling the hint away from edges.
- blur (5): Gaussian blur radius on the final mask, making it coarser.
The single output is alpha_hint (MASK), and it wires straight into the alpha_hint input on CorridorKey Greenscreen. That's the only place it's meant to go - it is not a final key.
You can also skip this node entirely
If your footage is nasty - fine hair, motion blur, spill the difference key can't separate - you don't have to use this node at all. The alpha_hint on CorridorKey Greenscreen accepts any mask from any source: a roto you painted, a mask out of Segment Anything, output from another keying tool. The prepass is the cheap default for when a fast first pass is good enough, which is most of the time. It also handles batches, keying each frame of a loaded video clip in sequence, so it works fine on footage.
Install and gotchas
It ships in the CorridorKey pack - ComfyUI Manager, search ComfyUI-CorridorKey, or:
cd ComfyUI/custom_nodes
git clone https://github.com/pixelworldai/ComfyUI-CorridorKeyWrapper
cd ComfyUI-CorridorKeyWrapper
pip install -r requirements.txt
No extra models: it's pure numpy/OpenCV and leans on the checkpoint Load CorridorKey Model pulls in.
Real gotchas: key a blue screen with screen_color left on green and you'll get a garbage hint that the neural keyer faithfully turns into garbage. And if the prepass lets too much spill through as background, the hint shrinks and CorridorKey clips your subject - drop the threshold. Tune the two-node combo as a unit: change the prepass, watch the final alpha, not the intermediate mask.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| screen_coloropt | COMBO | green | 2 options: green, blue |
| thresholdopt | FLOAT | 0.300–1 | How much the screen channel must exceed the others to be considered background. Lower = more aggressive keying. |
| softnessopt | FLOAT | 0.100–0.5 | Width of the soft falloff between foreground and background. 0 = hard edge. |
| erodeopt | INT | 20–50 | Shrink the foreground mask by this many pixels. Helps CorridorKey by pulling the hint away from edges. |
| bluropt | INT | 50–50 | Gaussian blur radius on the final mask. Makes the hint coarser, which CorridorKey handles well. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| alpha_hint | MASK | — |