[Insight-users] Representation of deformation field

Josiane Yankam Njiwa--DEA Clarysse--Fin 11/04 njiwa at creatis.insa-lyon.fr
Wed May 26 10:48:02 EDT 2004


Hi,

I use the deformableRegistration4.cxx, and I have problem to write the
deformationField in file ( image), so I hope to keep these values that i
will use in another viewer.
I wrote the code below, but I have in my file all the points at 0, and I
don't understand why.
Is somebody can help me .

Regards.

Josiane

typedef itk::Vector< float, ImageDimension >  VectorType;
  typedef itk::Image< VectorType, ImageDimension >  DeformationFieldType;

  DeformationFieldType::Pointer field = DeformationFieldType::New();
  field->SetRegions( fixedRegion );
  field->SetOrigin( fixedImage->GetOrigin() );
  field->SetSpacing( fixedImage->GetSpacing() );
  field->Allocate();

  typedef itk::ImageRegionIterator< DeformationFieldType > FieldIterator;
  FieldIterator fi( field, fixedRegion );

  fi.GoToBegin();

  TransformType::InputPointType  fixedPoint;
  TransformType::OutputPointType movingPoint;
  DeformationFieldType::IndexType index;

  VectorType displacement;

  std::ofstream file;
  std::ofstream file1;

  file.open("Essai.txt");
  file1.open("Essai1.txt");


  while( ! fi.IsAtEnd() )
    {
    index = fi.GetIndex();
    field->TransformIndexToPhysicalPoint( index, fixedPoint );
    movingPoint = transform->TransformPoint( fixedPoint );
	std::cout << fixedPoint    << std::endl;
	std::cout << movingPoint    << std::endl;
    displacement[0] = movingPoint[0] - fixedPoint[0];
    displacement[1] = movingPoint[1] - fixedPoint[1];
	file << displacement[0];
	file1 << displacement[1];
    fi.Set( displacement );
    ++fi;
    }
 file.close();
 file1.close();


More information about the Insight-users mailing list