Nodes/Pseudocomfy/Aggregate Masks
ComfyUI Node

Aggregate Masks

Fold a whole list of region masks into one, five ways

By Pseudotools·Created 2 years ago·Updated 20 days ago· 4
Aggregate Masks
  • msks_list
  • msk
operation
invertfalse

Regional prompting hands you a list of masks - one per material, per region, per object - and sooner or later you need them to stop being a list. You want the union of "where is anything happening," or the overlap, or a single combined region to feed something that accepts one mask. Aggregate Masks does the fold: it takes a whole list of masks on one wire and returns a single combined mask.

The code traces back to the Impact Pack lineage (Pseudocomfy's README credits ltdrdata's pack for the adapted mask utilities), and it's the same spirit: unglamorous, universally useful, no models involved.

The one choice that matters: operation

Five operations, and they behave differently enough that picking wrong gives you subtly wrong results:

  • sum_clamped - adds all masks and clamps to [0, 1]. Where any region is white, the result is white; where several overlap, it stays 1.0 (no brightness stacking). The default mental model for "union."
  • sum_normalized - adds all masks then normalizes the sum across the image, so the brightest areas map to 1.0 and dimmer overlaps stay proportional. Different feel: the strongest overlap becomes the peak.
  • average - the pixelwise mean. Overlaps stay mid-gray instead of saturating. Good when you want a soft, blended region rather than a hard union.
  • max - each pixel takes the brightest value across all masks. A true union with no softening; the composite keeps every mask's hardest edge.
  • min - each pixel takes the dimmest value. Only pixels white in every mask stay white: the strict intersection.

There's also an invert toggle (default off) that flips the combined result - 1 - mask - so "union of regions" becomes "everything except the regions," which is exactly what you want when the combined mask is destined for a background pass.

Practical notes

  • Input is msks_list (a MASK list - wire it from PseudoUnpackModelSnapshot or PseudoProcessMaterialPrompts), output is a single msk. All masks must share the same dimensions; stacking will fail loudly if they don't.
  • sum_clamped is the safe default for most "give me one mask of the whole scene" jobs. Reach for max when you need hard edges preserved, average when you want feathering, min when you genuinely need the intersection.
  • The inverted result isn't clamped to a range in all paths, so if you're feeding it to a picky node, run it through PseudoMaskClamp afterward.

It's a compact node that earns its place because list-to-single conversions are the kind of thing that otherwise becomes three reroute nodes and a headache. Pack-standard install: clone Pseudocomfy into custom_nodes and restart, or grab it from Manager.

CategoryPseudocomfy/Utils

Inputs (3)

NameTypeDefaultDescription
msks_listMASK
operationCOMBO5 options: sum_clamped, sum_normalized, average, max, min
invertBOOLEANfalse

Outputs (1)

NameTypeDescription
mskMASK