Nodes/comfyui_cv/CV Merge Contours
ComfyUI Node

CV Merge Contours

Merges contours that lie within 'gap' pixels of each other (boundary to boundary) into one contour per group - reuniting an outline that broke into pieces, or treating a cluster of blobs as one object. 'trace merged outline' closes the gaps morphologically and re-traces the union, keeping the original shapes; 'convex hull per group' spans each group with its hull (simpler, convex). The labels output gives the group id of every INPUT contour - inspect it to see what got merged with what. Output is sorted by area, largest first, like 'CV Find Contours'.

By bmad4ever·Created 3 months ago·Updated 2 days ago· 0
CV Merge Contours
  • image
  • contours
  • contours
  • count
  • labels
gap10
modetrace merged outline (close gaps)
Categoryimage/CV/contours

Inputs (4)

NameTypeDefaultDescription
imageNPARRAY,IMAGE,MASKOnly its width/height are used (the canvas the contours live on). 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.
contoursCV_CONTOURSFrom 'CV Find Contours'.
gapFLOAT100–10000Contours closer than about this many pixels are merged into one.
modeCOMBOtrace merged outline (close gaps)How each group becomes one contour: bridge the gaps and re-trace (keeps the shapes), or take the convex hull of all member points.

Outputs (3)

NameTypeDescription
contoursCV_CONTOURSOne merged contour per group, sorted by area.
countINT
labelsNPARRAYint32 group id per INPUT contour (same order as the input set) - which inputs were merged together.