Nodes/ComfyUI-SmartImageTools/Smart Point Set Merge
ComfyUI Node

Smart Point Set Merge

Building a multi-click background removal, one point at a time

By slvslvslv·Created about a year ago·Updated 24 days ago· 2
Smart Point Set Merge
  • point_set
  • point
  • POINT_SET

Smart Point Set Merge is where the pack's point system stops being plumbing and starts being useful. It takes a POINT_SET and one new POINT, and returns a new POINT_SET with that point appended. Chain a few of these together and you get a list of click-points you can hand to a flood-fill background remover so it eats every background region you care about in a single pass - the "remove the sky, the floor, and that table in the corner" workflow.

How it works

The mechanism is deliberately functional. merge_point copies the incoming set and appends the new point:

new_set = point_set.copy()
new_set.append(point)
return (new_set,)

Two things worth noticing. First, it returns a new set - the original POINT_SET is untouched, so you can branch the same set off to multiple merges if you ever want different subsets for different consumers. Second, order is preserved: points come out in the order you merge them, which matters if a downstream node treats the first point specially (SmartBackgroundRemove, for example, can sample its color from the first point when you're not using per-point colors).

Inputs: point_set (POINT_SET) and point (POINT). Output: POINT_SET.

Where it plugs in

The assembly pattern is a daisy chain:

  • SmartPointSmartPointSet → one SmartPointSetMerge, then a second SmartPointSmartPointSetMerge, and so on, each merge adding one more point.
  • The finished POINT_SET goes to SmartBackgroundRemove (start_points), which flood-fills from every point - each one a separate background color it samples on the spot. That's the real answer to "the background isn't one color."
  • It also feeds SmartDrawPoints, which renders a dot (circle, with configurable size and color) at every point in the set.

If you find yourself merging ten points by hand, step back - SmartImagePoint is the interactive node that lets you drag a bunch of dots directly on the image and outputs the whole POINT_SET without all the wiring. Hand-assembly makes sense for a handful of points or points driven by numbers; the canvas node is the better tool for clicky, visual work.

Installing it

Standard pack install - ComfyUI-SmartImageTools:

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

Restart, or grab it from ComfyUI Manager under "ComfyUI-SmartImageTools". The real requirements.txt installs scikit-learn, scikit-image, numpy, Pillow, opencv-python, and numba - expect a slow first start while those land.

Gotchas

  • Order matters if you rely on the first point for a shared background color. Merge your "main" background point first.
  • The merge is immutable - you don't grow a set in place, you keep threading the returned set forward. Wire the new POINT_SET output into the next merge, not the old one.
  • A point that lands inside your subject isn't filtered out anywhere. Garbage in, garbage out - the flood fill will happily sample a subject-colored pixel and eat your subject.

It's a dead-simple node, but it's the difference between one-click background removal and removal that actually works on messy images. And in a pack where the whole point system is this minimal, a tiny merge node is the hinge everything else swings on.

CategorySmartImageTools

Inputs (2)

NameTypeDefaultDescription
point_setPOINT_SET
pointPOINT

Outputs (1)

NameTypeDescription
POINT_SETPOINT_SET