Cv2.connectedComponents
lastmod 2026-11-10created 2023-10-162 edits
cv2.connectedComponents is an OpenCV function that performs connected-component labeling on a binary image. It assigns a unique integer label to each blob of adjacent foreground pixels and returns the number of labels and a label map of the same size as the input; the connectivity argument selects 4-connectivity or 8-connectivity. If you also need each blob's area and bounding box, use connectedComponentsWithStats.