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