CV Overlay Masks
See your masks before you trust them — color every one differently, in one node
- masks
- image
- overlay
Every mask pipeline in ComfyUI has the same debugging moment: you've got a MASK batch out of Connected Components or a K-Means cluster step, and you cannot tell by looking whether you have six regions or six hundred, or whether region 3 is the subject or the shadow. CV Overlay Masks answers that in one node - each mask in the batch gets its own color, painted over your image at a chosen opacity.
It's a visualization node, deliberately. The pack's own convention is that data nodes never draw and drawing nodes never produce data, so you choose what gets rendered and what stays data - with CV Array Statistic and friends doing the measuring and this node doing the looking. The counterpart for boxes is core's Draw BBoxes, which the author points you to rather than duplicating.
What goes in, what comes out
Three inputs, two of which you'll touch:
masks- the MASK batch. Each frame gets a distinct color, so a batch of 12 blobs looks like a color-coded map instead of a white smear.opacity- 0.6 by default. Cranking it toward 1 hides the underlying image; dropping it toward 0 makes the regions whisper. 0.4–0.7 is the useful band, and the reason it's a widget at all is that a mask debug view is usually about where the edges are, which you read off the half-transparent boundary.image- optional. Give it a background and the colors composite over that; leave it unconnected and you get the masks on black. On black is often better for judging mask shape, and over the image is better for judging mask semantics.
One output: overlay, an IMAGE you can preview, save, or stack next to the source. Masks are fitted to the background's size internally, so a mask batch that came from a differently sized branch still draws.
Why this matters more than it sounds
The single most common failure in background removal and segmentation workflows is silently wrong masks - a hole where the hair meets the sky, a blob that includes the shadow, one component out of nine being the actual subject. Those don't announce themselves; they show up as a bad composite three nodes later. A color-coded overlay turns "the matte looks a bit off" into "component 7 is the shadow, kill it."
The post-processing layer exists on the same principle: reach for the millisecond deterministic operation before you burn a diffusion pass. Looking at your masks is the cheapest operation in the whole pack.
Install
Manager → search ComfyUI CV, or:
cd ComfyUI/custom_nodes
git clone https://github.com/bmad4ever/comfyui_cv
cd comfyui_cv && pip install "opencv-contrib-python-headless~=5.0.0.93"
Restart. Python ≥ 3.12 and a ComfyUI on the V3 node API. This node itself only needs numpy and plain cv2, but the pack as a whole declares the contrib headless wheel and is curated against 5.0.0.93.
Common issues
- A single flat color and you see one region - your batch really is one mask, or everything upstream collapsed into one component. Check
countwherever the masks came from. - Colors too similar to tell apart - that's the palette cycling through many masks. Pass fewer, merged masks (most segmentation nodes have a merge option) or inspect in groups.
- The overlay is the size of the background, not the mask - intended; masks are fitted to the background so everything lines up.
- Contrib nodes missing from the pack entirely - a non-contrib OpenCV wheel has emptied the contrib submodules.
tools/repair_opencv_contrib.py --checkin the pack diagnoses it;--applyrepairs.
The pack's README says plainly that it's LLM-assisted, personal, and not production-verified. For a debug visualization, that's about as low-stakes as this pack gets.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| masks | MASK | MASK batch; each mask gets its own color. | |
| opacity | FLOAT | 0.600–1 | Color opacity over the background. |
| imageopt | IMAGE | Background to draw on; black if omitted. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| overlay | IMAGE | — |