影像组学学习笔记(27)-SimpleITK包介绍

本笔记来源于B站Up主: 有Li 的影像组学的系列教学视频
本节(27)主要讲解: 功能强大的图像处理工具SimpleITK

视频中李博士演示了SimpleITK的两个基本功能:图像格式转换以及图像镜像翻转

  1. 导入SimipleITK包
import SimpleITK as sitk
  1. .dcm格式转换为.nii格式
folderPath = 'C:/Users/RONG/Desktop/SimpleITK/'

reader = sitk.ImageSeriesReader()
dicom_names = reader.GetGDCMSeriesFileNames(folderPath)
reader.SetFileNames(dicom_names)
image = reader.Execute()

sitk.WriteImage(image, folderPath + 'test.nii.gz')

3.镜像翻转

image_arr = sitk.GetArrayFromImage(image) # Note: order:z, y, x !!
size = image.GetSize()
origin = image.GetOrigin() #order: x, y, z
spacing = image.GetSpacing() #order:x, y, z
direction = image.GetDirection()
print(spacing) 

pixelType = sitk.sitkUInt8
image_new = sitk.Image(size,pixelType)

image_arr_new = image_arr[:,:,::-1]
image_new = sitk.GetImageFromArray(image_arr_new)
image_new.SetDirection(direction)
image_new.SetSpacing(spacing)
image_new.SetOrigin(origin)
sitk.WriteImage(image_new,folderPath + "test_reverseX.nii.gz")

SimpleITK包图像处理功能很强大,更多内容请探索其官网SIMPLEITK: A simplified path to Insight

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容