Draw Mask On Image
See your mask. Actually see it, in color, on the image
- image
- mask
- images
Every mask workflow hits the same moment of doubt: is the mask actually where I think it is? A mask is invisible data - a tensor of floats you can't see until you do something with it. DrawMaskOnImage_lhy answers the question directly: it paints the masked region of your image in a solid color so you can look at it. Red means "this will be re-rendered," black means "this stays." That one glance catches more bad inpaint runs than any setting.
It's from the ComfyUI-lhyNodes pack, and it's the visualization half of the pack's mask toolchain - the WanAnimate mask preprocessor in the same pack uses the same color-fill approach to show you what's masked before video generation, and this node is that drawing logic as a standalone utility.
How it works
Straightforward math under the hood. For every pixel it blends the image toward your chosen color by the mask's intensity: result = image * (1 - mask*alpha) + color * (mask*alpha). A hard white mask gives a full-color fill; a soft, feathered mask gives a translucent tint, which is honestly useful for spotting weak regions. If the mask resolution doesn't match the image, it's resized to fit with bilinear interpolation. RGBA images get the color blended into RGB and the alpha channel maxed where the color was applied, so it composes cleanly downstream.
The color string is flexible: "0, 0, 0" (RGB, 0–255), "255, 0, 0, 128" (RGBA, where the fourth value sets blend opacity), or hex like "#ff0000".
Inputs and outputs
image(IMAGE) - the image you're inspecting, or a whole batch.mask(MASK) - what to paint. If it's a single mask and your image is a batch, the mask applies to every frame.color(STRING, default"0, 0, 0") - the fill color. The default is black, which reads as "erased" - change it to a bright red or green for a better visual.device-cpu/gpu, defaults tocpu.
One output: images (IMAGE), the image with the mask drawn on, sized to the source.
Installing it
Part of the ComfyUI-lhyNodes pack:
- ComfyUI Manager → search
lhyNodes→ Install, restart. - Or:
cd ComfyUI/custom_nodes
git clone https://github.com/lihaoyun6/ComfyUI-lhyNodes.git
python -m pip install -r ComfyUI-lhyNodes/requirements.txt
Restart ComfyUI afterward.
Where people get burned
Two gotchas, both about the color field. First, it's parsed at runtime - "0,0,0" without spaces works, but garbage text gets coerced to whatever floats parse and you can get a silent wrong color, so keep it in the r, g, b or #rrggbb format. Second, there's no threshold: this respects mask intensity, so a semi-transparent mask paints a semi-transparent color. If you want a hard "where does the mask begin" picture, run the mask through a threshold/round first. Wire the output into a Preview Image or Save node - it's not an output node itself, so don't forget to attach something that shows you the result.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| mask | MASK | — | |
| color | STRING | 0, 0, 0 | — |
| deviceopt | COMBO | cpu | 2 options: cpu, gpu |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| images | IMAGE | — |