I tried what you suggested, but it didn't work. I got the same result though.<div><br></div><div>Ming<br><br><div class="gmail_quote">On Wed, Nov 4, 2009 at 9:56 AM, 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;">Try making the InputPIxelType short<br>
<br>
typedef short InputPixelType;<br>
<div><div></div><div class="h5"><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 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 into a<br>
> multiframe dicom file. Please see the attached code. But I do encounter a<br>
> problem in the output dicom file. Basically the range of the voxel values of<br>
> the output file much narrower than expected ( I attached the images from<br>
> the output dicom and original dicom). I double checked the data types 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 = 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 are<br>
> done...." << std::endl;<br>
><br>
> return 0;<br>
><br>
</div></div>> _____________________________________<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>
</blockquote></div><br></div>