Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef __elxMetricBase_h
00016 #define __elxMetricBase_h
00017
00019 #include "elxMacro.h"
00020
00021 #include "elxBaseComponentSE.h"
00022 #include "itkAdvancedImageToImageMetric.h"
00023 #include "itkImageGridSampler.h"
00024 #include "itkPointSet.h"
00025
00026 #include "elxTimer.h"
00027
00028
00029 namespace elastix
00030 {
00031 using namespace itk;
00032
00072 template <class TElastix>
00073 class MetricBase : public BaseComponentSE<TElastix>
00074 {
00075 public:
00076
00078 typedef MetricBase Self;
00079 typedef BaseComponentSE<TElastix> Superclass;
00080
00082 itkTypeMacro( MetricBase, BaseComponentSE );
00083
00085 typedef typename Superclass::ElastixType ElastixType;
00086 typedef typename Superclass::ElastixPointer ElastixPointer;
00087 typedef typename Superclass::ConfigurationType ConfigurationType;
00088 typedef typename Superclass::ConfigurationPointer ConfigurationPointer;
00089 typedef typename Superclass::RegistrationType RegistrationType;
00090 typedef typename Superclass::RegistrationPointer RegistrationPointer;
00091
00093 typedef typename ElastixType::FixedImageType FixedImageType;
00094 typedef typename FixedImageType::PointType FixedPointType;
00095 typedef typename FixedPointType::ValueType FixedPointValueType;
00096 typedef typename ElastixType::MovingImageType MovingImageType;
00097 typedef typename MovingImageType::PointType MovingPointType;
00098 typedef typename MovingPointType::ValueType MovingPointValueType;
00099
00101 typedef SingleValuedCostFunction ITKBaseType;
00102 typedef AdvancedImageToImageMetric<
00103 FixedImageType, MovingImageType > AdvancedMetricType;
00104
00106 itkStaticConstMacro( FixedImageDimension, unsigned int, FixedImageType::ImageDimension );
00108 itkStaticConstMacro( MovingImageDimension, unsigned int, MovingImageType::ImageDimension );
00109
00111 typedef typename ITKBaseType::ParametersValueType CoordinateRepresentationType;
00112 typedef PointSet<
00113 CoordinateRepresentationType, FixedImageDimension,
00114 DefaultStaticMeshTraits<
00115 CoordinateRepresentationType,
00116 FixedImageDimension, FixedImageDimension,
00117 CoordinateRepresentationType, CoordinateRepresentationType,
00118 CoordinateRepresentationType > > FixedPointSetType;
00119 typedef PointSet<
00120 CoordinateRepresentationType, MovingImageDimension,
00121 DefaultStaticMeshTraits<
00122 CoordinateRepresentationType,
00123 MovingImageDimension, MovingImageDimension,
00124 CoordinateRepresentationType, CoordinateRepresentationType,
00125 CoordinateRepresentationType > > MovingPointSetType;
00126
00128 typedef typename AdvancedMetricType::ImageSamplerType ImageSamplerBaseType;
00129
00131 typedef typename ITKBaseType::MeasureType MeasureType;
00132
00134 virtual ITKBaseType * GetAsITKBaseType( void )
00135 {
00136 return dynamic_cast<ITKBaseType *>( this );
00137 }
00138
00140 virtual const ITKBaseType * GetAsITKBaseType( void ) const
00141 {
00142 return dynamic_cast<const ITKBaseType *>( this );
00143 }
00144
00149 virtual void BeforeEachResolutionBase( void );
00150
00154 virtual void AfterEachIterationBase( void );
00155
00159 virtual void SelectNewSamples( void );
00160
00164 virtual bool GetAdvancedMetricUseImageSampler( void ) const;
00165
00170 virtual void SetAdvancedMetricImageSampler( ImageSamplerBaseType * sampler );
00171
00176 virtual ImageSamplerBaseType * GetAdvancedMetricImageSampler( void ) const;
00177
00179 virtual bool GetShowExactMetricValue( void ) const
00180 { return this->m_ShowExactMetricValue; }
00181
00183 virtual MeasureType GetCurrentExactMetricValue( void ) const
00184 { return this->m_CurrentExactMetricValue; }
00185
00186 protected:
00187
00189 typedef typename ITKBaseType::ParametersType ParametersType;
00190
00192 typedef itk::ImageGridSampler<FixedImageType> ExactMetricImageSamplerType;
00193 typedef typename
00194 ExactMetricImageSamplerType::SampleGridSpacingType ExactMetricSampleGridSpacingType;
00195
00197 MetricBase();
00199 virtual ~MetricBase() {}
00200
00210 virtual MeasureType GetExactValue( const ParametersType& parameters );
00213 bool m_ShowExactMetricValue;
00214 typename ExactMetricImageSamplerType::Pointer m_ExactMetricSampler;
00215 MeasureType m_CurrentExactMetricValue;
00216 ExactMetricSampleGridSpacingType m_ExactMetricSampleGridSpacing;
00217
00218 private:
00219
00221 MetricBase( const Self& );
00223 void operator=( const Self& );
00224
00225 };
00226
00227
00228 }
00229
00230 #ifndef ITK_MANUAL_INSTANTIATION
00231 #include "elxMetricBase.hxx"
00232 #endif
00233
00234 #endif // end #ifndef __elxMetricBase_h