Mask_splitMask_by_color
Split a color-coded mask into 8 channel masks
- image
- red
- green
- blue
- cyan
- magenta
- yellow
- black
- white
If you've ever hand-painted a flat-color map to drive regional prompting - red for the head, blue for the jacket, green for the background, whatever - you've hit the annoying next step: ComfyUI wants each of those regions as its own separate mask, and painting eight of them by hand is nobody's idea of fun. Mask_splitMask_by_color does that split for you in one node. Feed it the color-coded image, get back eight masks, one per primary/secondary color.
It's part of ComfyUI-Apt_Preset, a big single-author preset/utility pack. The mask nodes in it, this one included, are plain image-processing tools - no models, no downloads, nothing exotic. That's worth knowing up front because a couple of this pack's other nodes do lean on external files; this one doesn't.
How it works
The node reads your image and, for each of the eight colors it recognizes - red, green, blue, cyan, magenta, yellow, black, and white - checks every pixel against a per-channel threshold to decide whether that pixel counts as "belonging" to that color. A pixel that's mostly red and not much else lands in the red mask; a pixel that's neither red, green, nor blue (i.e. black or white) lands in one of the two grayscale outputs. You get all eight masks out simultaneously, whether or not your source image actually used all eight colors - the ones you didn't paint just come back empty.
Inputs and outputs
The whole control surface is three thresholds:
- image - your color-coded reference. Pure, flat colors work best; anti-aliased edges or gradients will produce fuzzy mask boundaries.
- threshold_r / threshold_g / threshold_b - how strict the match has to be per channel, 0 to 1, default 0.15. Lower means a pixel has to be a purer, more saturated version of that channel to count; raise it if your paint tool left soft edges or slight color bleed and you're getting gaps in the mask.
Outputs are eight separate MASKs - red, green, blue, cyan, magenta, yellow, black, white - each ready to wire straight into whatever consumes a mask downstream: a Set Latent Noise Mask, a regional conditioning node, an inpaint node, or another Apt_Preset mask tool like Mask_transform_sum if you want to preview or reshape one of the splits before using it.
Installing it
Easiest path is ComfyUI Manager: open it, search for "ComfyUI-Apt_Preset" or "Apt_Preset", install, restart. If you'd rather do it by hand:
cd ComfyUI/custom_nodes
git clone https://github.com/cardenluo/ComfyUI-Apt_Preset.git
Then restart ComfyUI. The repo ships an install.bat for pulling in its Python dependencies on Windows; on Linux or Mac, activate your ComfyUI virtualenv and install whatever requirements file the repo carries the same way you would for any other custom node. This particular node has no model downloads or extra dependencies of its own - it's pure pixel math, so once the pack imports cleanly you're done.
Worth knowing before you install: this is a large, actively-maintained pack (commits as recent as this year) from a single author, not one of the household names like Impact Pack or rgthree - it doesn't show up much in general ComfyUI discussion, so you're mostly on your own with the GitHub issues page if something goes sideways rather than a big community thread to search.
Common issues
Empty masks for a color you definitely painted. Almost always a threshold problem, not a bug - if your "red" is actually more like a muddy orange-red at low saturation, the default 0.15 threshold may reject it. Bump the relevant threshold up a bit and check again.
Masks bleeding into each other at edges. Comes from anti-aliasing in whatever tool you used to paint the color map. Repaint with a hard-edge brush and no smoothing, or accept the soft boundary and clean it up afterward with a mask-blur/expand step (Apt_Preset's own Mask_transform_sum has a smoothness and mask_expand control that can help here).
The whole pack fails to import. If ComfyUI's console shows an IMPORT FAILED for ComfyUI-Apt_Preset on startup, it's a missing-dependency problem almost every time - re-run the install step for your platform (install.bat or a manual pip install of the requirements file) rather than assuming the node itself is broken.
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 | — |