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.
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)
| Name | Type | Default | Description |
|---|---|---|---|
| mask | MASK | BHW mask; white is the selected area. | |
| expand | INT | 0-1024β1024 | Pixels to grow (+) or shrink (-) the mask. |
| blur | FLOAT | 0.00β100 | Gaussian feather strength in pixels; 0 keeps hard edges. |
| fill_holes | BOOLEAN | false | Fill fully enclosed gaps inside the mask before feathering. |
| smooth | INT | 00β256 | Melts staircase jaggies by this many pixels while keeping a hard edge; 0 is off. Runs before the feather blur. |
| black_point | FLOAT | 0.000β1 | Mask values at or below this become fully black; clears faint gray haze outside the subject. Applied last. |
| white_point | FLOAT | 1.000β1 | Mask values at or above this become fully white; solidifies the mask core. Applied last. |
| edge_refine | COMBO | off | Snap 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_imageopt | IMAGE | RGB frames the mask belongs to; required when edge_refine is 'guided filter' or 'matting'. |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| mask | MASK | The refined BHW mask. |
| mask_inverted | MASK | The refined mask inverted, for operations that target the background. |