[Insight-users] strange dicom output file

Luis Ibanez luis.ibanez at kitware.com
Sun Nov 8 14:50:49 EST 2009


Hi Ming,

1)  What is the dynamic range of the original image ?

     That is,
      what is the lowest pixel value and the highest pixel value.

2) Is there a chance that you could share the image ?

    It will make a lot easier for us to replicate that problem
    that you are seeing, and to suggest a solution.


 Please let us know,


   Thanks


         Luis


----------------------------------------------------------------------
On Wed, Nov 4, 2009 at 3:05 PM, Ming Chao <mingchao2005 at gmail.com> wrote:
> 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
>> >> >
>> >> >
>> >
>> >
>
>
> _____________________________________
> 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
>
>


More information about the Insight-users mailing list