Mask Process Details (RBS)
VITMatte, PyMatting, or a guided filter
- image
- mask
- image
- mask
Every segmentation model hands you a hard mask: this pixel is foreground, that one is background. That's fine for a solid object and structurally wrong for hair, a veil, or glass - real edges are fractional. This node is the pack's answer to that. Feed it an image and a mask, and it refines the mask's edges into a soft, hair-aware alpha, then hands back both the transparent image and the improved mask. It's the step that turns a good cutout into one you'd actually composite.
Think of it as the manual version of what BiRefNet_HR-matting does natively - except it works on any mask, whether it came from BiRefNet, InSPyReNet, SAM, or your own hand-editing. If your cutouts fall apart against a colored background, this is usually the missing piece.
The method dropdown is the real choice
VITMatte(default) - a proper matting model (hustvl/vitmatte-small-composition-1k), auto-downloaded intoComfyUI/models/vitmatte/on first use. Given a trimap, it predicts fractional alpha. Best quality, costs a model download and GPU time.VITMatte(local)- same thing but withlocal_files_only, so it works offline once the model is cached. Pick this if you're on a machine without HuggingFace access.PyMatting- the classicestimate_alpha_lkmalgorithm. Pure scipy, runs on CPU, no model download at all. Slower on big images, but genuinely offline and dependable.GuidedFilter- an edge-preserving filter (cv2.ximgproc.guidedFilter) instead of a neural net. Cheapest option by far; it refines edges against the image structure rather than hallucinating alpha.
Where the actual fine-tuning happens
The two sliders that matter are detail_erode (default 4) and detail_dilate (default 2). Together they build the trimap: the mask is eroded to mark definite foreground, dilated to mark the unknown band, and that band is where the matte algorithm gets to work. Too thin a band and there's nothing to refine; too thick and you get slow, noisy edges. Start at the defaults and nudge.
black_point (0.01) and white_point (0.99) remap the mask's levels - used mainly in the GuidedFilter path to tighten or loosen the result. max_megapixels (default 2.0) and device work like the rest of the pack: big sources get downscaled for inference, then restored.
The gotcha hiding in the GuidedFilter option
GuidedFilter calls cv2.ximgproc.guidedFilter, and ximgproc lives in opencv-contrib-python - but the pack's requirements.txt only installs plain opencv-python. If you pick GuidedFilter and hit AttributeError: module 'cv2' has no attribute 'ximgproc', that's why:
pip install opencv-contrib-python
VITMatte and PyMatting paths won't have this problem; it's specific to the guided filter. Worth knowing before you pick it and stare at a traceback.
Outputs and wiring
Two outputs: image (RGBA with your refined alpha) and mask. A typical chain is BiRefNetUltra (or any matting node) → MaskProcessDetails → Save Image as PNG, with the improved mask optionally fed to compositing or inpainting. It slots in anywhere a mask needs to stop looking like a cardboard cutout.
Install
Same pack as the others - clone into custom_nodes, pip install -r requirements.txt, restart. The PyMatting path also wants scikit-image if it's not already in your environment (the node's own error message will tell you). ComfyUI Manager finds the pack by "RemoveBackgroundSuite".
Inputs (9)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| mask | MASK | — | |
| detail_method | COMBO | VITMatte | 4 options: VITMatte, VITMatte(local), PyMatting, GuidedFilter |
| detail_erode | INT | 41–100 | — |
| detail_dilate | INT | 21–100 | — |
| black_point | FLOAT | 0.010.01–0.98 | — |
| white_point | FLOAT | 0.990.02–0.99 | — |
| device | COMBO | cuda | 2 options: cuda, cpu |
| max_megapixels | FLOAT | 2.01–999 | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| mask | MASK | — |