-#ifndef __FPA__IMAGE__ALGORITHM__H__
-#define __FPA__IMAGE__ALGORITHM__H__
+// =========================================================================
+// @author Leonardo Florez Valencia
+// @email florez-l@javeriana.edu.co
+// =========================================================================
+
+#ifndef __fpa__Image__Algorithm__h__
+#define __fpa__Image__Algorithm__h__
#include <itkImage.h>
-#include <itkFunctionBase.h>
+#include <itkImageToImageFilter.h>
+
+#include <fpa/Base/Algorithm.h>
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, class CC >
+ template< class _TInputImage, class _TOutputImage, class _TMarksInterface, class _TSeedsInterface >
class Algorithm
- : public A
+ : public fpa::Base::Algorithm< itk::ImageToImageFilter< _TInputImage, _TOutputImage >, _TMarksInterface, _TSeedsInterface >
{
public:
- /// Standard class typdedefs
- typedef Algorithm Self;
- typedef A Superclass;
+ typedef _TInputImage TInputImage;
+ typedef _TOutputImage TOutputImage;
+ typedef _TMarksInterface TMarksInterface;
+ typedef _TSeedsInterface TSeedsInterface;
+ typedef itk::ImageToImageFilter< TInputImage, TOutputImage > TFilter;
+
+ typedef Algorithm Self;
+ typedef fpa::Base::Algorithm< TFilter, TMarksInterface, TSeedsInterface > Superclass;
typedef itk::SmartPointer< Self > Pointer;
typedef itk::SmartPointer< const Self > ConstPointer;
- /// Template input values
- typedef I TInputImage;
- typedef A TBaseAlgorithm;
- typedef CC TCostConversionFunction;
-
- 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;
-
- protected:
- typedef typename TTraits::TFrontId _TFrontId;
- typedef typename TTraits::TNode _TNode;
- typedef typename TTraits::TNodes _TNodes;
+ typedef typename TInputImage::PixelType TInputValue;
+ typedef typename TOutputImage::PixelType TOutputValue;
+ typedef typename Superclass::TFrontId TFrontId;
+ typedef typename Superclass::TNeighborhood TNeighborhood;
+ typedef typename Superclass::TNode TNode;
+ typedef typename Superclass::TNodes TNodes;
+ typedef typename Superclass::TSeeds TSeeds;
+ typedef typename Superclass::TVertex TVertex;
+ typedef typename Superclass::TPoint TPoint;
- private:
- typedef itk::Image< bool, I::ImageDimension > _TMarks;
- typedef itk::Image< _TFrontId, I::ImageDimension > _TFrontsIds;
- typedef itk::Image< TVertex, I::ImageDimension > _TParents;
+ typedef itk::Image< TFrontId, TInputImage::ImageDimension > TMarks;
public:
- itkTypeMacro( Algorithm, TAlgorithm );
+ itkTypeMacro( fpa::Image::Algorithm, fpa::Base::Algorithm );
- /// Set/Get
- itkGetConstMacro( NeighborhoodOrder, unsigned int );
- itkGetConstObjectMacro( CostConversion, TCostConversionFunction );
- itkGetObjectMacro( CostConversion, TCostConversionFunction );
+ itkGetConstMacro( NeigborhoodOrder, unsigned int );
+ itkSetMacro( NeigborhoodOrder, unsigned int );
- itkSetMacro( NeighborhoodOrder, unsigned int );
- itkSetObjectMacro( CostConversion, TCostConversionFunction );
+ public:
+ TMarks* GetMarks( );
+ const TMarks* GetMarks( ) const;
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 TNodes _UnifySeeds( ) override;
+ virtual void _ConfigureOutput( const TOutputValue& v ) override;
+ virtual TNeighborhood _GetNeighbors( const TVertex& v ) const override;
+ virtual TInputValue _GetInputValue( const TVertex& v ) const override;
+ virtual TOutputValue _GetOutputValue( const TVertex& v ) const override;
+ virtual void _UpdateOutputValue( const TNode& n ) override;
+ virtual bool _IsMarked( const TVertex& v ) const override;
+ virtual unsigned long _GetMark( const TVertex& v ) const override;
+ virtual bool _Mark( const TVertex& v, unsigned long frontId ) override;
private:
- Algorithm( const Self& ); // Not impl.
- void operator=( const Self& ); // Not impl.
+ // Purposely not implemented.
+ Algorithm( const Self& other );
+ Self& operator=( const Self& other );
protected:
- unsigned int m_NeighborhoodOrder;
- typename TCostConversionFunction::Pointer m_CostConversion;
+ unsigned long m_MarksIdx;
+ unsigned int m_NeigborhoodOrder;
};
} // ecapseman
} // ecapseman
-#include <fpa/Image/Algorithm.hxx>
+#ifndef ITK_MANUAL_INSTANTIATION
+# include <fpa/Image/Algorithm.hxx>
+#endif // ITK_MANUAL_INSTANTIATION
-#endif // __FPA__IMAGE__ALGORITHM__H__
+#endif // __fpa__Image__Algorithm__h__
// eof - $RCSfile$