Nodes/comfyui-momo-nodes/RGB Mask Splitter πŸ”€
ComfyUI Node

RGB Mask Splitter πŸ”€

RGB Mask Splitter β€” turn one painted color map into clean per-region masks

By PhykrexΒ·Created 4 months agoΒ·Updated 4 months agoΒ· 0
RGB Mask Splitter πŸ”€
  • image
  • mask_1
  • mask_2
  • mask_3
β—„color_1#FF0000β–Ί
β—„color_2#00FF00β–Ί
β—„color_3#0000FFβ–Ί
β—„tolerance30β–Ί

Regional prompting is the standing answer to "I want two characters that don't bleed into each other," and it works by giving each region of the canvas its own masked conditioning. That's fine in theory, but you need a mask per region, and a single painted image is just one mask. RGB Mask Splitter is the piece that turns one color-coded image into up to three separate masks, one per color, ready to wire into per-region conditioning. It's the middle of the Momo Nodes regional chain: RGB Mask Editor paints the map, this splits it, Conditioning Mask Combine does the regional conditioning.

How it works

The mechanism is deliberately simple, which is worth knowing because it sets your expectations. You hand it an image and up to three hex colors (color_1, color_2, color_3). For each color it converts the image's pixels to 0–255 RGB space and computes Euclidean distance from the target color. Any pixel within tolerance becomes part of that mask. Three masks out, named mask_1, mask_2, mask_3.

Defaults are already tuned for the pack's own flow: the editor's default background is red (#FF0000) and the splitter defaults to red/green/blue, so editor β†’ splitter works with zero color configuration. The intended pattern is one color per region - red background as your "outside the regions" bucket, then a green region, a blue region.

The inputs and outputs that matter

  • image - required. The RGB mask map you just painted or otherwise authored.
  • color_1 / color_2 / color_3 - hex strings, default red/green/blue. Three slots means three regions max per pass.
  • tolerance - integer, 0 to 128, default 30, measured in 0–255 RGB distance. 30 is a reasonably tight band: pixels near your target color match, and everything else is rejected.

Outputs are mask_1, mask_2, mask_3, plain MASK tensors. Each goes into a triplet of a Conditioning Mask Combine node (or any Conditioning (Set Mask) chain) with its own prompt.

Where people get burned

The masks are binary. A pixel is either inside the tolerance band or it's not - there's no soft falloff. The editor's shapes anti-alias at their edges, and those half-alpha pixels often land just outside the band, so expect hard, slightly jagged mask edges. If your final image shows seams, that's expected behavior for this style of masking, and lowering mask strength in the combine step (or letting masking end early in the sample) is the usual fix.

Tolerance is in RGB space, and it's per-pixel. Two colors that look close to your eye can be farther apart in RGB than 30. If a region isn't getting picked up, raise the tolerance - but don't crank it to 128, or adjacent regions start cross-matching.

It only reads the first frame (image[0]), so a batched or animated input silently ignores everything but frame one.

A bad hex color silently becomes red. If you typo color_2 into something unparseable, the code falls back to (255, 0, 0) - which, with the default red background, means that slot matches the background instead of your intended region. Check your hex codes if a mask comes out looking wrong.

Installing it

Same pack as the rest of Momo Nodes - one install covers everything. ComfyUI Manager: search Momo Nodes. Manual:

cd ComfyUI/custom_nodes/
git clone https://github.com/Phykrex/ComfyUI-Momo-Nodes.git

Restart ComfyUI after cloning. No model files, no extra Python deps - it's numpy and torch, both already in ComfyUI. Nodes live under MomoNodes/mask.

A last honest note: this pack is brand new with essentially no community track record, so the splitter is a young tool. It does one narrow thing (color-threshold three masks) and does it transparently - which is why it pairs so well with the editor, and why it's easy to debug when something's off.

CategoryMomoNodes/mask

Inputs (5)

NameTypeDefaultDescription
imageIMAGEβ€”
color_1optSTRING#FF0000β€”
color_2optSTRING#00FF00β€”
color_3optSTRING#0000FFβ€”
toleranceoptINT300–128β€”

Outputs (3)

NameTypeDescription
mask_1MASKβ€”
mask_2MASKβ€”
mask_3MASKβ€”