- 绝大多数格式的医学图像
import SimpleITK as sitk def readimg(path): img = sitk.ReadImage(path) data = sitk.GetArrayFromImage(img) data=data.transpose([1,2,0]) # sitk读取图像channel会转到第一维 # note that the transpose function should have a return value to save the data array return data def writeimg(data, path): img = sitk.GetImageFromArray(data) sitk.WriteImage(img,path)
- Nibabel 包 读nii
import nibabel as nib img_file = nib.load(img_path) data = img_file.get_data() affine = [[1,0,0],[0,1,0],[0,0,1]]# 保持不变 new_vol = nib.Nifti1Image(data,affine) nib.save(new_vol,path)
- Raw data,二进制文件,读取之前需要知道数据大小,类型,可用imageJ查看
import numpy as np Data = np.fromfile(path, dtype=np.int16).reshap
医学图像读写python
最新推荐文章于 2024-07-16 11:39:21 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)