ITK  4.0.0
Insight Segmentation and Registration Toolkit
itkMultiResolutionPDEDeformableRegistration.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 __itkMultiResolutionPDEDeformableRegistration_h
00019 #define __itkMultiResolutionPDEDeformableRegistration_h
00020 
00021 #include "itkImage.h"
00022 #include "itkDemonsRegistrationFilter.h"
00023 #include "itkMultiResolutionPyramidImageFilter.h"
00024 #include "itkVectorResampleImageFilter.h"
00025 #include "itkArray.h"
00026 
00027 namespace itk
00028 {
00080 template< class TFixedImage, class TMovingImage, class TDisplacementField, class TRealType = float >
00081 class ITK_EXPORT MultiResolutionPDEDeformableRegistration:
00082   public ImageToImageFilter< TDisplacementField, TDisplacementField >
00083 {
00084 public:
00085 
00087   typedef MultiResolutionPDEDeformableRegistration Self;
00088   typedef ImageToImageFilter< TDisplacementField, TDisplacementField >
00089   Superclass;
00090   typedef SmartPointer< Self >       Pointer;
00091   typedef SmartPointer< const Self > ConstPointer;
00092 
00094   itkNewMacro(Self);
00095 
00097   itkTypeMacro(MultiResolutionPDEDeformableRegistration,
00098                ImageToImageFilter);
00099 
00101   typedef TFixedImage                           FixedImageType;
00102   typedef typename FixedImageType::Pointer      FixedImagePointer;
00103   typedef typename FixedImageType::ConstPointer FixedImageConstPointer;
00104 
00106   typedef TMovingImage                           MovingImageType;
00107   typedef typename MovingImageType::Pointer      MovingImagePointer;
00108   typedef typename MovingImageType::ConstPointer MovingImageConstPointer;
00109 
00111   typedef TDisplacementField                      DisplacementFieldType;
00112   typedef typename DisplacementFieldType::Pointer DisplacementFieldPointer;
00113 #ifdef ITKV3_COMPATIBILITY
00114   typedef TDisplacementField                      DeformationFieldType;
00115   typedef typename DeformationFieldType::Pointer  DeformationFieldPointer;
00116 #endif
00117 
00119   itkStaticConstMacro(ImageDimension, unsigned int, FixedImageType::ImageDimension);
00120 
00122   typedef Image< TRealType, itkGetStaticConstMacro(ImageDimension) > FloatImageType;
00123 
00125   typedef PDEDeformableRegistrationFilter< FloatImageType, FloatImageType, DisplacementFieldType > RegistrationType;
00126   typedef typename RegistrationType::Pointer                                                      RegistrationPointer;
00127 
00129   typedef DemonsRegistrationFilter< FloatImageType, FloatImageType, DisplacementFieldType > DefaultRegistrationType;
00130 
00132   typedef MultiResolutionPyramidImageFilter< FixedImageType, FloatImageType > FixedImagePyramidType;
00133   typedef typename FixedImagePyramidType::Pointer                             FixedImagePyramidPointer;
00134 
00136   typedef MultiResolutionPyramidImageFilter< MovingImageType, FloatImageType > MovingImagePyramidType;
00137   typedef typename MovingImagePyramidType::Pointer                             MovingImagePyramidPointer;
00138 
00140   typedef VectorResampleImageFilter< DisplacementFieldType, DisplacementFieldType > FieldExpanderType;
00141   typedef typename FieldExpanderType::Pointer                                     FieldExpanderPointer;
00142 
00143   typedef Array< unsigned int > NumberOfIterationsType;
00144 
00146   virtual void SetFixedImage(const FixedImageType *ptr);
00147 
00149   const FixedImageType * GetFixedImage(void) const;
00150 
00152   virtual void SetMovingImage(const MovingImageType *ptr);
00153 
00155   const MovingImageType * GetMovingImage(void) const;
00156 
00159   virtual void SetInitialDisplacementField(DisplacementFieldType *ptr)
00160   {
00161     this->m_InitialDisplacementField = ptr;
00162   }
00163 
00167   virtual void SetArbitraryInitialDisplacementField(DisplacementFieldType *ptr)
00168   {
00169     this->SetInput(ptr);
00170   }
00171 
00173   const DisplacementFieldType * GetDisplacementField(void)
00174   { return this->GetOutput(); }
00175 
00176 #ifdef ITKV3_COMPATIBILITY
00177   virtual void SetInitialDeformationField(DisplacementFieldType *ptr)
00178   {
00179     this->SetInitialDisplacementField(ptr);
00180   }
00181 
00182   virtual void SetArbitraryInitialDeformationField(DisplacementFieldType *ptr)
00183   {
00184     this->SetArbitraryInitialDisplacementField(ptr);
00185   }
00186 
00188   const DeformationFieldType * GetDeformationField(void)
00189   {
00190     return static_cast<DeformationFieldType *> (this->GetDisplacementField());
00191   }
00192 #endif
00193 
00200   virtual std::vector< SmartPointer< DataObject > >::size_type GetNumberOfValidRequiredInputs() const;
00201 
00203   itkSetObjectMacro(RegistrationFilter, RegistrationType);
00204 
00206   itkGetObjectMacro(RegistrationFilter, RegistrationType);
00207 
00209   itkSetObjectMacro(FixedImagePyramid, FixedImagePyramidType);
00210 
00212   itkGetObjectMacro(FixedImagePyramid, FixedImagePyramidType);
00213 
00215   itkSetObjectMacro(MovingImagePyramid, MovingImagePyramidType);
00216 
00218   itkGetObjectMacro(MovingImagePyramid, MovingImagePyramidType);
00219 
00221   virtual void SetNumberOfLevels(unsigned int num);
00222 
00224   itkGetConstReferenceMacro(NumberOfLevels, unsigned int);
00225 
00227   itkGetConstReferenceMacro(CurrentLevel, unsigned int);
00228 
00230   itkSetObjectMacro(FieldExpander, FieldExpanderType);
00231 
00233   itkGetObjectMacro(FieldExpander, FieldExpanderType);
00234 
00236   itkSetMacro(NumberOfIterations, NumberOfIterationsType);
00237   itkSetVectorMacro(NumberOfIterations, unsigned int, m_NumberOfLevels);
00239 
00241   itkGetConstReferenceMacro(NumberOfIterations, NumberOfIterationsType);
00242 
00244   virtual void StopRegistration();
00245 
00246 protected:
00247   MultiResolutionPDEDeformableRegistration();
00248   // ~MultiResolutionPDEDeformableRegistration() {} default implementation ok
00249 
00250   void PrintSelf(std::ostream & os, Indent indent) const;
00251 
00254   virtual void GenerateData();
00255 
00259   virtual void GenerateInputRequestedRegion();
00260 
00267   virtual void GenerateOutputInformation();
00268 
00272   virtual void EnlargeOutputRequestedRegion(DataObject *ptr);
00273 
00276   virtual bool Halt();
00277 
00283   virtual void VerifyInputInformation() {}
00284 
00285 private:
00286   MultiResolutionPDEDeformableRegistration(const Self &); //purposely not
00287                                                           // implemented
00288   void operator=(const Self &);                           //purposely not
00289 
00290   // implemented
00291 
00292   RegistrationPointer       m_RegistrationFilter;
00293   FixedImagePyramidPointer  m_FixedImagePyramid;
00294   MovingImagePyramidPointer m_MovingImagePyramid;
00295   FieldExpanderPointer      m_FieldExpander;
00296   DisplacementFieldPointer  m_InitialDisplacementField;
00297 
00298   unsigned int                m_NumberOfLevels;
00299   unsigned int                m_CurrentLevel;
00300   NumberOfIterationsType      m_NumberOfIterations;
00301 
00303   bool m_StopRegistrationFlag;
00304 };
00305 } // end namespace itk
00306 
00307 #ifndef ITK_MANUAL_INSTANTIATION
00308 #include "itkMultiResolutionPDEDeformableRegistration.hxx"
00309 #endif
00310 
00311 #endif
00312