Nodes/ComfyUI_agilly1989_motorway/ImageToMask_motorway_edition
ComfyUI Node

ImageToMask_motorway_edition

Pull one channel out of an image and use it as a mask

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

Masks are just grayscale images under the hood, which means a lot of them can be stolen from an image you already have: the alpha channel of a PNG with transparency, the red channel of a painted overlay, the luminance of a black-and-white silhouette. ImageToMask extracts one channel and hands it to you as a mask. ImageToMask_motorway_edition is the same node reading from and writing to a MOTORWAY πŸšŒπŸ’¨ pipe.

It's part of agilly1989/ComfyUI_agilly1989_motorway, the author's key-value pipe pack. It reads the image out of the pipe under INPUT_image_key (default "image"), pulls out the channel you pick, and stores the mask back under OUTPUT_MASK_key (default "MASK"). Only visible output is the Motorway pipe.

Inputs that matter

  • INPUT_image_key (default "image") - pipe key of the source
  • channel - red, green, blue, or alpha
  • OUTPUT_MASK_key (default "MASK") - where the mask lands

The channel choice is the whole job. alpha is the common one: a PNG with transparency becomes a cutout mask in one step. The RGB channels are for when you've painted or rendered something where one channel carries the shape you want. Whatever you pick, you get a single-channel mask at the image's dimensions, ready to feed into mask plumbing - including this pack's GrowMask_motorway_edition if you want to expand or soften it before use.

How it works

Standard clone mechanics: pop the Motorway, pull the image out via the input key, run stock ImageToMask with your channel, store the result under the output key, and return a cloned pipe so nothing upstream is mutated. Note the direction: this is image-to-mask. The pack's ImageColorToMask is the sibling that matches a specific solid color instead of a channel.

Installing

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

Restart ComfyUI, or install via ComfyUI Manager (search "motorway"). Pure Python, no requirements.txt, no model downloads.

Gotchas

Keys are exact and case-sensitive; a 'MotorwayClass' object has no attribute 'hash_' error means your key string matches nothing in the pipe. Mind the case default - you read "image" (lowercase) and write "MASK" (uppercase) - so a chain of clones needs keys you set to agree. And the family status: BETA, with the motorway_edition clones disabled in the 1.1.7 hotfix - if the node's missing from your menu, stock ImageToMask is the same tool with wires.

Categoryagilly1989 Nodes/Motorway-ed/mask

Inputs (4)

NameTypeDefaultDescription
MOTORWAY πŸšŒπŸ’¨MOTORWAY πŸšŒπŸ’¨β€”
INPUT_image_keySTRINGimageβ€”
channelCOMBO4 options: red, green, blue, alpha
OUTPUT_MASK_keySTRINGMASKβ€”

Outputs (1)

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