[Insight-users] question ? Landmark based rigid registration

agata agatakrason at gmail.com
Wed Oct 10 16:07:04 EDT 2012


agatte

Hi,

I am working on landmark based rigid registration. 
I have a problem with extraction a points after registration. 
I need to return  new positions of points after rigid transformation.


Could anyone help me please ?

I would appreciate for any help. 

Here is some of my code :
int main()
{
	double tab[30] = {
		// dicom
		211.8,	367.4,	-342.2,
        145.9,	366.6,	-298.4,
        56.3,	300.2,	-222.2,
        228.3,	356.00,	-135.9,
        132.3,	343.3,	-182.2,
		//tracker
	   399.75,	-66.95,	-1192.5,
       407.32,	-106.15,-1128.63,
       481.56,	-148.32,-1024.61,
       445.21,	37.98,	-1037.52,
       448.87,	-63.5,	-1024.64

	};


	const    unsigned int   Dimension = 3;
    typedef  unsigned char  PixelType;
    typedef itk::Image< PixelType, Dimension > ImageType;
	typedef itk::ImageFileReader<ImageType> ReaderType;
	typedef itk::ImageFileWriter<ImageType> WriterType;


	typedef   float          VectorComponentType;
    typedef   itk::Vector< VectorComponentType, Dimension >    VectorType;

   typedef itk::VersorRigid3DTransform< double > Rigid3DTransformType;
   typedef
itk::LandmarkBasedTransformInitializer<Rigid3DTransformType,ImageType,
ImageType> 
      LandmarkBasedTransformInitializerType;

  LandmarkBasedTransformInitializerType::Pointer
landmarkBasedTransformInitializer =
  LandmarkBasedTransformInitializerType::New();

  //  Create source and target landmarks.
  typedef LandmarkBasedTransformInitializerType::LandmarkPointContainer    
LandmarkContainerType;
  typedef LandmarkBasedTransformInitializerType::LandmarkPointType         
LandmarkPointType;
 
  LandmarkContainerType imageLandmarks;
  LandmarkContainerType trackerLandmarks;
 
  LandmarkPointType imagePoint; // data from CT
  LandmarkPointType trackerPoint; //data from tracking system

  // 1 Landmark
  imagePoint[0] = tab[0];
  imagePoint[1] = tab[1];
  imagePoint[2] = tab[2];
  trackerPoint[0] = tab[15];
  trackerPoint[1] = tab[16];
  trackerPoint[2] = tab[17];
  imageLandmarks.push_back(imagePoint );
  trackerLandmarks.push_back(trackerPoint );
 
  // 2 Landmark
  imagePoint[0] = tab[3];
  imagePoint[1] = tab[4];
  imagePoint[2] = tab[5];
  trackerPoint[0] = tab[18];
  trackerPoint[1] = tab[19];
  trackerPoint[2] = tab[20];
  imageLandmarks.push_back(imagePoint );
  trackerLandmarks.push_back(trackerPoint );
 
  // 3 Landmark
  imagePoint[0] = tab[6];
  imagePoint[1] = tab[7];
  imagePoint[2] = tab[8];
  trackerPoint[0] = tab[21];
  trackerPoint[1] = tab[22];
  trackerPoint[2] = tab[23];
  imageLandmarks.push_back(imagePoint );
  trackerLandmarks.push_back(trackerPoint );
 
  // 4 Landmark
  imagePoint[0] = tab[9];
  imagePoint[1] = tab[10];
  imagePoint[2] = tab[11];
  trackerPoint[0] = tab[24];
  trackerPoint[1] = tab[25];
  trackerPoint[2] = tab[26];
  imageLandmarks.push_back(imagePoint );
  trackerLandmarks.push_back(trackerPoint );

  // 5 Landmark
  imagePoint[0] = tab[12];
  imagePoint[1] = tab[13];
  imagePoint[2] = tab[14];
  trackerPoint[0] = tab[27];
  trackerPoint[1] = tab[28];
  trackerPoint[2] = tab[29];
  imageLandmarks.push_back(imagePoint );
  trackerLandmarks.push_back(trackerPoint );
 
 
  landmarkBasedTransformInitializer->SetFixedLandmarks( imageLandmarks);
  landmarkBasedTransformInitializer->SetMovingLandmarks( trackerLandmarks);
 

  // RIGID TRANSFORM
  Rigid3DTransformType::Pointer rigidTransform =
Rigid3DTransformType::New();
  rigidTransform->SetIdentity();
  landmarkBasedTransformInitializer->SetTransform(rigidTransform);
  landmarkBasedTransformInitializer->InitializeTransform();

  cout<<"transform : \n"<<rigidTransform&lt;&lt;endl;
  cout&lt;&lt;&quot;Parametry : \n
&quot;&lt;&lt;rigidTransform->GetParameters()<<endl;

  Rigid3DTransformType::MatrixType matrixRigid =
rigidTransform->GetRotationMatrix();
  Rigid3DTransformType::OffsetType offsetRigid =
rigidTransform->GetOffset();
  cout<<"matrix:  "<<matrixRigid&lt;&lt;endl;
  cout&lt;&lt;&quot;offset:  &quot;&lt;&lt;offsetRigid&lt;&lt;endl;


  // Here I  am trying to extract new position of landmarks after
registration :

  LandmarkContainerType  transformed_points;
  LandmarkContainerType  transformed_points_container =
transformed_points->GetPoints();

  Rigid3DTransformType::InputPointType  trackerPointSourcePosition;
  Rigid3DTransformType::OutputPointType trackerPointNewPosition;


  LandmarkContainerType inputPointItr = imagePoint->Begin();
  LandmarkContainerType inputPointEnd = imagePoint->End();

  LandmarkPointType pointId = itk::NumericTraits< LandmarkPointType >::Zero;

  while( inputPointItr != inputPointEnd )
    {
    trackerPointNewPosition =
rigidTransform->TransformPoint(inputPointItr.Value());
   
transformed_points_container->InsertElement(pointId,trackerPointNewPosition);
    std::cout << "Input " << inputPointItr.Value() << " : ";
    std::cout << "Output " << trackerPointNewPosition << std::endl;
    ++inputPointItr;
    }

  return EXIT_SUCCESS;
}




--
View this message in context: http://itk-insight-users.2283740.n2.nabble.com/question-Landmark-based-rigid-registration-tp7581281.html
Sent from the ITK Insight Users mailing list archive at Nabble.com.


More information about the Insight-users mailing list