Hi,<div><br></div><div> I do not quite understand your question. I think you want to know how to compute the tracker points after registration </div><div>using TPS. If this is your question, I think you have already solved it with this line of your code.</div>
<div><br><br><div> TPSTransformType::OutputPointType trackerPointNewPosition;</div><div> trackerPointNewPosition = tps->TransformPoint(trackerPoint);</div><div> std::cout<<"trackerPointNewPosition: " <<trackerPointNewPosition<<std::endl;</div>
<div><br></div><div> You can create a new PointSetType object to keep your tracker points after TPS transform.</div><div>If this is not your question, could you make your question a little clearer and maybe more specific?</div>
<div><br></div><div><br></div><div>Regards,</div><div><br></div><div>Ja </div><br><br><div class="gmail_quote">On Sat, Aug 11, 2012 at 7:05 AM, agatte <span dir="ltr"><<a href="mailto:wiatrak11@poczta.onet.pl" target="_blank">wiatrak11@poczta.onet.pl</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
Hi,<br>
<br>
I have a question about TPS transformation in ITK.<br>
I have set of 5 sources and target points(landmarks).<br>
I want to compute TPS transformation.<br>
I used ThinPlateSpline example for it.<br>
I want to compute new positions of point after transformation.<br>
What I can compute new position of each landmark after transformation ?<br>
I would be appreciate for any help please.<br>
<br>
Here I attach code :<br>
<br>
int main()<br>
{<br>
<br>
double tab[30] =<br>
{<br>
// sources landmarks from tracker<br>
-81.29,-31.07, -770.58,<br>
-83.11, -21.26, -822.64,<br>
-93.45, -32.44, -858.72,<br>
-68.08, -126.89,-813.07,<br>
-61.04, 75.74, -808.36,<br>
<br>
// target landmarks from image - dicom<br>
140.6, 230.7, -30.5,<br>
140.2, 231.7, -71.1,<br>
144.8, 235.9, -116.1,<br>
45.8, 220.2, -66.7,<br>
231.6, 211.3, -66.1<br>
<br>
};<br>
<br>
<br>
const unsigned int Dimension = 3;<br>
typedef unsigned char PixelType;<br>
typedef double CoordinateRepType;<br>
typedef itk::ThinPlateSplineKernelTransform<<br>
CoordinateRepType,Dimension> TPSTransformType;<br>
typedef itk::Point< CoordinateRepType,Dimension > PointType;<br>
typedef std::vector< PointType > PointArrayType;<br>
typedef TPSTransformType::PointSetType PointSetType;<br>
typedef PointSetType::Pointer PointSetPointer;<br>
typedef PointSetType::PointIdentifier PointIdType;<br>
<br>
<br>
<br>
<br>
// Landmarks correspondances may be associated with the<br>
SplineKernelTransforms<br>
// via Point Set containers. Let us define containers for the landmarks.<br>
PointSetType::Pointer sourceLandMarks = PointSetType::New();<br>
PointSetType::Pointer targetLandMarks = PointSetType::New();<br>
PointType trackerPoint; PointType imagePoint;<br>
PointSetType::PointsContainer::Pointer sourceLandMarkContainer =<br>
sourceLandMarks->GetPoints();<br>
PointSetType::PointsContainer::Pointer targetLandMarkContainer =<br>
targetLandMarks->GetPoints();<br>
<br>
<br>
<br>
<br>
// 1 Landmark<br>
trackerPoint[0] = tab[0];<br>
trackerPoint[1] = tab[1];<br>
trackerPoint[2] = tab[2];<br>
imagePoint[0] = tab[15];<br>
imagePoint[1] = tab[16];<br>
imagePoint[2] = tab[17];<br>
sourceLandMarkContainer->InsertElement( 0,trackerPoint);<br>
targetLandMarkContainer->InsertElement(0,imagePoint);<br>
<br>
// 2 Landmark<br>
trackerPoint[0] = tab[3];<br>
trackerPoint[1] = tab[4];<br>
trackerPoint[2] = tab[5];<br>
imagePoint[0] = tab[18];<br>
imagePoint[1] = tab[19];<br>
imagePoint[2] = tab[20];<br>
sourceLandMarkContainer->InsertElement(1,trackerPoint);<br>
targetLandMarkContainer->InsertElement(1,imagePoint);<br>
<br>
// 3 Landmark<br>
trackerPoint[0] = tab[6];<br>
trackerPoint[1] = tab[7];<br>
trackerPoint[2] = tab[8];<br>
imagePoint[0] = tab[21];<br>
imagePoint[1] = tab[22];<br>
imagePoint[2] = tab[23];<br>
sourceLandMarkContainer->InsertElement( 2,trackerPoint);<br>
targetLandMarkContainer->InsertElement(2,imagePoint);<br>
<br>
// 4 Landmark<br>
trackerPoint[0] = tab[9];<br>
trackerPoint[1] = tab[10];<br>
trackerPoint[2] = tab[11];<br>
imagePoint[0] = tab[24];<br>
imagePoint[1] = tab[25];<br>
imagePoint[2] = tab[26];<br>
sourceLandMarkContainer->InsertElement( 3,trackerPoint);<br>
targetLandMarkContainer->InsertElement(3,imagePoint);<br>
<br>
// 5 Landmark<br>
trackerPoint[0] = tab[12];<br>
trackerPoint[1] = tab[13];<br>
trackerPoint[2] = tab[14];<br>
imagePoint[0] = tab[27];<br>
imagePoint[1] = tab[28];<br>
imagePoint[2] = tab[29];<br>
sourceLandMarkContainer->InsertElement(4,trackerPoint);<br>
targetLandMarkContainer->InsertElement(4,imagePoint);<br>
<br>
TPSTransformType::Pointer tps = TPSTransformType::New();<br>
tps->SetSourceLandmarks(sourceLandMarks);<br>
tps->SetTargetLandmarks(targetLandMarks);<br>
// ComputeMAtrix<br>
tps->ComputeWMatrix();<br>
<br>
TPSTransformType::OutputPointType trackerPointNewPosition;<br>
trackerPointNewPosition = tps->TransformPoint(trackerPoint);<br>
std::cout<<"trackerPointNewPosition:<br>
"<<trackerPointNewPosition<<std::endl;<br>
<br>
// TPSTransformType::OutputVectorType pointsAfterTr;<br>
// pointsAfterTr = tps->TransformVector(sourceLandMarks);<br>
<br>
<br>
// save transformation<br>
typedef itk::TransformFileWriter TransformWriterType;<br>
TransformWriterType::Pointer transformWriter = TransformWriterType::New();<br>
transformWriter->AddTransform( tps);<br>
transformWriter->SetInput(tps);<br>
transformWriter->SetFileName("tps.txt");<br>
transformWriter->Update();<br>
<br>
<br>
<br>
return EXIT_SUCCESS;<br>
<br>
<br>
}<br>
<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://old.nabble.com/TPS--compute-new-position-of-points--tp34285325p34285325.html" target="_blank">http://old.nabble.com/TPS--compute-new-position-of-points--tp34285325p34285325.html</a><br>
Sent from the ITK - Users mailing list archive at Nabble.com.<br>
<br>
_____________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at<br>
<a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Kitware offers ITK Training Courses, for more information visit:<br>
<a href="http://www.kitware.com/products/protraining.php" target="_blank">http://www.kitware.com/products/protraining.php</a><br>
<br>
Please keep messages on-topic and check the ITK FAQ at:<br>
<a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
</blockquote></div><br></div>