ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkSyNImageRegistrationMethod.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 __itkSyNImageRegistrationMethod_h
00019 #define __itkSyNImageRegistrationMethod_h
00020 
00021 #include "itkImageRegistrationMethodv4.h"
00022 
00023 #include "itkDisplacementFieldTransform.h"
00024 
00025 namespace itk
00026 {
00027 //Forward-declare these because of module dependency conflict.
00028 //They will soon be moved to a different module, at which
00029 // time this can be removed.
00030 template <unsigned int VDimension, class TDataHolder>
00031 class ImageToData;
00032 template <class TDataHolder>
00033 class Array1DToData;
00034 
00072 template<typename TFixedImage, typename TMovingImage, typename TTransform =
00073   DisplacementFieldTransform<double, GetImageDimension<TFixedImage>::ImageDimension> >
00074 class ITK_EXPORT SyNImageRegistrationMethod
00075 : public ImageRegistrationMethodv4<TFixedImage, TMovingImage, TTransform>
00076 {
00077 public:
00079   typedef SyNImageRegistrationMethod                                            Self;
00080   typedef ImageRegistrationMethodv4<TFixedImage, TMovingImage, TTransform>      Superclass;
00081   typedef SmartPointer<Self>                                                    Pointer;
00082   typedef SmartPointer<const Self>                                              ConstPointer;
00083 
00085   itkNewMacro( Self );
00086 
00088   itkStaticConstMacro( ImageDimension, unsigned int, TFixedImage::ImageDimension );
00089 
00091   itkTypeMacro( SyNImageRegistrationMethod, SimpleImageRegistrationMethod );
00092 
00094   typedef TFixedImage                                                 FixedImageType;
00095   typedef typename FixedImageType::Pointer                            FixedImagePointer;
00096   typedef TMovingImage                                                MovingImageType;
00097   typedef typename MovingImageType::Pointer                           MovingImagePointer;
00098 
00100   typedef typename Superclass::MetricType                             MetricType;
00101   typedef typename MetricType::Pointer                                MetricPointer;
00102   typedef typename MetricType::VirtualImageType                       VirtualImageType;
00103   typedef typename MetricType::MeasureType                            MeasureType;
00104   typedef TTransform                                                  TransformType;
00105   typedef typename TransformType::Pointer                             TransformPointer;
00106   typedef typename TransformType::ScalarType                          RealType;
00107   typedef typename TransformType::DerivativeType                      DerivativeType;
00108   typedef typename DerivativeType::ValueType                          DerivativeValueType;
00109   typedef typename TransformType::DisplacementFieldType               DisplacementFieldType;
00110   typedef typename DisplacementFieldType::Pointer                     DisplacementFieldPointer;
00111   typedef typename DisplacementFieldType::PixelType                   DisplacementVectorType;
00112 
00113   typedef CompositeTransform<RealType, ImageDimension>                CompositeTransformType;
00114   typedef typename CompositeTransformType::TransformType              TransformBaseType;
00115 
00116   typedef typename Superclass::TransformOutputType                    TransformOutputType;
00117   typedef typename TransformOutputType::Pointer                       TransformOutputPointer;
00118 
00119   typedef Array<SizeValueType>                                        NumberOfIterationsArrayType;
00120 
00122   itkSetMacro( LearningRate, RealType );
00123   itkGetConstMacro( LearningRate, RealType );
00125 
00127   itkSetMacro( NumberOfIterationsPerLevel, NumberOfIterationsArrayType );
00128   itkGetConstMacro( NumberOfIterationsPerLevel, NumberOfIterationsArrayType );
00130 
00132   itkSetMacro( ConvergenceThreshold, RealType );
00133   itkGetConstMacro( ConvergenceThreshold, RealType );
00135 
00140   itkSetMacro( DownsampleImagesForMetricDerivatives, bool );
00141   itkGetConstMacro( DownsampleImagesForMetricDerivatives, bool );
00143 
00147   itkSetMacro( AverageMidPointGradients, bool );
00148   itkGetConstMacro( AverageMidPointGradients, bool );
00150 
00155   itkSetMacro( GaussianSmoothingVarianceForTheUpdateField, RealType );
00156   itkGetConstReferenceMacro( GaussianSmoothingVarianceForTheUpdateField, RealType );
00158 
00163   itkSetMacro( GaussianSmoothingVarianceForTheTotalField, RealType );
00164   itkGetConstReferenceMacro( GaussianSmoothingVarianceForTheTotalField, RealType );
00166 
00167 protected:
00168   SyNImageRegistrationMethod();
00169   virtual ~SyNImageRegistrationMethod();
00170   virtual void PrintSelf( std::ostream & os, Indent indent ) const;
00171 
00173   virtual void  GenerateData();
00174 
00176   virtual void StartOptimization();
00177 
00182   virtual void InitializeRegistrationAtEachLevel( const SizeValueType );
00183 
00184   virtual DisplacementFieldPointer ComputeUpdateField( const TFixedImage *, const TransformBaseType *, const TMovingImage *, const TransformBaseType * , MeasureType & );
00185   virtual DisplacementFieldPointer GaussianSmoothDisplacementField( const DisplacementFieldType *, const RealType );
00186 
00187 private:
00188   SyNImageRegistrationMethod( const Self & );   //purposely not implemented
00189   void operator=( const Self & );               //purposely not implemented
00190 
00191   RealType                                                        m_LearningRate;
00192 
00193   RealType                                                        m_GaussianSmoothingVarianceForTheUpdateField;
00194   RealType                                                        m_GaussianSmoothingVarianceForTheTotalField;
00195 
00196   TransformPointer                                                m_MiddleToMovingTransform;
00197   TransformPointer                                                m_MiddleToFixedTransform;
00198 
00199   RealType                                                        m_ConvergenceThreshold;
00200 
00201   NumberOfIterationsArrayType                                     m_NumberOfIterationsPerLevel;
00202   bool                                                            m_DownsampleImagesForMetricDerivatives;
00203   bool                                                            m_AverageMidPointGradients;
00204 
00205 };
00206 } // end namespace itk
00207 
00208 #ifndef ITK_MANUAL_INSTANTIATION
00209 #include "itkSyNImageRegistrationMethod.hxx"
00210 #endif
00211 
00212 #endif
00213