[Insight-developers] InsightApplications/ConvertBetweenFileFormats not working for DICOM images with slope/intercept

Kent Williams kent at psychiatry.uiowa.edu
Thu Feb 9 10:30:39 EST 2006


The reason there was a problem is this: DICOM supports integer pixels, 
but also gives a slope and intercept for scaling and offsetting pixel 
values. If the slope is other than 1.0 and the intercept other than 0.0, 
GDCM converts the integer data to floating point so that no precision is 
lost. 

At any rate, there doesn't seem to be any harmful effects for putting 
the floating point conversions back in, other than code size.

Marius Staring wrote:

> The reason why I commented the float part out was because I thought 
> that GDCM did not support float types, but only doubles. Checking the 
> code I think I was wrong, however in the function 
> InternalReadImageInformation() there is no check for float pixeltypes, 
> only for (unsigned) char short int and double.
>
> So, the commenting out was intentional, and I am not sure if floats 
> are supported.
>
> Regards,
>
> Marius
>
> Kent Williams wrote:
>
>> ConvertBetweenFileFormats, in addition to being a useful example, is 
>> a very useful program to have around for use in shell scripts.  It 
>> does a good job job of converting between any ITK-supported file 
>> format, to any other ITK-supported file format.
>>
>> But, it was defeated by a DICOM data set that turned up here at 
>> Iowa.  ConvertBetweenFileFormats silently gives up the ghost without 
>> writing any output.
>>
>> This seemed mysterious until I poked around in itkGDCMImageIO.cxx and 
>> saw what it was doing to recover the input image data type.  In the 
>> case of integer data, if the slope is not 1.0 and/or the intercept is 
>> not 0.0, it promotes the ComponentType of the file to float, in order 
>> to allow the Pixel(X) = Slope * X + Intercept calculation to get 
>> reasonable results.
>>
>> This, unfortunately runs afoul of the DicomFileConverterScaler and 
>> DicomFileConverterScalerA functions that do the real work for 
>> ConvertBetweenFileFormats, because the code to convert from float to 
>> other data types was commented out.  I've just checked in a change 
>> that uncomments this code -- it looks as though the commenting-out 
>> was unintentional.
>>
>> _______________________________________________
>> Insight-developers mailing list
>> Insight-developers at itk.org
>> http://www.itk.org/mailman/listinfo/insight-developers
>>
>



More information about the Insight-developers mailing list