X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2Ffpa%2FImage%2FAlgorithm.h;h=70a87a611543fe78b7d3076a44df96eba271355a;hb=490e6f877a3537463de4281b0366337ab73ced99;hp=289eb6c0e7da7dad12899fcf8c929b3b0e58d5f1;hpb=9622bd5b833a8845881003228207e0caca59b081;p=FrontAlgorithms.git diff --git a/lib/fpa/Image/Algorithm.h b/lib/fpa/Image/Algorithm.h index 289eb6c..70a87a6 100644 --- a/lib/fpa/Image/Algorithm.h +++ b/lib/fpa/Image/Algorithm.h @@ -1,105 +1,70 @@ -#ifndef __FPA__IMAGE__ALGORITHM__H__ -#define __FPA__IMAGE__ALGORITHM__H__ +#ifndef __fpa__Image__Algorithm__h__ +#define __fpa__Image__Algorithm__h__ -#include #include +#include +#include +#include namespace fpa { namespace Image { /** - * A generic front propagation algorithm were vertices are image pixels. - * - * @param I Input image type - * @param A Base algorithm (RegionGrow, Dijkstra or FastMarching) */ - template< class I, class A > + template< class _TInputImage, class _TOutputImage > class Algorithm - : public A + : public fpa::Base::Algorithm< itk::ImageToImageFilter< _TInputImage, _TOutputImage >, typename _TInputImage::IndexType, typename _TOutputImage::PixelType > { public: - /// Standard class typdedefs - typedef Algorithm Self; - typedef A Superclass; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; + typedef itk::ImageToImageFilter< _TInputImage, _TOutputImage > TFilter; + typedef typename _TInputImage::IndexType TVertex; + typedef typename _TOutputImage::PixelType TOutput; - /// Template input values - typedef I TInputImage; - typedef A TBaseAlgorithm; + typedef Algorithm Self; + typedef fpa::Base::Algorithm< TFilter, TVertex, TOutput > Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; - typedef typename A::TTraits TTraits; - typedef typename TTraits::TCost TCost; - typedef typename TTraits::TResult TResult; - typedef typename TTraits::TVertex TVertex; - typedef typename TTraits::TVertexValue TVertexValue; - - typedef itk::Image< TResult, I::ImageDimension > TOutputImage; - typedef itk::FunctionBase< TCost, TCost > TCostConversionFunction; + typedef typename Superclass::TFrontId TFrontId; + typedef typename Superclass::TNeighborhood TNeighborhood; + typedef fpa::Image::Functors::Base< itk::ImageBase< _TInputImage::ImageDimension >, itk::FunctionBase< TVertex, TNeighborhood > > TNeighborhoodFunction; protected: - typedef typename TTraits::TFrontId _TFrontId; - typedef typename TTraits::TNode _TNode; - typedef typename TTraits::TNodes _TNodes; - - private: - typedef itk::Image< bool, I::ImageDimension > _TMarks; - typedef itk::Image< _TFrontId, I::ImageDimension > _TFrontsIds; - typedef itk::Image< TVertex, I::ImageDimension > _TParents; + typedef typename Superclass::_TQueueNode _TQueueNode; public: - itkTypeMacro( Algorithm, TAlgorithm ); - - /// Set/Get - itkGetConstMacro( NeighborhoodOrder, unsigned int ); - itkGetConstObjectMacro( CostConversion, TCostConversionFunction ); - itkGetObjectMacro( CostConversion, TCostConversionFunction ); - - itkSetMacro( NeighborhoodOrder, unsigned int ); - itkSetObjectMacro( CostConversion, TCostConversionFunction ); + itkTypeMacro( fpa::Image::Algorithm, fpa::Base::Algorithm ); protected: Algorithm( ); virtual ~Algorithm( ); - /// Base interface - virtual bool _UpdateResult( _TNode& n ); - - /// Pure virtual interface: vertices - virtual unsigned long _NumberOfVertices ( ) const; - virtual TVertexValue _Value ( const TVertex& v ) const; - virtual TResult _Result ( const TVertex& v ) const; - - /// Pure virtual interface: edges - virtual double _Norm ( const TVertex& a, const TVertex& b ) const; - virtual bool _Edge ( const TVertex& a, const TVertex& b ) const; - virtual TCost _Cost ( const TVertex& a, const TVertex& b ) const; - - /// Pure virtual interface: neighborhood - virtual void _Neighs ( const _TNode& n, _TNodes& N ) const; - virtual void _NeighsInDim ( const _TNode& n, - const unsigned int& d, - _TNodes& N ); - - /// Pure virtual interface: results - virtual void _InitializeResults ( ); + virtual void _BeforeGenerateData( ) fpa_OVERRIDE; + virtual void _InitMarks( ) fpa_OVERRIDE; + virtual void _InitResults( const TOutput& init_value ) fpa_OVERRIDE; + virtual bool _IsMarked( const TVertex& v ) const fpa_OVERRIDE; + virtual void _Mark( const _TQueueNode& n ) fpa_OVERRIDE; + virtual TFrontId _GetMark( const TVertex& v ) const fpa_OVERRIDE; + virtual void _UpdateResult( const _TQueueNode& n ) fpa_OVERRIDE; private: - Algorithm( const Self& ); // Not impl. - void operator=( const Self& ); // Not impl. + // Purposely not defined + Algorithm( const Self& other ); + Self& operator=( const Self& other ); protected: - unsigned int m_NeighborhoodOrder; - typename TCostConversionFunction::Pointer m_CostConversion; + unsigned int m_MarksIdx; }; } // ecapseman } // ecapseman -#include +#ifndef ITK_MANUAL_INSTANTIATION +# include +#endif // ITK_MANUAL_INSTANTIATION -#endif // __FPA__IMAGE__ALGORITHM__H__ +#endif // __fpa__Image__Algorithm__h__ // eof - $RCSfile$