[Insight-users] Problem [ with iterators]

agatte wiatrak11 at poczta.onet.pl
Sat Aug 18 12:56:59 EDT 2012


Hi ITK  Users ;)

I have a little problem with iterators into Points.
I lost. It's something wrong with my code.
I always receive the same value of points (the last).
Could anyone help me please ?

int main(int argc, char* argv[])
{

	double tab[30] = 
	{
	 // Tracker
	-81.29,-31.07,	-770.58, 
    -83.11,	-21.26,	-822.64,
    -93.45,	-32.44,	-858.72,
    -68.08,	-126.89,-813.07,
    -61.04,	75.74,	-808.36,

	 // Image
    140.6,	230.7,	-30.5,
    140.2,	231.7,	-71.1,
    144.8,	235.9,	-116.1,
    45.8,	220.2,	-66.7,
    231.6,	211.3,	-66.1
	
	};
	

  const     unsigned int   Dimension = 3;
  typedef   unsigned char  PixelType;
  typedef   double CoordinateRepType;
  typedef   itk::ThinPlateSplineKernelTransform<
CoordinateRepType,Dimension>     TPSTransformType;
  typedef   itk::Point< CoordinateRepType,Dimension >  PointType;
  typedef   std::vector< PointType >                   PointArrayType;
  typedef   TPSTransformType::PointSetType      PointSetType;
  typedef   PointSetType::Pointer            PointSetPointer;
  typedef   PointSetType::PointIdentifier  PointIdType;


  // Landmarks correspondances may be associated with the
SplineKernelTransforms
  // via Point Set containers. Let us define containers for the landmarks.
  PointSetType::Pointer sourceLandMarks = PointSetType::New();
  PointSetType::Pointer targetLandMarks = PointSetType::New();
  PointType trackerPoint;     PointType imagePoint;
  PointSetType::PointsContainer::Pointer sourceLandMarkContainer = 
                                   sourceLandMarks->GetPoints();
  PointSetType::PointsContainer::Pointer targetLandMarkContainer = 
                                   targetLandMarks->GetPoints();
 



  // 1 Landmark
  trackerPoint[0] = tab[0];
  trackerPoint[1] = tab[1];
  trackerPoint[2] = tab[2];
  imagePoint[0] = tab[15];
  imagePoint[1] = tab[16];
  imagePoint[2] = tab[17];
  sourceLandMarkContainer->InsertElement( 0,trackerPoint);
  targetLandMarkContainer->InsertElement(0,imagePoint);


 
  // 2 Landmark
  trackerPoint[0] = tab[3];
  trackerPoint[1] = tab[4];
  trackerPoint[2] = tab[5];
  imagePoint[0] = tab[18];
  imagePoint[1] = tab[19];
  imagePoint[2] = tab[20];
  sourceLandMarkContainer->InsertElement(1,trackerPoint);
  targetLandMarkContainer->InsertElement(1,imagePoint);
 
  // 3 Landmark
  trackerPoint[0] = tab[6];
  trackerPoint[1] = tab[7];
  trackerPoint[2] = tab[8];
  imagePoint[0] = tab[21];
  imagePoint[1] = tab[22];
  imagePoint[2] = tab[23];
  sourceLandMarkContainer->InsertElement( 2,trackerPoint);
  targetLandMarkContainer->InsertElement(2,imagePoint);
 
  // 4 Landmark
  trackerPoint[0] = tab[9];
  trackerPoint[1] = tab[10];
  trackerPoint[2] = tab[11];
  imagePoint[0] = tab[24];
  imagePoint[1] = tab[25];
  imagePoint[2] = tab[26];
  sourceLandMarkContainer->InsertElement( 3,trackerPoint);
  targetLandMarkContainer->InsertElement(3,imagePoint);

  // 5 Landmark
  trackerPoint[0] = tab[12];
  trackerPoint[1] = tab[13];
  trackerPoint[2] = tab[14];
  imagePoint[0] = tab[27];
  imagePoint[1] = tab[28];
  imagePoint[2] = tab[29];

  sourceLandMarkContainer->InsertElement(4,trackerPoint);
  targetLandMarkContainer->InsertElement(4,imagePoint);

  TPSTransformType::Pointer tps = TPSTransformType::New();
  tps->SetSourceLandmarks(sourceLandMarks);
  tps->SetTargetLandmarks(targetLandMarks);
  tps->ComputeWMatrix();


agatte
typedef PointSetType::PointsContainer::ConstIterator PointIterator;
PointSetType::PointsContainer::Pointer transformed_points_container
=sourceLandMarks->GetPoints();
PointSetType::Pointer transformed_points = PointSetType::New();
PointIterator pointIterator = sourceLandMarks->GetPoints()->Begin();
PointIterator pointEnd = sourceLandMarks->GetPoints()->End();
TPSTransformType::OutputPointType trackerPointNewPosition;

while( pointIterator != pointEnd )
{

   trackerPointNewPosition = tps->TransformPoint(trackerPoint);
   trackerPointNewPosition = pointIterator.Value();
   std::cout << trackerPointNewPosition<< std::endl;
   ++pointIterator;
}



  return EXIT_SUCCESS;


}


agatte

-- 
View this message in context: http://old.nabble.com/Problem---with-iterators--tp34317145p34317145.html
Sent from the ITK - Users mailing list archive at Nabble.com.



More information about the Insight-users mailing list