Nodes/ComfyUI-UniversalToolkit/Fill Masked Area (UTK)
ComfyUI Node

Fill Masked Area (UTK)

Fill the hole in your image — neutral, content-aware, or feathered

By whmc76·Created about a year ago·Updated 2 months ago· 72
Fill Masked Area (UTK)
  • image
  • mask
  • image
fill_modeneutral
feathering0

The step before most inpainting is preparation: get the thing you want to replace out of the frame, or at least out of the way. Fill Masked Area (UTK) does that in three flavors - fill the masked region with a neutral color, or patch it with OpenCV's content-aware inpainting. It's a preprocessor, the "masked area now looks like a hole someone filled" step that sets up a cleaner regeneration.

How it works

Feed it an image and a mask. The fill_mode decides what happens to the masked pixels:

  • neutral (default) - fills the masked area with a neutral gray. This is the classic pre-inpaint prep: a flat, low-detail patch the sampler can regenerate over without fighting whatever was there.
  • telea - OpenCV's Telea inpainting: propagates surrounding pixels inward. Content-aware, so the hole gets filled with plausible surrounding texture - good when you want the region to blend but not re-generate it.
  • navier-stokes - OpenCV's Navier-Stokes method, which models the fill as fluid flow. Similar idea to Telea, slightly different edge behavior; tends to keep sharper structure along edges.

feathering (default 0) controls the transition at the mask boundary. It erodes the mask and blurs it (the code uses erosion + a Gaussian with sigma = feathering/3), so the fill softens into the surrounding image instead of ending in a hard line. For anything that's going to be inpainted, a small feather is usually the difference between a seamless regen and a visible patch.

One output: image, with the masked area filled.

Where it fits

  • Before inpaint/outpaint - neutral-fill the region you're regenerating so the sampler starts from a blank slate (the KB's inpainting doc covers why that gives cleaner results).
  • Object removal without generation - content-aware fill for small objects on uniform backgrounds.
  • Fixing "holes" from a crop/restore pipeline - the region left over after cropping something out.

The honest distinction from a real inpaint pass: Telea/Navier-Stokes fill with existing image texture, so on a busy background they smear instead of invent. For that, you still need an actual inpainting model. This node is the cheap prep or the quick fix, not the creative tool.

Installing it

Standard pack install - ComfyUI Manager → search ComfyUI-UniversalToolkit, or:

cd ComfyUI/custom_nodes
git clone https://github.com/whmc76/ComfyUI-UniversalToolkit
cd ComfyUI-UniversalToolkit && pip install -r requirements.txt

Then restart. Needs OpenCV and scipy (scipy for the feathering) - both in the pack's requirements.

Gotchas

  • Telea/Navier-Stokes are CPU, sometimes slow, and quality is input-dependent. On a textured background they look like smearing; don't expect them to synthesize missing detail.
  • feathering=0 gives a hard edge - for inpainting prep, leave a little feather (5–15) or the regen boundary will show up as a seam.
  • The mask is binarized at 0.5 internally (the mask_floor helper), so soft-edged masks get snapped before filling. Feed it the sharpest mask you can.
  • Neutral gray ≠ magic. The neutral fill is a flat value, not "the average of the surroundings" - a bright scene's neutral fill can look like a gray rectangle until you inpaint over it. That's expected; it's prep, not final.

For pre-inpaint cleanup and quick object removal, it's the right tool at the right time. Just remember the division of labor: this node removes, the sampler re-imagines.

CategoryUniversalToolkit/Image

Inputs (4)

NameTypeDefaultDescription
imageIMAGE
maskMASK
fill_modeCOMBOneutral3 options: neutral, telea, navier-stokes
featheringINT00–100

Outputs (1)

NameTypeDescription
imageIMAGE