Dilate Mask Regions
Grow a mask outward before inpainting so the edges actually blend
- masks
- MASKS
Probably the single most commonly needed operation in this whole mask-filter family, if you've ever done any serious inpainting. A mask that fits your subject exactly, pixel-perfect, actually inpaints worse than one with a little breathing room - the model needs some margin around the edge to blend new content in cleanly, which is why growing or feathering a mask before inpainting shows up in basically every real workflow. Dilate Mask Regions does the growing side of that.
How it works
This is straightforward morphological dilation - a core OpenCV operation (dilate) - that expands the white, masked region outward in every direction, roughly one pixel-ish per iteration. There's no separate "amount per pass" to configure; iterations is the whole control surface. It's a close cousin to mask blur/feathering (typically applied in the 4–12px range in most inpainting workflows), except dilation grows the hard region itself rather than softening the edge - you often want both, growing first and then softening.
The inputs and outputs that matter
masks(required, MASK).iterations(required, default 5, 1–64) - higher grows the mask more. Default 5 is a modest expansion; nudge it up if you're still seeing hard seams at the mask edge after generation.
Output is MASKS, the grown region.
How to install it
ComfyUI Manager: search SaltAI-Open-Resources or SaltAI, install, restart. Manual:
cd ComfyUI/custom_nodes
git clone https://github.com/get-salt-AI/SaltAI
then restart. OpenCV-backed (dilate is a core cv2 morphology op), no model download.
Common issues & troubleshooting
Grew the mask into territory that was supposed to stay untouched. Too many iterations for the image size - a handful of iterations covers a much bigger fraction of a small image than it does on a 4K source, so subject regions that were meant to stay protected start getting swept into the inpaint area. Scale iterations to your resolution, not to a fixed number you always reach for.
Seams still visible after generous dilation. More dilation alone isn't the fix past a certain point - it just makes the edge bigger, not softer, and dilation on its own still leaves a hard boundary. Pair it with an actual smoothing step afterward, either a blur/feather node or SaltMaskBilateralFilter (softer than a plain blur, since it won't blur away the boundary you just grew).
Mask shape looks blobby, lost fine detail. High iteration counts round off thin protrusions and small gaps - fine for a rough subject region, bad if you needed to preserve something delicate like individual fingers or hair strands in the mask. Drop iterations back down for anything with fine structure.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| masks | MASK | — | |
| iterations | INT | 51–64 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| MASKS | MASK | — |