2
votes

I denoise an image as describe in Pyscience as follow:

import SimpleITK as sitk

image=sitk.ReadImage("myimage.dcm")
imgSmooth = sitk.CurvatureFlow(image1=image,
                                timeStep=0.00125,
                                numberOfIterations=100)

And I am trying to save it as dicom file:

sitk.WriteImage(imgSmooth, 'denoised.dcm')

But I am having the following error:

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 

I cannot in general save as dicom file using SimpleITK? How can I save my denoised image as dicom file?

1
Because I am facing a major problem, can someone give me some guidance? - DimKoim
Have you tried converting you image back to an signed short? - blowekamp

1 Answers

6
votes

I think you need to convert float to int (or 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')