π§ Mask From RGB/CMY/BW
Mask From RGB/CMY/BW β split a color map into eight separate masks
- image
- red
- green
- blue
- cyan
- magenta
- yellow
- black
- white
Here's a neat trick for regional workflows. Paint a rough map where each area is a solid color - red here, green there, blue over there - and this node splits that single image into eight separate masks, one per color: red, green, blue, cyan, magenta, yellow, black, and white. Now you've got a clean mask for each region, ready to drive different prompts, ControlNets, or edits per area. It turns "I colored in my regions" into "I have eight usable masks" in one step.
What it does
Input is an image (your color map), plus three thresholds:
- threshold_r, threshold_g, threshold_b - how close a pixel's red/green/blue channel has to be to count as "on" for that color (each 0β1, default 0.15). These control how strict the color detection is. Loosen them if your colors aren't landing in the right masks; tighten them if colors are bleeding into each other.
Outputs are eight MASKs, each named for its color: red, green, blue, cyan, magenta, yellow, black, white. You pull off whichever ones your regions used and ignore the rest.
The logic is channel-based: pure red is high R, low G/B; cyan is low R, high G/B; and so on through the primaries, secondaries, plus black (all low) and white (all high). The thresholds decide how forgiving that classification is.
Where you'd use it
Regional prompting and multi-area control. Instead of hand-drawing a separate mask for each region, you paint one color-blocked image and let this node explode it into per-region masks. Feed the red mask to one conditioning path, the blue mask to another, and you've got a color-coded regional setup that's fast to author and easy to re-edit - change the map, re-run, done.
It's also handy for pulling a specific colored element out of an existing image, as long as that element is a reasonably pure color against a different-colored background.
Installing it
Part of ComfyUI Essentials by cubiq - Matteo Spinelli, the developer behind ComfyUI_IPAdapter_plus:
- ComfyUI Manager: search "ComfyUI Essentials" β Install β restart.
- Manual:
cd ComfyUI/custom_nodes && git clone https://github.com/cubiq/ComfyUI_essentials, installrequirements.txt, restart.
Recognise it by the π§ wrench and the + (MaskFromRGBCMYBW+).
Gotchas
Use pure, saturated colors in your map. This works on clean primary/secondary colors; muddy, desaturated, or anti-aliased colors sit between categories and land in the wrong mask or none at all. If your regions come out wrong, that's usually the cause - paint with fully saturated red/green/blue/etc., not "reddish."
Soft edges are the enemy of clean classification. Anti-aliased boundaries between two colored regions produce intermediate pixels that fall into neither mask, leaving thin gaps at the seams. Painting with hard edges helps; running the output masks through Mask Fix (dilate a touch, then blur) cleans up the boundaries afterward.
Tune the thresholds if things aren't separating - but change them a little at a time, since all three interact when classifying a given pixel.
Pack note: cubiq set Essentials to maintenance-only in April 2025. It still works, but if it breaks after a major ComfyUI update, roll ComfyUI back or patch it - no upstream fixes. A red "missing node" box means the pack didn't load; check the startup log and reinstall via Manager.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | β | |
| threshold_r | FLOAT | 0.150β1 | β |
| threshold_g | FLOAT | 0.150β1 | β |
| threshold_b | FLOAT | 0.150β1 | β |
Outputs (8)
| Name | Type | Description |
|---|---|---|
| red | MASK | β |
| green | MASK | β |
| blue | MASK | β |
| cyan | MASK | β |
| magenta | MASK | β |
| yellow | MASK | β |
| black | MASK | β |
| white | MASK | β |