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 __itkSymmetricForcesDemonsRegistrationFunction_h 00019 #define __itkSymmetricForcesDemonsRegistrationFunction_h 00020 00021 #include "itkPDEDeformableRegistrationFunction.h" 00022 #include "itkPoint.h" 00023 #include "itkLinearInterpolateImageFunction.h" 00024 #include "itkCentralDifferenceImageFunction.h" 00025 00026 namespace itk 00027 { 00060 template< class TFixedImage, class TMovingImage, class TDisplacementField > 00061 class ITK_EXPORT SymmetricForcesDemonsRegistrationFunction: 00062 public PDEDeformableRegistrationFunction< TFixedImage, 00063 TMovingImage, TDisplacementField > 00064 { 00065 public: 00066 00068 typedef SymmetricForcesDemonsRegistrationFunction Self; 00069 typedef PDEDeformableRegistrationFunction< TFixedImage, 00070 TMovingImage, TDisplacementField > 00071 Superclass; 00072 typedef SmartPointer< Self > Pointer; 00073 typedef SmartPointer< const Self > ConstPointer; 00074 00076 itkNewMacro(Self); 00077 00079 itkTypeMacro(SymmetricForcesDemonsRegistrationFunction, 00080 PDEDeformableRegistrationFunction); 00081 00083 typedef typename Superclass::MovingImageType MovingImageType; 00084 typedef typename Superclass::MovingImagePointer MovingImagePointer; 00085 00087 typedef typename Superclass::FixedImageType FixedImageType; 00088 typedef typename Superclass::FixedImagePointer FixedImagePointer; 00089 typedef typename FixedImageType::IndexType IndexType; 00090 typedef typename FixedImageType::SizeType SizeType; 00091 typedef typename FixedImageType::SpacingType SpacingType; 00092 00094 typedef typename Superclass::DisplacementFieldType DisplacementFieldType; 00095 typedef typename Superclass::DisplacementFieldTypePointer 00096 DisplacementFieldTypePointer; 00097 00099 itkStaticConstMacro(ImageDimension, unsigned int, Superclass::ImageDimension); 00100 00102 typedef typename Superclass::PixelType PixelType; 00103 typedef typename Superclass::RadiusType RadiusType; 00104 typedef typename Superclass::NeighborhoodType NeighborhoodType; 00105 typedef typename Superclass::FloatOffsetType FloatOffsetType; 00106 typedef typename Superclass::TimeStepType TimeStepType; 00107 00109 typedef double CoordRepType; 00110 typedef InterpolateImageFunction< MovingImageType, CoordRepType > InterpolatorType; 00111 typedef typename InterpolatorType::Pointer InterpolatorPointer; 00112 typedef typename InterpolatorType::PointType PointType; 00113 typedef LinearInterpolateImageFunction< MovingImageType, CoordRepType > DefaultInterpolatorType; 00114 00116 typedef CovariantVector< double, itkGetStaticConstMacro(ImageDimension) > CovariantVectorType; 00117 00119 typedef CentralDifferenceImageFunction< FixedImageType > GradientCalculatorType; 00120 typedef typename GradientCalculatorType::Pointer GradientCalculatorPointer; 00121 00123 void SetMovingImageInterpolator(InterpolatorType *ptr) 00124 { m_MovingImageInterpolator = ptr; } 00125 00127 InterpolatorType * GetMovingImageInterpolator(void) 00128 { return m_MovingImageInterpolator; } 00129 00131 virtual TimeStepType ComputeGlobalTimeStep( void *itkNotUsed(GlobalData) ) const 00132 { return m_TimeStep; } 00133 00136 virtual void * GetGlobalDataPointer() const 00137 { 00138 GlobalDataStruct *global = new GlobalDataStruct(); 00139 00140 global->m_SumOfSquaredDifference = 0.0; 00141 global->m_NumberOfPixelsProcessed = 0L; 00142 global->m_SumOfSquaredChange = 0; 00143 return global; 00144 } 00145 00147 virtual void ReleaseGlobalDataPointer(void *GlobalData) const; 00148 00150 virtual void InitializeIteration(); 00151 00154 virtual PixelType ComputeUpdate( const NeighborhoodType & neighborhood, 00155 void *globalData, 00156 const FloatOffsetType & offset = FloatOffsetType(0.0) ); 00157 00161 virtual double GetMetric() const 00162 { return m_Metric; } 00163 00165 virtual const double & GetRMSChange() const 00166 { return m_RMSChange; } 00167 00172 virtual void SetIntensityDifferenceThreshold(double); 00173 00174 virtual double GetIntensityDifferenceThreshold() const; 00175 00176 protected: 00177 SymmetricForcesDemonsRegistrationFunction(); 00178 ~SymmetricForcesDemonsRegistrationFunction() {} 00179 void PrintSelf(std::ostream & os, Indent indent) const; 00180 00182 typedef ConstNeighborhoodIterator< FixedImageType > FixedImageNeighborhoodIteratorType; 00183 00186 struct GlobalDataStruct { 00187 double m_SumOfSquaredDifference; 00188 SizeValueType m_NumberOfPixelsProcessed; 00189 double m_SumOfSquaredChange; 00190 }; 00191 private: 00192 SymmetricForcesDemonsRegistrationFunction(const Self &); //purposely not 00193 // implemented 00194 void operator=(const Self &); //purposely not 00196 00197 // implemented 00198 00200 SpacingType m_FixedImageSpacing; 00201 PointType m_FixedImageOrigin; 00202 double m_Normalizer; 00203 00205 GradientCalculatorPointer m_FixedImageGradientCalculator; 00206 00208 InterpolatorPointer m_MovingImageInterpolator; 00209 00211 TimeStepType m_TimeStep; 00212 00214 double m_DenominatorThreshold; 00215 00217 double m_IntensityDifferenceThreshold; 00218 00222 mutable double m_Metric; 00223 mutable double m_SumOfSquaredDifference; 00224 mutable SizeValueType m_NumberOfPixelsProcessed; 00225 mutable double m_RMSChange; 00226 mutable double m_SumOfSquaredChange; 00227 00229 mutable SimpleFastMutexLock m_MetricCalculationLock; 00230 }; 00231 } // end namespace itk 00232 00233 #ifndef ITK_MANUAL_INSTANTIATION 00234 #include "itkSymmetricForcesDemonsRegistrationFunction.hxx" 00235 #endif 00236 00237 #endif 00238