SEGS Merge
Collapse a pile of detections into one combined region
- segs
- segs
Detectors are greedy. Point a face detector at a group photo and you get a SEGS batch with a dozen overlapping bounding boxes where a human would see one "group of people." XJSegsMerge is the node that says "fine, treat all of that as one thing" - it takes a SEGS stream and merges every segment into a single combined SEG, with a bounding box that covers all of them and a mask that ORs them together.
The merge rules are the interesting part, because they're sensible rather than naive:
- Crop region and bbox cover the union of all input segments, so the merged region spans the whole group.
- The mask is the OR of every input mask, projected into that union region - if any segment covered a pixel, the merged mask covers it.
- Confidence is the maximum across all segments.
- Label comes from the most confident segment (defaulting to
"merged"if confidence is missing).
Note the output is still a SEGS tuple - it just contains exactly one SEG. That's deliberate, so it can plug straight back into anything that expects SEGS, including an Impact Pack Detailer. If you feed it empty SEGS, it passes them through untouched rather than erroring.
The interface is a single pair:
segs- SEGS in.- Output:
segs- SEGS containing one merged SEG.
When you'd reach for it: any time the object you care about spans multiple detections. A face detector that fires multiple boxes on one face, an object that got split across segments by a SAM pass, or a group shot where you want one detail pass over everyone rather than a dozen tiny passes. Merging first also saves the detailer from wasting cycles on heavily overlapping crops. It pairs naturally with the pack's Dilate Mask Expand and Refine nodes to clean up the merged mask afterward.
Install is the standard pack routine:
cd ComfyUI/custom_nodes
git clone https://github.com/alexjx/ComfyUI-XJNodes
Restart ComfyUI, find it under XJNodes/segs, or install via ComfyUI Manager by searching "ComfyUI-XJNodes". No model downloads; requirements.txt is empty. The dependency is conceptual again - SEGS is Impact Pack's format, so this node lives inside that ecosystem.
Worth knowing before you rely on it: it's a personal-use pack with a tiny footprint, so behavior like "empty SEGS passes through" is the author's choice, not a documented contract. It's simple enough that the source is easy to read if you ever need to verify what it'll do to your data.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| segs | SEGS | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| segs | SEGS | — |