ITK  4.0.0
Insight Segmentation and Registration Toolkit
itkLevelSetMotionRegistrationFunction.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 __itkLevelSetMotionRegistrationFunction_h
00019 #define __itkLevelSetMotionRegistrationFunction_h
00020 
00021 #include "itkPDEDeformableRegistrationFunction.h"
00022 #include "itkPoint.h"
00023 #include "itkCovariantVector.h"
00024 #include "itkLinearInterpolateImageFunction.h"
00025 #include "itkSmoothingRecursiveGaussianImageFilter.h"
00026 
00027 namespace itk
00028 {
00053 template< class TFixedImage, class TMovingImage, class TDisplacementField >
00054 class ITK_EXPORT LevelSetMotionRegistrationFunction:
00055   public PDEDeformableRegistrationFunction< TFixedImage,
00056                                             TMovingImage,
00057                                             TDisplacementField >
00058 {
00059 public:
00060 
00062   typedef LevelSetMotionRegistrationFunction Self;
00063   typedef PDEDeformableRegistrationFunction< TFixedImage,
00064                                              TMovingImage, TDisplacementField
00065                                              > Superclass;
00066 
00067   typedef SmartPointer< Self >       Pointer;
00068   typedef SmartPointer< const Self > ConstPointer;
00069 
00071   itkNewMacro(Self);
00072 
00074   itkTypeMacro(LevelSetMotionRegistrationFunction,
00075                PDEDeformableRegistrationFunction);
00076 
00078   typedef typename Superclass::MovingImageType    MovingImageType;
00079   typedef typename Superclass::MovingImagePointer MovingImagePointer;
00080   typedef typename MovingImageType::SpacingType   MovingSpacingType;
00081 
00083   typedef typename Superclass::FixedImageType    FixedImageType;
00084   typedef typename Superclass::FixedImagePointer FixedImagePointer;
00085   typedef typename FixedImageType::IndexType     IndexType;
00086   typedef typename FixedImageType::SizeType      SizeType;
00087   typedef typename FixedImageType::SpacingType   SpacingType;
00088 
00090   typedef typename Superclass::DisplacementFieldType DisplacementFieldType;
00091   typedef typename Superclass::DisplacementFieldTypePointer
00092   DisplacementFieldTypePointer;
00093 
00095   itkStaticConstMacro(ImageDimension, unsigned
00096                       int, Superclass::ImageDimension);
00097 
00099   typedef typename Superclass::PixelType        PixelType;
00100   typedef typename Superclass::RadiusType       RadiusType;
00101   typedef typename Superclass::NeighborhoodType NeighborhoodType;
00102   typedef typename Superclass::FloatOffsetType  FloatOffsetType;
00103   typedef typename Superclass::TimeStepType     TimeStepType;
00104 
00106   typedef double                                                    CoordRepType;
00107   typedef InterpolateImageFunction< MovingImageType, CoordRepType > InterpolatorType;
00108   typedef typename InterpolatorType::Pointer                        InterpolatorPointer;
00109   typedef typename InterpolatorType::PointType                      PointType;
00110   typedef LinearInterpolateImageFunction< MovingImageType, CoordRepType >
00111   DefaultInterpolatorType;
00112 
00114   typedef Vector< double, itkGetStaticConstMacro(ImageDimension) > VectorType;
00115   typedef CovariantVector< double, itkGetStaticConstMacro(ImageDimension) >
00116   CovariantVectorType;
00118 
00120   typedef SmoothingRecursiveGaussianImageFilter< MovingImageType >
00121   MovingImageSmoothingFilterType;
00122   typedef typename MovingImageSmoothingFilterType::Pointer
00123   MovingImageSmoothingFilterPointer;
00124 
00126   void SetMovingImageInterpolator(InterpolatorType *ptr)
00127   { m_MovingImageInterpolator = ptr; }
00128 
00130   InterpolatorType * GetMovingImageInterpolator(void)
00131   { return m_MovingImageInterpolator; }
00132 
00135   virtual TimeStepType ComputeGlobalTimeStep(void *GlobalData) const;
00136 
00139   virtual void * GetGlobalDataPointer() const
00140   {
00141     GlobalDataStruct *global = new GlobalDataStruct();
00142 
00143     global->m_SumOfSquaredDifference  = 0.0;
00144     global->m_NumberOfPixelsProcessed = 0L;
00145     global->m_SumOfSquaredChange      = 0;
00146     global->m_MaxL1Norm            = NumericTraits< double >::NonpositiveMin();
00147     return global;
00148   }
00149 
00151   virtual void ReleaseGlobalDataPointer(void *GlobalData) const;
00152 
00154   virtual void InitializeIteration();
00155 
00158   virtual PixelType  ComputeUpdate( const NeighborhoodType & neighborhood,
00159                                     void *globalData,
00160                                     const FloatOffsetType & offset =
00161                                       FloatOffsetType(0.0) );
00162 
00166   virtual double GetMetric() const
00167   { return m_Metric; }
00168 
00170   virtual double GetRMSChange() const
00171   { return m_RMSChange; }
00172 
00179   virtual void SetAlpha(double);
00180 
00181   virtual double GetAlpha() const;
00182 
00187   virtual void SetIntensityDifferenceThreshold(double);
00188 
00189   virtual double GetIntensityDifferenceThreshold() const;
00190 
00193   virtual void SetGradientMagnitudeThreshold(double);
00194 
00195   virtual double GetGradientMagnitudeThreshold() const;
00196 
00199   virtual void SetGradientSmoothingStandardDeviations(double);
00200 
00201   virtual double GetGradientSmoothingStandardDeviations() const;
00202 
00206   void SetUseImageSpacing(bool);
00207 
00208   bool GetUseImageSpacing() const;
00209 
00210 protected:
00211   LevelSetMotionRegistrationFunction();
00212   ~LevelSetMotionRegistrationFunction() {}
00213   void PrintSelf(std::ostream & os, Indent indent) const;
00214 
00216   typedef ConstNeighborhoodIterator< FixedImageType >
00217   FixedImageNeighborhoodIteratorType;
00218 
00221   struct GlobalDataStruct {
00222     double m_SumOfSquaredDifference;
00223     SizeValueType m_NumberOfPixelsProcessed;
00224     double m_SumOfSquaredChange;
00225     double m_MaxL1Norm;
00226   };
00227 private:
00228   LevelSetMotionRegistrationFunction(const Self &); //purposely not implemented
00229   void operator=(const Self &);                     //purposely not implemented
00231 
00233   SpacingType m_FixedImageSpacing;
00234   PointType   m_FixedImageOrigin;
00235 
00237   MovingImageSmoothingFilterPointer m_MovingImageSmoothingFilter;
00238 
00240   InterpolatorPointer m_MovingImageInterpolator;
00241   InterpolatorPointer m_SmoothMovingImageInterpolator;
00242 
00245   double m_Alpha;
00246 
00248   double m_GradientMagnitudeThreshold;
00249 
00251   double m_IntensityDifferenceThreshold;
00252 
00254   double m_GradientSmoothingStandardDeviations;
00255 
00259   mutable double        m_Metric;
00260   mutable double        m_SumOfSquaredDifference;
00261   mutable SizeValueType m_NumberOfPixelsProcessed;
00262   mutable double        m_RMSChange;
00263   mutable double        m_SumOfSquaredChange;
00264 
00266   mutable SimpleFastMutexLock m_MetricCalculationLock;
00267 
00268   bool m_UseImageSpacing;
00269 };
00270 } // end namespace itk
00271 
00272 #ifndef ITK_MANUAL_INSTANTIATION
00273 #include "itkLevelSetMotionRegistrationFunction.hxx"
00274 #endif
00275 
00276 #endif
00277