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'.
CV Merge Contours
- image
- contours
- contours
- count
- labels
◄gap10►
◄modetrace merged outline (close gaps)►
Categoryimage/CV/contours
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| image | NPARRAY,IMAGE,MASK | Only 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. | |
| contours | CV_CONTOURS | From 'CV Find Contours'. | |
| gap | FLOAT | 100–10000 | Contours closer than about this many pixels are merged into one. |
| mode | COMBO | trace 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)
| Name | Type | Description |
|---|---|---|
| contours | CV_CONTOURS | One merged contour per group, sorted by area. |
| count | INT | — |
| labels | NPARRAY | int32 group id per INPUT contour (same order as the input set) - which inputs were merged together. |