Nodes/comfyui_cv/CV Find Contours
ComfyUI Node

CV Find Contours

Extracts contours from a binary image (cv2.findContours) - feed it edges (cv2.Canny) or a threshold/mask image. Color input is converted to grayscale; any non-zero pixel counts as foreground. Contours come out sorted by area, largest first, with specks below min_area dropped. Zero contours is a valid result (count = 0), not an error.

By bmad4ever·Created 3 months ago·Updated 2 days ago· 0
CV Find Contours
  • image
  • contours
  • count
modeRETR_EXTERNAL
methodCHAIN_APPROX_SIMPLE
min_area0
Categoryimage/CV/contours

Inputs (4)

NameTypeDefaultDescription
imageNPARRAY,IMAGE,MASKBinary image (edges or MASK); non-zero = foreground. Accepts a ComfyUI IMAGE/MASK directly (frame 0 of a batch) or an NPARRAY. Arithmetic ops (add, multiply, etc.) process the full IMAGE batch when both inputs have the same batch size.
modeCOMBORETR_EXTERNALRETR_EXTERNAL: only outermost contours (usual choice). RETR_LIST: all, ungrouped; uses the TRUCO parallel engine (OpenCV 4.14+).
methodCOMBOCHAIN_APPROX_SIMPLECHAIN_APPROX_SIMPLE compresses straight segments to their endpoints; CHAIN_APPROX_NONE keeps every boundary pixel.
min_areaFLOAT00–1000000000Drop contours whose area (px²) is below this - filters noise specks. 0 keeps everything.

Outputs (2)

NameTypeDescription
contoursCV_CONTOURS
countINT