/*========================================================================= * * Copyright Insight Software Consortium * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0.txt * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * *=========================================================================*/ #ifndef __itkCustomTransformInitializer_h #define __itkCustomTransformInitializer_h #include "itkObject.h" #include "itkObjectFactory.h" #include "itkImageMomentsCalculator.h" #include "itkPointSetMomentsCalculator.h" #include namespace itk { /** \class CustomTransformInitializer * \brief CustomTransformInitializer is a helper class intended to * initialize the center of rotation and the translation of Transforms having * the center of rotation among their parameters. * * This class is connected to the fixed point set, moving image and transform * involved in a point set to image registration. * * In the second mode, the moments of gray level values are computed * for the image while the point set center of mass is computed from the mean * of the points. The center of mass of the moving image is then * used as center of rotation. The vector between the two centers of * mass is passes as the initial translation to the transform. This * approach assumes that the moments of the anatomical objects * are similar for both images and hence the best initial guess for * registration is to superimpose both mass centers. Note that this * assumption will probably not hold in multi-modality registration. * * \ingroup ITKRegistrationCommon * \ingroup ITKTransform */ template< class TTransform, class TPointSet, class TMovingImage > class ITK_EXPORT CustomTransformInitializer:public Object { public: /** Standard class typedefs. */ typedef CustomTransformInitializer Self; typedef Object Superclass; typedef SmartPointer< Self > Pointer; typedef SmartPointer< const Self > ConstPointer; /** New macro for creation of through a Smart Pointer. */ itkNewMacro(Self); /** Run-time type information (and related methods). */ itkTypeMacro(CustomTransformInitializer, Object); /** Type of the transform to initialize */ typedef TTransform TransformType; typedef typename TransformType::Pointer TransformPointer; /** Dimension of parameters. */ itkStaticConstMacro(InputSpaceDimension, unsigned int, TransformType::InputSpaceDimension); itkStaticConstMacro(OutputSpaceDimension, unsigned int, TransformType::OutputSpaceDimension); /** Image Types to use in the initialization of the transform */ typedef TPointSet PointSetType; typedef TMovingImage MovingImageType; typedef typename PointSetType::ConstPointer PointSetPointer; typedef typename MovingImageType::ConstPointer MovingImagePointer; /** Moment calculators */ typedef PointSetMomentsCalculator< PointSetType > PointSetCalculatorType; typedef ImageMomentsCalculator< MovingImageType > MovingImageCalculatorType; typedef typename PointSetCalculatorType::Pointer PointSetCalculatorPointer; typedef typename MovingImageCalculatorType::Pointer MovingImageCalculatorPointer; /** Offset type. */ typedef typename TransformType::OffsetType OffsetType; /** Point type. */ typedef typename TransformType::InputPointType InputPointType; /** Vector type. */ typedef typename TransformType::OutputVectorType OutputVectorType; /** Set the transform to be initialized */ itkSetObjectMacro(Transform, TransformType); /** Set the fixed image used in the registration process */ itkSetConstObjectMacro(PointSet, PointSetType); /** Set the moving image used in the registration process */ itkSetConstObjectMacro(MovingImage, MovingImageType); /** Initialize the transform using data from the images */ virtual void InitializeTransform(); /** Get() access to the moments calculators */ itkGetConstObjectMacro(FixedCalculator, PointSetCalculatorType); itkGetConstObjectMacro(MovingCalculator, MovingImageCalculatorType); protected: CustomTransformInitializer(); ~CustomTransformInitializer(){} void PrintSelf(std::ostream & os, Indent indent) const; itkGetObjectMacro(Transform, TransformType); private: CustomTransformInitializer(const Self &); //purposely not implemented void operator=(const Self &); //purposely not implemented TransformPointer m_Transform; PointSetPointer m_PointSet; MovingImagePointer m_MovingImage; PointSetCalculatorPointer m_FixedCalculator; MovingImageCalculatorPointer m_MovingCalculator; }; //class CustomTransformInitializer } // namespace itk #ifndef ITK_MANUAL_INSTANTIATION #include "itkCustomTransformInitializer.hxx" #endif #endif /* __itkCustomTransformInitializer_h */