ComfyUI Node
LC Mask Refine ✨
Tighten a mask with a trimap. edge_erode and edge_dilate set how wide the unknown band is; a guided filter or VITMatte decides only that band. Before/after wipe and trimap view on the node.
LC Mask Refine ✨
- image
- mask
- detail_region
- cutout
- mask
- trimap
◄methodvitmatte►
◄vitmatte_model▾►
◄grow0.0►
◄fix_gap0.0►
◄fix_threshold0.750►
◄edge_erode10.0►
◄edge_dilate10.0►
◄softness0.0010►
◄threshold0.500►
◄black_point0.010►
◄white_point0.990►
◄feather0.0►
◄edge_color_spread0►
◄max_megapixels3.00►
◄detail_erode72.0►
◄detail_dilate64.0►
◄detail_blur4.0►
◄preview_viewcutout►
CategoryLC MaskMaker/mask
Inputs (21)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | The image the mask belongs to. Used as the guide. | |
| mask | MASK | Mask to refine. Any size; it is resized to the image. | |
| method | COMBO | vitmatte | vitmatte: matting model, best for hair and fine detail. guided_filter: fast, no model, snaps the unknown band to image edges. none: skip matting, only grow, fix gaps, levels and feather. |
| vitmatte_model | COMBO | Only used by vitmatte. Entries marked 'Download' are fetched the first time you run. | |
| grow | FLOAT | 0.0-512–512 | Pixels to grow (positive) or shrink (negative) the mask before the trimap is built. |
| fix_gap | FLOAT | 0.00–64 | Close small holes and cracks up to about this many pixels wide. 0 = off. |
| fix_threshold | FLOAT | 0.7500.01–0.999 | How white a mask pixel must be to count as solid when fixing gaps. |
| edge_erode | FLOAT | 10.00–1024 | TRIMAP. How far the sure-foreground area is pulled in from the mask edge, in pixels. Everything inside this is locked white. Smaller = tighter, less to decide. |
| edge_dilate | FLOAT | 10.00–1024 | TRIMAP. How far the unknown band reaches out past the mask edge, in pixels. Everything beyond this is locked black. Smaller = tighter, less to decide. |
| softness | FLOAT | 0.00100.00001–0.1 | guided_filter only. Lower follows image edges tighter, higher is smoother. |
| threshold | FLOAT | 0.5000.05–0.999 | Where the input mask is split into inside and outside when the trimap is built. Raise toward 1.0 to use only the solid core of a soft mask. |
| black_point | FLOAT | 0.0100–0.999 | Mask values at or below this become 0. Clears faint haze. |
| white_point | FLOAT | 0.9900.001–1 | Mask values at or above this become 1. Solidifies the subject. |
| feather | FLOAT | 0.00–100 | Final edge softness in pixels. |
| edge_color_spread | INT | 00–64 | Cutout only. Pushes solid subject colors outward this many pixels to cut background halos. 0 = off. |
| max_megapixels | FLOAT | 3.000.25–16 | vitmatte only. Larger images are matted at this size, then scaled back. |
| detail_erode | FLOAT | 72.00–1024 | Same as edge_erode, but for the detail_region area (hair). Wider gives fine strands room. |
| detail_dilate | FLOAT | 64.00–1024 | Same as edge_dilate, but for the detail_region area. |
| detail_blur | FLOAT | 4.00–512 | Softens the seam where the detail_region result blends into the rest. |
| preview_view | COMBO | cutout | What the wipe on the node shows. trimap: left is the trimap (black = sure background, gray = unknown, white = sure foreground), right is the result. |
| detail_regionopt | MASK | Optional. White areas (like hair) use detail_erode / detail_dilate instead of edge_erode / edge_dilate. |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| cutout | IMAGE | — |
| mask | MASK | — |
| trimap | MASK | — |