converting pixel type of dicom series and saving them

Hello there,

for my purposes I had to load a 2D dicom series (I used the example DicomSeriesReadSeriesWrite) and create a volume, then I had to change pixel format because my filter accepts only ‘float’ type. I used the CastImageFilter for this, and the RescaleIntensityImageFilter to scale my image between 0 and 255… would it be better for filtering and mathematical operations to put the range between 0 and 1? Do I really have to rescale the original intensity (-3200 and 3200) ?

Now I have to save the filtered volume into 2D slices, so I have to change again the pixel type into the original one…do I need to rescale the intensity into the original -3200, +3200? Or can i leave it between 0 - 255? Does it change something?

Thanks in advance for any help!

Is it a filter you wrote? Or a colleague? And why is float a problem? You can cast all scalar types into float without much trouble. You could also request reading a float image type from the reader and have that image type throughout your pipeline.

And your output could be in the same range as input, or a different range. It depends on what you want to do with your images afterwards.

1 Like

Thank you @dzenanz for answering once again. Nope, it’s the itkCurvatureFlowImageFilter that I want to use (for what i know, it requires ‘float’ type).

Do u know how could i restore the initial range of the dicom series if I want to? Also, do u know if rescaling the range (maybe between 0 and 1) is better for filtering/mathematical operations?
Sorry for my english and thanks in advance for all your help and support!

Judging by its documentation, CurvatureFlowImageFilter is not restricted to float type. You should be able to use it with double, int, unsigned char etc.

Range 0.0-1.0 is not better than other ranges for filtering.

If you use RescaleIntensityImageFilter, you can then use GetScale() and GetShift() methods to know the scaling and offset which that filter applied. Then you can work out the inverse intensity transform, and apply it using ShiftScaleImageFilter, in order to transform filtered values back to the original range of intensities.

1 Like

Perfect! Thank u!