Nodes/MTB Nodes/Mask To Image (mtb)
ComfyUI Node Runs on cloud

Mask To Image (mtb)

Turn a mask into a colored, visible image

By melMass·Created 3 years ago·Updated about a month ago· 721
Mask To Image (mtb)
  • mask
  • color
  • background
  • IMAGE
invertfalse

Masks are single-channel and, frankly, a pain to look at while you're building a graph - a preview of one is just a grayscale smear that's easy to misread. Mask To Image turns that mask into a proper RGB image you can actually see, and it does one thing the built-in version doesn't: it lets you pick the colors. The masked region becomes one color, everything else becomes a background color of your choosing.

That sounds cosmetic, but it's genuinely useful in two ways. First, debugging - paint your mask bright magenta on black and you'll instantly spot where the edges landed. Second, it's a quick way to generate a flat colored fill in the shape of a mask, which you can then composite, use as a solid background, or feed anywhere that wants an image instead of a mask.

How it works

The mask acts as an alpha: wherever it's white (1.0), the node fills your color; wherever it's black (0.0), it fills background; soft grey values blend between the two. So a feathered mask gives you a soft-edged color transition, not a hard cutout. That's it - no model, no VRAM, instant.

The inputs and outputs that matter

  • mask (MASK) - the mask you're visualizing or filling.
  • color (COLOR) - what the masked (white) area becomes.
  • background (COLOR, default #000000) - what the rest becomes.
  • invert (optional, default false) - flips which region gets color. If the wrong half is painted, tick this instead of re-plumbing.

Output is a single IMAGE. Send it to a Preview to eyeball a mask, or into a compositing/blend node if you're using it as a color fill.

How to install it

Via ComfyUI Manager: search MTB Nodes, install, restart. Or manually:

cd ComfyUI/custom_nodes
git clone https://github.com/melMass/comfy_mtb

then restart. This is a pure-Python node - no models, no heavy dependencies, nothing to download. It loads with the base pack. (Heads up: MTB's master branch is deliberately kept a bit behind while the author works on the next version in dev/0.6.0, so what you install is the stable-but-older set. Fine for a node this simple.)

Common issues & troubleshooting

The wrong area is colored. Use invert. Masks get flipped all the time upstream and this is the one-click fix.

Edges look soft when you wanted hard. That's the mask, not this node - it's faithfully blending your grey pixels. Threshold or sharpen the mask before this if you need a crisp cut.

You just want a grayscale mask preview. ComfyUI core has a plain Mask-to-Image that does exactly that with no color options. Reach for MTB's version specifically when you want the color control - otherwise the built-in is one less thing.

Categorymtb/generate

Inputs (4)

NameTypeDefaultDescription
maskMASK
colorCOLOR
backgroundCOLOR#000000
invertoptBOOLEANfalse

Outputs (1)

NameTypeDescription
IMAGEIMAGE