Nodes/SaltAI-Open-Resources/Fill Mask Regions
ComfyUI Node

Fill Mask Regions

Patch the holes in a segmentation mask

By get-salt-AI·Created 2 years ago·Updated 2 years ago· 84
Fill Mask Regions
  • masks
  • MASKS

Segmentation masks get holes. A subject mask from SAM or a background-removal model can come back with a donut in it - the model was confident about the edges of, say, an arm crossing in front of a torso, and less confident about the torso pixels behind it, so you end up with a ring of "foreground" around a patch of "background" that should obviously be foreground too. SaltMaskFillRegion patches exactly that: it fills in any enclosed hole inside a masked region, solid.

How it works

This is the classic binary_fill_holes operation from image morphology. For each connected region in the mask, it finds any background-colored area fully enclosed by foreground and flips it to foreground. Nothing on the outside of a region is touched - a hole has to be completely surrounded to get filled, so if there's a gap that reaches the region's edge, it isn't a hole in this sense and stays as-is.

The inputs and outputs that matter

There's exactly one field here, no knobs to turn:

  • masks (required, MASK) - your input mask. This node runs the fill and gives you back the same mask with any enclosed gaps solid.

Output: MASKS. Feed it straight back into whatever was going to consume the original mask - a composite node, an inpaint mask, an ImageCompositeMasked call.

How to install it

SaltMaskFillRegion ships in get-salt-AI/SaltAI ("SaltAI-Open-Resources"), the node pack from Salt AI (getsalt.ai). The company launched in March 2024 building infrastructure to run ComfyUI workflows as Discord bots and, later, via API; this masking node family and a set of animation-schedule nodes were the general-purpose part of the repo that worked with or without their platform.

One practical note before you go hunting for it: github.com/get-salt-AI/SaltAI currently 404s. The GitHub org is still up, with a few other repos, but this specific one isn't in the listing anymore, and it's absent from ComfyUI Manager's node index too. So the usual "search Manager, install, restart" flow and a fresh git clone https://github.com/get-salt-AI/SaltAI both come up empty right now - that's not a local problem if you hit it. If it's already sitting in your custom_nodes folder from an earlier install or a bundled workflow environment, it should keep running fine; the node itself is a self-contained bit of mask math with no model weights to fetch and nothing that depends on Salt AI's platform being reachable.

Common issues & troubleshooting

Nothing changed. If your mask has no fully-enclosed holes - most single-subject cutouts from a decent segmentation model don't - this node is a no-op. It earns its place specifically on masks with donut-shaped gaps: crossed limbs, objects seen through a gap, anything where the model lost confidence in the middle of a shape it got right at the edges.

A hole near the edge of the frame didn't get filled. That's expected behavior for a fill-holes operation - a gap only counts as a "hole" if foreground pixels surround it on every side. A notch that touches the mask's border, or the edge of the canvas, isn't enclosed, so it's left alone.

You're getting a soft, feathered mask and the fill looks abrupt. This node fills based on connectivity, not on gradient values - it doesn't know or care about partial opacity. If you're working with a matting-style alpha mask rather than a hard binary one, filling a hole can leave a harsh edge where the soft original had a gradient. Run SaltMaskGaussianRegion after this one if you need the result feathered back out.

No node-level docs to check against. The README covers the pack in one paragraph and doesn't go node by node - if you want certainty about how this handles a specific tricky mask, the fastest way is a Preview Image node before and after.

CategorySALT/Masking/Filter

Inputs (1)

NameTypeDefaultDescription
masksMASK

Outputs (1)

NameTypeDescription
MASKSMASK