Teeth Find Contours
OpenCV Contours Without Leaving ComfyUI
- image
- Contour_List
- ContoursMask
- GrayMask
- BinaryMask
- markedImage
- numContoursFound
Sometimes you don't want to detect a face, you want to detect every bright blob in an image and know where it is. That's Teeth Find Contours: classic OpenCV contour detection wrapped as a ComfyUI node, with a size filter, a pile of masks, and a marked-up preview on output. It comes from the ComfyUI-Teeth pack, a small single-author utility collection that sits in the "computer vision plumber's knife" category. It won't win awards, but when you need it, nothing else in the base install does it.
The natural use: you've segmented something (teeth, cells, parts, any mask-ish image) and you want each discrete region's bounding box and center to drive a crop or feed into another node. This is the step that turns "an image with bright bits" into "a list of regions I can act on."
How it works
The node does the standard OpenCV pipeline in one shot. Your IMAGE tensor becomes a grayscale numpy array, gets thresholded at threshold_thresh (default 180), and cv2.findContours runs with external-only retrieval and simple approximation. The detect_white_contours toggle flips between THRESH_BINARY (bright regions) and THRESH_BINARY_INV (dark regions) - default is on, so it's looking for light blobs on a darker background.
Then comes the filter that matters. Every contour's minimum-area rectangle (the rotated one) is checked: width must be between min_width and max_width, height between min_height and max_height. And here's the trap: max_width and max_height default to 33. If you feed it a normal-sized image, nearly every contour is bigger than 33 pixels and you get zero results. The first thing to do on any real input is raise those caps.
Inputs and outputs that matter
- image (IMAGE, required)
- threshold_thresh - binarization cutoff, 0–255, default 180.
- min_width / min_height / max_width / max_height - the size filter. Defaults (1 to 33) are tuned for tiny blobs; raise the maxes.
- detect_white_contours - bright vs. dark blob detection.
Six outputs come out, and they're the reason this node is worth it:
- Contour_List - a LIST of dicts, one per surviving contour, each with
area,bounding_rect_x/y/width/height, the rotatedmin_rect_*geometry, andmin_rect_center. Wire this into a text node to eyeball it. - ContoursMask - a filled-in MASK of the detected contours.
- GrayMask / BinaryMask - the grayscale and thresholded versions, useful for debugging or as masks.
- markedImage - the preview with each contour drawn in a rotating color.
- numContoursFound - the count.
Because it's an output node, it also pushes a read-only info box into the UI showing the count - the pack's frontend adds it automatically.
Common issues
- Zero contours found. Almost always the 33px default caps. Raise
max_width/max_heightuntil results appear. - The wrong things detected. Flip
detect_white_contours- it's binary vs. inverse binary, and dark-on-light images need the inverse. - Threshold too low or high. Everything below
threshold_threshbecomes background. If you're getting one giant blob swallowing the image, raise it.
Install
ComfyUI Manager: search ComfyUI-Teeth. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/steelan9199/ComfyUI-Teeth
Restart. The heavy dependency here is opencv-python, which virtually every ComfyUI install already has. There are no model files - this is pure numpy + OpenCV, no weights, no downloads. That's the good news about the whole pack.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| threshold_thresh | INT | 1800–255 | — |
| min_width | INT | 10–1000000 | — |
| min_height | INT | 10–1000000 | — |
| max_width | INT | 330–1000000 | — |
| max_height | INT | 330–1000000 | — |
| detect_white_contours | BOOLEAN | true | — |
Outputs (6)
| Name | Type | Description |
|---|---|---|
| Contour_List | LIST | — |
| ContoursMask | MASK | — |
| GrayMask | MASK | — |
| BinaryMask | MASK | — |
| markedImage | IMAGE | — |
| numContoursFound | INT | — |