🐳遮罩虚实
One node that turns fuzzy masks into crisp cutouts
- mask
- MASK
This is the kind of node that has one job and does it perfectly. 🐳遮罩虚实 (AutoMaskSolidifier) takes any mask and binarizes it: every pixel brighter than pure black becomes pure white, everything else becomes pure black. That's it. One input, one output, zero knobs. And yet it quietly fixes a huge class of ComfyUI problems.
Why would you want that? Detector masks are rarely clean. MediaPipe, SAM, and even hand-painted masks come out with soft feathered edges, faint gray smears where the model was unsure, or a barely-there gradient that's supposed to be a hard boundary. Feed one of those into a composite or an inpaint and you get halos, leaking edges, and blur bleeding into the background. Solidify first and the mask becomes a hard, unambiguous cutout - no gray areas for the compositor to misinterpret. The name "虚实" (solid/hollow) captures it: it makes the mask decisive.
How it works
The implementation is about as minimal as a node can be. It ensures the mask has a batch dimension, then runs a torch.where(mask > 0, 1, 0) - any pixel above zero becomes one, everything else zero. That's the entire mechanism. Because it's pure tensor math there's no OpenCV dependency, no model, no download, and it runs on GPU as fast as a copy. It's the cheapest node in the pack to run.
Inputs and outputs
- Input:
mask(MASK). Can be 2D or batched - it handles both. - Output: a single
MASK, fully binary.
Wire the output into any mask consumer: Composite nodes, inpainting (the sharp edge means the inpaint region boundary is crisp), or mask-based composite nodes like AdvancedMaskImageComposite from the same pack. That last pairing is genuinely common - you'll see 遮罩虚实 feeding the subject mask slot of a composite so the paste seam is clean.
Install and honest trade-offs
Part of comfy_Pond_Nodes:
cd ComfyUI/custom_nodes
git clone https://github.com/Pondowner857/comfy_Pond_Nodes
cd comfy_Pond_Nodes && pip install -r requirements.txt
The trade-off is the one you'd expect from hard thresholding: anything that should be a soft gradient - a feathered selection, a smoke edge, a glow - gets killed. If your mask has intentional softness, don't run it through this. The README of the pack doesn't document it in detail (it's one line in the mask section), so the rule of thumb is yours to keep: solidify masks meant to be hard edges, never masks meant to be soft. For a utility this small, that's the only real decision.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| mask | MASK | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| MASK | MASK | — |