[Insight-users] strange dicom output file

Ming Chao mingchao2005 at gmail.com
Wed Nov 4 15:05:39 EST 2009


because of the 3D volumetric image was in float. I can change that back to
int.

On Wed, Nov 4, 2009 at 2:04 PM, Bill Lorensen <bill.lorensen at gmail.com>wrote:

> Why are you writing the dicom file in floating point?
>
> On Wed, Nov 4, 2009 at 12:59 PM, Ming Chao <mingchao2005 at gmail.com> wrote:
> > I tried what you suggested, but it didn't work. I got the same result
> > though.
> > Ming
> >
> > On Wed, Nov 4, 2009 at 9:56 AM, Bill Lorensen <bill.lorensen at gmail.com>
> > wrote:
> >>
> >> Try making the InputPIxelType short
> >>
> >>  typedef short InputPixelType;
> >>
> >>
> >> On Wed, Nov 4, 2009 at 10:38 AM, Ming Chao <mingchao2005 at gmail.com>
> wrote:
> >> > Hi ITKers.
> >> > Recently I was asking questions here about how to write out an
> >> > multiframe
> >> > dicom file. Thanks for all the help.
> >> > As a matter of fact, it is not so hard to save a 3D volumetric image
> >> > into a
> >> > multiframe dicom file. Please see the attached code. But I do
> encounter
> >> > a
> >> > problem in the output dicom file. Basically the range of the voxel
> >> > values of
> >> > the output file  much narrower than expected ( I attached the images
> >> > from
> >> > the output dicom and original dicom). I double checked the data types
> >> > and
> >> > they seemed fine. Could anyone help? thanks.
> >> > Ming
> >> >
> >> > int main( int argc, char* argv[] ) {
> >> > // Verify the number of parameters in the command line
> >> > if( argc < 4 ) {
> >> > std::cerr << "Usage: " << std::endl;
> >> > std::cerr << argv[0] << " vtkImage InputDicomImage ";
> >> > std::cerr << " OutputImage \n";
> >> > return EXIT_FAILURE;
> >> >     }
> >> > // the following is for an input 2D dicom file
> >> > typedef unsigned short InputPixelType;
> >> > const unsigned int   InputDimension = 3;
> >> > typedef itk::Image< InputPixelType, InputDimension > InputImageType;
> >> > typedef itk::ImageFileReader< InputImageType > InputReaderType;
> >> > InputReaderType::Pointer reader1 = InputReaderType::New();
> >> > reader1->SetFileName( argv[1] );
> >> > typedef itk::GDCMImageIO          InputImageIOType;
> >> > InputImageIOType::Pointer gdcmImageIO = InputImageIOType::New();
> >> > reader1->SetImageIO( gdcmImageIO );
> >> > reader1->Update();
> >> > std::cout << " (1) first dicom file is read in successfully ...." <<
> >> > std::endl;
> >> > // The following is a print out of the tag info
> >> > typedef itk::MetaDataDictionary   DictionaryType;
> >> > const  DictionaryType & dictionary =
> >> > gdcmImageIO->GetMetaDataDictionary();
> >> > typedef itk::MetaDataObject< std::string > MetaDataStringType;
> >> > DictionaryType::ConstIterator itr = dictionary.Begin();
> >> > DictionaryType::ConstIterator end = dictionary.End();
> >> > while( itr != end )
> >> >     {
> >> > itk::MetaDataObjectBase::Pointer  entry = itr->second;
> >> > MetaDataStringType::Pointer entryvalue =
> >> > dynamic_cast<MetaDataStringType *>( entry.GetPointer() ) ;
> >> > if( entryvalue )
> >> > {
> >> > std::string tagkey   = itr->first;
> >> > std::string tagvalue = entryvalue->GetMetaDataObjectValue();
> >> > std::cout << tagkey <<  " = " << tagvalue << std::endl;
> >> > }
> >> > ++itr;
> >> >     }
> >> > // the following is for a 3D volume file
> >> > typedef float PixelType;
> >> > const unsigned int   Dimension = 3;
> >> > typedef itk::Image< PixelType, Dimension > ImageType;
> >> > typedef itk::ImageFileReader< ImageType  >  ReaderType;
> >> >     ReaderType::Pointer reader2 = ReaderType::New();
> >> >     reader2->SetFileName( argv[2] );
> >> > reader2->Update();
> >> > std::cout << " (2) the 3D volume file is read in successfully ...." <<
> >> > std::endl;
> >> >     // the following is for an output 3D dicom file
> >> > typedef float OutputPixelType;
> >> > const unsigned int   OutputDimension = 3;
> >> > typedef itk::Image< OutputPixelType, OutputDimension >
> OutputImageType;
> >> > typedef itk::ImageSeriesWriter< ImageType, OutputImageType >
> >> > OutputWriterType;
> >> > OutputWriterType::Pointer writer = OutputWriterType::New();
> >> > writer->SetFileName( argv[3] );
> >> > writer->SetInput( reader2->GetOutput() );
> >> > writer->SetMetaDataDictionary( reader1->GetMetaDataDictionary() );
> >> > gdcmImageIO->KeepOriginalUIDOn();
> >> > writer->SetImageIO( gdcmImageIO );
> >> > writer->Update();
> >> > std::cout << " (3) the output dicom file is saved successfully and we
> >> > are
> >> > done...." << std::endl;
> >> >
> >> > return 0;
> >> >
> >> > _____________________________________
> >> > Powered by www.kitware.com
> >> >
> >> > Visit other Kitware open-source projects at
> >> > http://www.kitware.com/opensource/opensource.html
> >> >
> >> > Kitware offers ITK Training Courses, for more information visit:
> >> > http://www.kitware.com/products/protraining.html
> >> >
> >> > Please keep messages on-topic and check the ITK FAQ at:
> >> > http://www.itk.org/Wiki/ITK_FAQ
> >> >
> >> > Follow this link to subscribe/unsubscribe:
> >> > http://www.itk.org/mailman/listinfo/insight-users
> >> >
> >> >
> >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20091104/c20b0e86/attachment-0001.htm>


More information about the Insight-users mailing list