ComfyUI Node Runs on cloud

Mask Grow

Push a mask around without wrecking its soft edges

By WASasquatch·Created 3 years ago·Updated 4 days ago· 1,844
Mask Grow
  • mask
  • MASK
expand0
tapered_cornerstrue

Mask Grow moves a mask's edge out or in by a set number of pixels, and it does it in a way that respects what the mask already is: it shifts every grey level along with the edge, so a soft feathered edge stays soft instead of getting a harsh new boundary stamped on it. Lots of "grow" tools just threshold-and-dilate, which turns a gentle mask into a hard-edged one and quietly throws away the feathering you paid for. This one grows the shape, not a binary version of it.

It's a WAS Node Suite mask node (WAS Suite/Image/Masking), and it's the tool for the boring-but-constant compositing chore: "the detected region is a few pixels too small" or "the mask bleeds a little past the subject."

How it works

Two inputs that matter. expand is the edge movement in pixels - positive grows, negative shrinks. 0 leaves the mask alone; 8 grows it 8 pixels in every direction and closes gaps up to 16 across; -8 pulls the edge in by 8 and erases anything thinner than 16. The sign math is worth internalizing: a positive grow doesn't just inflate, it bridges - small holes and separations narrower than twice the distance get closed, which is why you grow a mask to heal the cracks in a rough selection. Shrinking does the reverse, deleting thin protrusions.

tapered_corners (on by default) rounds the shape off by leaving the corners of the 3×3 step out; turn it off and the growth squares off and reaches one pixel further on the diagonals. For organic subjects, leave it on.

The honest caveat is in the tooltip and it's worth repeating: each pixel of movement is one pass, so growing a mask by a few hundred pixels takes a while. On a big image with a large expansion, this is not instant - plan for it or keep the movement modest.

Like the suite's other mask nodes, it reports its work on a band drawn on the node: coverage before and after, what was set and cleared, connected regions, and the box the mask fills. An expand that swallows the whole frame, or a shrink that erases the mask entirely, reads off the node instead of arriving downstream as a blank result. The output is a single MASK at the input's size and batch length.

Why you'd reach for it

Inpainting is the classic case: you want to re-render a region plus a margin so the model has context to match against. A tight detected mask inpaints a region with no breathing room; growing it 20–40 pixels gives the sampler surroundings to blend with, which is the difference between a blended fix and a visible patch. In the detailer loop the KB describes, that padding usually happens as part of crop-and-return - growing the mask first is the manual version of the same instinct.

Shrinking earns its keep too: eroding a mask that bleeds past a subject's outline (say, one that includes background sky around a head) so the composite doesn't carry a fringe of the old background.

Installing it

Part of WAS Node Suite v3:

cd ComfyUI/custom_nodes
git clone https://github.com/WASasquatch/was-node-suite-comfyui.git

or ComfyUI Manager → "WAS Node Suite v3", restart. ComfyUI 0.14.0+, Python 3.10+, no pip installs.

Where people get burned

Expecting a grow to "fix" a mask that's offset from the subject - it can't, it only inflates/deflates; that's a job for Mask Guided Filter. Second, big expand values are slow by design, and a mask that already touches the frame edge will grow right off the edge, which the coverage band will show you as coverage hitting 100%. And remember the grow/shrink symmetry: to shrink by 10 you type -10, and a shrink removes anything thinner than 20 pixels, which can silently delete hair strands or thin details a detector drew for you.

CategoryWAS Suite/Image/Masking

Inputs (3)

NameTypeDefaultDescription
maskMASKThe mask to grow or shrink. A batch is handled one plane at a time, all by the same amount.
expandINT0-16384–16384Pixels the edge moves by; INT. 0 leaves the mask alone, 8 grows it 8 pixels in every direction and closes gaps up to 16 across, -8 pulls it in by 8 and erases anything thinner than 16. Each pixel is one pass, so a few hundred takes a while.
tapered_cornersBOOLEANtrueWhether the four corners of the 3 by 3 step are left out. `true` rounds the shape off, `false` squares it and reaches a pixel further on the diagonals.

Outputs (1)

NameTypeDescription
MASKMASKThe mask with its edge moved, at the same size and batch length as the one that went in.