Nodes/ComfyUI-WJNodes/color segmentation v2
ComfyUI Node

color segmentation v2

Pick masks by tag name instead of by color list

By 807502278·Created 2 years ago·Updated 11 months ago· 20
color segmentation v2
  • image
  • Color_dict
  • select_mask
  • mask
skip_threshold0.050
merge_maskfalse
invert_maskfalse
output_typeall tag
custom_keyswall,sky,floor,ceiling,windowpane,traffic
invert_select_maskfalse
invert_selectfalse

color segmentation v2 does the same core job as the original color segmentation node - turning a segmentation color-block image into a mask - but swaps the config format and the selection model. Instead of picking colors by list position, you pick by tag name, and instead of a flat Color_list, it wants a Color_dict: a keyed color-to-label mapping, again produced by the pack's load_color_config node, which shows you every available tag when you load it so you're not guessing at names.

The inputs and outputs that matter

output_type controls what you're asking for: all tag grabs every labeled region, background tag isolates whatever the config marks as background, and custom tag lets you type your own comma-separated list into custom_keys - the field ships with a default of wall,sky,floor,ceiling,windowpane,traffic, a straight lift of real ADE20K class names, so this node is clearly built with that dataset's ~150-category palette in mind. Everything else tracks the v1 node: skip_threshold filters out matches too small to be a real region, merge_mask combines everything into one mask, invert_mask flips it, and the same select_mask / invert_select_mask / invert_select trio restricts matches to a region you define with an external mask.

The author's own notes on this node are unusually thorough and worth repeating, because they explain results that would otherwise look like bugs:

  • If a single frame has none of your requested colors present, you get a full black mask back (full white if invert_mask is on) - not an error, not an empty output.
  • In a batch, if only some frames are missing a match, those specific frames come back black while the rest process normally.
  • merge_mask gets forced on automatically whenever the input is a batch, even if you've toggled it off - batches always merge, single frames respect your toggle.
  • select_mask currently only works with a single mask, not a batch.

Installing it

Comes with the rest of ComfyUI-WJNodes - no separate install. ComfyUI Manager, search "ComfyUI-WJNodes," or:

cd ComfyUI/custom_nodes
git clone https://github.com/807502278/ComfyUI-WJNodes.git

Restart, and it sits right next to the original under WJNode → ImageEdit → Color. Nothing extra to download for this node - load_color_config handles reading the palette files that ship with the pack.

Where people get burned

Most of the confusion here maps directly to the four behaviors above - a batch mask output with a few solid-black frames scattered through it, or a merge_mask that appears to ignore your toggle, are both documented, not broken. If you already know the numeric palette and don't mind a list, v1 (color_segmentation) is simpler. If you'd rather think in class names - "give me sky and floor" instead of "give me colors 3 and 4" - this node's tag-based Color_dict and custom_keys field is the more legible option for picking a handful of specific classes out of a busy scene.

CategoryWJNode/ImageEdit/Color

Inputs (10)

NameTypeDefaultDescription
imageIMAGE
skip_thresholdFLOAT0.0500–1
Color_dictDICT
merge_maskBOOLEANfalse
invert_maskBOOLEANfalse
output_typeCOMBOall tag3 options: all tag, background tag, custom tag
custom_keysSTRINGwall,sky,floor,ceiling,windowpane,traffic
select_maskoptMASK
invert_select_maskoptBOOLEANfalse
invert_selectoptBOOLEANfalse

Outputs (1)

NameTypeDescription
maskMASK