Nodes/WAS Node Suite v3/Bounding Boxes Filter
ComfyUI Node Runs on cloud

Bounding Boxes Filter

Turn a detector's 'everything' into a shortlist

By WASasquatch·Created 3 years ago·Updated 4 days ago· 1,844
Bounding Boxes Filter
  • bounding_boxes
  • image
  • bounding_boxes
  • count
  • dropped
order
keep0
overlap1.00
min_width0
min_height0
expand0

A detector never answers "the face." It answers everything it saw at its confidence threshold - every face, every false positive, every speck it half-believed in, often the same subject twice. That raw firehose is the starting material for automated detailing, and this node is the funnel that turns it into the shortlist you actually want to work on.

Bounding Boxes Filter lives under WAS Suite/Image/Bound and takes a bounding_boxes input straight from a detector (SAM 3 Detect, Run Real-Time Detection, a MediaPipe landmarker, or Bounds to Bounding Boxes) - it even reads JSON text holding the same boxes. What it does to them is a pipeline of classic region-cleanup steps, each with one input:

  • min_width / min_height - drop anything too small. Set to 64 and every speck under 64 pixels across vanishes. This is the first thing to raise when a low-confidence detector is littering your image with junk regions.
  • overlap - merge duplicates. When two regions overlap by more than this fraction (0.0–1.0), the smaller one is dropped. 0.5 means "drop a region sharing half its area with a larger one." This is how you handle a detector that found the same face twice. Default 1.0 keeps everything, so it does nothing until you lower it.
  • expand - pad (or shrink) every region before it leaves. Positive numbers add room around the subject, which matters because a tight bounding box makes a bad crop; negative numbers pull in the edges and trim a detector that habitually frames loosely.
  • order - put the survivors in a defined sequence: area, largest first (so the main subject lands at index 0, which is what an index switch reads), left to right / top to bottom (for a row of faces or a contact sheet), or as found (the detector's own order).
  • keep - how many of the ordered survivors to actually keep. 0 = all, 1 = only the first. Set order first, since this counts from the top of that order.

The optional image input matters more than it looks: connect the picture the regions were found on, and every region is clamped inside the frame, so an expanded region can't run off the edge of the canvas. Leave it unconnected and a padded region may sit partly outside the picture.

What comes out

Three outputs. bounding_boxes is the filtered, ordered list, ready for the next stage. count tells you how many survived - the wire to read if "none" is a real possibility and your graph should branch on it. dropped tells you how many the settings removed, which is the debugging output: when you can't work out why a detector's five regions became zero, dropped shows the filter ate them all and you'll know to loosen overlap or drop min_width.

The workflow it belongs to

This is the front end of the detect → crop → upscale → refine → paste loop that automated detailing runs on (the same loop Impact Pack's SEGS make famous on its side of the fence). WAS's version: a detector finds regions, this node cleans and orders them, converters hand them to the bounds system, and Bounds to Mask or a bounded crop turns each into work. Where people go wrong, it's usually the ordering of settings: filter before you order and keep, so keep: 1 means "the largest face," not "whatever the detector listed first." And if you're feeding an index switch per region, remember index 0 is whatever order put at the top - set area, largest first and index 0 becomes the main subject.

Installing

Part of WAS Node Suite v3 (WASasquatch/was-node-suite-comfyui), WASasquatch's MIT pack - going since 2023, over a million downloads, and where a lot of these image operations first reached ComfyUI. This node runs on torch and needs no detector model of its own - it just sorts and filters what you feed it. Requires ComfyUI 0.14.0+ (v3 is built on the newer node backend).

Via ComfyUI Manager, search WAS Node Suite v3, or clone it:

cd ComfyUI/custom_nodes
git clone https://github.com/WASasquatch/was-node-suite-comfyui

Restart ComfyUI and it appears under WAS Suite/Image/Bound. Missing after install? Update ComfyUI first.

CategoryWAS Suite/Image/Bound

Inputs (8)

NameTypeDefaultDescription
bounding_boxesBOUNDING_BOX,BOUNDING_BOXES,STRINGThe regions to reduce. Wire in SAM3 Detect, Run Real-Time Detection, MediaPipe's landmarker or Bounds to Bounding Boxes. JSON text holding the same boxes is read too.
orderCOMBOWhat order the regions come out in. `area, largest first` puts the main subject at index 0, which is what an index switch reads; `left to right` and `top to bottom` suit a row of faces or a contact sheet; `as found` leaves the detector's own order.
keepINT00–4096How many to keep after ordering. 0 = all, 1 = only the first, 5 = the first five. Set order first, since this counts from the top of that order.
overlapFLOAT1.000–1How much two regions may share before the smaller is dropped. 1.0 = keep everything, 0.5 = drop a region sharing half its area with a larger one, 0.0 = drop anything touching. Use it where a detector found the same subject twice.
min_widthINT00–16384Narrowest region kept, in pixels. 0 = keep every width, 64 = drop anything under 64 across, which clears the specks a low threshold picks up.
min_heightINT00–16384Shortest region kept, in pixels. 0 = keep every height, 64 = drop anything under 64 tall.
expandINT0-16384–16384Pixels every edge moves out by, applied after the size test. 0 = as found, 32 = 32px of room on every side for a crop, -8 = pulled in, which trims a detector's habit of framing loosely.
imageoptIMAGEThe picture the regions were found on. Connected, every region is held inside the frame, so an expanded one cannot run off the edge. Unconnected, a region may sit partly outside the picture.

Outputs (3)

NameTypeDescription
bounding_boxesBOUNDING_BOXThe regions kept, in the chosen order.
countINTHow many were kept, for a switch that handles none.
droppedINTHow many the settings removed, so a filter that took too much shows.