Nodes/ComfyUI-SmartImageTools/Smart Semi-Transparence Remove
ComfyUI Node

Smart Semi-Transparence Remove

Baking the soggy edges of a cutout into a solid color

By slvslvslv·Created about a year ago·Updated 25 days ago· 2
Smart Semi-Transparence Remove
  • image
  • IMAGE
blend_color
threshold0.10
over_threshold
fill_threshold0.95

Smart Semi-Transparence Remove (yes, the spelling is a bit off - search for "Smart Semi" and it'll show up) exists for one very specific pain: background removal hands you an image with fractional alpha - hair strands, glass, smoke, soft edges - and when you drop that cutout onto a colored background, it looks terrible. This node cleans that up by flattening every semi-transparent pixel into a solid color you choose, so what's left is either fully opaque or fully gone. No more grey smudge halo.

How it works

The node works entirely on the alpha channel of an RGBA image (it adds an opaque alpha channel if you feed it plain RGB). It splits pixels into three bands:

  • Alpha < threshold → fully transparent (alpha 0). The default threshold is 0.1, so anything basically transparent stays transparent.
  • Alpha ≥ threshold → made fully opaque, and the RGB is blended toward your chosen blend_color in proportion to how transparent it was. A 50% pixel gets roughly half blend color, half original - which is exactly what a soft edge becomes when you place it on a solid backdrop.
  • over_threshold flips the middle behavior: "Blend" does the proportional blend above; "Fill blend color" fills everything between threshold and fill_threshold with the solid blend color instead, and only blends above fill_threshold (default 0.95). Use Fill when you want hard, clean edges fast - e.g. glass surfaces you want to read as fully colored.

blend_color has 14 named presets (red, green, blue, black, white, yellow, cyan, magenta, gray, dark gray, orange, purple, brown, pink). Pick the color of the background the cutout will sit on.

Input: image. Output: one IMAGE - now RGBA, with alpha almost entirely 0 or 1.

Where it plugs in

It goes right after background removal. The KB's own background-removal material makes the same point in a different way: a segmentation model (u2net, BiRefNet) labels pixels foreground/background, which is structurally wrong for veils and smoke - matting models output fractional alpha instead. This node is the practical resolution: accept the fractional alpha, then bake it into the color of your final backdrop so the edge looks intentional instead of ghostly.

Typical wiring: BiRefNet (or rembg) → SmartSemiTransparenceRemove → composite onto background. Set blend_color to match where the subject lands, run, and the hair edge that used to grey out now reads as background-colored - the standard fix for "my cutout looks dirty."

Installing it

Pack install:

cd ComfyUI/custom_nodes/
git clone https://github.com/slvslvslv/ComfyUI-SmartImageTools
pip install -r ComfyUI-SmartImageTools/requirements.txt

Restart or use ComfyUI Manager ("ComfyUI-SmartImageTools"). Real requirements include scikit-learn, scikit-image, opencv-python, numba on top of numpy/Pillow.

Gotchas

  • Set the blend color first. If the cutout lands on a white page and you blended toward black, you've just baked black into every hair strand. Match the destination.
  • threshold too high eats faint-but-real detail; too low leaves annoying faint pixels. 0.1 is a sane default - nudge by 0.05 and eyeball it.
  • The node is a one-shot flattener - there's no going back to the original alpha afterward, so run it on a copy or downstream of your master branch.
  • "Fill blend color" + high fill_threshold gives you hard-edged, fully colored glass/veils - great for stylized work, wrong if you actually wanted translucency.

It's a small node, but it's the difference between a cutout that looks amateur and one that sits in a scene. If you do any background removal for compositing, this is the cleanup step you didn't know you were missing.

CategorySmartImageTools

Inputs (5)

NameTypeDefaultDescription
imageIMAGE
blend_colorCOMBO14 options: red, green, blue, black, white, yellow, +8
thresholdFLOAT0.100–1
over_thresholdCOMBO2 options: Blend, Fill blend color
fill_thresholdFLOAT0.950–1

Outputs (1)

NameTypeDescription
IMAGEIMAGE