Dilate Mask
Grow or shrink a mask by a set number of pixels
- mask
- MASK
Small, boring, and you'll use it constantly. Dilate Mask takes a MASK and pushes its edges outward (or pulls them inward) by a fixed number of pixels. That's the whole node. It earns its keep because so many mask problems in image generation are really just "the mask is a little too tight" or "a little too loose," and this is the one-knob fix.
The classic case is inpainting and detailing: a mask that hugs an object exactly leaves the regenerated region butting right up against untouched pixels, and you get a seam. Grow the mask a few pixels and the transition lands in an area the model is free to blend. It's the same instinct as mask blur, just operating on the mask's shape instead of its softness.
How it works
This is a standard morphological dilation. Every white pixel in the mask spreads outward by the dilation amount, so the masked area gets uniformly larger. The pack exposes it as a signed value, and that's the key feature: the README notes it supports "erosion for negative value." So a positive number dilates (grows the mask) and a negative number erodes (shrinks it), all through the same input. No mode switch, just the sign.
Where you put it in the graph matters. Dilate before feeding a mask into a sampler when you want the fix to cover a bit more than the detector or your hand-drawn mask captured; erode when the mask is spilling into areas you want left alone.
The inputs and outputs
mask- the mask to resize. Required.dilation(default 10) - signed pixel amount. Positive grows, negative shrinks. The range runs from −512 to 512, but realistic values are small; a dozen pixels is a meaningful nudge on a normal image.
Output is a single MASK. What you do with it is up to the rest of your graph - inpaint conditioning, a composite, a detailer, wherever a slightly-resized mask helps.
How to install it
Via ComfyUI Manager: search ComfyUI Impact Pack, install, restart. Manually: cd ComfyUI/custom_nodes && git clone https://github.com/ltdrdata/ComfyUI-Impact-Pack, install requirements into the same Python running ComfyUI (pip install -r requirements.txt, or ..\..\..\python_embeded\python.exe -m pip install -r requirements.txt on Windows portable), then restart. Auto-install was removed at v7.6, so the requirements step is manual now. A small SAM model downloads to ComfyUI/models/sams on first run - irrelevant to this node, but that's the pack's install behavior.
Common issues
The mask disappeared. You eroded it past its own size. A small mask with a large negative dilation just vanishes. Reduce the magnitude, or check you didn't mean to dilate.
Hard edges after growing. Dilation makes the mask bigger but not softer - the boundary is still crisp. If you want a feathered transition too, follow this with the pack's Gaussian Blur Mask node, or feather at the paste/composite step. Growing and softening are two different operations, and this node only does the first.
It's for plain masks, not SEGS. If your region lives inside a SEGS object, this node won't take it - use Dilate Mask (SEGS) instead, which does the same thing to every mask inside the SEGS at once.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| mask | MASK | — | |
| dilation | INT | 10-512–512 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| MASK | MASK | — |