Nodes/comfyui_gr85/Mask Splitter
ComfyUI Node

Mask Splitter

Breaking one mask into its separate islands, with bounding boxes

By veighnsche·Created 2 years ago·Updated 8 months ago· 1
Mask Splitter
  • input_mask
  • processed_masks
  • bbox_metadata
size_threshold128

Mask Splitter is the other half of the reconnect job Mask Connect MST does - where that node stitches scattered regions into one shape, this one takes a mask with multiple disconnected blobs and pulls them apart into individually addressable pieces. Feed it a mask that contains, say, three separate detected regions, and you get back each region as its own entry, plus a bounding box for each one. That's the shape you want any time you need to process detected regions independently rather than as one lump - running a detail pass per-face instead of one pass across a whole group shot, for instance, or handing each region off to the pack's own Mask Batch to SEGS node one at a time.

The one knob that matters. size_threshold (32–512, default 128, step 32) filters out regions below that size - the schema doesn't document the exact unit, so treat it as roughly "islands this small are noise, drop them" rather than reading it as a precise pixel-area or side-length spec. It exists for the same reason drop_size exists on Mask Batch to SEGS: without it, a handful of stray pixels from a noisy upstream mask turn into a batch of useless micro-regions downstream.

Outputs. processed_masks - plural, which is the tell that this comes back as a batch of individual island masks rather than one combined mask, even though ComfyUI's type system doesn't distinguish that in the schema itself. bbox_metadata is the matching bounding box for each surviving island, in Impact Pack's BBOX format - which means it slots straight into anything expecting BBOX, including the pack's own Sam2Segmentation node's optional bboxes input if you want to re-segment each island more precisely, or any Impact Pack detector-consuming node.

Installing it. No different from the rest of comfyui_gr85: find it by name in ComfyUI Manager, or clone it manually -

cd ComfyUI/custom_nodes
git clone https://github.com/veighnsche/comfyui_gr85
  • and restart. Connected-component extraction like this is typically a scipy.ndimage.label or skimage job under the hood; nothing here should need a model download, just make sure whatever image-processing dependency it leans on actually installed (check the ComfyUI console on startup if the node fails to import).

Common trip-ups. size_threshold set too high will quietly eat real small regions along with the noise - if your processed_masks batch has fewer entries than you expected, that's the first thing to turn down. And because the output is a batch rather than a Python list, some downstream nodes that expect a true list (rather than a stacked tensor) may not accept it directly - if you hit a shape-mismatch error piping this into something unusual, a batch-to-list conversion node in between is the usual fix for that class of problem across ComfyUI generally, not something specific to this node.

CategoryGR85/Mask

Inputs (2)

NameTypeDefaultDescription
input_maskMASK
size_thresholdINT12832–512

Outputs (2)

NameTypeDescription
processed_masksMASK
bbox_metadataBBOX