Nodes/tri3d-comfyui-nodes/Fill mask v5.1.0
ComfyUI Node

Fill mask v5.1.0

Fill a mask by cloning neighboring pixels — no model, no VRAM, instant

By TRI3D-LC·Created 3 years ago·Updated about a year ago· 27
Fill mask v5.1.0
  • image
  • mask
  • negative_mask
  • image
offset1.00

Fill mask is the cheap seat at the inpainting table. Instead of loading a diffusion model and regenerating a masked region, it fills the mask by sampling neighboring pixels and copying them in - a paint-by-numbers approach that runs on CPU in milliseconds and costs you exactly zero VRAM. You wouldn't use it to hallucinate a new sleeve, but for erasing a seam, a watermark, a specular highlight, or any blemish where the surrounding pixels already contain the answer, it's far more reliable and way faster than a diffusion pass.

The mechanism is about as transparent as it gets. For every pixel inside mask, it looks at the pixel a short distance away and copies it - but it uses the negative_mask to decide which direction is safe. The negative mask is your "don't fill from here" region (typically the body or garment silhouette). It tries right first: if the pixel to the right is outside the negative mask, copy from there; otherwise try left, then up, then down. Pixels outside the mask are left untouched, so the final image is mask * source + (1 - mask) * original.

Inputs that matter

  • image - the image being repaired.
  • mask - the region to fill (white = fill).
  • negative_mask - the protected region. This is the input that makes or breaks the result. If your negative mask is wrong, the node happily copies skin-colored pixels into the middle of a garment. Think of it as "the thing you're not allowed to sample from."
  • offset - sampling distance as a percentage of the image dimension, default 1 (1%). Small offsets stay faithful to nearby texture; larger offsets blur more but cover bigger gaps.

Output

One image output, the repaired frame. Wire it straight to a preview or on to the next step.

When it fits your workflow

The pack's try-on pipeline uses this kind of neighbor-fill to tidy up mask edges after extracting or repositioning garment parts - the sort of cleanup that would be absurdly slow with a diffusion inpaint. It also pairs naturally with tri3d-image-mask-box-2-image: after you regenerate a cropped box and stitch it back, this node can feather away the boundary artifacts.

Gotchas

  • It's a heuristic, so it has a tell: results look great on uniform backgrounds and cloth, and look like a cheap clone-stamp on busy texture. Don't expect it to rebuild detail.
  • It samples from the right direction first, always. If your negative mask is empty (all zeros), every direction is "safe" and it'll copy from the rightmost neighbor in a lopsided way. Give it a real negative mask.
  • No dependencies beyond the pack's own install - no model downloads, no GPU requirement. If this node is the only one you need from the pack, you can even dodge most of the heavier optional deps.

For a "fill this hole with what's around it" job, this is the node. Just keep your expectations in line with what pixel-cloning can actually do.

CategoryTRI3D

Inputs (4)

NameTypeDefaultDescription
imageIMAGE
maskMASK
negative_maskMASK
offsetFLOAT1.000–100

Outputs (1)

NameTypeDescription
imageIMAGE