Mask to Image 🦾
Turn a mask into something you can actually see (and save)
- mask
- color
- background
- IMAGE
A mask is just a grayscale float tensor - technically useful, completely unreadable when you're trying to eyeball whether your subject is actually covered. Mask to Image exists to make it visible: it renders the mask as an RGB image where the masked area gets one color and the background another. Feed the output to a Preview Image or Save Image node and you finally see what your inpainting/conditioning setup is actually targeting.
It also quietly does something more useful than visualization: it converts a MASK into an IMAGE, which matters because a bunch of downstream nodes and tools only accept images. Need to hand your mask to something that wants an RGB tensor, or save it as a real file? This is the bridge.
How it works
The mechanism is trivial in the best way. The node takes your mask tensor, converts it to grayscale, and uses it as an alpha channel to composite a solid color over a solid background. Masked areas (white, value 1) become color; unmasked areas become background. The optional invert toggle flips the mask before compositing, which is handy because ComfyUI convention ("white = active region") isn't the same as every other tool's.
The inputs that matter
mask(required) - the MASK tensor to render.color(required) - the foreground color for the masked region. A COLOR picker, so you can click it open and choose.background(required, default#000000) - what the rest of the image becomes. Leave black for maximum contrast.invert(optional, default false) - flips which side getscolor.
Output: IMAGE - the rendered RGB tensor, ready for Preview Image, Save Image, or any image-only consumer.
One nice touch: it handles batched masks, so a stack of masks renders as a batch of images, not one.
Install
Part of the ComfyUI-Beyond_nodes pack. In ComfyUI Manager search "Beyond_nodes" and install, then restart. Manual route:
cd ComfyUI/custom_nodes
git clone https://github.com/beyondprompting/ComfyUI-Beyond_nodes
Restart and you're done - no extra pip packages, the pack only needs what ComfyUI already ships.
Common issues
- Everything is one flat color. That means your mask is binary all-or-nothing (fine) or - more likely - you've plugged the wrong mask in and it's all zeros or all ones. Check it with a Preview Image after rendering.
- Colors look "wrong." There's no meaning attached to
color; you chose it. Pick white-on-black and it'll read like a textbook mask. - You wanted the opposite. Reach for
invertrather than a separate invert node. That's exactly what the toggle is there for.
For anything fancier - colored alpha overlays, RGBA output, mask-to-image with feathering - the WAS Node Suite has heavier hitters. But for a quick "show me the mask" this node is the whole job in three clicks.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| mask | MASK | — | |
| color | COLOR | — | |
| background | COLOR | #000000 | — |
| invertopt | BOOLEAN | false | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |