00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkSumOfSquaresImageFunction_h
00018 #define __itkSumOfSquaresImageFunction_h
00019
00020 #include "itkImageFunction.h"
00021 #include "itkNumericTraits.h"
00022 #include "itkNeighborhood.h"
00023
00024 namespace itk
00025 {
00026
00042 template <class TInputImage, class TCoordRep = float >
00043 class ITK_EXPORT SumOfSquaresImageFunction :
00044 public ImageFunction< TInputImage, ITK_TYPENAME NumericTraits<typename TInputImage::PixelType>::RealType,
00045 TCoordRep >
00046 {
00047 public:
00048
00050 typedef SumOfSquaresImageFunction Self;
00051 typedef ImageFunction<TInputImage, ITK_TYPENAME NumericTraits<typename TInputImage::PixelType>::RealType,
00052 TCoordRep > Superclass;
00053 typedef SmartPointer<Self> Pointer;
00054 typedef SmartPointer<const Self> ConstPointer;
00055
00057 itkTypeMacro(SumOfSquaresImageFunction, ImageFunction);
00058
00060 itkNewMacro(Self);
00061
00063 typedef TInputImage InputImageType;
00064
00066 typedef typename Superclass::OutputType OutputType;
00067
00069 typedef typename Superclass::IndexType IndexType;
00070
00072 typedef typename Superclass::ContinuousIndexType ContinuousIndexType;
00073
00075 typedef typename Superclass::PointType PointType;
00076
00078 itkStaticConstMacro(ImageDimension, unsigned int,
00079 InputImageType::ImageDimension);
00080
00082 typedef typename NumericTraits<typename InputImageType::PixelType>::RealType
00083 RealType;
00084
00086 virtual RealType EvaluateAtIndex( const IndexType& index ) const;
00087
00089 virtual RealType Evaluate( const PointType& point ) const
00090 {
00091 IndexType index;
00092 this->ConvertPointToNearestIndex( point, index );
00093 return this->EvaluateAtIndex( index );
00094 }
00095 virtual RealType EvaluateAtContinuousIndex(
00096 const ContinuousIndexType& cindex ) const
00097 {
00098 IndexType index;
00099 this->ConvertContinuousIndexToNearestIndex( cindex, index );
00100 return this->EvaluateAtIndex( index );
00101 }
00103
00106 itkGetConstReferenceMacro( NeighborhoodRadius, unsigned int );
00107
00108 void SetNeighborhoodRadius(unsigned int radius)
00109 {
00110 m_NeighborhoodRadius = radius;
00111
00112 m_NeighborhoodSize = 1;
00113 long twoRPlus1 = 2*m_NeighborhoodRadius + 1;
00114 for (unsigned int i=0; i < ImageDimension; i++)
00115 {
00116 m_NeighborhoodSize *= twoRPlus1;
00117 }
00118 }
00119
00120 itkGetConstReferenceMacro(NeighborhoodSize, unsigned int);
00121
00122 protected:
00123 SumOfSquaresImageFunction();
00124 ~SumOfSquaresImageFunction(){};
00125 void PrintSelf(std::ostream& os, Indent indent) const;
00126
00127 private:
00128 SumOfSquaresImageFunction( const Self& );
00129 void operator=( const Self& );
00130
00131 unsigned int m_NeighborhoodRadius;
00132 unsigned int m_NeighborhoodSize;
00133 };
00134
00135 }
00136
00137
00138 #define ITK_TEMPLATE_SumOfSquaresImageFunction(_, EXPORT, x, y) namespace itk { \
00139 _(2(class EXPORT SumOfSquaresImageFunction< ITK_TEMPLATE_2 x >)) \
00140 namespace Templates { typedef SumOfSquaresImageFunction< ITK_TEMPLATE_2 x > \
00141 SumOfSquaresImageFunction##y; } \
00142 }
00143
00144 #if ITK_TEMPLATE_EXPLICIT
00145 # include "Templates/itkSumOfSquaresImageFunction+-.h"
00146 #endif
00147
00148 #if ITK_TEMPLATE_TXX
00149 # include "itkSumOfSquaresImageFunction.txx"
00150 #endif
00151
00152
00153 #endif
00154