[ITK] [ITK-users] Transforming a point

Swetha Sharma swetha.bsharma at gmail.com
Thu Apr 13 01:12:20 EDT 2017


It was helpful thanks ziv
Swetha

On Wed, 12 Apr 2017, 19:11 Yaniv, Ziv Rafael (NIH/NLM/LHC) [C], <
zivrafael.yaniv at nih.gov> wrote:

> 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/community/attachments/20170413/42c718fc/attachment-0001.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