[Insight-users] how to save a dicom file after processing with its original header infomation

Chris Lee yuexili at gmail.com
Tue May 1 20:21:17 EDT 2007


Hi, Lius,

2007/5/2, Luis Ibanez <luis.ibanez at kitware.com>:
>
>
> Hi Chris,
>
> What exactly was changed in the image content (the pixel data) ?
>
> Did the intensities of the pixels changed ?


---------------Yes, I changed the intensities of the pixels.

What was the pixel type of the original data ?


---------------I didn't know the exactly pixel type of the original data,
>From it header infomation of "(0028,0100) Bits Allocated
    US          2    16"        and       " (0028,0101) Bits Stored
US          2    12" , I think it may be 16-bits.  Is it unsigned short??.


What was the pixel type that you used for
> instantiating the itk::Image<> in your code ?




If you instantiate the image using the correct pixel type,
> then the values should not change.
>
> What tool are you using for looking at the DICOM image
> pixel data ?


 --------------------Actualy I used the filter work-flow described in the
example "CurvesLevelSet".
typedef itk::Image< float, 2 >  InputImageType;
 typedef itk::Image< unsigned char, 2 >  OutputImageType;

typedef
itk::BinaryThresholdImageFilter<    InputImageType,  OutputImageType    >
ThresholdingFilterType;
ThresholdingFilterType::Pointer thresholder = ThresholdingFilterType::New();

 typedef  itk::ImageFileReader< InternalImageType > ReaderType;
 typedef  itk::ImageFileWriter<  OutputImageType  > WriterType;

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

 reader->SetFileName( argv[1] );
 reader->SetImageIO( gdcmIO );
 writer->SetFileName( argv[2] );
 //writer->SetImageIO( gdcmIO );

............. // filter and process

///--------------------I use this to make the output images'dicom image
header

 typedef itk::MetaDataDictionary DictionaryType;
 DictionaryType & dictionary = gdcmIO->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 labelId;
   bool found = itk::GDCMImageIO::GetLabelFromTag( tagkey, labelId );
   std::string tagvalue = entryvalue->GetMetaDataObjectValue();
   itk::EncapsulateMetaData<std::string>( dictionary, labelId, tagvalue );

   if( found )
   {
    std::cout << "(" << tagkey << ") " << labelId;
    std::cout << " = " << tagvalue.c_str() << std::endl;
   }
   // Software Guide : EndCodeSnippet
   else
   {
    std::cout << "(" << tagkey <<  ") " << "Unknown";
    std::cout << " = " << tagvalue.c_str() << std::endl;
   }
  }

  ++itr;
 }

//-------------------header infomation end

 thresholder->SetInput( geodesicActiveContour->GetOutput() );
 writer->SetInput( thresholder->GetOutput() );
Is it right? The problem exist the data type change from float to unsighed
char??





>   Please let us know,
>
>
>     Thanks
>
>
>
>        Luis
>
>
>
> ------------------
> Chris Lee wrote:
> > Hi, itkers,
> >
> > I need help about the problem how to save a dicom file after processing
> > with its orginal header infomation.
> > In detail, I filter and segment a dicom image file, for example, CT
> image,
> > and I want the result file can be saved in the format of dicom and with
> > the same header infomation( including image position, instance number
> > and so on ).
> >
> > I learned from the example "DicomImageReadChangeHeaderWrite",.
> > However, when I run this example, I made the paramaters Entry as "
> > 0020|0013", Value as "7".
> > As a result, I found the output dicom image file with the correct
> > Instance Number as 7, and the image content (the pixel data) was
> changed.
> >
> > Did I misunderstand this example?
> > And if I want to achive my goal as the title said, what can I do?
> >
> > Thank you.
> >
> > --
> > Best wishes,
> > Chris
> >
> >
> > ------------------------------------------------------------------------
> >
> > _______________________________________________
> > Insight-users mailing list
> > Insight-users at itk.org
> > http://www.itk.org/mailman/listinfo/insight-users
>



-- 
Best wishes,
Chris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20070502/7e1565c2/attachment.htm


More information about the Insight-users mailing list