/*========================================================================= Program: vtkINRIA3D Module: $Id: itkLandmarkRegistrationMethod.cxx 1 2008-01-22 19:01:33Z ntoussaint $ Language: C++ Author: $Author: ntoussaint $ Date: $Date: 2008-01-22 20:01:33 +0100 (Tue, 22 Jan 2008) $ Version: $Revision: 1 $ Copyright (c) 2007 INRIA - Asclepios Project. All rights reserved. See Copyright.txt for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef _itkLandmarkRegistrationMethod_cxx #define _itkLandmarkRegistrationMethod_cxx #include "itkLandmarkRegistrationMethod.h" namespace itk { /* * Constructor */ template LandmarkRegistrationMethod ::LandmarkRegistrationMethod() { m_Rigid2DInitializer = LandmarkRigid2DTransformInitializerType::New(); m_Rigid3DInitializer = LandmarkRigid3DTransformInitializerType::New(); m_NonLinearKernelTransform = NonLinearKernelTransformType::New(); m_FixedPointSet = PointSetType::New(); m_MovingPointSet = PointSetType::New(); this->SetExportTransformType (TRANSFORM_RIGID); this->SetName ("Manual Landmark based"); } /* * Constructor */ template void LandmarkRegistrationMethod ::Initialize() { this->Superclass::Initialize (); } /* * PrintSelf */ template void LandmarkRegistrationMethod ::PrintSelf(std::ostream& os, Indent indent) const { Superclass::PrintSelf( os, indent ); } template void LandmarkRegistrationMethod ::InsertLandmarkPair (PointType FixedImagePoint, PointType MovingImagePoint) { unsigned long id = m_FixedLandmarks.size(); m_FixedLandmarks.push_back (FixedImagePoint); m_MovingLandmarks.push_back (MovingImagePoint); m_FixedPointSet->GetPoints()->InsertElement (id, FixedImagePoint); m_MovingPointSet->GetPoints()->InsertElement (id, MovingImagePoint); this->Modified(); } /* * Generate Data */ template void LandmarkRegistrationMethod ::GenerateData() { typename Rigid2DTransformType::Pointer Transform2D = Rigid2DTransformType::New(); typename Rigid3DTransformType::Pointer Transform3D = Rigid3DTransformType::New(); this->UpdateProgress (0); switch (this->GetExportTransformType()) { case TRANSFORM_AFFINE: this->UpdateProgress (1); itkExceptionMacro ("AFFINE TRANSFORMATION NOT SUPPORTED ! !"); break; case TRANSFORM_RIGID: switch(ImageType::ImageDimension) { case 2: if (!m_FixedLandmarks.size()) { this->UpdateProgress (1); itkWarningMacro ("No landmark to initialize transform."); } else { Transform2D->SetIdentity(); m_Rigid2DInitializer->SetTransform (Transform2D); m_Rigid2DInitializer->SetFixedLandmarks (m_FixedLandmarks); m_Rigid2DInitializer->SetMovingLandmarks (m_MovingLandmarks); this->UpdateProgress (0.5); m_Rigid2DInitializer->InitializeTransform(); } this->SetTransform ((TransformType*)(Transform2D.GetPointer())); break; case 3: if (!m_FixedLandmarks.size()) { this->UpdateProgress (1); itkWarningMacro ("No landmark to initialize transform."); } else { Transform3D->SetIdentity(); m_Rigid3DInitializer->SetTransform (Transform3D); m_Rigid3DInitializer->SetFixedLandmarks (m_FixedLandmarks); m_Rigid3DInitializer->SetMovingLandmarks (m_MovingLandmarks); this->UpdateProgress (0.5); m_Rigid3DInitializer->InitializeTransform(); } this->SetTransform ((TransformType*)(Transform3D.GetPointer())); break; default: this->UpdateProgress (1); itkExceptionMacro ("Dimension not supported by LandmarkRegistrationMethod !"); break; } break; case TRANSFORM_NON_LINEAR_KERNEL: if (!m_FixedLandmarks.size()) { this->UpdateProgress (1); itkWarningMacro ("No landmark to initialize transform."); } else { m_NonLinearKernelTransform->SetSourceLandmarks(m_FixedPointSet); m_NonLinearKernelTransform->SetTargetLandmarks(m_MovingPointSet); this->UpdateProgress (0.5); m_NonLinearKernelTransform->ComputeWMatrix(); } this->SetTransform ((TransformType*)(m_NonLinearKernelTransform.GetPointer())); break; default: this->UpdateProgress (1); itkExceptionMacro ("Transformation type not supported by the LandmarkRegistrationMethod !"); break; } this->UpdateProgress (1); } } // end namespace itk #endif