Nodes/ComfyUI_Fill-Nodes/FL Image To Mask
ComfyUI Node

FL Image To Mask

Pull a MASK out of any image channel

By filliptm·Created 3 years ago·Updated 2 days ago· 632
FL Image To Mask
  • image
  • mask
channelluminance

ComfyUI keeps images and masks as separate types even though a mask is really just a single-channel image, and that split trips people up constantly - you have an image with the information you need (an alpha channel, or just a bright/dark region) but every downstream node wants a MASK, not an IMAGE. FL_ImageToMask is the bridge: pick a channel, get a proper MASK tensor back.

How it works

It reads the image and extracts one channel as the mask, with five choices for which channel: luminance (a perceptual brightness value computed with Rec. 601 weighting - the standard weighted combination of R, G, and B that matches how the eye perceives brightness, rather than a flat average), or the raw red, green, blue, or alpha channel directly. If you pick alpha on an image that doesn't actually have an alpha channel, it falls back to a mask of all ones (fully opaque/fully selected) rather than erroring.

The inputs and outputs that matter

Both required:

  • image - the source.
  • channel (luminance / red / green / blue / alpha, default luminance) - which channel becomes the mask.

Output: a single mask (type MASK), ready for any mask-consuming node - inpainting, compositing, conditioning.

How to install it

Ships inside ComfyUI_Fill-Nodes. ComfyUI Manager: search ComfyUI_Fill-Nodes, install, restart. Manual:

cd ComfyUI/custom_nodes
git clone https://github.com/filliptm/ComfyUI_Fill-Nodes

then restart. Pure channel extraction - no models, no dependencies beyond ComfyUI's baseline.

Common issues & troubleshooting

luminance is the right default for "extract the bright/dark regions as a mask" - don't reach for a single RGB channel by habit. If what you actually want is "select the light areas of this image," luminance gives you the perceptually correct weighting; picking red or green on a whim gives you a different, usually less useful, selection unless you specifically know that channel carries the signal you want (a depth map baked into one channel, for instance).

alpha silently returns an all-opaque mask if there's no alpha channel - that's easy to miss. If you expect a meaningful selection from alpha and get back a mask that selects everything, the real problem is upstream: your image doesn't actually carry transparency. Check that whatever produced the image (a background-removal node, a PNG load) actually wrote an alpha channel before assuming this node is broken.

Inverted mask when you didn't expect it. Depending on convention, 1.0 can mean "selected" or "masked out" depending on which downstream node consumes it - if your result looks backwards (background selected instead of subject, or vice versa), a mask-invert node right after this one is the fix, not a sign this node did something wrong.

Batch dimensions follow the image batch. Feed it a batch of images and you get a batch of masks back, one per image, same as you'd expect - no special handling needed for multi-image inputs.

Category🏵️Fill Nodes/Image

Inputs (2)

NameTypeDefaultDescription
imageIMAGE
channelCOMBOluminance5 options: luminance, red, green, blue, alpha

Outputs (1)

NameTypeDescription
maskMASK