RefineNode Mask Batch Process
Split it or merge it in one click
- mask
- mask
The fastest way to break a local-refinement workflow is a mask with three separate painted blobs on it. Feed that to RefineNode Preprocess Mask and you either get one job covering all three regions at once (bad - a tiny logo between them becomes one giant refinement area), or you have to manually separate them. RefineNode Mask Batch Process is the two-switch utility that settles it: split every disconnected painted island into its own mask, or union everything into one.
It exists because this pack's philosophy is that the refinement job list should be explicit. Preprocess Mask deliberately stopped deciding whether masks get split or combined - that decision moved to a node you control, and this is the simple end of it. (RefineNode Slice And Match Masks is the more powerful cousin for grid slicing and two-view matching.)
The whole thing, in two toggles
mask(required) - "a normal mask, a batched mask, or a ComfyUI mask list." So whatever upstream node produced it, this accepts it.combined_mask(default off) - off splits each disconnected painted island into a separate output mask; on unions all incoming masks into one.
That's the entire API: one input, one mask output, and the second checkbox decides whether you get several jobs or one merged job. Set it to off and three blobs on a product shot become three tight region masks, each of which becomes its own refinement job downstream - which means each region gets its own full-resolution generation budget instead of being dragged down to a shared crop.
When you'd reach for it
Two concrete cases. A single Load Image mask contains several separated painted regions and you want one refinement job per region - split them with combined_mask off. Or the mask is messy - overlapping scribbles, speckles, stray dots - and you just want the whole painted area handled as one region, so flip combined_mask on. If the node finds no painted pixels at all it outputs an empty black mask rather than erroring, which is friendlier than it sounds.
Install
ComfyUI Manager, search "ComfyUI-RefineNode", or:
cd ComfyUI/custom_nodes
git clone https://github.com/1Kynx/ComfyUI-RefineNode.git
Restart ComfyUI. That's it - the node is pure mask math (numpy/torch/PIL, no model files, no extra requirements). Wire its mask output into RefineNode Preprocess Mask (optionally after a Slice And Match Masks pass) and the job list builds itself.
Notes
- Disconnected painted islands are what get split - a mask with holes inside one region stays one piece, which is correct behavior.
- This node doesn't filter speckle noise for you; that's
min_area_ratioterritory over inSlice And Match Masks. If your mask is full of dust specks, you want that node, not this one.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| mask | MASK | — | |
| combined_mask | BOOLEAN | false | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| mask | MASK | — |