[ITK] [ITK-users] Transforming a point
Swetha Sharma
swetha.bsharma at gmail.com
Wed Apr 12 04:11:35 EDT 2017
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/community/attachments/20170412/fb0df69f/attachment.html>
-------------- next part --------------
_____________________________________
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.php
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://public.kitware.com/mailman/listinfo/insight-users
More information about the Community
mailing list