上采样:丰富图像信息
下采样:降低图像维度
利用zoom函数
order=0,最近邻插值
order=1,双线性插值
order=2,
zoom<1,下采样,>1,上采样
import SimpleITK as sitk from scipy.ndimage.interpolation import zoom import matplotlib.pyplot as plt path = 'G:/brats17-paper/Brats18preprocessing/HGG/Brats18_2013_2_1/Brats18_2013_2_1.nii.gz' img = sitk.ReadImage(path) data = sitk.GetArrayFromImage(img) plt.imshow(data[100,:,:], cmap = 'gray') plt.show() data_img = zoom(data, zoom = 0.5, order=1) print(data_img.shape) plt.imshow(data_img[50,:,:], cmap = 'gray') plt.show()
文章来源: https://blog.csdn.net/weixin_42338058/article/details/85048902