PDtools_Filter_WPNG_v2
Soft alpha plus unpremultiply, no more halo fringes
- image
- image
- mask
The v2 that's a different animal, not a better v1
PDtools_Filter_WPNG_v2 looks like the sequel to the white-logo threshold node, but it's built for a completely different material: glowing assets on black - neon text, light effects, fire, anything with a bright core and a soft, semi-transparent halo. Instead of a hard threshold that snaps pixels to pure black or white, it produces a soft alpha from brightness and then unpremultiplies the color, which is what makes a glow sit naturally on a new background instead of carrying a dark fringe.
If you've ever cut out a neon sign and watched it composite with an ugly grey edge, you've met the problem this node solves. The halo is semi-transparent, and semi-transparent means its color was premultiplied against the black background - darken the halo by 30% when you composite and you see the seam. This node estimates that alpha and divides the color back out (unpremultiply), recovering the glow's true color, which is the standard trick of the compositing world and is exactly the family the KB's background-removal.md says the ecosystem keeps rediscovering. AI matting gives you a mask; this gives you an alpha that knows the halo is a halo.
How it works
From the source: alpha starts as the max of the RGB channels (the classic "luminosity as transparency" estimate), anything at or below black_threshold is zeroed (kills JPG noise and the near-black background), then a small Gaussian blur (sigma 0.8) smooths it into a soft edge. The image is then divided by that alpha to undo the premultiplication, clamped, and black where alpha is zero. Output: the glow with its color restored on black, plus the soft mask.
black_threshold (default 0.02) is the knob: raise it and you crush more of the dark background and faint speckle, but you also start eating the faint outer edge of the glow. Lower it and you keep every wisp of halo, plus whatever noise the JPEG threw in.
Inputs and outputs
image- the glow-on-black source.black_threshold- float, 0.0 to 0.5, default 0.02.- Outputs:
image(unpremultiplied RGB, black background) andmask(soft alpha). Composite with the mask, not by trusting the black preview.
Installing it
Part of Comfyui_PDuse:
cd ComfyUI/custom_nodes
git clone https://github.com/7BEII/Comfyui_PDuse.git
cd Comfyui_PDuse
pip install -r requirements.txt
Or search "Comfyui_PDuse" in ComfyUI Manager and restart.
v1 vs v2, and the traps
Pick v1 for clean black-and-white logos (you want hard edges and a binary mask). Pick v2 for anything with glow, soft edges, or semi-transparency - and know that feeding v2 a flat white logo will give you a soft, slightly-rounded result instead of the crisp punch v1 gives. The main trap is the same as the sibling nodes: the output is RGB-on-black plus a mask, so remember the mask is the thing you composite with, and a dark-but-not-black asset (dark grey text on black) will get its colors brightened by the unpremultiply - that's the intended behavior, but it can look "lifted" if your source was already dark grey rather than genuinely glowing. For neon and light effects, it's the right member of the family.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| black_threshold | FLOAT | 0.0200–0.5 | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| mask | MASK | — |