图像遮罩丨预览
Finally, a mask preview that's actually readable
- image
- mask
- preview
- image
- mask
The worst part of working with masks in ComfyUI isn't making them - it's seeing them. A raw mask is a black-and-white blob on a black background, and good luck telling whether that blob actually hugs the subject's hairline. ImageMaskPreview fixes that with a colored, semi-transparent overlay you can actually read: pick any of nine colors, dial the opacity, and see the mask the way a Photoshop user sees a selection.
It's from ComfyUI-QING (display name "图像遮罩丨预览"), and it's the preview node you'll wish you'd had before you spent twenty minutes squinting at a preview of a grayscale mask.
How it works
The node does three things depending on what you give it:
- Image only → shows the image unchanged.
- Mask only → renders the mask as a solid color (no image behind it).
- Image + mask → composites the colored mask over the image at the opacity you set. This is the mode you'll actually use.
The inputs that matter:
image(optional) - your image.mask(optional) - the mask you want to inspect.mask_alpha- opacity of the mask overlay, 0–100, default 50. 0 is invisible, 100 is a solid color covering the image.mask_color- the overlay color, from nine choices: 黑 (black), 白 (white), 赤 (red), 橙 (orange), 黄 (yellow), 绿 (green), 青 (cyan), 蓝 (blue), 紫 (purple). Default is purple, which is a sensible choice - purple reads well over almost anything.
It's flagged as an output node, so the preview renders in the UI the moment the graph runs. And it passes everything through: the outputs are preview (the composite), plus image and mask passthroughs, so you can insert it in the middle of a wire without breaking the flow - preview here, keep sending the same image and mask onward.
Where this fits in a real workflow
Any mask-heavy pipeline. That's the short answer. Whether the mask came from a segmentation model, an alpha channel you extracted, or a hand-drawn selection, you want to see it before you burn a sampler pass on it. The masking-detection-detailing playbook is full of "the seam shows because the mask was wrong" stories - this node is the cheap insurance against those. A mask that looks right in grayscale often turns out to be bleeding past the subject's outline; the colored overlay makes that bleeding obvious in one glance.
The color choice isn't cosmetic, either. Purple over skin tones, green over foliage, red when you're checking against a blue background - the point is contrast, and having nine options means you can usually find one that makes the mask legible against whatever your image is.
Installing
Part of ComfyUI-QING, so it appears with the whole pack. ComfyUI Manager: search "ComfyUI-QING". Or by hand:
cd ComfyUI/custom_nodes
git clone https://github.com/GAO-SHIQING/ComfyUI-QING
cd ComfyUI-QING
python install_dependencies.py # or: pip install -r requirements.txt
Restart ComfyUI. Plain pip deps (Pillow, opencv-python, scipy, scikit-image, cairosvg), no models. China mirror: --mirror --auto. Python ≥ 3.9, current ComfyUI.
Gotchas
If you feed it neither image nor mask, it renders a placeholder image that says "无输入" (no input) - a helpful nudge rather than an error, but it does mean an empty preview is a wiring problem, not a crash. Also note that with a mask-only input there's no image behind the color, so the overlay may look solid until you lower mask_alpha. And because it's an output node that always runs, a preview left in a hot loop can slow large batch runs - drop it in while you're inspecting, bypass it when you're generating for real.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| mask_alpha | INT | 500–100 | — |
| mask_color | COMBO | 紫 | 9 options: 黑, 白, 赤, 橙, 黄, 绿, +3 |
| imageopt | IMAGE | — | |
| maskopt | MASK | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| preview | IMAGE | — |
| image | IMAGE | — |
| mask | MASK | — |