<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Title" content="">
<meta name="Keywords" content="">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:Arial;
panose-1:2 11 6 4 2 2 2 2 2 4;}
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
span.gmail-apple-tab-span
{mso-style-name:gmail-apple-tab-span;}
span.EmailStyle18
{mso-style-type:personal-reply;
font-family:Calibri;
color:windowtext;}
span.msoIns
{mso-style-type:export-only;
mso-style-name:"";
text-decoration:underline;
color:teal;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style>
</head>
<body bgcolor="white" lang="EN-US" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Calibri">Hello Swetha,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Calibri"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Calibri">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. <o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Calibri"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Calibri">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.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Calibri"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Calibri"> hope this helps<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Calibri"> Ziv</span><span style="font-size:10.5pt;font-family:Calibri;color:black"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Calibri"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Calibri"><o:p> </o:p></span></p>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-family:Calibri;color:black">From: </span>
</b><span style="font-family:Calibri;color:black">Swetha Sharma <swetha.bsharma@gmail.com><br>
<b>Date: </b>Wednesday, April 12, 2017 at 4:11 AM<br>
<b>To: </b>Insight-users <insight-users@itk.org><br>
<b>Subject: </b>[ITK] [ITK-users] Transforming a point<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Hi, <o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"> 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:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<div>
<p class="MsoNormal">typedef itk::AffineTransform<double,3> AffineTransformType;<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">AffineTransformType::Pointer transf;<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">transf = dynamic_cast<AffineTransformType*>( transfm.GetPointer() );<o:p></o:p></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal">typedef itk::Similarity3DTransform<double> SimilarityTransformType;<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">SimilarityTransformType::Pointer transform = SimilarityTransformType::New();<o:p></o:p></p>
</div>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<div>
<p class="MsoNormal">typedef itk::LandmarkBasedTransformInitializer< SimilarityTransformType, InputImageType, InputImageType > <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">LandmarkBasedTransformInitializerType;<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> LandmarkBasedTransformInitializerType::Pointer landmarkBasedTransformInitializer =<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> LandmarkBasedTransformInitializerType::New();<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"> typedef LandmarkBasedTransformInitializerType::LandmarkPointContainer LandmarkContainerType;<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> typedef LandmarkBasedTransformInitializerType::LandmarkPointType LandmarkPointType;<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> LandmarkContainerType movingLandmarks;<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> LandmarkPointType movingPoint;<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"> double *ptrf_moving_point = ptf_moving_landmark_pointslist;<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> for(int iPointIndex=0;iPointIndex<iNumberofLandMarkPoints_moving;iPointIndex++){<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> movingPoint[0] = (*( ptrf_moving_point )) ;<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">movingPoint[1] = (*( ptrf_moving_point + 1));<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">movingPoint[2] = (*( ptrf_moving_point + 2));<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">movingLandmarks.push_back( movingPoint );<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">ptrf_moving_point = ptrf_moving_point + 3;<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> }<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"> typedef itk::PointSet< double, 3 > PointSetType;<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> PointSetType::Pointer registeredPointSet = PointSetType::New();<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> typedef PointSetType::PointType PointType;<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> PointType registeredPoint;<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> typedef PointSetType::PointsContainer PointsContainer;<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> PointsContainer::Pointer registeredPointContainer = PointsContainer::New();<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> for(int i=0;i<movingLandmarks.size();i++){<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> registeredPoint = transf->TransformPoint( movingLandmarks[i] );<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> registeredPointContainer->InsertElement( i, registeredPoint );<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> }<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"> registeredPointSet->SetPoints(registeredPointContainer);<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">//Write the registered pointset into file<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">std::ofstream registeredFile;<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">registeredFile.open( "registered_points.txt");<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">if( registeredFile.fail() )<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">{<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> return -1;<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">}<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">for( int i = 0; i<registeredPointSet->GetNumberOfPoints(); i++)<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">{<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> registeredPointSet->GetPoint( i, & registeredPoint );<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> for(int j = 0; j<3; j++)<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> {<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> registeredFile<<registeredPoint[j]<<"\t";<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> }<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> registeredFile<<"\n";<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">}<o:p></o:p></p>
</div>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"> Is there a mistake in the code ?How do I transform the points?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">-swetha<o:p></o:p></p>
</div>
</div>
</div>
</body>
</html>