Nodes/ComfyUI-Utility-Suite/SEGS Overlap to MASK
ComfyUI Node

SEGS Overlap to MASK

Turn where your tiles collide into an actual mask

By tom-m-2020·Created about a month ago·Updated 7 days ago· 1
SEGS Overlap to MASK
  • segs
  • segs
◄keep_original_maskfalse►
◄compare_mode▾►
◄cap_overlap_to0►
◄invertfalse►

Every tiled pipeline creates a second image nobody looks at: the map of which pixels got covered twice. Tiled diffusion handles that internally with blending weights. Hand-rolled pipelines don't, which is why seams happen. This node makes that map explicit and hands it back inside the SEGS - each entry's cropped_mask gets replaced with a hard local mask of where that tile's crop region overlaps its neighbours' crop regions.

That's a rewiring of what the SEGS mean, so read the next paragraph before you use it: the crop regions, bboxes and any stored images are untouched, but the mask field you were relying on is gone unless you tell the node to keep a piece of it.

Inputs and what each one really does

  • segs - the tile SEGS.
  • compare_mode - all_segs compares every entry against every other, so the result is symmetric: a pixel in the overlap of tiles A and B is marked in both. previous_segs compares each entry only against entries earlier in the list, which makes the result asymmetric - tile 5 knows it overlaps tile 2, tile 2 doesn't know about tile 5. That's the setting you want when you're compositing in order and should blend each new tile away from the ones already laid down, but it means order is now part of your maths, which is what Reorder SEGS is for.
  • cap_overlap_to - 0 by default, meaning no cap: the whole intersection is marked. Set it and each overlap band is trimmed to at most that many pixels, measured from the current entry's own edges. Only edges the overlap actually touches get capped, so an intersection floating in the middle of a tile is left whole. The point of capping is to stop a large overlap from making an enormous mask; a 200px overlap doesn't need a 200px blend band.
  • invert - flips the mask. You get everything except the overlap, which is the mask you want if you're assigning the shared band to one specific pass rather than both.
  • keep_original_mask - off by default, and worth understanding what it does when on: the overlap mask is intersected with the entry's original cropped mask. Since this node needs that original mask to be present, it raises if it isn't. In practice that's "keep the subject's shape, restricted to the overlap", which is a much more useful mask than a raw rectangle for anything downstream that samples.

Output is SEGS, same entries, rewritten masks. Output is hard-edged - 0 or 1, no ramp - which is deliberate, and means you'll want a blur or feather node after it if you're compositing rather than masking a pass.

Why you'd reach for it

Three honest cases:

  1. Hand-rolled tile blending. Where tiles overlap you often want one more low-denoise pass concentrated on the seam. This gives you the seam as a mask per tile.
  2. Seeing the collision map. Run it, invert it, paste it - now you know whether your overlap setting is producing a 16px band or a 200px swamp. That's the same argument as Preview SEGS Regions, one level of detail down.
  3. Order-aware compositing. previous_segs plus Reorder SEGS plus ascending paste order is a legitimate way to build a tile composite where each tile only blends into what came before.

Caveat, said plainly: this is the fiddliest node in the pack. It rewrites a field you may be using elsewhere, it has an order-dependence mode, and its cap semantics only apply on touching axes. If you're not blending tiles by hand, you don't need it.

Install

Manager: search ComfyUI Utility Suite (publisher tom-m) → install → restart. Or:

cd ComfyUI/custom_nodes
git clone https://github.com/tom-m-2020/ComfyUI-Utility-Suite

No models; the pack's only requirement is opencv-python-headless, which this node doesn't need (NumPy and the pack's own geometry helpers do the work). Keep ComfyUI current - the pack targets the V3 node API, so an outdated install shows no Utility Suite/* nodes at all.

Troubleshooting

"SEGS entry N has no cropped_mask for keep_original_mask." The incoming SEGS don't carry masks - some detectors emit bbox-only regions. Turn the option off, or use a source that provides masks.

My subsequent node now sees a rectangle where the subject was. Expected, and the reason keep_original_mask exists. Without it you've replaced the subject mask with a geometric overlap band.

Overlaps came out asymmetric. That's previous_segs. Switch to all_segs, or accept that processing order is now load-bearing and pin it with Reorder SEGS.

The mask is huge. cap_overlap_to is the dial. A blend band wider than a few dozen pixels rarely improves a seam.

CategoryUtility Suite/SEGS

Inputs (5)

NameTypeDefaultDescription
segsSEGS—
keep_original_maskBOOLEANfalse—
compare_modeCOMBO2 options: all_segs, previous_segs
cap_overlap_toINT00–32768—
invertBOOLEANfalse—

Outputs (1)

NameTypeDescription
segsSEGS—