Nodes/KJNodes for ComfyUI/Grow Mask With Blur
ComfyUI Node Runs on cloud

Grow Mask With Blur

The inpainting mask node you'll actually use

By kijai·Created 3 years ago·Updated about 18 hours ago· 2,930
Grow Mask With Blur
  • mask
  • mask
  • mask_inverted
expand0
incremental_expandrate0.0
tapered_cornerstrue
flip_inputfalse
blur_radius0.0
lerp_alpha1.00
decay_factor1.00
fill_holesfalse

This is the node that turns a hard-edged mask into one that inpaints cleanly. Two jobs, both essential: grow the masked region outward so the model gets a little breathing room around the edit, and blur the edge so the result blends into the original instead of leaving a visible seam. If you've ever done inpainting and gotten a sharp rectangular scar around your fix, this is what you were missing.

It's one of the workhorse masking nodes in the KJNodes pack, and it shows up in a lot of inpainting and video-masking graphs because it does the two adjustments you almost always need in one node.

How it works

A mask is just a grayscale image - white is "edit here," black is "leave alone." Growing (dilating) the white region by a few pixels means the sampler has real image context right at the boundary to blend against, which kills the hard-edge problem. Blurring feathers the black-to-white transition so the edit fades in rather than snapping on. Do both and the repair disappears into the picture.

The inputs that matter

The node description documents every field, but for a beginner these are the two you'll set:

  • expand (default 0) - grow the mask by this many pixels. Positive grows, negative shrinks (yes, it goes negative, all the way to -16384). A handful of pixels of growth is the usual inpainting move.
  • blur_radius (default 0) - anything above 0 feathers the edge. This is the seam-hider. Start small (a few px) and go up until the blend looks natural.

The rest are situational: tapered_corners (on by default) softens the shape of the growth so you don't get boxy corners; fill_holes closes gaps inside the mask (it's slow, and it's the one optional input); flip_input inverts the incoming mask.

A cluster of them exists specifically for animated / batch masks - i.e. video. incremental_expandrate grows the mask a bit more on each successive frame, lerp_alpha interpolates the mask between frames, and decay_factor fades it over the batch. On a single image these do nothing useful; on a frame sequence they let a mask breathe over time.

Two outputs: mask (the grown, blurred result) and mask_inverted (the same thing flipped), so you can grab whichever polarity your next node wants without adding an invert node.

Where it wires in

Between your mask source (a manual mask, a segmentation node, a ColorToMask, whatever) and your inpainting sampler's mask input. The pattern is: make a rough mask → grow and blur it here → feed it to the sampler. The mask_inverted output is handy when you want to protect the region instead of edit it.

Installing it

Part of kijai's KJNodes pack.

  • ComfyUI Manager - search KJNodes for ComfyUI, install, restart.
  • Manual - cd ComfyUI/custom_nodes && git clone https://github.com/kijai/ComfyUI-KJNodes, then pip install -r requirements.txt, and restart.

No downloads, no heavy dependencies - this is pure image math.

Common issues

Over-growing is the classic mistake. Push expand too far and your "fix the eye" mask starts covering half the face, and the model happily regenerates all of it. Grow just enough to give the edge context.

Too little blur_radius leaves a seam; too much bleeds the edit into areas you wanted untouched. It's a balance you tune per image - there's no universal number.

And if you're using this on video and the mask seems to "drift" or fade across frames, check incremental_expandrate, lerp_alpha, and decay_factor - those are frame-over-frame behaviors, and a nonzero value you didn't mean to set will make a still mask animate. On a single image, leave them at their defaults.

CategoryKJNodes/masking

Inputs (9)

NameTypeDefaultDescription
maskMASK
expandINT0-16384–16384
incremental_expandrateFLOAT0.00–100
tapered_cornersBOOLEANtrue
flip_inputBOOLEANfalse
blur_radiusFLOAT0.00–100
lerp_alphaFLOAT1.000–1
decay_factorFLOAT1.000–1
fill_holesoptBOOLEANfalse

Outputs (2)

NameTypeDescription
maskMASK
mask_invertedMASK