Nodes/ComfyUI-SmartImageTools/Smart Remove Background
ComfyUI Node

Smart Remove Background

Cut out a background without loading a single AI model

By slvslvslv·Created about a year ago·Updated 25 days ago· 2
Smart Remove Background
  • image
  • start_point
  • start_points
  • IMAGE
fill_size1
tolerance0.01
each_point_own_colortrue
debug_pointsfalse
clearEdges0

The name oversells it, and that's the good news. Smart Remove Background isn't an AI cutout tool and it doesn't secretly call some API - it's a classic flood-fill background remover, the digital descendant of the "click the magic wand on the white area" trick that predates diffusion by decades. It loads no model, needs no VRAM, and runs fully on CPU. If that sounds like a downgrade next to BiRefNet and rembg, it sort of is - but for the right input, it's faster, free, and 100% deterministic.

How it works

You give it a starting point (or several) on the background. The node samples the color there, then flood-fills outward, wiping every connected pixel whose color is close enough to that seed into transparency. The core loop is compiled with Numba so it stays fast on big images, and OpenCV handles a morphological closing pass to scrub stray specks at the boundary. Give it multiple points and each flood is ANDed together, so clicking a few background patches gets you a much cleaner cut than any single seed could.

There's a catch baked into the approach: it only removes contiguous, similar-colored background. Hair, fur, and busy real-world backdrops defeat it, and nobody has fixed that in thirty years. If you're cutting a person out of a photo, go use an actual matting model - this node is for flat, solid, or clean-gradient backgrounds: studio product shots, white/green screen captures, or AI generations on a solid backdrop.

The inputs that matter

  • tolerance - how different a pixel can be from the seed color and still count as background (0–1). Start at the 0.01 default and raise it if the background has a slight gradient or JPEG noise; too high and it eats into your subject.
  • fill_size - the size of the edge-cleaning pass. Bump it when you see background-colored specks clinging to edges.
  • each_point_own_color - when off, every seed uses the first point's sampled color. Keep it on unless your background is one uniform color.
  • debug_points - draws red dots where your seeds landed. Turn it on the first time; you'll be glad you did.
  • clearEdges - how many pixels to force transparent along the frame edge. Great for images where the background bleeds all the way to the border.

The optional start_point (a single POINT) and start_points (a POINT_SET) come straight from SmartImagePoint in this same pack - drop one in, click your seeds on the preview, and wire it across. Leave them disconnected and it defaults to the top-left corner.

Output: a single IMAGE, now with an alpha channel - the removed background is transparent.

Installing it

Everything lives in the ComfyUI-SmartImageTools pack. Easiest path is ComfyUI Manager (search "SmartImageTools"), or:

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

Then restart ComfyUI. The dependency list is heavier than the node looks: scikit-learn, scikit-image, OpenCV, and numba - no model downloads, no keys, but real pip installs. Numba is picky about its numpy version, so if pip starts fighting you over numpy, install inside the same Python environment ComfyUI runs in and let it resolve.

Where people get burned

The most common failure is expecting magic on a busy background. If the flood keeps eating into the subject, your tolerance is too high - dial it back and add more seed points instead. If you're fighting hair, stop: this is the wrong tool, and the KB's own verdict is that you pick a background-removal tool by which failure you can tolerate. For flat backgrounds this is genuinely the one I'd reach for - it's instant, offline, and you know exactly what it did.

CategorySmartImageTools

Inputs (8)

NameTypeDefaultDescription
imageIMAGE
fill_sizeINT11–100
toleranceFLOAT0.010–1
each_point_own_colorBOOLEANtrue
debug_pointsBOOLEANfalse
clearEdgesINT00–1000
start_pointoptPOINT
start_pointsoptPOINT_SET

Outputs (1)

NameTypeDescription
IMAGEIMAGE