Nodes/Image Processing Suite for ComfyUI/Image to Mask (AnotherUtils)
ComfyUI Node

Image to Mask (AnotherUtils)

Image to Mask — pull one channel out of an image and use it as a mask

By marcoc2·Created 2 years ago·Updated 5 months ago· 1
Image to Mask (AnotherUtils)
  • image
  • MASK
channelluminance

Masks in ComfyUI are just single-channel tensors where 1.0 is "keep" and 0.0 is "cut." Any grayscale image can be a mask if you squint. AnotherImageToMask is the squinting - it takes an image, extracts one channel of your choice, and hands you a MASK tensor ready to wire into an inpaint, a composite, or a VAE encode.

You reach for this when you have an image that's already effectively a mask but living in image space: a depth map you want to feed a control pipeline, a grayscale height map, an alpha-heavy PNG where you want the transparency itself as the mask, or any luminance-based selection you want to play with. It's a format converter, and format converters are the unsung plumbing of half of all workflows.

How it works

It's a channel extraction with a dropdown. Feed it an image and pick a channel:

  • red, green, blue - the named color channel, straight out of the tensor.
  • alpha - the transparency channel. If the image has no alpha channel at all, it returns an all-ones mask (everything "kept"), which is the safe and sensible fallback.
  • luminance (the default) - the mean of the RGB channels, which is a decent proxy for perceived brightness.

The output is a MASK with the same height and width as the input. That's the whole trick. It's the sibling of AnotherMaskToImage, which does the reverse if you ever need to take a mask back into image space.

Inputs and outputs

Just two things to touch:

  • image (IMAGE) - the source.
  • channel - the enum dropdown. luminance is the default and the most useful for most "turn a grayscale image into a mask" cases.

Output: MASK. Wire it into anything that accepts a mask - inpainting, compositing, mask math.

Installing it

Part of the AnotherUtils pack:

cd ComfyUI/custom_nodes
git clone https://github.com/marcoc2/ComfyUI-AnotherUtils.git

Restart ComfyUI, or use ComfyUI Manager and search "AnotherUtils". Pure tensor slicing, no dependencies, no model downloads.

Where people get tripped up

The luminance default catches people. It's a mean of RGB, not a proper perceptual luma (which would weight green highest). For most mask purposes the mean is close enough that you won't notice; for anything where exact brightness matters, use the green channel instead - it's the closest single channel to human brightness perception.

The alpha fallback also deserves a mention: if you pick alpha on a 3-channel image, you get a full-white mask rather than an error. That's deliberate and safe, but it's also the easiest way to silently get a useless all-white mask. If your mask looks "wrong" after using alpha, check that your source actually has an alpha channel.

Also worth noting it returns the channel values as-is - this isn't a thresholding node. If your image has a gray background, your mask has a gray background, and anything downstream that expects a clean binary mask will behave oddly. Pair it with a mask math or blur node to push values where you want them.

CategoryAnotherUtils/utils

Inputs (2)

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

Outputs (1)

NameTypeDescription
MASKMASK