Nodes/ComfyUI-BrainDead/BD Fill Mask Holes
ComfyUI Node

BD Fill Mask Holes

Fill interior holes in a binary mask. Uses scipy binary_fill_holes to flood-fill any enclosed region inside the mask boundary. Optional morphological closing first connects near-touching edges so enclosed regions are fully closed before filling. Use after SAM3 when the perimeter is detected but interior pixels are missing.

By BizaNator·Created 7 months ago·Updated 16 days ago· 14
BD Fill Mask Holes
  • mask
  • filled_mask
  • status
threshold0.50
closing_radius4
smooth_edges0
Category🧠BrainDead/Segmentation

Inputs (4)

NameTypeDefaultDescription
maskMASK
thresholdoptFLOAT0.500–1Binarize the input mask at this value before filling. 0.5 = standard binary threshold.
closing_radiusoptINT40–64Morphological closing radius (pixels) applied BEFORE fill_holes. Closing = dilate then erode — it bridges small gaps in the mask perimeter so that enclosed regions are properly sealed before filling. 0 = skip closing (only fill_holes). 4–8 = good for SAM3 lip/teeth gaps.
smooth_edgesoptINT00–16Gaussian blur radius applied to the filled mask for soft edges. 0 = hard binary output. 2–4 = slight feathering at boundaries.

Outputs (2)

NameTypeDescription
filled_maskMASK
statusSTRING