BackgroundRemover
The bluntest 'remove background' node you'll ever meet
- image
- IMAGE
Straight talk before you get excited: this node has nothing to do with the AI background-removal models you've heard of. No BiRefNet, no rembg, no segmentation network, no downloaded weights. It finds the single most common color in your image and turns every pixel of exactly that color transparent. That's the whole algorithm - a color counter plus a pixel loop.
Which sounds useless for photos, and it is. But this pack is about SDXL pixel art, and that's exactly the situation where a blunt flat-color heuristic is the right tool. When you generate pixel art on a solid background, that background is one giant block of a single color - which is precisely what "most common color" finds. What comes out is an RGBA image with the flat backdrop knocked out, ready to drop onto another canvas, an avatar, or a sprite sheet.
How it works
The node counts every unique RGB triple with a Counter, takes the mode (the most common color), then walks the image pixel by pixel: exact match → alpha 0, anything else → alpha 255. No tolerance, no edge feathering, no smoothing. The output is a 4-channel RGBA image; the input is just an image (it throws an error if you feed it anything that isn't 3-channel).
Because it's pure pixel logic, it's instant - no GPU involved, no model load, works on a batch in a single pass.
Where it burns you
The exact-match requirement is the whole story. JPEG or WebP compression, gradients, film grain, or even a soft shadow means the "background" pixels are all slightly different, and almost none of them equal the mode exactly. The result is a fully opaque image and a silent "why didn't it work" moment. It also only handles one background color - a two-tone backdrop leaves the second one behind. And if your subject's dominant color happens to be the same as the background's, you carve holes straight through the subject.
If you actually need real subject extraction - hair, fur, semi-transparency - don't reach for this. That's what BiRefNet (now built into ComfyUI core) and rembg/InSPyReNet are for; this pack's node isn't competing with them. It's for one job: killing a flat, solid background on clean rendered art, and pairing with AstropulsePixelDetector in the pack's SDXL pixel-art workflow - generate, snap to pixels, knock out the background, composite.
The inputs
One input, image (IMAGE). One output, the RGBA IMAGE. That's it. There isn't a color picker, a tolerance slider, or a "pick which color" override - you get the mode, and you live with it. For the pack's pixel-art use case that's fine; for anything else it's a very sharp corner.
How to install it
Shared with the rest of this pack, which is a work in progress (the README says "not tested, yet"). The author, Pfaeff, is a long-time community handle from the early diffusers era. Install with ComfyUI Manager if it shows up in the registry, or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/Pfaeff/pfaeff-comfyui
then restart. Dependencies are opencv-python-headless and diffusers, installed automatically on first load.
Common issues & troubleshooting
Output is fully opaque. Your background isn't one exact color. Render clean (PNG, no compression) or skip this node and use a real segmentation model.
Holes in the subject. The subject shares the dominant color with the background. Change the background color or don't use this node.
"Input must be a 3-channel image" - you fed it something with an alpha channel already, or a 1-channel mask. Run it on the plain RGB image.
Jagged edges are normal here - hard 0/255 alpha with no cleanup. For pixel art that's actually correct; the chunky edges are the aesthetic.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |