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.
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)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| mask | MASK | — | |
| grabcut_iterations | INT | 31–10 | Number of GrabCut refinement iterations |
| edge_refinement | FLOAT | 0.50–1 | Edge smoothing strength |
| edge_blur_amount | FLOAT | 0.00–10 | Amount of Gaussian blur to apply to mask edges (0=none, 10=maximum) |
| expand_margin | INT | 100–50 | Pixels to expand mask boundary for refinement |
| bbox_safety_margin | INT | 200–100 | Extra pixels beyond detected bounding box for safety |
| min_bbox_size | INT | 6432–256 | Minimum bounding box dimensions to prevent over-cropping |
| output_size | COMBO | ORIGINAL | Target output size for the refined image and mask |
| scaling_method | COMBO | NEAREST | Interpolation method for scaling |
| custom_widthopt | INT | 51264–4096 | Custom width (used when output_size is 'custom') |
| custom_heightopt | INT | 51264–4096 | Custom height (used when output_size is 'custom') |
| invert_maskopt | BOOLEAN | false | Invert the output mask (foreground becomes background and vice versa) |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| refined_mask | MASK | — |