Mask Connect MST
Stitching scattered mask islands back into one shape
- mask
- split_mask
- MASK
Mask Connect MST does the opposite job of the pack's Mask Splitter (and, in a roundabout way, its Island Mask Generator): where those two pull a mask apart into separate disconnected regions, this one puts scattered regions back together. Feed it a mask with multiple disconnected white blobs - "islands" - and it draws the minimum set of connecting lines needed to join every island into one continuous shape. "MST" is minimum spanning tree, the standard graph-theory answer to "connect every point with the least total wiring" - the same algorithm you'd use to lay the shortest possible network of roads between a set of towns, applied here to mask regions instead of towns.
That matters practically because a naive "connect everything to everything" approach would draw way more lines than you need. MST gives you the shortest total connector set that still guarantees the whole mask is one connected piece - useful any time downstream logic (an inpainting pass, an outline extraction, a single Detailer crop) needs one contiguous region rather than a scatter of disjoint ones.
The inputs, and both of them have tooltips worth trusting over guessing. mask is the mask you're reconnecting. to_skeletonize - "Enable skeletonization of the connected mask," per the node's own tooltip - reduces the final connected shape down to a 1-pixel-wide centerline instead of leaving it as a filled blob, which is what you want if you're after line-art or a vein/circuit-like structure rather than a solid mask. line_thickness - "Thickness of the connecting lines," 1 to 10, default 1 - controls how chunky the MST connectors themselves are drawn before any skeletonization happens. There's also an optional split_mask input, letting you feed in a second mask - plausibly the per-island output from Mask Splitter - to connect against, rather than relying purely on whatever connected components already exist inside mask. Output is a single MASK.
Installing it. Standard pack install: ComfyUI Manager search for "comfyui_gr85," or:
cd ComfyUI/custom_nodes
git clone https://github.com/veighnsche/comfyui_gr85
Restart ComfyUI. One honest flag since the README doesn't cover this node at all: skeletonization is usually implemented with scikit-image's morphology functions, so if to_skeletonize throws an import error on a fresh install, check whether scikit-image made it into your Python environment - the pack's README doesn't list a requirements file for this corner of it.
Where this bites. to_skeletonize shrinking your connected mask down to a razor-thin line is great for line art and bad for inpainting - if you skeletonize and then feed the result straight into VAEEncodeForInpaint, you'll get almost no region to actually regenerate, because your mask is one pixel wide. Grow it back out with a GrowMask node afterward if you need inpainting-usable width. And on large or genuinely scattered masks, keep line_thickness high enough to actually read in a preview - an MST connector drawn at 1px across a big canvas is easy to lose entirely.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| mask | MASK | — | |
| to_skeletonize | BOOLEAN | false | Enable skeletonization of the connected mask. |
| line_thickness | INT | 11–10 | Thickness of the connecting lines. |
| split_maskopt | MASK | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| MASK | MASK | — |