ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkCurvatureRegistrationFilter.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 __itkCurvatureRegistrationFilter_h
00019 #define __itkCurvatureRegistrationFilter_h
00020 
00021 #include "itkPDEDeformableRegistrationFilter.h"
00022 #include "itkMeanSquareRegistrationFunction.h"
00023 
00024 #if defined( USE_FFTWF ) || defined( USE_FFTWD )
00025 #include "fftw3.h"
00026 
00027 namespace itk
00028 {
00097 template< class TFixedImage, class TMovingImage, class TDisplacementField,
00098           class TImageForceFunction =
00099             MeanSquareRegistrationFunction< TFixedImage, TMovingImage, TDisplacementField > >
00100 class ITK_EXPORT CurvatureRegistrationFilter:
00101   public PDEDeformableRegistrationFilter< TFixedImage, TMovingImage,
00102                                           TDisplacementField >
00103 {
00104 public:
00106   typedef CurvatureRegistrationFilter                                                     Self;
00107   typedef PDEDeformableRegistrationFilter< TFixedImage, TMovingImage, TDisplacementField > Superclass;
00108   typedef SmartPointer< Self >                                                            Pointer;
00109   typedef SmartPointer< const Self >                                                      ConstPointer;
00110 
00112   itkNewMacro(Self);
00113 
00115   itkTypeMacro(CurvatureRegistrationFilter,
00116                PDEDeformableRegistrationFilter);
00117 
00119   typedef typename Superclass::TimeStepType TimeStepType;
00120 
00122   typedef typename Superclass::FixedImageType    FixedImageType;
00123   typedef typename Superclass::FixedImagePointer FixedImagePointer;
00124   itkStaticConstMacro(ImageDimension, unsigned int, FixedImageType::ImageDimension);
00125 
00127   typedef typename Superclass::MovingImageType    MovingImageType;
00128   typedef typename Superclass::MovingImagePointer MovingImagePointer;
00129 
00131   typedef typename Superclass::DisplacementFieldType
00132   DisplacementFieldType;
00133   typedef typename Superclass::DisplacementFieldPointer
00134   DisplacementFieldPointer;
00135 
00136   typedef typename TDisplacementField::PixelType         DisplacementFieldPixelType;
00137   typedef typename DisplacementFieldPixelType::ValueType DisplacementFieldComponentType;
00138   itkStaticConstMacro(DeformationVectorDimension, unsigned int, DisplacementFieldPixelType::Dimension);
00139 
00140   #if defined( USE_FFTWD )
00141   //Prefer to use double precision
00142   typedef double RealTypeDFT;
00143   #else
00144     #if defined( USE_FFTWF )
00145   //Allow to use single precision
00146       #warning "Using single precision for FFT computations!"
00147   typedef double RealTypeDFT;
00148     #endif
00149   #endif
00150 
00151   typedef Image< RealTypeDFT, TDisplacementField::ImageDimension > DisplacementFieldComponentImageType;
00152   typedef typename DisplacementFieldComponentImageType::Pointer    DisplacementFieldComponentImagePointer;
00153 
00155   typedef typename Superclass::FiniteDifferenceFunctionType
00156   FiniteDifferenceFunctionType;
00157 
00159   typedef TImageForceFunction RegistrationFunctionType;
00160 
00162   void SetConstraintWeight(const float w) { m_ConstraintWeight = w; }
00163 
00165   void SetTimeStep(const TimeStepType ts) { m_TimeStep = ts; }
00166 
00172   virtual double GetMetric() const;
00173 
00174 protected:
00175   CurvatureRegistrationFilter();
00176   ~CurvatureRegistrationFilter();
00177   void PrintSelf(std::ostream & os, Indent indent) const;
00178 
00180   virtual void Initialize();
00181 
00183   virtual void ApplyUpdate(const TimeStepType& dt);
00184 
00185 private:
00186   CurvatureRegistrationFilter(const Self &); //purposely not implemented
00187   void operator=(const Self &);              //purposely not implemented
00188 
00189   unsigned int m_FixedImageDimensions[ImageDimension];
00190 
00191   RealTypeDFT *m_DisplacementFieldComponentImage;
00192   RealTypeDFT *m_DisplacementFieldComponentImageDCT;
00193 
00194   float m_ConstraintWeight;
00195 
00196   fftw_plan m_PlanForwardDCT;
00197   fftw_plan m_PlanBackwardDCT;
00198 
00199   TimeStepType m_TimeStep;
00200 
00201   RealTypeDFT *m_DiagonalElements[ImageDimension];
00202 };
00203 } // end namespace itk
00204 
00205 #ifndef ITK_MANUAL_INSTANTIATION
00206 #include "itkCurvatureRegistrationFilter.hxx"
00207 #endif
00208 
00209 #endif //defined(USE_FFTWF) || defined(USE_FFTWD)
00210 
00211 #endif
00212