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.

By lonecatone23·Created 6 days ago·Updated about 10 hours ago· 0
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)

NameTypeDefaultDescription
imageIMAGEThe image the mask belongs to. Used as the guide.
maskMASKMask to refine. Any size; it is resized to the image.
methodCOMBOvitmattevitmatte: 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_modelCOMBOOnly used by vitmatte. Entries marked 'Download' are fetched the first time you run.
growFLOAT0.0-512–512Pixels to grow (positive) or shrink (negative) the mask before the trimap is built.
fix_gapFLOAT0.00–64Close small holes and cracks up to about this many pixels wide. 0 = off.
fix_thresholdFLOAT0.7500.01–0.999How white a mask pixel must be to count as solid when fixing gaps.
edge_erodeFLOAT10.00–1024TRIMAP. 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_dilateFLOAT10.00–1024TRIMAP. How far the unknown band reaches out past the mask edge, in pixels. Everything beyond this is locked black. Smaller = tighter, less to decide.
softnessFLOAT0.00100.00001–0.1guided_filter only. Lower follows image edges tighter, higher is smoother.
thresholdFLOAT0.5000.05–0.999Where 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_pointFLOAT0.0100–0.999Mask values at or below this become 0. Clears faint haze.
white_pointFLOAT0.9900.001–1Mask values at or above this become 1. Solidifies the subject.
featherFLOAT0.00–100Final edge softness in pixels.
edge_color_spreadINT00–64Cutout only. Pushes solid subject colors outward this many pixels to cut background halos. 0 = off.
max_megapixelsFLOAT3.000.25–16vitmatte only. Larger images are matted at this size, then scaled back.
detail_erodeFLOAT72.00–1024Same as edge_erode, but for the detail_region area (hair). Wider gives fine strands room.
detail_dilateFLOAT64.00–1024Same as edge_dilate, but for the detail_region area.
detail_blurFLOAT4.00–512Softens the seam where the detail_region result blends into the rest.
preview_viewCOMBOcutoutWhat the wipe on the node shows. trimap: left is the trimap (black = sure background, gray = unknown, white = sure foreground), right is the result.
detail_regionoptMASKOptional. White areas (like hair) use detail_erode / detail_dilate instead of edge_erode / edge_dilate.

Outputs (3)

NameTypeDescription
cutoutIMAGE—
maskMASK—
trimapMASK—