ITK  4.0.0
Insight Segmentation and Registration Toolkit
itkDiffeomorphicDemonsRegistrationFilter.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 __itkDiffeomorphicDemonsRegistrationFilter_h
00019 #define __itkDiffeomorphicDemonsRegistrationFilter_h
00020 
00021 #include "itkPDEDeformableRegistrationFilter.h"
00022 #include "itkESMDemonsRegistrationFunction.h"
00023 
00024 #include "itkMultiplyImageFilter.h"
00025 #include "itkExponentialDisplacementFieldImageFilter.h"
00026 
00027 namespace itk
00028 {
00077 template< class TFixedImage, class TMovingImage, class TDisplacementField >
00078 class ITK_EXPORT DiffeomorphicDemonsRegistrationFilter:
00079   public PDEDeformableRegistrationFilter< TFixedImage, TMovingImage,
00080                                           TDisplacementField >
00081 {
00082 public:
00084   typedef DiffeomorphicDemonsRegistrationFilter                                           Self;
00085   typedef PDEDeformableRegistrationFilter< TFixedImage, TMovingImage, TDisplacementField > Superclass;
00086   typedef SmartPointer< Self >                                                            Pointer;
00087   typedef SmartPointer< const Self >                                                      ConstPointer;
00088 
00090   itkNewMacro(Self);
00091 
00093   itkTypeMacro(DiffeomorphicDemonsRegistrationFilter, PDEDeformableRegistrationFilter);
00094 
00096   typedef typename Superclass::FixedImageType    FixedImageType;
00097   typedef typename Superclass::FixedImagePointer FixedImagePointer;
00098 
00100   typedef typename Superclass::MovingImageType    MovingImageType;
00101   typedef typename Superclass::MovingImagePointer MovingImagePointer;
00102 
00104   typedef typename Superclass::DisplacementFieldType    DisplacementFieldType;
00105   typedef typename Superclass::DisplacementFieldPointer DisplacementFieldPointer;
00106 #ifdef ITKV3_COMPATIBILITY
00107   typedef typename Superclass::DeformationFieldType    DeformationFieldType;
00108   typedef typename Superclass::DeformationFieldPointer DeformationFieldPointer;
00109 #endif
00110 
00112   typedef typename Superclass::FiniteDifferenceFunctionType FiniteDifferenceFunctionType;
00113 
00115   typedef typename FiniteDifferenceFunctionType::TimeStepType TimeStepType;
00116 
00118   typedef ESMDemonsRegistrationFunction< FixedImageType, MovingImageType,
00119                                          DisplacementFieldType > DemonsRegistrationFunctionType;
00120   typedef typename DemonsRegistrationFunctionType::GradientType GradientType;
00121 
00122   itkStaticConstMacro(
00123     ImageDimension, unsigned int, FixedImageType::ImageDimension);
00124 
00129   virtual double GetMetric() const;
00130 
00131   virtual const double & GetRMSChange() const;
00132 
00133   virtual void SetUseGradientType(GradientType gtype);
00134 
00135   virtual GradientType GetUseGradientType() const;
00136 
00140   itkSetMacro(UseFirstOrderExp, bool);
00141   itkGetConstMacro(UseFirstOrderExp, bool);
00142   itkBooleanMacro(UseFirstOrderExp);
00144 
00149   virtual void SetIntensityDifferenceThreshold(double);
00150 
00151   virtual double GetIntensityDifferenceThreshold() const;
00152 
00155   virtual void SetMaximumUpdateStepLength(double);
00156 
00157   virtual double GetMaximumUpdateStepLength() const;
00158 
00159 protected:
00160   DiffeomorphicDemonsRegistrationFilter();
00161   ~DiffeomorphicDemonsRegistrationFilter() {}
00162   void PrintSelf(std::ostream & os, Indent indent) const;
00163 
00165   virtual void InitializeIteration();
00166 
00169   virtual void AllocateUpdateBuffer();
00170 
00172   virtual void ApplyUpdate(const TimeStepType& dt);
00173 
00174 private:
00175   DiffeomorphicDemonsRegistrationFilter(const Self &); //purposely not
00176                                                        // implemented
00177   void operator=(const Self &);                        //purposely not
00178 
00179   // implemented
00180 
00183   DemonsRegistrationFunctionType *  DownCastDifferenceFunctionType();
00184 
00185   const DemonsRegistrationFunctionType *  DownCastDifferenceFunctionType() const;
00186 
00188   typedef MultiplyImageFilter< DisplacementFieldType,
00189     itk::Image<TimeStepType, ImageDimension>,
00190     DisplacementFieldType >                              MultiplyByConstantType;
00191 
00192   typedef ExponentialDisplacementFieldImageFilter<
00193     DisplacementFieldType, DisplacementFieldType >        FieldExponentiatorType;
00194 
00195   typedef WarpVectorImageFilter<
00196     DisplacementFieldType,
00197     DisplacementFieldType, DisplacementFieldType >        VectorWarperType;
00198 
00199   typedef VectorLinearInterpolateNearestNeighborExtrapolateImageFunction<
00200     DisplacementFieldType, double >                      FieldInterpolatorType;
00201 
00202   typedef AddImageFilter<
00203     DisplacementFieldType,
00204     DisplacementFieldType, DisplacementFieldType >        AdderType;
00205 
00206   typedef typename MultiplyByConstantType::Pointer   MultiplyByConstantPointer;
00207   typedef typename FieldExponentiatorType::Pointer   FieldExponentiatorPointer;
00208   typedef typename VectorWarperType::Pointer         VectorWarperPointer;
00209   typedef typename FieldInterpolatorType::Pointer    FieldInterpolatorPointer;
00210   typedef typename FieldInterpolatorType::OutputType FieldInterpolatorOutputType;
00211   typedef typename AdderType::Pointer                AdderPointer;
00212 
00213   MultiplyByConstantPointer m_Multiplier;
00214   FieldExponentiatorPointer m_Exponentiator;
00215   VectorWarperPointer       m_Warper;
00216   AdderPointer              m_Adder;
00217   bool                      m_UseFirstOrderExp;
00218 };
00219 } // end namespace itk
00220 
00221 #ifndef ITK_MANUAL_INSTANTIATION
00222 #include "itkDiffeomorphicDemonsRegistrationFilter.hxx"
00223 #endif
00224 
00225 #endif
00226