Nodes/ComfyUI-NKD-Basic-Tools/😺NKD Mask Ops Lean
ComfyUI Node

😺NKD Mask Ops Lean

Fill holes, expand, feather — the three mask tweaks a composite needs

By Nekodificador·Created about a month ago·Updated 3 days ago· 71
😺NKD Mask Ops Lean
  • mask
  • mask
  • mask_inverted
â—„fill_holesfalseâ–º
â—„expand0â–º
â—„feather0â–º

Most masks don't need a pipeline - they need three tweaks: fill the holes a segmentation model left, grow or shrink the edge a little, and soften it so the composite doesn't show. That's the entire surface of 😺NKD Mask Ops Lean, which is the pack's full Mask Ops engine stripped down to exactly those three widgets.

The point of the "Lean" isn't fewer features, it's a smaller node on the canvas and - more importantly - the same GPU treatment. Growing or feathering a mask is usually done frame by frame on the CPU, one pixel of growth per pass, which is why it quietly becomes the slow step of a video graph. Here the whole batch makes a single trip to the GPU and the radius is nearly free: the author's own benchmark table has expanding a mask by 200px costing about the same as expanding by 8, and an 81-frame batch that takes 32 seconds with a per-frame CPU node drops to a quarter of a second.

The three inputs (that's the whole panel)

  • fill_holes - a boolean. Fill gaps fully enclosed by the mask so each area becomes a solid shape. The classic fix for a segmentation that left the middle of a subject hollow.
  • expand - grow the mask outward by this many pixels, or shrink it with a negative value. Range −512 to 512. This is how you stop a mask from clipping an edge you care about.
  • feather - soften the edge by this many pixels. Runs last, so nothing hardens it again. 4–12px is the usual range for a clean composite.

mask in, mask and mask_inverted out. The inverted output is a genuinely handy convenience - flipping the mask is a zero-cost habit to keep.

When to use Lean vs the full node

The author's split is right: reach for the full 😺NKD Mask Ops when you need levels, speck removal, gap closing, blockify, or the temporal steps (temporal expand/smooth for video). If it's a still, or a simple composite prep, the Lean node is the one you want on the canvas - same engine, three widgets, no panel of zeros to stare at.

Install and gotchas

Install via ComfyUI Manager (search ComfyUI-NKD-Basic-Tools) or:

cd ComfyUI/custom_nodes
git clone https://github.com/Nekodificador/ComfyUI-NKD-Basic-Tools

Restart after. Pack dependencies are onnxruntime and huggingface_hub; neither is needed here. One thing to keep straight: expand and feather interact - feathering after a big expand gives you a soft halo of the grown area, which is sometimes exactly what you want (a feathered expanded mask for a composite) and sometimes not. If the feather looks too heavy, it's usually the expand talking.

Category😺NKD Nodes/Masking

Inputs (4)

NameTypeDefaultDescription
maskMASKMask or mask batch (one per video frame).
fill_holesBOOLEANfalseFill gaps fully enclosed by the mask, so each area becomes a solid shape.
expandINT0-512–512Grow the mask outward by this many pixels, or shrink it with a negative value.
featherINT00–256Soften the edge by this many pixels. Runs last, so nothing hardens it again.

Outputs (2)

NameTypeDescription
maskMASK—
mask_invertedMASK—