Nodes/ComfyUI_agilly1989_motorway/ImageColorToMask_motorway_edition
ComfyUI Node

ImageColorToMask_motorway_edition

Turn a solid color into a mask, no wires touched

By agilly1989Β·Created 2 years agoΒ·Updated about a year agoΒ· 7
ImageColorToMask_motorway_edition
  • MOTORWAY πŸšŒπŸ’¨
  • MOTORWAY πŸšŒπŸ’¨
β—„INPUT_image_keyimageβ–Ί
β—„color0β–Ί
β—„OUTPUT_MASK_keyMASKβ–Ί

Sometimes the fastest way to get a mask is to have an image where the thing you want masked is basically one flat color - a chroma background, a solid backdrop, a flat fill. ImageColorToMask turns exactly that into a mask. ImageColorToMask_motorway_edition is the same node with its input and output routed through the MOTORWAY πŸšŒπŸ’¨ pipe in agilly1989/ComfyUI_agilly1989_motorway.

It reads the image out of the pipe under INPUT_image_key (default "image"), finds the pixels that match color, and stores the resulting mask back into the pipe under OUTPUT_MASK_key (default "MASK"). Output is the Motorway pipe only - the mask is waiting in the pipe for whatever reads that key next.

Inputs that matter

  • INPUT_image_key (default "image") - pipe key of the source image
  • color (INT, 0 to 16777215, default 0) - the RGB value as a packed integer. 0 is black, 16777215 is white, and pure green is 0x00FF00 = 65280
  • OUTPUT_MASK_key (default "MASK") - where the mask lands

That packed-integer color is the field beginners trip over, because it's not a friendly hex picker. The math is red*65536 + green*256 + blue, so a pure red is 16711680 and a pure blue is 255. If your target isn't a clean match, the mask will come out spotty - this node is honest about exact color, it does no tolerance fuzzing.

How it works

The wrapper is the standard clone pattern: pop the Motorway, pull the image via the input key, call stock ImageColorToMask with color, store the mask under the output key, and return a cloned pipe. The resulting mask feeds naturally into mask utilities - including the pack's own GrowMask_motorway_edition if you want to expand it a few pixels so the edge blends.

Installing

cd ComfyUI/custom_nodes
git clone https://github.com/agilly1989/ComfyUI_agilly1989_motorway

Restart ComfyUI, or search "motorway" in ComfyUI Manager. No requirements.txt, no model downloads - pure Python.

Gotchas

Same pack-wide caveats: keys are exact and case-sensitive (hash_ errors mean your key string matches nothing in the pipe), the defaults read lowercase ("image") and write uppercase ("MASK") so chained clones need hand-aligned keys, and the motorway_edition family is the pack's experimental clone feature, disabled in the 1.1.7 hotfix - if it's not in your menu, stock ImageColorToMask is the same node with wires. And if your colors aren't perfectly flat, don't fight it - that's what feathering and a GrowMask shrink are for.

Categoryagilly1989 Nodes/Motorway-ed/mask

Inputs (4)

NameTypeDefaultDescription
MOTORWAY πŸšŒπŸ’¨MOTORWAY πŸšŒπŸ’¨β€”
INPUT_image_keySTRINGimageβ€”
colorINT00–16777215β€”
OUTPUT_MASK_keySTRINGMASKβ€”

Outputs (1)

NameTypeDescription
MOTORWAY πŸšŒπŸ’¨MOTORWAY πŸšŒπŸ’¨β€”