[Insight-users] Problem with ItkImageFileWriter
Bill Lorensen
bill.lorensen at gmail.com
Tue May 11 16:42:50 EDT 2010
0002 0000 is a group length. I'm not sure gdcm lets you change that. I
think group lengths are computed.
On Mon, May 10, 2010 at 2:17 AM, satyanarayana reddy
<satyajanga at gmail.com> wrote:
>
>
>
>
> Hi,
> I am facing a problem with ItkImageFileWriter. I am using the same code
> as in example file(DicomImageReadChangeHeader.cxx) to update a dcmtag but
> the tag is not getting changed in the output file. Plz help me in this..
> The input to this example is one dcm file and one newly created dcm file.
> I have tried to change the tag value of (0002,0000) to 192, but its not
> getting modified. And the header in the output file is little different to
> original input file.
> After removing the comments and doing little modifications the example code
> looks like this..
> #include "itkImageFileReader.h"
>
> #include "itkImageFileWriter.h"
>
> #include "itkImage.h"
>
> #include "itkMetaDataDictionary.h"
>
> #include "itkMetaDataObject.h"
>
> #include "itkGDCMImageIO.h"
>
> #include <list>
>
> #include <fstream>
>
> int main(int argc, char* argv[])
>
> {
>
> typedef signed short InputPixelType;
>
> const unsigned int Dimension = 2;
>
> typedef itk::Image< InputPixelType, Dimension > InputImageType;
>
> typedef itk::ImageFileReader< InputImageType > ReaderType;
>
> ReaderType::Pointer reader = ReaderType::New();
>
> reader->SetFileName( argv[1] );
>
> typedef itk::GDCMImageIO ImageIOType;
>
> ImageIOType::Pointer gdcmImageIO = ImageIOType::New();
>
> reader->SetImageIO( gdcmImageIO );
>
> try
>
> {
>
> reader->Update();
>
> }
>
> catch (itk::ExceptionObject & e)
>
> {
>
> std::cerr << "exception in file reader " << std::endl;
>
> std::cerr << e.GetDescription() << std::endl;
>
> std::cerr << e.GetLocation() << std::endl;
>
> return EXIT_FAILURE;
>
> }
>
> InputImageType::Pointer inputImage = reader->GetOutput();
>
> typedef itk::MetaDataDictionary DictionaryType;
>
> DictionaryType & dictionary = inputImage->GetMetaDataDictionary();
>
> //for (int i = 3; i < argc; i+=2)
>
> //{
>
> std::string entryId( "0002|0000") );
>
> std::string value( "192" );
>
> itk::EncapsulateMetaData<std::string>( dictionary, entryId, value );
>
> //}
>
> std::string value1;
>
> itk::ExposeMetaData<std::string>(dictionary,entryId,value1);
>
> cout << value << " :: " << value1 << endl;
>
> typedef itk::ImageFileWriter< InputImageType > Writer1Type;
>
> Writer1Type::Pointer writer1 = Writer1Type::New();
>
> writer1->SetInput( reader->GetOutput() );
>
> writer1->SetFileName( argv[2] );
>
> writer1->SetImageIO( gdcmImageIO );
>
> try
>
> {
>
> writer1->Update();
>
> }
>
> catch (itk::ExceptionObject & e)
>
> {
>
> std::cerr << "exception in file writer " << std::endl;
>
> std::cerr << e.GetDescription() << std::endl;
>
> std::cerr << e.GetLocation() << std::endl;
>
> return EXIT_FAILURE;
>
> }
>
> return EXIT_SUCCESS;
>
> }
>
>
> The output both value and value1 are same..
>
> But in the file its not getting changed. i am using dcmdump to see the
> header information.
>
> Thank You,
>
> Satya.
>
> _____________________________________
> 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