[Insight-users] I/O issue

Alyassin, Abdalmajeid M (Research) alyassin at crd.ge.com
Mon, 1 Mar 2004 11:41:25 -0500


Hi,

I'm having a hard time reading back a 2D Deformation Field I saved in itk.
I'm using the following code ...

#include "itkImageFileReader.h" 
#include "itkImageFileWriter.h" 
#include "itkVector.h"
#include "itkRawImageIO.h"
#include "itkImageIOBase.h"

 const unsigned int Dimension = 2;
 typedef float PixelType;
 typedef itk::Vector< float, Dimension >    VectorPixelType;
 typedef itk::ImageFileReader< DFImageType >   DFImageReaderType;

 itk::RawImageIO<PixelType,Dimension>::Pointer io =
itk::RawImageIO<PixelType,Dimension>::New();
  io->SetFileDimensionality(2);
  io->CanReadFile(argv[3]);
  io->SetDimensions(0,175);
  io->SetDimensions(1,175);
  io->SetByteOrderToLittleEndian();
  io->SetFileTypeToBinary();
  io->SetSpacing(0,1);
  io->SetSpacing(1,1);
  io->SetNumberOfComponents(2);

  DFImageReaderType::Pointer dfImageReader = DFImageReaderType::New();
  dfImageReader->SetFileName( argv[3] );
  dfImageReader->SetImageIO(io);
  dfImageReader->Update();

the code compiles ok but it reads in zero values that are different than
what is actually in deformation field files !!!
is there a better way to read this? Any help is appreciated.

Majeid