[Insight-users] Fwd: Help on DICOM image reading bug

S Sam sd2usa at gmail.com
Mon Aug 28 01:06:04 EDT 2006


Since my first try to send this message was bounced back. I have to resend
it again and remove the DICOM image due to restricted bytes in the message.

If you are interested in solving this problem, please let me know your
e-mail address, and I will send the DICOM image immediately.

Thank you again.
Sam

---------- Forwarded message ----------
From: Xuejun <sd2usa at gmail.com>
Date: Aug 28, 2006 12:51 AM
Subject: Help on DICOM image reading bug
To: insight-users at itk.org
Cc: sd2usa at gmail.com



Dear all ITK users and developers;



I am encountering a problem in reading DICOM image and I am attaching the
image asking for your help and advice.



Since the pixel type of the DICOM image is "14U", I modified the file
itkGDCMImageIO.cxx accordingly and recompiled and generated the ITK library.
After getting the bufferpointer using GetBufferPointer, it was found that
about half of the image data were lost, and the image display using OpenGL
indicates obviously that upper part of the image is blank. I tested the code
using a TIFF image whose dimension is larger than that of the DICOM image,
it works very well. That leads to me doubt about if there is a bug in
GDCMImageIO for reading such DICOM image or something wrong with my code.
The following is the major part of the code:



typedef unsigned short InputPixelType;

       const unsigned int   InputDimension = 2;



       typedef itk::Image< InputPixelType, InputDimension > InputImageType;

       typedef itk::ImageFileReader< InputImageType > ReaderType;

       typedef InputImageType::SizeType         SizeType;



       ReaderType::Pointer reader = ReaderType::New();

       reader->SetFileName( "Slice_38.dcm" );



//     DICOM image IO type

       typedef itk::GDCMImageIO           DicomImageIOType;

       DicomImageIOType::Pointer gdcmImageIO = DicomImageIOType::New();

       reader->SetImageIO( gdcmImageIO );

//     END DICOM image IO type



// TIFF image IO type

//     typedef itk::TIFFImageIO           TiffImageIOType;

//     TiffImageIOType::Pointer TiffImageIO = TiffImageIOType::New();

//     reader->SetImageIO( TiffImageIO );

// END TIFF image IO type



       try

    {

              reader->Update();

    }

       catch (itk::ExceptionObject & err)

    {

              std::cerr << "exception in file reader " << std::endl;

              std::cerr << err << std::endl;

              return ;

    }





       InputImageType::Pointer image = reader->GetOutput() ;



       InputPixelType *pointer = image->GetBufferPointer() ;

       unsigned long lWidth = image->GetBufferedRegion().GetSize()[0] ;

       unsigned long lHeight = image->GetBufferedRegion().GetSize()[1] ;



// Display the image by OpenGL

glClearColor(0.0, 0.0, 0.0, 0.0);



       glShadeModel(GL_FLAT);

       glPixelStorei(GL_UNPACK_ALIGNMENT, 1);



       glClear(GL_COLOR_BUFFER_BIT);



       glRasterPos2i(0, 0);



       glDrawPixels(lWidth, lHeight, GL_LUMINANCE, GL_UNSIGNED_SHORT,
pointer ) ;

       glPixelZoom(0.2, 0.2);



The DICOM image can be displayed normally using DICOM image display
software.



Your kind help and any advice are greatly appreciated.





Best regards,

Sam
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20060828/65ebc532/attachment.htm


More information about the Insight-users mailing list