[ITK-users] [ITK] Transforming a point

Yaniv, Ziv Rafael (NIH/NLM/LHC) [C] zivrafael.yaniv at nih.gov
Wed Apr 12 09:41:13 EDT 2017


Hello Swetha,

In general, the transformations computed using the ITK registration framework are from the fixed coordinate system to the moving coordinate system. Thus, the transformation should be applied as T(point_fixed) = point_moving.

I did not read your code so I may be missing something specific to your work, but this mapping is something that many newcomers to ITK seem to get confused with.

     hope this helps
             Ziv


From: Swetha Sharma <swetha.bsharma at gmail.com>
Date: Wednesday, April 12, 2017 at 4:11 AM
To: Insight-users <insight-users at itk.org>
Subject: [ITK] [ITK-users] Transforming a point

Hi,

  I have a affine transformation matrix with a set of points as fixed landmarks and moving landmarks. I was trying to verify the transformation by using the transform point method in the transformation class,ideally i should get back the fixed points when i give the moving points as input , but I am not getting it as the output.  The code which i used is as below:

typedef itk::AffineTransform<double,3> AffineTransformType;
AffineTransformType::Pointer transf;

transf = dynamic_cast<AffineTransformType*>( transfm.GetPointer() );
typedef itk::Similarity3DTransform<double> SimilarityTransformType;
SimilarityTransformType::Pointer transform = SimilarityTransformType::New();

typedef itk::LandmarkBasedTransformInitializer< SimilarityTransformType, InputImageType, InputImageType >
LandmarkBasedTransformInitializerType;
   LandmarkBasedTransformInitializerType::Pointer landmarkBasedTransformInitializer =
   LandmarkBasedTransformInitializerType::New();

   typedef LandmarkBasedTransformInitializerType::LandmarkPointContainer     LandmarkContainerType;
   typedef LandmarkBasedTransformInitializerType::LandmarkPointType          LandmarkPointType;

   LandmarkContainerType movingLandmarks;

   LandmarkPointType movingPoint;

   double *ptrf_moving_point = ptf_moving_landmark_pointslist;
   for(int iPointIndex=0;iPointIndex<iNumberofLandMarkPoints_moving;iPointIndex++){
   movingPoint[0] = (*( ptrf_moving_point )) ;
movingPoint[1] = (*( ptrf_moving_point + 1));
movingPoint[2] = (*( ptrf_moving_point + 2));
movingLandmarks.push_back( movingPoint );
ptrf_moving_point = ptrf_moving_point + 3;
   }

   typedef itk::PointSet< double, 3 >   PointSetType;
   PointSetType::Pointer registeredPointSet = PointSetType::New();
   typedef PointSetType::PointType     PointType;
   PointType registeredPoint;
   typedef PointSetType::PointsContainer  PointsContainer;
   PointsContainer::Pointer registeredPointContainer = PointsContainer::New();

   for(int i=0;i<movingLandmarks.size();i++){
  registeredPoint =   transf->TransformPoint( movingLandmarks[i] );
       registeredPointContainer->InsertElement( i, registeredPoint );
   }

   registeredPointSet->SetPoints(registeredPointContainer);

//Write the registered pointset into file
std::ofstream   registeredFile;
registeredFile.open( "registered_points.txt");
if( registeredFile.fail() )
{
  return -1;
}
for( int i = 0; i<registeredPointSet->GetNumberOfPoints(); i++)
{
  registeredPointSet->GetPoint( i, & registeredPoint );
  for(int j = 0; j<3; j++)
  {
   registeredFile<<registeredPoint[j]<<"\t";
  }
  registeredFile<<"\n";
}

 Is there a mistake in the code ?How do I transform the points?
-swetha
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/insight-users/attachments/20170412/c1e7dd11/attachment.html>


More information about the Insight-users mailing list