我正在尝试在 MRI 切片的特定部分绘制轮廓。代码如下:
epi_img = nib.load('G:\BTech Project Dataset\MICCAI_BraTS17_Data_Training\HGG\Brats17_CBICA_AAL_1\Brats17_CBICA_AAL_1_t2.nii.gz')
epi_img_data = epi_img.get_data()
slice_2 = epi_img_data[:, :, 78]
###Selection of the best region for tumor incidence
se1 = cv2.getStructuringElement(cv2.MORPH_RECT, (7,7))
se2 = cv2.getStructuringElement(cv2.MORPH_RECT, (5,5))
###Performing Closing Operation
closing_mask = cv2.morphologyEx(thresholded2, cv2.MORPH_CLOSE, se1)
###Performing Opening Operation
opening_mask = cv2.morphologyEx(closing_mask, cv2.MORPH_OPEN, se2)
### find contours in the edge map
cnts = cv2.findContours(thresholded2.copy(), cv2.RETR_EXTERNAL,cv2.CHAIN_APPROX_SIMPLE)
cnts = cnts[0] if imutils.is_cv2() else cnts[1]
cnts=np.array(cnts)
cv2.drawContours(slice_2,cnts, -1, (0, 255, 0), 2)
我在这里提到了类似的其他问题,并应用了他们建议的解决方案。不过,我一直收到同样的错误