MaskDilate(膨胀)
Grow a mask's edges outward
- mask
- MASK
The node's own display name spells out what it does in two languages: MaskDilate(膨胀) - 膨胀 means "swell" or "expand." That's the entire function: take a mask and push its boundary outward, growing the masked region by a margin you control.
Why you'd grow a mask
Most automated masks are drawn a little too tight. A SAM detection, a CLIPSeg pass, a background-removal cutout - they trace the subject closely, which sounds like a good thing until you inpaint or composite right up against that exact line and get a visible seam, or a thin sliver of the original background peeking through where the model didn't quite paint far enough. Growing the mask by a small margin before you use it gives the generation room to cover past the exact outline instead of hugging it.
This is a different move from mask feathering, which softens the edge of a mask so the transition blends rather than cuts hard - dilate changes the actual coverage, feather changes how sharp the boundary is once it's set. They solve different problems and people commonly use both: dilate first for margin, feather on top for a soft blend.
Inputs and outputs
mask(MASK) - what you're growing.kernel_height,kernel_width(FLOAT, 0–1, default0.005) - how far the mask expands, one value per axis.- Output:
MASK, same shape as the input, grown.
The gotcha: this isn't a pixel radius
Here's where this node differs from most grow/dilate nodes elsewhere in the ecosystem (Impact Pack, WAS Node Suite), which typically take an integer pixel count - type 8, get an 8-pixel grow. MaskDilate's kernel_height and kernel_width are floats between 0 and 1: a fraction of the mask's dimension, not a pixel count. The default 0.005 means the kernel spans half a percent of that dimension - on a 1024px-tall mask that's roughly 5px, on a 512px mask roughly 2.5px.
If you carry the habit from another pack and type 8 here expecting an 8-pixel grow, you'll get a kernel clamped near 1.0 - spanning the entire dimension - and your mask balloons to cover the whole image. Start in the 0.005–0.02 range and nudge from there; you almost never need to go much higher for a normal margin grow.
Installing it
ComfyUI Manager: search RuiquNodes, install, restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/ruiqutech/ComfyUI-RuiquNodes
then restart. No models to download.
Common issues
The mask barely looks different. You're probably still well under 1% - this node's whole range lives in a much smaller window than pixel-based dilate nodes you might be used to. Bump the value in small steps (0.001–0.005 at a time) rather than jumping by whole integers.
The mask suddenly covers almost everything. You've overshot toward the 1.0 end. Dial it back down - remember you're setting a fraction of the whole image dimension, not a pixel count.
Where the output goes. Wire MASK into whatever consumes it next - a KSampler's mask input via Set Latent Noise Mask, VAEEncodeForInpaint, or an image compositing node.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| mask | MASK | — | |
| kernel_height | FLOAT | 0.00500–1 | — |
| kernel_width | FLOAT | 0.00500–1 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| MASK | MASK | — |