X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;ds=sidebyside;f=lib%2Ffpa%2FImage%2FAlgorithm.h;h=e23a1084c3a585826adb7f9e54ac44bf233f6767;hb=d3bb16bf060b7249a9ed1a49e6b118ca9394a22a;hp=289eb6c0e7da7dad12899fcf8c929b3b0e58d5f1;hpb=a1f9f98345f6d717e908f0507f60fd2841a73a1c;p=FrontAlgorithms.git diff --git a/lib/fpa/Image/Algorithm.h b/lib/fpa/Image/Algorithm.h index 289eb6c..e23a108 100644 --- a/lib/fpa/Image/Algorithm.h +++ b/lib/fpa/Image/Algorithm.h @@ -8,13 +8,85 @@ namespace fpa { namespace Image { + namespace Functors + { + /** + */ + template< class VV, class C > + class CastVertexValueToCost + : public itk::FunctionBase< VV, C > + { + public: + // Type-related and pointers + typedef CastVertexValueToCost Self; + typedef itk::FunctionBase< VV, C > Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; + + public: + itkNewMacro( Self ); + itkTypeMacro( CastVertexValueToCost, itkFunctionBase ); + + public: + virtual C Evaluate( const VV& v ) const + { return( C( v ) ); } + + protected: + CastVertexValueToCost( ) + : Superclass( ) + { } + virtual ~CastVertexValueToCost( ) + { } + + private: + // Purposely not implemented + CastVertexValueToCost( const Self& ); + void operator=( const Self& ); + }; + + /** + */ + template< class VV, class C > + class CastVertexValueToConstantCost + : public itk::FunctionBase< VV, C > + { + public: + // Type-related and pointers + typedef CastVertexValueToConstantCost Self; + typedef itk::FunctionBase< VV, C > Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; + + public: + itkNewMacro( Self ); + itkTypeMacro( CastVertexValueToConstantCost, itkFunctionBase ); + + public: + virtual C Evaluate( const VV& v ) const + { return( C( 1 ) ); } + + protected: + CastVertexValueToConstantCost( ) + : Superclass( ) + { } + virtual ~CastVertexValueToConstantCost( ) + { } + + private: + // Purposely not implemented + CastVertexValueToConstantCost( const Self& ); + void operator=( const Self& ); + }; + + } // ecapseman + /** * 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 I, class A, class CC > class Algorithm : public A { @@ -26,8 +98,9 @@ namespace fpa typedef itk::SmartPointer< const Self > ConstPointer; /// Template input values - typedef I TInputImage; - typedef A TBaseAlgorithm; + typedef I TInputImage; + typedef A TBaseAlgorithm; + typedef CC TCostConversionFunction; typedef typename A::TTraits TTraits; typedef typename TTraits::TCost TCost; @@ -36,7 +109,6 @@ namespace fpa typedef typename TTraits::TVertexValue TVertexValue; typedef itk::Image< TResult, I::ImageDimension > TOutputImage; - typedef itk::FunctionBase< TCost, TCost > TCostConversionFunction; protected: typedef typename TTraits::TFrontId _TFrontId;