Split Mask (Yogurt Nodes)
Connected components for repaint workflows
- mask
- masks
- mask_info
Split Mask answers a question you've definitely hit while inpainting: "I painted a mask that covers three separate objects - how do I treat them as three separate jobs?" This node does exactly that, via connected-component analysis. It takes one mask (or a batch) and splits it into one mask per distinct blob, so each region can be repainted, cropped, or processed on its own.
Here's the mechanism, in plain terms. The node looks at your mask at a given threshold, finds every connected group of "on" pixels, and returns them as separate items in a mask batch. Each connected component becomes its own mask. Alongside the masks, mask_info comes out as a dict with per-component metadata - which is what you feed into the pack's region planner/cropping/compositing nodes (Mask Region Planner, Crop Image By Regions, Composite Repaint Regions) that form its little repaint region system.
The inputs that do the work
- threshold - 0.5 default. Pixels below this value count as background. If your mask is soft-edged, this decides what's "in" the component; raise it to ignore faint coverage.
- min_area - 16 default. Blobs smaller than this get dropped. This is your noise filter: speckles and anti-aliased fuzz vanish, real regions survive. Raise it when the mask picks up thousands of micro-dots.
- connectivity -
8or4. 8-connectivity treats diagonally-touching pixels as one blob; 4 requires edge adjacency. For loose hand-painted masks, 8 is usually right. Switch to 4 when two touching regions keep merging that you want kept apart. - close_radius - 0 default. Morphological closing radius. This one's the merge tool: it bridges narrow gaps so a mask with a thin separation collapses into one component instead of two. Set it when your blobs are connected only by a hairline and you want them unified.
- mode -
split_components(the star feature: split every blob into its own mask) orpreserve_batch(keep the input batch structure, still do the analysis per mask).
Outputs: masks (the split batch) and mask_info (the dict of per-component metadata).
Where it shines
The classic use is regional repainting. Split a full-mask into per-object masks, repaint each at native resolution with its own prompt - faces, hands, text, whatever - then composite the results back. That's the workflow the pack's repaint-region nodes are built around, and Split Mask is where the whole thing starts. It's also handy for cleanup: drop tiny components with min_area and you've cleaned a noisy selection without touching a paint tool.
Install
One pack, one install, as always:
cd ComfyUI/custom_nodes
git clone https://github.com/yogurt7771/ComfyUI-YogurtNodes.git
cd ComfyUI-YogurtNodes
pip install -r requirements.txt
or ComfyUI Manager → ComfyUI-YogurtNodes → install → restart. Under Yogurt Nodes → Masks.
The trap
The threshold interacts with everything. A soft mask at threshold 0.5 can look one way, then split into radically different component counts at 0.7 - faint regions vanish and components fragment. If your split comes out with ten pieces where you saw three, lower the threshold or raise min_area before you blame the node. And if preserve_batch isn't doing what you expect, remember it preserves the input's batch shape; the per-batch analysis still applies.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| mask | MASK | Input mask or mask batch. | |
| threshold | FLOAT | 0.500–1 | — |
| min_area | INT | 160–1048576 | — |
| connectivity | COMBO | 8 | 2 options: 8, 4 |
| close_radius | INT | 00–128 | — |
| mode | COMBO | split_components | 2 options: split_components, preserve_batch |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| masks | MASK | — |
| mask_info | DICT | — |