Nodes/Comfyui_PDuse/PD-remove white background
ComfyUI Node

PD-remove white background

The no-model magic wand

By 7BEII·Created 2 years ago·Updated a day ago· 53
PD-remove white background
  • image
  • image
  • mask
white_threshold0.95
edge_black_threshold0.10
invert_maskfalse
binary_maskfalse

By mid-2026 "remove background" in ComfyUI means loading a segmentation model - BiRefNet ships in core, rembg and InSPyReNet are a node away, and they're all fighting over hair and transparency. PDRemoveWhiteBackground is the opposite of that world. No model, no download, no VRAM. It's a flood-fill "magic wand" that starts at the image edge and eats the white background until it hits the subject. Deterministic, instant, and free.

That makes it the right tool for a specific job: clean, flat, solid-color backgrounds. Product shots on white, scans, renders with a white card backdrop. For those, a 200MB model is overkill and a threshold approach is exact - the background is literally white, so you don't need to infer anything. For hair, gradients, or a noisy backdrop, this is the wrong node and you know it before you start.

How it works

The mechanism is three steps per frame, all plain numpy:

  1. A pixel counts as "white" when all three channels are at or above white_threshold (default 0.95 - it takes a bright white, not off-white).
  2. A pixel counts as "dark" when all channels are at or below edge_black_threshold (default 0.1), if that's enabled.
  3. A flood fill runs from all four borders through any candidate pixel, and everything it reaches is marked as background.

That flood-fill-from-the-edge detail is the whole trick. Because background is defined as edge-connected white (or black), a white shirt, white text, or specular highlights sitting inside the subject survive - they're not connected to the border, so the wand doesn't touch them. Isolated white blobs in the middle of the image are safe. That's what makes this a magic wand instead of a dumb threshold.

What you actually get

image (IMAGE) out is the original, untouched image - this node does not composite a transparent PNG for you. It's a mask generator. The mask (MASK) output marks the background as 1.0 and the subject as 0.0, so you still have to apply it: multiply the image by 1 - mask, feed the pair to a compositor, or wire the mask wherever your workflow suppresses a region. If your downstream expects the subject in white, run the mask through core InvertMask first. Watch the polarity - it's the difference between "removed background" and "removed subject."

The two inputs worth touching:

  • white_threshold (0–1, default 0.95) - how bright "white" must be. A cream or slightly grey backdrop? Drop it toward 0.85–0.9 and it'll catch more. Drop it too far and it starts eating bright parts of the subject that touch a dimmer background.
  • edge_black_threshold (0–0.5, default 0.1) - also treat near-black edge pixels as background. It exists for the classic case of a bright subject on a black backing, or a dark shadow rim around the subject. Set it to 0 to disable if your subject is dark and touches the border, or it'll get nibbled.

Troubleshooting

Expect a hard edge. There's no feathering or edge-blur control in this node, so anti-aliased pixels against white leave a thin halo - a common and honest limitation of the approach. If the halo matters, either feed this mask through a blur/feather node or step up to a model-based remover. And know the honest limits: a white background with soft shadows or gradients won't cut cleanly, because "all channels >= 0.95" doesn't hold in the gradient. That's not a bug; it's the tool telling you which job it does.

Install

It's part of the Comfyui_PDuse pack, so pack-level install. ComfyUI Manager, search "Comfyui_PDuse", or:

cd ComfyUI/custom_nodes
git clone https://github.com/7BEII/Comfyui_PDuse
cd Comfyui_PDuse
pip install -r requirements.txt

No model files, ever. The pack's heavy requirements (scipy, opencv-python) are for its batch and file nodes - this one is pure numpy and torch. It's the cheap, repeatable, no-download path to a clean cutout, sitting right next to the fancy model-based ones. Reach for it first on flat backgrounds; graduate to BiRefNet when the background fights back.

CategoryPDuse/Image

Inputs (5)

NameTypeDefaultDescription
imageIMAGE
white_thresholdFLOAT0.950–1
edge_black_thresholdFLOAT0.100–0.5Treat edge-connected pixels at or below this brightness as background. Set to 0 to disable.
invert_maskBOOLEANfalseInvert the final foreground/background selection.
binary_maskBOOLEANfalseConvert the final mask to pure black and white. This disables soft anti-aliased edges.

Outputs (2)

NameTypeDescription
imageIMAGE
maskMASK