Light-Tool: Image to Mask
Pull one color channel out of an image and make it a mask
- image
- mask
A mask is just a single channel of data. Light-Tool: ImageToMask is the node that admits it: it takes an image and hands you one channel back as a proper MASK tensor. Feed it a red image, get a red-channel mask. Feed it a cutout with an alpha channel, get an alpha mask. That's the whole job, and it's a genuinely useful one when you're building inpainting regions or compositing cutouts.
Two inputs, both required: image and channel, where channel is a dropdown with red, green, blue, and alpha. The outputs are a single mask.
How it works. It's deliberately boring. The image is converted to RGB (or RGBA if you asked for alpha), the chosen channel is sliced out as a 2D array, and that becomes a MASK tensor. Nothing is thresholded, nothing is cleaned up - if the red channel is a noisy gradient, your mask is a noisy gradient. For inpainting masks you usually want a hard white/black boundary, so plan to clean it up (the pack's MorphologicalTF can smooth it, and InvertMask flips the convention) or feed it a source that's already flat.
The alpha gotcha. This is the one that trips people up. ComfyUI loads most images as RGB by default, and once the alpha channel is gone it's gone - the alpha option on a batch of RGB tensors doesn't error, it just converts RGB→RGBA with a fully opaque alpha, giving you a blank white mask. To actually extract transparency, the image has to arrive with its alpha intact, which means keep_alpha_channel on this pack's LoadImage or LoadImageFromURL, or loading an RGBA source. If your alpha mask comes back pure white, that's the diagnosis, not a bug.
The honest take. Core ComfyUI already ships an ImageToMask node with the same R/G/B/A channels. This one is a near-identical reimplementation inside the pack - which is fine, because it means you don't need a second pack installed just to feed masks into the rest of the Light-Tool family. Reach for it when you're already living inside this pack's image/mask nodes and want to stay consistent; if you're not, the stock node does the same thing.
Installing. Install the whole pack once and this comes with it. ComfyUI Manager → search ComfyUI-Light-Tool → Install → restart, or:
cd ComfyUI/custom_nodes
git clone https://github.com/ihmily/ComfyUI-Light-Tool.git
pip install -r requirements.txt
No model downloads. Heavy dependency is opencv-python, already present on most setups.
Where it fits. Typical flow: load a cutout with alpha kept, pull alpha out as a mask, InvertMask it if your downstream wants the opposite convention, then feed it to an inpainting or compositing node. It's also handy for turning a chroma key or a grayscale depth map into a mask when the source data is just an image with the information baked into a channel.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| channel | COMBO | red | 4 options: red, green, blue, alpha |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| mask | MASK | — |