[Insight-users] Qs about reading and writing (DICOM) images
Andinet Enquobahrie
andinet.enqu at kitware.com
Tue Oct 17 07:49:14 EDT 2006
Hi Alexander,
>Hello all,
>
>I have some questions regarding reading and writing images. I am currently working on a file converter, that is able to read and write various ITK and VTK file formats.
>Here are my questions:
>
>1) Is there a possibility, to determine the component type of an images before defining the reader type? I want to be able to automatically detect images of the types "short", "unsigned short" and "char", or is this only possible with user interaction?
>
>
Yes it is possible. Look at the following code fragment
typedef itk::ImageIOBase::IOComponentType PixelType;
itk::ImageIOBase::Pointer imageIO =
itk::ImageIOFactory::CreateImageIO( this->FileName.c_str(),
itk::ImageIOFactory::ReadMode );
imageIO->SetFileName( this->FileName.c_str() );
imageIO->ReadImageInformation();
PixelType pixelType = imageIO->GetComponentType();
Then you can check
switch( pixelType )
{
case itk::ImageIOBase::UCHAR:
{
......
}
case itk::ImageIOBase:CHAR:
{
.......
}
etc ....
>2) Is it possible to write 12 bit DICOM images (i.e. 16 bit, of which only 12 are effectively used)? So far, when I write a "short" or "unsigned short" image, it is always stored with 16 bit, so the largest possible value is around 65k. In my opinion, I should somehow be able to set the "BitsStored" tag (0028,0101) to 12 and "HighBit" (0028,0102) to 11.
>
>3) How exactly is the "RescaleIntercept" tag (0028,1052) handled? When I read a DICOM image with the value -1000, I get pixels with negative values. Does this mean, the negative values are stored in the file? Or does it mean, that the positive values have been reduced by 1000 by the GDCMImageIO in order to get the Hounsfield values? In the latter case, is there a way to avoid this and write the tag to the output file instead?
>
>
The answer is the latter.
The GDCM IO extracts/parses the slope and intercept parameters from the
DICOM header and applies
these transformation parameters to the CT values automatically when
DICOM image is read.
Take a look at "itkGDCMImageIO.cxx". Specifically, method
GDCMImageIO::Read( void * buffer )
Hope that answers your questions
-Andinet
>
>
More information about the Insight-users
mailing list