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 "itkImageFullSampler.h"
00024 #include "itkPointSet.h"
00025
00026 #include "elxTimer.h"
00027
00028
00029 namespace elastix
00030 {
00031 using namespace itk;
00032
00061 template <class TElastix>
00062 class MetricBase : public BaseComponentSE<TElastix>
00063 {
00064 public:
00065
00067 typedef MetricBase Self;
00068 typedef BaseComponentSE<TElastix> Superclass;
00069
00071 itkTypeMacro( MetricBase, BaseComponentSE );
00072
00074 typedef typename Superclass::ElastixType ElastixType;
00075 typedef typename Superclass::ElastixPointer ElastixPointer;
00076 typedef typename Superclass::ConfigurationType ConfigurationType;
00077 typedef typename Superclass::ConfigurationPointer ConfigurationPointer;
00078 typedef typename Superclass::RegistrationType RegistrationType;
00079 typedef typename Superclass::RegistrationPointer RegistrationPointer;
00080
00082 typedef typename ElastixType::FixedImageType FixedImageType;
00083 typedef typename FixedImageType::PointType FixedPointType;
00084 typedef typename FixedPointType::ValueType FixedPointValueType;
00085 typedef typename ElastixType::MovingImageType MovingImageType;
00086 typedef typename MovingImageType::PointType MovingPointType;
00087 typedef typename MovingPointType::ValueType MovingPointValueType;
00088
00090 typedef SingleValuedCostFunction ITKBaseType;
00091 typedef AdvancedImageToImageMetric<
00092 FixedImageType, MovingImageType > AdvancedMetricType;
00093
00095 itkStaticConstMacro( FixedImageDimension, unsigned int, FixedImageType::ImageDimension );
00097 itkStaticConstMacro( MovingImageDimension, unsigned int, MovingImageType::ImageDimension );
00098
00100 typedef typename ITKBaseType::ParametersValueType CoordinateRepresentationType;
00101 typedef PointSet<
00102 CoordinateRepresentationType, FixedImageDimension,
00103 DefaultStaticMeshTraits<
00104 CoordinateRepresentationType,
00105 FixedImageDimension, FixedImageDimension,
00106 CoordinateRepresentationType, CoordinateRepresentationType,
00107 CoordinateRepresentationType > > FixedPointSetType;
00108 typedef PointSet<
00109 CoordinateRepresentationType, MovingImageDimension,
00110 DefaultStaticMeshTraits<
00111 CoordinateRepresentationType,
00112 MovingImageDimension, MovingImageDimension,
00113 CoordinateRepresentationType, CoordinateRepresentationType,
00114 CoordinateRepresentationType > > MovingPointSetType;
00115
00117 typedef typename AdvancedMetricType::ImageSamplerType ImageSamplerBaseType;
00118
00120 virtual ITKBaseType * GetAsITKBaseType( void )
00121 {
00122 return dynamic_cast<ITKBaseType *>( this );
00123 }
00124
00126 virtual const ITKBaseType * GetAsITKBaseType( void ) const
00127 {
00128 return dynamic_cast<const ITKBaseType *>( this );
00129 }
00130
00135 virtual void BeforeEachResolutionBase( void );
00136
00140 virtual void AfterEachIterationBase( void );
00141
00145 virtual void SelectNewSamples( void );
00146
00150 virtual bool GetAdvancedMetricUseImageSampler( void ) const;
00151
00156 virtual void SetAdvancedMetricImageSampler( ImageSamplerBaseType * sampler );
00157
00162 virtual ImageSamplerBaseType * GetAdvancedMetricImageSampler( void ) const;
00163
00164 protected:
00165
00167 typedef typename ITKBaseType::MeasureType MeasureType;
00168 typedef typename ITKBaseType::ParametersType ParametersType;
00169
00171 typedef itk::ImageFullSampler<FixedImageType> ImageFullSamplerType;
00172
00174 MetricBase();
00176 virtual ~MetricBase() {}
00177
00187 virtual MeasureType GetExactValue( const ParametersType& parameters );
00190 bool m_ShowExactMetricValue;
00191 typename ImageFullSamplerType::Pointer m_ExactMetricSampler;
00192
00193 private:
00194
00196 MetricBase( const Self& );
00198 void operator=( const Self& );
00199
00200 };
00201
00202
00203 }
00204
00205 #ifndef ITK_MANUAL_INSTANTIATION
00206 #include "elxMetricBase.hxx"
00207 #endif
00208
00209 #endif // end #ifndef __elxMetricBase_h