#ifndef __FPA__IMAGE__ALGORITHM__H__
#define __FPA__IMAGE__ALGORITHM__H__
+#include <fpa/Base/Algorithm.h>
#include <itkImage.h>
-#include <fpa/Image/MinimumSpanningTree.h>
+#include <itkImageToImageFilter.h>
namespace fpa
{
namespace Image
{
/**
- * A generic front propagation algorithm were vertices are image pixels.
- *
- * @param I Input image type
- * @param O Output image type
- * @param A Base algorithm (RegionGrow, Dijkstra or FastMarching)
*/
- template< class I, class O, class A >
+ template< class _TInputImage, class _TOutputImage >
class Algorithm
- : public A
+ : public fpa::Base::Algorithm< typename _TInputImage::IndexType, typename _TOutputImage::PixelType, itk::ImageToImageFilter< _TInputImage, _TOutputImage >, typename _TInputImage::IndexType::LexicographicCompare >
{
public:
- /// Standard class typdedefs
+ typedef fpa::Base::Algorithm< typename _TInputImage::IndexType, typename _TOutputImage::PixelType, itk::ImageToImageFilter< _TInputImage, _TOutputImage >, typename _TInputImage::IndexType::LexicographicCompare > Superclass;
typedef Algorithm Self;
- typedef A Superclass;
typedef itk::SmartPointer< Self > Pointer;
typedef itk::SmartPointer< const Self > ConstPointer;
- /// Template input values
- typedef I TInputImage;
- typedef O TOutputImage;
-
- typedef typename Superclass::TVertex TVertex;
- typedef typename Superclass::TValue TValue;
- typedef typename Superclass::TResult TResult;
-
- protected:
- typedef typename Superclass::_TVertices _TVertices;
- typedef typename Superclass::_TCollision _TCollision;
- typedef typename Superclass::_TCollisionsRow _TCollisionsRow;
- typedef typename Superclass::_TCollisions _TCollisions;
- typedef typename Superclass::_TNode _TNode;
- typedef typename Superclass::_TNodes _TNodes;
-
- typedef fpa::Image::MinimumSpanningTree< TVertex, _TNode, _TCollisions, I::ImageDimension, Self::AliveLabel > _TMarks;
+ // Input types
+ typedef _TInputImage TInputImage;
+ typedef _TOutputImage TOutputImage;
+ itkConceptMacro(
+ ImagesSameDimension,
+ (
+ itk::Concept::
+ SameDimension<
+ TInputImage::ImageDimension,
+ TOutputImage::ImageDimension
+ >
+ )
+ );
+
+ // Template arguments
+ typedef typename Superclass::TVertex TVertex;
+ typedef typename Superclass::TScalar TScalar;
+ typedef typename Superclass::TFilter TFilter;
+ typedef typename Superclass::TVertexCompare TVertexCompare;
+ typedef typename Superclass::TFrontId TFrontId;
+ typedef typename Superclass::TCollision TCollision;
+ typedef typename Superclass::TCollisionsRow TCollisionsRow;
+ typedef typename Superclass::TCollisions TCollisions;
+ typedef typename Superclass::TNodeLabel TNodeLabel;
+ typedef typename Superclass::TNode TNode;
+ typedef typename Superclass::TNodes TNodes;
+ typedef typename Superclass::TVertices TVertices;
+
+ typedef itk::Image< TFrontId, TInputImage::ImageDimension > TMarkImage;
public:
- typedef _TMarks TMinimumSpanningTree;
+ itkTypeMacro( Algorithm, _TFilter );
- public:
- itkTypeMacro( Algorithm, TAlgorithm );
-
- /// Set/Get
- itkGetConstMacro( NeighborhoodOrder, unsigned int );
- itkSetMacro( NeighborhoodOrder, unsigned int );
-
- public:
- TMinimumSpanningTree* GetMinimumSpanningTree( );
- const TMinimumSpanningTree* GetMinimumSpanningTree( ) const;
- void GraftMinimumSpanningTree( itk::DataObject* obj );
+ itkGetConstMacro( NeighborhoodOrder, unsigned short );
+ itkSetMacro( NeighborhoodOrder, unsigned short );
protected:
+ // Methods to extend itk-imaged architecture
Algorithm( );
virtual ~Algorithm( );
- virtual void _BeforeGenerateData( );
- virtual void _AfterGenerateData( );
-
- // Graph-related abstract methods
- virtual unsigned long _NumberOfVertices( ) const;
- virtual const TValue& _VertexValue( const TVertex& v ) const;
- virtual double _Distance(
- const TVertex& a, const TVertex& b
- ) const;
- virtual bool _HasEdge( const TVertex& a, const TVertex& b ) const;
- virtual void _Neighborhood(
- _TVertices& neighborhood, const TVertex& v
- ) const;
-
- // Results-related abstract methods
- virtual void _InitResults( );
- virtual const TResult& _Result( const TVertex& v ) const;
- virtual void _SetResult( const TVertex& v, const TResult& r );
-
- // Marks-related abstract methods
- virtual const _TNode& _Node( const TVertex& v ) const;
- virtual void _InitMarks( );
- virtual void _Mark( const _TNode& node );
+ // Front propagation methods to be overloaded
+ virtual void _BeforeGenerateData( ) fpa_OVERRIDE;
+ virtual void _InitMarks( ) fpa_OVERRIDE;
+ virtual void _InitResults( ) fpa_OVERRIDE;
+ virtual void _DeallocateAuxiliary( ) fpa_OVERRIDE;
+ virtual TFrontId _GetMark( const TVertex& v ) fpa_OVERRIDE;
+ virtual void _Visit( const TNode& n ) fpa_OVERRIDE;
+ virtual TVertices _GetNeighborhood(
+ const TVertex& v
+ ) const fpa_OVERRIDE;
private:
// Purposely not implemented
Self& operator=( const Self& other );
protected:
- unsigned int m_NeighborhoodOrder;
+ unsigned short m_NeighborhoodOrder;
+ typename TMarkImage::Pointer m_Marks;
};
} // ecapseman
} // ecapseman
-#include <fpa/Image/Algorithm.hxx>
+#ifndef ITK_MANUAL_INSTANTIATION
+# include <fpa/Image/Algorithm.hxx>
+#endif
#endif // __FPA__IMAGE__ALGORITHM__H__