Nodes/ComfyUI-AusBoss/Mask Refine πŸ†Ž
ComfyUI Node

Mask Refine πŸ†Ž

Cleans up a mask in one fixed-order pass: expand (grow/shrink by whole pixels), fill enclosed holes, smooth (melts staircase jaggies without feathering), feather with a gaussian blur, edge-refine against the optional guide_image (guided filter or alpha matting), then remap levels with black_point/white_point to clear gray haze. Returns the refined mask and its inverse.

By ausbossΒ·Created about a month agoΒ·Updated 7 days agoΒ· 2
Mask Refine πŸ†Ž
  • mask
  • guide_image
  • mask
  • mask_inverted
β—„expand0β–Ί
β—„blur0.0β–Ί
β—„fill_holesfalseβ–Ί
β—„smooth0β–Ί
β—„black_point0.00β–Ί
β—„white_point1.00β–Ί
β—„edge_refineoffβ–Ί
CategoryπŸ†Ž AusBoss/Mask

Inputs (9)

NameTypeDefaultDescription
maskMASKBHW mask; white is the selected area.
expandINT0-1024–1024Pixels to grow (+) or shrink (-) the mask.
blurFLOAT0.00–100Gaussian feather strength in pixels; 0 keeps hard edges.
fill_holesBOOLEANfalseFill fully enclosed gaps inside the mask before feathering.
smoothINT00–256Melts staircase jaggies by this many pixels while keeping a hard edge; 0 is off. Runs before the feather blur.
black_pointFLOAT0.000–1Mask values at or below this become fully black; clears faint gray haze outside the subject. Applied last.
white_pointFLOAT1.000–1Mask values at or above this become fully white; solidifies the mask core. Applied last.
edge_refineCOMBOoffSnap the mask edge to the guide_image. 'guided filter' is fast edge-aware filtering (needs opencv-contrib-python); 'matting' solves closed-form alpha matting around the edge (needs pymatting). Both require the guide_image input.
guide_imageoptIMAGERGB frames the mask belongs to; required when edge_refine is 'guided filter' or 'matting'.

Outputs (2)

NameTypeDescription
maskMASKThe refined BHW mask.
mask_invertedMASKThe refined mask inverted, for operations that target the background.