Jags-CombineMasks
Merge two or three masks into one — and preview it as a heatmap
- input_image
- mask_1
- mask_2
- mask_3
- Combined Mask
- Heatmap Mask
- BW Mask
Sometimes one mask isn't enough. Your subject is "person sitting on a chair" and your text-segmentation node nailed the person but clipped the chair. Or you've masked a face and hair separately and you want a single mask that covers both. Jags-CombineMasks is the two-second glue: it takes two masks - optionally a third - and unions them into one, with a heatmap preview so you can see what you actually got.
It's the natural companion to Jags-Clipseg in the same pack, but it doesn't care where the masks came from. Any two MASK tensors work: CLIPSeg output, a hand-painted mask, output from any other segmentation node. That's the whole job - combine, preview, hand off.
How it works
Simple and transparent. It adds the masks together: mask_1 + mask_2, plus mask_3 if you've wired it. If the masks overlap, that overlap region sums to a value above 1.0 in the combined mask. In practice ComfyUI mask consumers handle that fine (they treat anything nonzero as "masked"), but it's worth knowing if you feed the result somewhere that expects a strict 0–1 range.
The other two outputs are previews, not afterthoughts. The node takes your original image, renders the combined mask as a viridis heatmap overlay and as a black-and-white overlay, resizes them to match your image, and blends them on - heatmap at 50% opacity, BW at full. So you wire in the input image and the masks, and you get a visual check of what's covered without a separate preview node.
Inputs and outputs
- input_image (required) - used as the background for the preview overlays. The combined mask itself doesn't depend on it, but the node needs it for the heatmap/BW outputs to make sense.
- mask_1, mask_2 (required) - the masks to combine.
- mask_3 (optional) - a third mask if you need it. Leave it unwired and it's skipped.
Outputs:
- Combined Mask (
MASK) - the union, wire this into your inpainting/masking pipeline. - Heatmap Mask (
IMAGE) - viridis overlay preview. - BW Mask (
IMAGE) - black-and-white overlay preview.
Where it fits in a workflow
The classic pattern: two Jags-Clipseg nodes running different prompts on the same image, both feeding this node, and the combined MASK going into Set Latent Noise Mask ahead of a KSampler. "Face" + "hair" → one mask → inpaint the whole head region in one pass. Or combine a CLIPSeg mask with a hand-drawn mask when the model's segmentation and your intent disagree.
Installing it
Same pack, same drill: ComfyUI Manager → search Jags_VectorMagic → install → restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/jags111/ComfyUI_Jags_VectorMagic
You don't need any model weights for this node - it's pure tensor math and PIL overlays - but the pack installs its full heavy requirements list anyway (ultralytics, librosa, clip-interrogator, opencv-python, …), which is the main friction if you're only here for mask combining.
Gotchas
- Mask size mismatch. If your two masks are different resolutions, the sum just broadcasts or fails depending on shapes. Keep masks at the same resolution - run both through the same-size pipeline.
- The preview needs the image. Leave
input_imageunwired and the heatmap/BW outputs will fail, even though the combined mask itself computes fine. - It's an older pack. The README labels the whole repo work-in-progress, so if ComfyUI's frontend updates break things, check the repo for fixes before assuming your workflow is wrong.
For "I have two masks and I want one mask with a look at it" - that's the node. Three masks if you're greedy.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| input_image | IMAGE | — | |
| mask_1 | MASK | — | |
| mask_2 | MASK | — | |
| mask_3opt | MASK | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| Combined Mask | MASK | — |
| Heatmap Mask | IMAGE | — |
| BW Mask | IMAGE | — |