我对Pyscience中描述的图像进行去噪,如下所示:
import SimpleITK as sitk
image=sitk.ReadImage("myimage.dcm")
imgSmooth = sitk.CurvatureFlow(image1=image,
timeStep=0.00125,
numberOfIterations=100)
我正在尝试将其保存为dicom文件:
sitk.WriteImage(imgSmooth, 'denoised.dcm')
但我遇到以下错误:
RuntimeError: Exception thrown in SimpleITK WriteImage: ..\..\..\..\..\ITK\Modules\IO\GDCM\src\itkGDCMImageIO.cxx:1035:
itk::ERROR: GDCMImageIO(000000000F268380): A Floating point buffer was passed but the stored pixel type was not specified.This is currently not supported
我一般不能使用SimpleITK保存为dicom文件?如何将我的去噪图像保存为dicom文件?
答案 0 :(得分:2)
我认为你需要将float转换为int(或uint)。
castFilter = sitk.CastImageFilter()
castFilter.SetOutputPixelType(sitk.sitkInt16)
# Convert floating type image (imgSmooth) to int type (imgFiltered)
imgFiltered = castFilter.Execute(imgSmooth)
sitk.WriteImage(imgFiltered, 'denoised.dcm')