src = cv2.imread('/directorypath/image.bmp')
ret, thresh = cv2.threshold(src, 0, 255, cv2.THRESH_BINARY + cv2.THRESH_OTSU)
connectivity = 4
How to use openCV's connected components with stats in python?