Nodes/Transparency Background Remover/GrabCut Mask Refinement
ComfyUI Node

GrabCut Mask Refinement

Refine an existing mask with GrabCut. Takes an IMAGE and a MASK and returns an image + cleaner mask, with optional resize and alpha inversion.

By Limbicnation·Created about a year ago·Updated 4 months ago· 21
GrabCut Mask Refinement
  • image
  • mask
  • image
  • refined_mask
grabcut_iterations3
edge_refinement0.5
edge_blur_amount0.0
expand_margin10
bbox_safety_margin20
min_bbox_size64
output_sizeORIGINAL
scaling_methodNEAREST
custom_width512
custom_height512
invert_maskfalse
Categoryimage/processing

Inputs (13)

NameTypeDefaultDescription
imageIMAGE
maskMASK
grabcut_iterationsINT31–10Number of GrabCut refinement iterations
edge_refinementFLOAT0.50–1Edge smoothing strength
edge_blur_amountFLOAT0.00–10Amount of Gaussian blur to apply to mask edges (0=none, 10=maximum)
expand_marginINT100–50Pixels to expand mask boundary for refinement
bbox_safety_marginINT200–100Extra pixels beyond detected bounding box for safety
min_bbox_sizeINT6432–256Minimum bounding box dimensions to prevent over-cropping
output_sizeCOMBOORIGINALTarget output size for the refined image and mask
scaling_methodCOMBONEARESTInterpolation method for scaling
custom_widthoptINT51264–4096Custom width (used when output_size is 'custom')
custom_heightoptINT51264–4096Custom height (used when output_size is 'custom')
invert_maskoptBOOLEANfalseInvert the output mask (foreground becomes background and vice versa)

Outputs (2)

NameTypeDescription
imageIMAGE
refined_maskMASK