import cv2 import numpy as np import matplotlib.pyplot as plt img=np.load("E:/prostate3Dmask/0/0.npy") img=img[0,:,:]*255 img=img.astype(np.uint8)#读取图像 如果为png等格式直接读取即可 ret,thresh = cv2.threshold(img,127,255,cv2.THRESH_BINARY)#相当于二值化 image,contours,hierarchy = cv2.findContours(thresh,cv2.RETR_TREE,cv2.CHAIN_APPROX_NONE)#即是将图像label的轮廓计算出来 cnt = contours[0] plt.imshow(img) plt.show() (x,y),radius=cv2.minEnclosingCircle(cnt)#利用轮廓计算最小外接圆 print(radius)
图像标签的最小外接圆
最新推荐文章于 2022-07-23 17:01:40 发布