图南蒙版微调
Tidy up a rough mask before it ever touches a sampler
- 蒙版
- 蒙版
A mask straight out of a selection tool is pixel-sharp and jagged. Great for selecting, wrong for inpainting. TuNanMaskRefine is the clean-up step: grow or shrink the boundary, feather the edge into a smooth falloff, or flip the whole thing. MASK goes in, MASK comes out, no model involved. It's one of the two standalone utilities in the 图南画桥 (TuNan Paint Bridge) pack, and it's the fix for the most common reason inpaints look like a sticker was pasted on.
How it works
Four controls, all doing classical image processing (morphology and a Gaussian blur via scipy - fast, deterministic, no VRAM drama):
- 边缘收缩 is where people trip. Despite the name, it's a signed slider from −128 to 128, and positive values expand the mask (dilation), negative values contract it (erosion). +4 grows the boundary outward by four pixels, −4 trims it inward. Think "signed," not "shrink," and you're fine.
- 边缘柔化 feathers the edge with a Gaussian blur, 0–64 (the sigma works out to about a third of the radius you set). This is the seam-killer: hard mask edges are what make regenerated regions show a visible cut line, and a feathered mask blends the boundary into the surrounding image.
- 蒙版反转 is just
1 − mask, for when the selection came over inverted. - In, out, that's the node. 蒙版 (MASK) → 蒙版 (MASK).
Why you'd reach for it
Two very different lives. In the pack's own Photoshop loop, it refines the selection mask TuNanPSBridge hands you before you feed it to SetLatentNoiseMask - shave the fringe, feather the edge, and the inpaint only touches what you actually intended. Standalone, it's the same trick on any mask-based workflow: the classic recipe is shrink a few pixels then feather, so the model regenerates slightly inside the region boundary and the blend is invisible. A 4–12 pixel feather is the usual range people land on; too much and the regeneration bleeds past where you meant it to.
Getting it installed
ComfyUI Manager (search tunan-paint-bridge-nodes or 图南画桥), or:
cd ComfyUI/custom_nodes
git clone https://github.com/beiyue0208ly/tunan-paint-bridge-nodes
cd tunan-paint-bridge-nodes
pip install -r requirements.txt
Restart. Requirements are aiohttp, numpy, Pillow, scipy - no models to download. Like TuNanSmartResize, this node works fully standalone: install the pack for the utilities and you can skip the Photoshop plugin (.ccx) entirely.
Where it bites
The 边缘收缩 sign confusion is the main one - if your mask is bigger than the selection after you "shrunk" it, you've met it. Second: expanding or contracting makes the mask binary and harsh again, so if you grew it several pixels you usually want to re-feather afterward; the controls compose, and the order that works is shrink → feather, not feather → shrink. And the slider's 0.5 step means fractional feathers are fine - you don't need to jump straight to a heavy blur if the hard edge is only mildly ugly.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| 蒙版 | MASK | — | |
| 边缘扩缩 | INT | 0-128–128 | — |
| 边缘柔化 | FLOAT | 0.00–64 | — |
| 蒙版反转 | BOOLEAN | false | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| 蒙版 | MASK | — |