Image to Mask
Make a mask from an image's brightness, with a safe fallback
- image
- mask
Sometimes the easiest mask is hiding in plain sight: the brightness of an image. A white studio background is bright, your subject is dark - so the luminance of that image is a usable mask. Image to Mask does the conversion: it takes an image, computes the standard luminance weights (0.299·R + 0.587·G + 0.114·B, the same Rec. 601 math every grayscale converter uses), and outputs a grayscale MASK.
The second half of its personality is what makes it interesting in a graph: if you leave the image input empty, it outputs a 64×64 black mask instead of erroring. That's a deliberately designed fallback for optional branches - the workflow keeps running, and downstream mask ops get a harmless all-black input rather than a crash.
How it works
One input, one output, no knobs. image (optional) → mask. If the image has a single channel it's used directly; if it's RGB, luminance weighting applies; batch sizes and dimensions carry through. When image is unconnected, you get that single 64×64 black mask.
That's the whole thing. It's a utility node, not a feature stack - and it's useful precisely because it's boring.
Install
Ships in ComfyUI-1hewNodes:
cd ComfyUI/custom_nodes
git clone https://github.com/1hew/ComfyUI-1hewNodes
Restart ComfyUI. No models, no dependencies beyond the pack's base install.
Where it fits
- Guide images into masks - a grayscale depth map, a brightness gradient, a rendered shadow pass: all of these convert straight into something a mask node will eat.
- Safe fallback branches - this is the real reason the 64×64 fallback exists. Build an "if this image exists, use it, else black mask" pattern and let the graph stay green.
- Compositing prep - pair the output with
Image Mask Blendfrom the same pack when you want a luminance-keyed blend rather than a hand-drawn mask.
Common issues
- The fallback is 64×64 - if you're feeding a "no image" result straight into an operation expecting your full canvas size, the 64×64 mask won't match. It's a placeholder, not a canvas-sized black mask. Resize it (the pack's
Image Resize Universalis right there) if you need it to fill. - Colored images make gray masks - luminance conversion collapses color to brightness, so a red-on-blue design becomes a mid-gray mush. If you need color-based separation, you want a different tool; this one only sees light.
Honest verdict: you won't build a workflow around this node, but when an image-branch needs to feed a mask slot and shouldn't hard-fail on empty input, it's exactly the right five-second fix.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| imageopt | IMAGE | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| mask | MASK | — |