cv2.distanceTransform()计算一幅图像的确定前景,并观察效果 import os import cv2 import numpy as np import matplotlib.pyplot as plt def read_img(img_7_path,img_8_path): img=cv2.imread(img_7_path) gray=cv2.cvtColor(img,cv2.COLOR_BGR2GRAY) img=cv2.cvtColor(img,cv2.COLOR_BGR2RGB) ishow