Masks From Colors
Turn a color map into region masks for regional prompting
- image_color_swatches
- image_color_mask
- masks
If you've ever wanted to say "this half of the image is a forest, that half is a city, and this blob in the corner is a dragon" without drawing five separate masks by hand, this is the node that does the boring part. You paint a rough color map - one flat color per region - hand it a strip of the colors you used, and Masks From Colors hands you back a clean mask for each region. It's the front door to RES4LYF's regional conditioning, where you can drive a different prompt into each masked zone.
RES4LYF is ClownsharkBatwing's sampler-and-scheduler pack - the one that mostly replaced DPM++ 2M Karras for flow-matching models like Flux, Chroma, SD3.5 and WAN. Regional (and even frame-by-frame temporal) prompting is one of its headline features, and the README shows it running with rigid, blocky masks exactly like the ones this node produces. So while the pack is famous for its solvers, this is a quiet little utility that feeds the fancy stuff.
How it works
The mechanism is dead simple, which is the appeal. You give it two images. One is your color mask - a picture where each region you care about is filled with a distinct solid color. The other is a swatch image: a small strip or grid containing exactly those colors, in the order you want the masks. The node walks the swatches, finds every pixel in the color map matching each swatch, and emits one mask per color. Draw the color map freely in any paint tool, or build a rigid grid - both work.
The inputs and outputs that matter
image_color_swatches(IMAGE) - the palette. Each distinct color here becomes one output mask. Keep the colors far apart (pure red, pure green, pure blue) so matching is unambiguous.image_color_mask(IMAGE) - your painted region map, using those same colors.
The single output is masks (MASK) - the set of region masks, which the node's own description calls a list. You wire that into whatever consumes masks in your regional setup: RES4LYF's conditioning/guide nodes, or a mask combiner, or an attention-couple style node.
How to install it
Grab the whole RES4LYF pack, not just this node. Easiest path is ComfyUI Manager: open it, hit Install Custom Nodes, search RES4LYF, install, restart. Manually:
cd ComfyUI/custom_nodes
git clone https://github.com/ClownsharkBatwing/RES4LYF/
cd RES4LYF
pip install -r requirements.txt
Portable ComfyUI users swap pip for the embedded one (python_embedded\Scripts\pip.exe). Restart ComfyUI and hard-refresh the browser with F5. No model downloads are needed for this node - it's pure image processing.
Common issues
The thing that trips people up is color matching. If a region comes back empty or bleeds into its neighbor, your color map almost certainly has anti-aliased or JPEG-compressed edges, so the "solid" red isn't a single RGB value anymore. Paint with a hard, aliased brush, save as PNG, and use saturated primaries that can't be confused. Second: swatch order defines mask order, so if your regions come out shuffled downstream, reorder the swatches. And the usual RES4LYF new-install gotcha - if the node doesn't show up at all, you skipped the pip install -r requirements.txt step or forgot the hard refresh.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| image_color_swatches | IMAGE | — | |
| image_color_mask | IMAGE | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| masks | MASK | — |