ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkLandmarkBasedTransformInitializer.h
Go to the documentation of this file.
00001 /*=========================================================================
00002  *
00003  *  Copyright Insight Software Consortium
00004  *
00005  *  Licensed under the Apache License, Version 2.0 (the "License");
00006  *  you may not use this file except in compliance with the License.
00007  *  You may obtain a copy of the License at
00008  *
00009  *         http://www.apache.org/licenses/LICENSE-2.0.txt
00010  *
00011  *  Unless required by applicable law or agreed to in writing, software
00012  *  distributed under the License is distributed on an "AS IS" BASIS,
00013  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  *  See the License for the specific language governing permissions and
00015  *  limitations under the License.
00016  *
00017  *=========================================================================*/
00018 #ifndef __itkLandmarkBasedTransformInitializer_h
00019 #define __itkLandmarkBasedTransformInitializer_h
00020 
00021 #include "itkObject.h"
00022 #include "itkObjectFactory.h"
00023 #include "itkVersorRigid3DTransform.h"
00024 #include "itkRigid2DTransform.h"
00025 #include "itkAffineTransform.h"
00026 #include <vector>
00027 #include <iostream>
00028 
00029 namespace itk
00030 {
00067 template< class TTransform,
00068           class TFixedImage,
00069           class TMovingImage >
00070 class ITK_EXPORT LandmarkBasedTransformInitializer:
00071   public Object
00072 {
00073 public:
00075   typedef LandmarkBasedTransformInitializer Self;
00076   typedef Object                            Superclass;
00077   typedef SmartPointer< Self >              Pointer;
00078   typedef SmartPointer< const Self >        ConstPointer;
00079 
00081   itkNewMacro(Self);
00082 
00084   itkTypeMacro(LandmarkBasedTransformInitializer, Object);
00085 
00087   typedef TTransform                      TransformType;
00088   typedef typename TransformType::Pointer TransformPointer;
00089 
00091   itkStaticConstMacro(InputSpaceDimension, unsigned int, TransformType::InputSpaceDimension);
00092   itkStaticConstMacro(OutputSpaceDimension, unsigned int, TransformType::OutputSpaceDimension);
00094 
00096   itkSetObjectMacro(Transform,   TransformType);
00097 
00099   typedef TFixedImage  FixedImageType;
00100   typedef TMovingImage MovingImageType;
00101 
00102 
00103   typedef   typename FixedImageType::ConstPointer  FixedImagePointer;
00104   typedef   typename MovingImageType::ConstPointer MovingImagePointer;
00105 
00107   itkStaticConstMacro(ImageDimension, unsigned int, FixedImageType::ImageDimension);
00108 
00110   typedef typename TransformType::InputPointType                  InputPointType;
00111   typedef typename TransformType::OutputVectorType                OutputVectorType;
00112   typedef Point< double, itkGetStaticConstMacro(ImageDimension) > LandmarkPointType;
00113   typedef std::vector< LandmarkPointType >                        LandmarkPointContainer;
00114   typedef typename LandmarkPointContainer::const_iterator         PointsContainerConstIterator;
00115   typedef typename TransformType::ParametersType                  ParametersType;
00116   typedef typename ParametersType::ValueType                      ParameterValueType;
00117   typedef std::vector< double >                                   LandmarkWeightType;
00118   typedef LandmarkWeightType::const_iterator                      LandmarkWeightConstIterator;
00119 
00121   void SetFixedLandmarks(const LandmarkPointContainer & fixedLandmarks)
00122   {
00123     this->m_FixedLandmarks = fixedLandmarks;
00124   }
00125 
00127   void SetMovingLandmarks(const LandmarkPointContainer & movingLandmarks)
00128   {
00129     this->m_MovingLandmarks = movingLandmarks;
00130   }
00131 
00135   void SetLandmarkWeight(LandmarkWeightType & landmarkWeight)
00136   {
00137     this->m_LandmarkWeight= landmarkWeight;
00138   }
00139 
00141   typedef VersorRigid3DTransform< ParameterValueType >                          VersorRigid3DTransformType;
00142   typedef Rigid2DTransform< ParameterValueType >                                Rigid2DTransformType;
00143   typedef AffineTransform< ParameterValueType, FixedImageType::ImageDimension > AffineTransformType;
00144 
00146   virtual void InitializeTransform();
00147 
00148 protected:
00149   LandmarkBasedTransformInitializer();
00150   ~LandmarkBasedTransformInitializer(){}
00151 
00152   void PrintSelf(std::ostream & os, Indent indent) const;
00153 
00154   // Supported Transform types
00155   typedef enum {
00156     VersorRigid3Dtransform = 1,
00157     Rigid2Dtransfrom,
00158     Else
00159     } InputTransformType;
00160 private:
00161   LandmarkBasedTransformInitializer(const Self &); //purposely not implemented
00162   void operator=(const Self &);                    //purposely not implemented
00163 
00164 
00166   template <class TTransform2>
00167     void InternalInitializeTransform(TTransform *);
00168 
00170   void InternalInitializeTransform(VersorRigid3DTransformType *);
00171 
00173   void InternalInitializeTransform(Rigid2DTransformType *);
00174 
00176   void InternalInitializeTransform(AffineTransformType *);
00177 
00178   FixedImagePointer  m_FixedImage;
00179   MovingImagePointer m_MovingImage;
00180 
00181   LandmarkPointContainer m_FixedLandmarks;
00182   LandmarkPointContainer m_MovingLandmarks;
00183 
00184   TransformPointer m_Transform;
00186   LandmarkWeightType m_LandmarkWeight;
00187 
00188 }; //class LandmarkBasedTransformInitializer
00189 }  // namespace itk
00190 
00191 #ifndef ITK_MANUAL_INSTANTIATION
00192 #include "itkLandmarkBasedTransformInitializer.hxx"
00193 #endif
00194 
00195 #endif /* __itkLandmarkBasedTransformInitializer_h */
00196