00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef _itkImageFunction_h
00018 #define _itkImageFunction_h
00019
00020 #include "itkFunctionBase.h"
00021 #include "itkPoint.h"
00022 #include "itkIndex.h"
00023 #include "itkContinuousIndex.h"
00024 #include "itkImageBase.h"
00025
00026 namespace itk
00027 {
00028
00029
00055 template <
00056 class TInputImage,
00057 class TOutput,
00058 class TCoordRep = float
00059 >
00060 class ITK_EXPORT ImageFunction :
00061 public FunctionBase< Point<TCoordRep,
00062 ::itk::GetImageDimension<TInputImage>::ImageDimension>,
00063 TOutput >
00064 {
00065 public:
00067 itkStaticConstMacro(ImageDimension, unsigned int,
00068 TInputImage::ImageDimension);
00069
00071 typedef ImageFunction Self;
00072 typedef FunctionBase< Point<TCoordRep,
00073 itkGetStaticConstMacro(ImageDimension)>,
00074 TOutput > Superclass;
00075 typedef SmartPointer<Self> Pointer;
00076 typedef SmartPointer<const Self> ConstPointer;
00077
00079 itkTypeMacro(ImageFunction, FunctionBase);
00080
00082 typedef TInputImage InputImageType;
00083
00085 typedef typename InputImageType::PixelType InputPixelType;
00086
00088 typedef typename InputImageType::ConstPointer InputImageConstPointer;
00089
00091 typedef TOutput OutputType;
00092
00094 typedef TCoordRep CoordRepType;
00095
00097 typedef typename InputImageType::IndexType IndexType;
00098
00100 typedef ContinuousIndex<TCoordRep,itkGetStaticConstMacro(ImageDimension)>
00101 ContinuousIndexType;
00102
00104 typedef Point<TCoordRep,itkGetStaticConstMacro(ImageDimension)> PointType;
00105
00110 virtual void SetInputImage( const InputImageType * ptr );
00111
00113 const InputImageType * GetInputImage() const
00114 { return m_Image.GetPointer(); }
00115
00118 virtual TOutput Evaluate( const PointType& point ) const = 0;
00119
00122 virtual TOutput EvaluateAtIndex( const IndexType & index ) const = 0;
00123
00126 virtual TOutput EvaluateAtContinuousIndex(
00127 const ContinuousIndexType & index ) const = 0;
00128
00132 inline bool IsInsideBuffer( const IndexType & index ) const;
00133
00137 inline bool IsInsideBuffer( const ContinuousIndexType & index ) const;
00138
00142 inline bool IsInsideBuffer( const PointType & point ) const;
00143
00147 inline void ConvertPointToContinuousIndex(
00148 const PointType& point, ContinuousIndexType& index ) const;
00149
00150 inline void ConvertContinuousIndexToPoint(
00151 const ContinuousIndexType& index, PointType& point ) const;
00152
00153 inline void ConvertIndexToPoint(
00154 const IndexType& index, PointType& point ) const;
00155
00156 inline void ConvertPointToNearestIndex(
00157 const PointType& point, IndexType& index ) const;
00158
00159 inline void ConvertContinuousIndexToNearestIndex(
00160 const ContinuousIndexType &cindex, IndexType& index ) const;
00161
00162 protected:
00163 ImageFunction();
00164 ~ImageFunction() {}
00165 void PrintSelf(std::ostream& os, Indent indent) const;
00166
00168 InputImageConstPointer m_Image;
00169
00171 const double * m_Origin;
00172 const double * m_Spacing;
00173 PointType m_GeometricStart;
00174 PointType m_GeometricEnd;
00175 IndexType m_BufferStart;
00176 IndexType m_BufferEnd;
00177
00178 private:
00179 ImageFunction(const Self&);
00180 void operator=(const Self&);
00181
00182 };
00183
00184 }
00185
00186 #ifndef ITK_MANUAL_INSTANTIATION
00187 #include "itkImageFunction.txx"
00188 #endif
00189
00190 #endif