[IGSTK-Users] question about example LandmarkRegistration1 ?

Agata Krasoń agatakrason at gmail.com
Sun Jul 31 08:40:40 EDT 2011


Hi  all Users & Developers,


I' m fresh user.  I'm begining my adventure with IGSTK...
I 'm  just working with example LandmarkRegistration1(Sandbox).
I  have to do  a DLL & wrapper  with this example.
I have already made  a method with this transformation but I have a problem
with  *returned type*.
I want to return for example 1 element (point)  after transformation .
Could You help me please ?
I would  appreciate for any help .


Code :

extern "C"
{

*  __declspec(dllexport) double RegistrationDLL(double tab[30])*
 {

igstk::RealTimeClock::Initialize();


// BeginCodeSnippet
  typedef igstk::Object::LoggerType             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;
// EndCodeSnippet


// BeginLatex
//
// Then, the registration component is instantiated as follows:
//
// EndLatex

// BeginCodeSnippet
  Landmark3DRegistrationType::Pointer landmarkRegister =
                                        Landmark3DRegistrationType::New();
// EndCodeSnippet


// BeginLatex
//
// Next, the landmark containers that hold the landmark image and tracker
// coordinates are instantiated:
//
// EndLatex

// BeginCodeSnippet
  LandmarkPointContainerType  imagePointContainer;
  LandmarkPointContainerType  trackerPointContainer;
// EndCodeSnippet


  LandmarkImagePointType      imagePoint;
  LandmarkTrackerPointType    trackerPoint;

// BeginLatex
//
// Then, error event callback objects are instantiated and added to the
observer
// list of the registration component, as follows:
//
// EndLatex

// BeginCodeSnippet
  Landmark3DRegistrationInvalidRequestCallback::Pointer
                  lrcb =
Landmark3DRegistrationInvalidRequestCallback::New();

  typedef igstk::InvalidRequestErrorEvent  InvalidRequestEvent;

  landmarkRegister->AddObserver( InvalidRequestEvent(), lrcb );

  Landmark3DRegistrationErrorCallback::Pointer ecb =
                  Landmark3DRegistrationErrorCallback::New();
  typedef igstk::Landmark3DRegistration::TransformComputationFailureEvent

 ComputationFailureEvent;
  landmarkRegister->AddObserver( ComputationFailureEvent(), ecb );

// EndCodeSnippet

// BeginLatex
//
// A logger can then be connected to the registration component for
// debugging purpose, as follows:
//
// EndLatex


// BeginCodeSnippet
  LoggerType::Pointer   logger = LoggerType::New();
  LogOutputType::Pointer logOutput = LogOutputType::New();
  logOutput->SetStream( std::cout );
  logger->AddLogOutput( logOutput );
  logger->SetPriorityLevel( LoggerType::DEBUG );
  landmarkRegister->SetLogger( logger );
// EndCodeSnippet


// BeginLatex
//
// Next, landmark points are added to the image and tracker containers.  The
// state machine of this registration component is designed so that the
image
// and tracker coordinates that correspond to each landmark are added
// consecutively. This scheme prevents the mismatch in landmark
correspondence
// that could occur when all landmarks image coordinates are recorded first
and
// followed by the tracker coordinates.  This design choice is consistent
with
// the ``safety by design'' philosophy of IGSTK. The commands are as
follows:
//
//EndLatex

// BeginCodeSnippet
  // Add entry
  imagePoint[0] = tab[0];
  imagePoint[1] = tab[1];
  imagePoint[2] = tab[2];
  imagePointContainer.push_back(imagePoint);
  landmarkRegister->RequestAddImageLandmarkPoint(imagePoint);

  trackerPoint[0] = tab[3];
  trackerPoint[1] = tab[4];
  trackerPoint[2] = tab[5];
  trackerPointContainer.push_back(trackerPoint);
  landmarkRegister->RequestAddTrackerLandmarkPoint(trackerPoint);

  // Add 1st landmark
  imagePoint[0] = tab[6];
  imagePoint[1] = tab[7];
  imagePoint[2] = tab[8];
  imagePointContainer.push_back(imagePoint);
  landmarkRegister->RequestAddImageLandmarkPoint(imagePoint);

  trackerPoint[0] = tab[9];
  trackerPoint[1] = tab[10];
  trackerPoint[2] = tab[11];
  trackerPointContainer.push_back(trackerPoint);
  landmarkRegister->RequestAddTrackerLandmarkPoint(trackerPoint);

  // Add 2nd landmark
  imagePoint[0] = tab[12];
  imagePoint[1] = tab[13];
  imagePoint[2] = tab[14];
  imagePointContainer.push_back(imagePoint);
  landmarkRegister->RequestAddImageLandmarkPoint(imagePoint);

  trackerPoint[0] = tab[15];
  trackerPoint[1] = tab[16];
  trackerPoint[2] = tab[17];
  trackerPointContainer.push_back(trackerPoint);
  landmarkRegister->RequestAddTrackerLandmarkPoint(trackerPoint);

  // EndCodeSnippet

  // BeginLatex
  //
  // More landmarks can be added for the transform computation.
  //
  // EndLatex

  // Add 3n landmark
  imagePoint[0] = tab[18];
  imagePoint[1] = tab[19];
  imagePoint[2] = tab[20];
  imagePointContainer.push_back(imagePoint);
  landmarkRegister->RequestAddImageLandmarkPoint(imagePoint);

  trackerPoint[0] = tab[21];
  trackerPoint[1] = tab[22];
  trackerPoint[2] = tab[23];
  trackerPointContainer.push_back(trackerPoint);
  landmarkRegister->RequestAddTrackerLandmarkPoint(trackerPoint);

  // Add target
  imagePoint[0] = tab[24];
  imagePoint[1] = tab[25];
  imagePoint[2] = tab[26];
  imagePointContainer.push_back(imagePoint);
  landmarkRegister->RequestAddImageLandmarkPoint(imagePoint);

  trackerPoint[0] = tab[27];
  trackerPoint[1] = tab[28];
  trackerPoint[2] = tab[29];
  trackerPointContainer.push_back(trackerPoint);
  landmarkRegister->RequestAddTrackerLandmarkPoint(trackerPoint);

  // BeginLatex
  //
  // After all landmark coordinates are added, the transform computation is
  // requested as follows:
  //
  // EndLatex

  // Calculate transform

  // BeginCodeSnippet
  landmarkRegister->RequestComputeTransform();
  // EndCodeSnippet

  typedef itk::VersorRigid3DTransform<double>
 VersorRigid3DTransformType;
  typedef VersorRigid3DTransformType::ParametersType ParametersType;




  TransformType  transform;
  ParametersType     parameters(6);

  // BeginLatex
  //
  // To access the transform parameters, a GetTransform callback is
instantiated
  // to observe the transform event, as follows:
  //
  // EndLatex

  // BeginCodeSnippet
  Landmark3DRegistrationGetTransformCallback::Pointer lrtcb =
    Landmark3DRegistrationGetTransformCallback::New();

  landmarkRegister->AddObserver(
    igstk::CoordinateSystemTransformToEvent(), lrtcb );
  //EndCodeSnippet


  // BeginLatex
  //
  // To request that the registration component throw an event loaded with
  // transform parameters, a \code{RequestGetTransform} function is invoked
as
  // follows:
  //
  // EndLatex

  // BeginCodeSnippet
  landmarkRegister->RequestGetTransformFromTrackerToImage();
  std::cout<<"  "<<std::endl;
 std::cout << "Transform " << transform << std::endl;

  // EndCodeSnippet





*  // return tab[4];  // ????? *
*
*
*return  ... ?? *
}

}

Best,
Agata
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/igstk-users/attachments/20110731/eb9d0767/attachment.html>


More information about the IGSTK-Users mailing list