[IGSTK-Users] Problem on landmark registration reuse

jiafucang at 126.com jiafucang at 126.com
Mon Jan 22 07:35:26 EST 2007


 
Hi,
 
I encoutered a strange problem. I need to reuse landmark registration for several times.
In FourViewsTrackingWithCT application, I see that when the second set of image and tracker
landmarks were set, the landmark registration could not give the correct result.
 
Here is an example, could anyone find anything wrong in the following code?
 
 
#if defined(_MSC_VER)
#pragma warning( disable : 4786 )
#endif
#include <iostream>
#include "igstkLandmark3DRegistration.h"
#include "igstkLandmark3DRegistrationErrorEstimator.h"
#include "itkLogger.h"
#include "itkStdStreamLogOutput.h"
#include "itkObject.h"
#include "itkCommand.h"
#include "itkMacro.h"
#include "igstkEvents.h"
#include "igstkTransform.h"
 
class Landmark3DRegistrationGetTransformCallback: public itk::Command
{
public:
 typedef Landmark3DRegistrationGetTransformCallback    Self;
 typedef itk::SmartPointer<Self>                       Pointer;
 typedef itk::Command                                  Superclass;
 itkNewMacro(Self);
 
 typedef igstk::TransformModifiedEvent TransformModifiedEventType;
 
 void Execute( const itk::Object *caller, const itk::EventObject & event )
    {
    }
 
 void Execute( itk::Object *caller, const itk::EventObject & event )
    {
  std::cout<< " TransformEvent is thrown" << std::endl;
  const TransformModifiedEventType * transformEvent =
   dynamic_cast < const TransformModifiedEventType* > ( &event );
  m_Transform = transformEvent->Get();
  m_EventReceived = true;
    } 
 bool GetEventReceived()
    {
  return m_EventReceived;
    }
 igstk::Transform GetTransform()
    {
  return m_Transform;
    }  
protected:
 
 Landmark3DRegistrationGetTransformCallback()   
    {
  m_EventReceived = true;
    }
 
private:
 bool m_EventReceived;
 igstk::Transform m_Transform;
};
int main( int argv, char * argc[] )
{
 
 
 
 igstk::RealTimeClock::Initialize();
 
 
 typedef itk::Logger                   LoggerType;
 typedef itk::StdStreamLogOutput       LogOutputType;
    
 typedef igstk::Landmark3DRegistration
  Landmark3DRegistrationType;
 typedef igstk::Landmark3DRegistration::LandmarkPointContainerType
  LandmarkPointContainerType;
 typedef igstk::Landmark3DRegistration::LandmarkImagePointType 
  LandmarkImagePointType;
 typedef igstk::Landmark3DRegistration::LandmarkTrackerPointType
  LandmarkTrackerPointType;
 typedef Landmark3DRegistrationType::TransformType::OutputVectorType 
  OutputVectorType;
 typedef igstk::Transform  TransformType;
 
 
 
 Landmark3DRegistrationType::Pointer landmarkRegister = 
  Landmark3DRegistrationType::New();
 
 LandmarkImagePointType      imagePoint;
 LandmarkTrackerPointType    trackerPoint;
 
 
 
 typedef itk::VersorRigid3DTransform<double>        VersorRigid3DTransformType;
 typedef VersorRigid3DTransformType::ParametersType ParametersType;
 
 TransformType      transform;
 ParametersType     parameters(6);
 
 
 Landmark3DRegistrationGetTransformCallback::Pointer lrtcb =
  Landmark3DRegistrationGetTransformCallback::New();
 landmarkRegister->AddObserver( igstk::TransformModifiedEvent(), lrtcb );
 
 typedef igstk::Landmark3DRegistrationErrorEstimator   ErrorEstimatorType;
 
 typedef ErrorEstimatorType::TargetPointType   TargetPointType;
 typedef ErrorEstimatorType::ErrorType         ErrorType;
 
 ErrorType                   landmarkRegistrationError;
 
 // test landmark registration reuse
 if(1)
 {
  imagePoint[0] =  78.3163;
  imagePoint[1] =  15.3252;
  imagePoint[2] =  16;
  landmarkRegister->RequestAddImageLandmarkPoint(imagePoint);
  
  trackerPoint[0] =  199.274;
  trackerPoint[1] =  -26.6466;
  trackerPoint[2] =  -869.895;
  landmarkRegister->RequestAddTrackerLandmarkPoint(trackerPoint);
  
  imagePoint[0] =  12.5937;
  imagePoint[1] =   9.9381;
  imagePoint[2] =  16;
  landmarkRegister->RequestAddImageLandmarkPoint(imagePoint);
  
  trackerPoint[0] =  218.485;
  trackerPoint[1] =  -2.90349;
  trackerPoint[2] =  -882.859;
  landmarkRegister->RequestAddTrackerLandmarkPoint(trackerPoint);
  
  
  imagePoint[0] =  45.3473;
  imagePoint[1] =   7.78325;
  imagePoint[2] =  60;
  landmarkRegister->RequestAddImageLandmarkPoint(imagePoint);
  
  trackerPoint[0] =  304.046;
  trackerPoint[1] =  -34.6625;
  trackerPoint[2] =  -885.358;
  landmarkRegister->RequestAddTrackerLandmarkPoint(trackerPoint);
  
  landmarkRegister->RequestComputeTransform();
  
  landmarkRegister->RequestGetTransform();
  
  transform = lrtcb->GetTransform();
  std::cout << "Transform " << transform << std::cout;
  
  landmarkRegistrationError = landmarkRegister->ComputeRMSError();
  std::cout<<"RMS Error is "<<landmarkRegistrationError<<std::endl;
 }
 
 
 // reuse landmark registration
 landmarkRegister->RequestResetRegistration();
 
 imagePoint[0] =  77.2389;
 imagePoint[1] =  15.9716;
 imagePoint[2] =  16;
 landmarkRegister->RequestAddImageLandmarkPoint(imagePoint);
 trackerPoint[0] =  230.525;
 trackerPoint[1] =  -44.7263;
 trackerPoint[2] =  -894.183;
 landmarkRegister->RequestAddTrackerLandmarkPoint(trackerPoint);
 
 // Add 2nd landmark
 imagePoint[0] =  14.1021;
 imagePoint[1] =  10.3691;
 imagePoint[2] =  16;
 landmarkRegister->RequestAddImageLandmarkPoint(imagePoint);
 trackerPoint[0] =  211.976;
 trackerPoint[1] =  -41.8738;
 trackerPoint[2] =  -875.216;
 landmarkRegister->RequestAddTrackerLandmarkPoint(trackerPoint);
 
 // Add 3d landmark
 imagePoint[0] =  45.9937;
 imagePoint[1] =  6.27483;
 imagePoint[2] =  68;
 landmarkRegister->RequestAddImageLandmarkPoint(imagePoint);
 trackerPoint[0] =  303.781;
 trackerPoint[1] =  -35.4769;
 trackerPoint[2] =  -887.587;
 landmarkRegister->RequestAddTrackerLandmarkPoint(trackerPoint);
 
 landmarkRegister->RequestComputeTransform();
 landmarkRegister->RequestGetTransform();
 
 transform = lrtcb->GetTransform();
 std::cout << "Transform " << transform << std::cout;
 
 landmarkRegistrationError = landmarkRegister->ComputeRMSError();
 std::cout<<"RMS Error is "<<landmarkRegistrationError<<std::endl;
 
 return 0;
}
 
 
Thank you very much!
 
Best,
Fucang
 
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/igstk-users/attachments/20070122/093151b2/attachment-0001.html>


More information about the IGSTK-Users mailing list