可以使用OpenCV库,它包含一系列的图像处理函数,可以帮助你分离多个粘连的物体。示例代码如下: import cv2 # 读取图像 img = cv2.imread("image.jpg") # 转为灰度图 gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) # 使用阈值分割图像 ret, thresh = cv2.threshold(gray, 0, 255, cv2.THRESH_BINARY_INV + cv2.THRESH_OTSU) # 寻找轮廓 contours = cv2.findContours(thresh, cv2.RETR_EXT