[IGSTK-Users] Problem on landmark registration reuse
jiafucang
jiafucang at 126.com
Mon Jan 22 23:25:32 EST 2007
Hi Patrick,
The trick do solve the problem.
It seems that the code may be put into ResetRegistrationProcessing(),
m_Transform = NULL;
m_Transform = TransformType::New();
Thank you very much!
Fucang
Hi Fucang,
I found the cause of this issue.
Around line 337 in igstkLandmark3DRegistration class,
m_TransformInitializer- >SetFixedLandmarks(m_TrackerLandmarks);
m_TransformInitializer- >SetMovingLandmarks(m_ImageLandmarks);
m_TransformInitializer- >SetTransform( m_Transform );
If I change this into:
m_TransformInitializer- >SetFixedLandmarks(m_TrackerLandmarks);
m_TransformInitializer- >SetMovingLandmarks(m_ImageLandmarks);
m_Transform = NULL;
m_Transform = TransformType::New();
m_TransformInitializer- >SetTransform( m_Transform );
Your code will give a consistent result.
The igstkLandmark3DRegistration uses
itkLandmarkBaseTransformInitializer.txx inside. I thought
m_TransformInitializer- >SetTransform( m_Transform );
is just passing a pointer to store the resulting transform.
But in the itkLandmarkBaseTransformInitializer.txx class line 123.
RotationCenterType rotationCenter = transform- >GetCenter();
So it's using the center of the transform as the rotation center. I
don't quite understand this algorithm.
So when you reuse the igstkLandmark3DRegistration, because m_Transform
in this class, stores the results from last registration, so you are
passing a different m_Transform to the m_TransformInitializer, that's
why it's giving a different results.
I still don't quite understand why it's behaving like that. Maybe ITK
guru can answer this question?
Thank you,
Patrick
jiafucang at 126.com wrote:
>
> 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
>
>
>
>
> ------------------------------------------------------------------------
> 独家!网易3G免费邮,还赠送280兆网盘 www.126.com <http://www.126.com/ >
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> IGSTK-Users mailing list
> IGSTK-Users at public.kitware.com
> http://public.kitware.com/cgi-bin/mailman/listinfo/igstk-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/igstk-users/attachments/20070123/eb15409f/attachment.html>
More information about the IGSTK-Users
mailing list