ITK
4.1.0
Insight Segmentation and Registration Toolkit
|
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 __itkDemonsRegistrationFunction_h 00019 #define __itkDemonsRegistrationFunction_h 00020 00021 #include "itkPDEDeformableRegistrationFunction.h" 00022 #include "itkPoint.h" 00023 #include "itkLinearInterpolateImageFunction.h" 00024 #include "itkCentralDifferenceImageFunction.h" 00025 00026 namespace itk 00027 { 00052 template< class TFixedImage, class TMovingImage, class TDisplacementField > 00053 class ITK_EXPORT DemonsRegistrationFunction: 00054 public PDEDeformableRegistrationFunction< TFixedImage, 00055 TMovingImage, 00056 TDisplacementField > 00057 { 00058 public: 00059 00061 typedef DemonsRegistrationFunction Self; 00062 typedef PDEDeformableRegistrationFunction< TFixedImage, 00063 TMovingImage, TDisplacementField 00064 > Superclass; 00065 typedef SmartPointer< Self > Pointer; 00066 typedef SmartPointer< const Self > ConstPointer; 00067 00069 itkNewMacro(Self); 00070 00072 itkTypeMacro(DemonsRegistrationFunction, 00073 PDEDeformableRegistrationFunction); 00074 00076 typedef typename Superclass::MovingImageType MovingImageType; 00077 typedef typename Superclass::MovingImagePointer MovingImagePointer; 00078 00080 typedef typename Superclass::FixedImageType FixedImageType; 00081 typedef typename Superclass::FixedImagePointer FixedImagePointer; 00082 typedef typename FixedImageType::IndexType IndexType; 00083 typedef typename FixedImageType::SizeType SizeType; 00084 typedef typename FixedImageType::SpacingType SpacingType; 00085 00087 typedef typename Superclass::DisplacementFieldType DisplacementFieldType; 00088 typedef typename Superclass::DisplacementFieldTypePointer DisplacementFieldTypePointer; 00089 00090 #ifdef ITKV3_COMPATIBILITY 00091 typedef typename Superclass::DeformationFieldType DeformationFieldType; 00092 typedef typename Superclass::DeformationFieldTypePointer DeformationFieldTypePointer; 00093 #endif 00094 00096 itkStaticConstMacro(ImageDimension, unsigned 00097 int, Superclass::ImageDimension); 00098 00100 typedef typename Superclass::PixelType PixelType; 00101 typedef typename Superclass::RadiusType RadiusType; 00102 typedef typename Superclass::NeighborhoodType NeighborhoodType; 00103 typedef typename Superclass::FloatOffsetType FloatOffsetType; 00104 typedef typename Superclass::TimeStepType TimeStepType; 00105 00107 typedef double CoordRepType; 00108 typedef InterpolateImageFunction< MovingImageType, CoordRepType > InterpolatorType; 00109 typedef typename InterpolatorType::Pointer InterpolatorPointer; 00110 typedef typename InterpolatorType::PointType PointType; 00111 typedef LinearInterpolateImageFunction< MovingImageType, CoordRepType > DefaultInterpolatorType; 00112 00114 typedef CovariantVector< double, itkGetStaticConstMacro(ImageDimension) > CovariantVectorType; 00115 00117 typedef CentralDifferenceImageFunction< FixedImageType > GradientCalculatorType; 00118 typedef typename GradientCalculatorType::Pointer GradientCalculatorPointer; 00119 00121 typedef CentralDifferenceImageFunction< MovingImageType, CoordRepType > 00122 MovingImageGradientCalculatorType; 00123 typedef typename MovingImageGradientCalculatorType::Pointer 00124 MovingImageGradientCalculatorPointer; 00125 00127 void SetMovingImageInterpolator(InterpolatorType *ptr) 00128 { m_MovingImageInterpolator = ptr; } 00129 00131 InterpolatorType * GetMovingImageInterpolator(void) 00132 { return m_MovingImageInterpolator; } 00133 00135 virtual TimeStepType ComputeGlobalTimeStep( void *itkNotUsed(GlobalData) ) 00136 const 00137 { return m_TimeStep; } 00138 00141 virtual void * GetGlobalDataPointer() const 00142 { 00143 GlobalDataStruct *global = new GlobalDataStruct(); 00144 00145 global->m_SumOfSquaredDifference = 0.0; 00146 global->m_NumberOfPixelsProcessed = 0L; 00147 global->m_SumOfSquaredChange = 0; 00148 return global; 00149 } 00150 00152 virtual void ReleaseGlobalDataPointer(void *GlobalData) const; 00153 00155 virtual void InitializeIteration(); 00156 00159 virtual PixelType ComputeUpdate( const NeighborhoodType & neighborhood, 00160 void *globalData, 00161 const FloatOffsetType & offset = 00162 FloatOffsetType(0.0) ); 00163 00167 virtual double GetMetric() const 00168 { return m_Metric; } 00169 00171 virtual double GetRMSChange() const 00172 { return m_RMSChange; } 00173 00177 virtual void SetUseMovingImageGradient(bool flag) 00178 { m_UseMovingImageGradient = flag; } 00179 virtual bool GetUseMovingImageGradient() const 00180 { return m_UseMovingImageGradient; } 00182 00187 virtual void SetIntensityDifferenceThreshold(double); 00188 00189 virtual double GetIntensityDifferenceThreshold() const; 00190 00191 protected: 00192 DemonsRegistrationFunction(); 00193 ~DemonsRegistrationFunction() {} 00194 void PrintSelf(std::ostream & os, Indent indent) const; 00195 00197 typedef ConstNeighborhoodIterator< FixedImageType > 00198 FixedImageNeighborhoodIteratorType; 00199 00202 struct GlobalDataStruct { 00203 double m_SumOfSquaredDifference; 00204 SizeValueType m_NumberOfPixelsProcessed; 00205 double m_SumOfSquaredChange; 00206 }; 00207 private: 00208 DemonsRegistrationFunction(const Self &); //purposely not implemented 00209 void operator=(const Self &); //purposely not implemented 00211 00213 //SpacingType m_FixedImageSpacing; 00214 //PointType m_FixedImageOrigin; 00215 PixelType m_ZeroUpdateReturn; 00216 double m_Normalizer; 00217 00219 GradientCalculatorPointer m_FixedImageGradientCalculator; 00220 00222 MovingImageGradientCalculatorPointer m_MovingImageGradientCalculator; 00223 bool m_UseMovingImageGradient; 00224 00226 InterpolatorPointer m_MovingImageInterpolator; 00227 00229 TimeStepType m_TimeStep; 00230 00232 double m_DenominatorThreshold; 00233 00235 double m_IntensityDifferenceThreshold; 00236 00240 mutable double m_Metric; 00241 mutable double m_SumOfSquaredDifference; 00242 mutable SizeValueType m_NumberOfPixelsProcessed; 00243 mutable double m_RMSChange; 00244 mutable double m_SumOfSquaredChange; 00245 00247 mutable SimpleFastMutexLock m_MetricCalculationLock; 00248 }; 00249 } // end namespace itk 00250 00251 #ifndef ITK_MANUAL_INSTANTIATION 00252 #include "itkDemonsRegistrationFunction.hxx" 00253 #endif 00254 00255 #endif 00256