Nodes/ComfyUI-RMBG/Color to Mask (RMBG) 🎭
ComfyUI Node Runs on cloud

Color to Mask (RMBG) 🎭

Turn a specific color into a mask

By 1038lab·Created 2 years ago·Updated 12 days ago· 2,057
Color to Mask (RMBG) 🎭
  • images
  • mask_color
  • MASK
invertfalse
threshold10

Sometimes you don't need a neural network to find your subject - you need to select everything that's green. Color to Mask does the old chroma-key trick: pick a color, set a tolerance, and it hands you a mask of every pixel close enough to that color. No model, no download, instant.

This is the un-clever tool in a pack full of clever ones, and that's the point. When your image already has a flat, known background - a green screen, a solid studio backdrop, a color-coded control map - running BiRefNet or SAM on it is a waste. A color threshold nails it in milliseconds and gives you a cleaner edge than a segmentation model would, because there's nothing to guess. The mask is defined by math, not inference.

How it works

It compares every pixel to your chosen mask_color and marks the ones within threshold distance as masked. Bigger threshold, wider net. That's the entire mechanism, and it's why it's fast and predictable.

The inputs that matter

There are only four, and three of them you'll actually touch:

  • mask_color (default #FFFFFF) - the color you're selecting. A color-picker widget, so grab the exact background color from your image.
  • threshold (0–255, default 10) - the tolerance. Low values select only near-exact matches; raise it if your background has gradients, JPEG noise, or lighting variation. This is the dial you'll nudge most.
  • invert (default off) - flip it, so you mask everything except the color. This is the one you'll usually want for background removal: pick the background color, invert, and now your mask is the subject.

The single output is MASK, ready to feed into an extractor, a combiner, or an inpaint node.

How to install it

  • ComfyUI Manager: search Comfyui-RMBG, install, restart.
  • Manual: cd ComfyUI/custom_nodes && git clone https://github.com/1038lab/ComfyUI-RMBG, then pip install -r requirements.txt, and restart.

Nothing downloads for this node - it's pure pixel math, live as soon as the pack loads.

Where it shines and where it doesn't

Reach for it when the background is genuinely a flat color: green screens, solid product backdrops, alpha-flattened renders. It'll beat a segmentation model on those, hands down.

Where it falls apart is exactly where color-keying always has: fine detail and spill. Flyaway hair against a green screen picks up green light, so the edge pixels aren't quite your key color and either get left out or fringed. Semi-transparent stuff - glass, veils - has no single color to key on. If your subject contains the background color (a green shirt on a green screen), you'll punch a hole right through it. For any of those, this is the wrong tool and you want a real matting model like BiRefNet's matting weights. But for a clean flat backdrop, Color to Mask is the fastest, most reliable option in the pack, and it's genuinely underrated for how simple it is.

Category🧪AILab/🧽RMBG

Inputs (4)

NameTypeDefaultDescription
imagesIMAGE
invertBOOLEANfalse
thresholdINT100–255
mask_colorCOLORCODE#FFFFFFMask color (hex)

Outputs (1)

NameTypeDescription
MASKMASK