图像间距在simpleITK中如何工作?

时间:2019-09-09 08:30:06

标签: simpleitk

我是SimpleITK的新手,我对调整图像大小有疑问。 以我的理解,间距是像素之间的距离。因此,我认为如果将间距减小一半,则可以得到一个新的半尺寸图像而不会丢失像素数据。但是,当我运行下面的代码时,我需要增加两次间距以获取一半大小的图像。另外,新文件的大小比原始文件小得多,因此我担心数据丢失。我在这里做错什么了吗?

dicom_names = reader.GetGDCMSeriesFileNames(data_directory)
reader.SetFileNames(dicom_names)
image = reader.Execute()
size = image.GetSize()
spacing = image.GetSpacing()
print("Original image size:", size)
print("Original image spacing:", spacing)

new_spacing = np.array(spacing) * 2
new_size = (np.round(size * (np.array(spacing)/new_spacing))).astype(int).tolist()

resampled_image = sitk.Resample(image, new_size, sitk.Transform(), sitk.sitkNearestNeighbor, image.GetOrigin(), new_spacing, image.GetDirection(), 0.0, image.GetPixelID())
resampled_image_size = resampled_image.GetSize()
resampled_image_spacing = resampled_image.GetSpacing()
print("Resampled image size:", resampled_image_size)
print("Resampled image spacing:", resampled_image_spacing)

0 个答案:

没有答案