cv2.connectedComponentsWithAlgorithm, implements faster, more efficient algorithms for connected component analysis. If you have OpenCV compiled with parallel processing support then both cv2.connectedComponentsWithAlgorithm and cv2.connectedComponentsWithStatsWithAlgorithm will run faster than plain connectedcomponents without algorithm func.