问题描述
我一直在研究 DICOM CT 扫描图像。我使用 simleITK 将图像读取到一个 numpy 数组。但是图像像素值是负浮点值,如图所示,每个像素的 dtype 是 float32。如何转换此像素值以训练 TensorFlow 3D CNN 模型?
# Read the .nii image containing the volume with SimpleITK:
sitk_obj = sitk.ReadImage(filename)
# and access the numpy array:
image = sitk.GetArrayFromImage(sitk_obj)
读取的图像形状各异,如何将它们调整为特定的恒定图像形状?(如下图所示)
解决方法
如果您使用 SimpleITK 的 RescaleIntensity 函数,您可以将像素值重新缩放到您需要的任何范围。这是该功能的文档:
要调整图像大小,您可以使用 SimpleITK 的 ResampleImageFilter。这是该课程的文档:
https://simpleitk.org/doxygen/latest/html/classitk_1_1simple_1_1ResampleImageFilter.html
以下 StackOverflow 答案显示了如何创建一个参考图像,您可以将图像重新采样到该图像上:
https://stackoverflow.com/a/48065819/3712577
这个 Github Gist 如何将多个图像重新采样为相同的参考图像:
https://gist.github.com/zivy/79d7ee0490faee1156c1277a78e4a4c4
请注意,SimpleITK 将图像视为物理空间中的对象。因此,如果图像的原点、方向和像素间距不匹配,那么您将不会得到您期望的结果。