Pixelwise(SEGS - SEGS)
Keep only where two detections actually overlap
- base_segs
- mask_segs
- SEGS
The display name says "subtract," but read the pack's own description closely and the behavior is a little sharper than that: Pixelwise(SEGS - SEGS) "removes only the overlapping areas between the masks included in base_segs and the mask regions of mask_segs. SEGS with no overlapping mask areas are filtered out." So it's not a blanket subtraction across everything - it's a per-region overlap trim, and anything in base_segs that never touches mask_segs at all disappears from the output entirely rather than passing through unchanged.
This is one of Impact Pack's pixelwise SEGS-operation nodes, sitting alongside the AND and OR variants the README documents for combining detections. Use it when you've got two detectors finding different things and you specifically want to erase the parts of one detection set that another detection set also claims - hand-vs-face overlap, a body silhouette carving into a face-only detection, that kind of region math.
How it works
For each SEG in base_segs, the node checks whether its mask overlaps any region in mask_segs. Where there's overlap, that overlapping pixel area is cut out of the base SEG's mask. Where there's no overlap at all for a given base SEG, that SEG is dropped from the result rather than kept intact - so this node does double duty as both a mask trimmer and an implicit filter. If you expected base_segs entries with zero overlap to survive untouched, that's the detail to unlearn: they don't survive, they vanish.
The inputs and output
base_segs(SEGS, required) - the detections you're trimming. Each entry gets its mask reduced by whatever overlapsmask_segs, or gets dropped if there's no overlap at all.mask_segs(SEGS, required) - the detections defining what to cut away.
Output is a single SEGS - the trimmed (and possibly shorter) result, ready to feed into a detailer, a preview, or any other SEGS-consuming node downstream exactly like an ordinary SEGS output.
How to install it
Via ComfyUI Manager: search ComfyUI Impact Pack, install, restart. Manually:
cd ComfyUI/custom_nodes
git clone https://github.com/ltdrdata/ComfyUI-Impact-Pack comfyui-impact-pack
cd comfyui-impact-pack
python -m pip install -r requirements.txt # ComfyUI's python; python_embeded on portable
then restart. No models needed for this node specifically - you'll need whatever detector produced base_segs and mask_segs in the first place (a BBOX Detector (SEGS), SEGM Detector (SEGS), or similar), which is a separate part of your graph.
Common issues & troubleshooting
My output SEGS has fewer entries than I expected. That's the filtering behavior, not a bug - any base SEG with zero overlap against mask_segs gets dropped entirely, not passed through untouched. If you wanted non-overlapping regions preserved as-is, this is the wrong node; you want the plain SEGS-and-mask intersection tools, or to route non-overlapping cases around this node separately.
Result is empty SEGS. Check that base_segs and mask_segs are actually detecting overlapping regions in the same image space. Two SEGS from detectors run on differently-sized or differently-cropped images won't align correctly, and you'll get no meaningful overlap even if visually the objects seem related.
Not sure this is the node you want. If you want to keep everything in base_segs and just trim the overlapping part - with non-overlapping SEGs surviving unchanged - double check this node's exact behavior against your case first, since the "drop non-overlapping SEGs" step is easy to miss when skimming the node's name alone.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| base_segs | SEGS | — | |
| mask_segs | SEGS | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| SEGS | SEGS | — |