// ------------------------------------------------------------------------- // @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co) // ------------------------------------------------------------------------- #ifndef __CPEXTENSIONS__ALGORITHMS__GRADIENTFUNCTIONBASE__H__ #define __CPEXTENSIONS__ALGORITHMS__GRADIENTFUNCTIONBASE__H__ #include #include namespace cpExtensions { namespace Algorithms { /** */ template< class G > class GradientFunctionBase : public itk::ImageFunction< G, typename G::PixelType::ValueType, typename G::PixelType::ValueType > { public: // Types from input arguments typedef G TGradient; typedef typename G::PixelType TVector; typedef typename TVector::ValueType TScalar; itkStaticConstMacro( Dimension, unsigned int, G::ImageDimension ); // Standard itk types typedef GradientFunctionBase Self; typedef itk::ImageFunction< G, TScalar, TScalar > Superclass; typedef itk::SmartPointer< Self > Pointer; typedef itk::SmartPointer< const Self > ConstPointer; // Types from base itk::ImageFunction typedef typename Superclass::InputType TInput; typedef typename Superclass::OutputType TOutput; typedef typename Superclass::PointType TPoint; typedef typename Superclass::ContinuousIndexType TContIndex; typedef typename Superclass::IndexType TIndex; // Sparse buffer typedef std::map< TIndex, TOutput, typename TIndex::LexicographicCompare > TBuffer; public: itkTypeMacro( GradientFunctionBase, itkImageFunction ); itkBooleanMacro( BufferResults ); itkGetConstMacro( BufferResults, bool ); itkSetMacro( BufferResults, bool ); public: virtual void ResetBuffer( ); virtual TOutput Evaluate( const TPoint& p ) const; virtual TOutput EvaluateAtIndex( const TIndex& i ) const; virtual TOutput EvaluateAtContinuousIndex( const TContIndex& i ) const; protected: GradientFunctionBase( ); virtual ~GradientFunctionBase( ); virtual TOutput _Evaluate( const TIndex& i ) const = 0; private: // Purposely not implemented. GradientFunctionBase( const Self& ); void operator=( const Self& ); protected: mutable TBuffer m_Buffer; bool m_BufferResults; }; } // ecapseman } // ecapseman #include #endif // __CPEXTENSIONS__ALGORITHMS__GRADIENTFUNCTIONBASE__H__ // eof - $RCSfile$