From: Leonardo Flórez-Valencia Date: Tue, 18 Jul 2017 21:45:09 +0000 (-0500) Subject: ... X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?p=FrontAlgorithms.git;a=commitdiff_plain;h=6cdba92a782c9ca52b1be25868c2267b2e3966ca ... --- diff --git a/lib/fpa/Base/Algorithm.h b/lib/fpa/Base/Algorithm.h index 5a02d6e..785b818 100644 --- a/lib/fpa/Base/Algorithm.h +++ b/lib/fpa/Base/Algorithm.h @@ -8,7 +8,6 @@ #include -#include #include #include @@ -18,28 +17,28 @@ namespace fpa { /** */ - template< class _TFilter, class _TMarksInterface, class _TSeedsInterface > + template< class _TTraits > class Algorithm - : public _TFilter, - public _TMarksInterface, - public _TSeedsInterface + : public _TTraits::TFilter, + public _TTraits::TMarksInterface, + public _TTraits::TSeedsInterface { public: - typedef Algorithm Self; - typedef _TFilter Superclass; - typedef _TMarksInterface TMarksInterface; - typedef _TSeedsInterface TSeedsInterface; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; - - typedef typename _TSeedsInterface::TInputValue TInputValue; - typedef typename _TSeedsInterface::TOutputValue TOutputValue; - typedef typename _TSeedsInterface::TNode TNode; - typedef typename _TSeedsInterface::TNodes TNodes; - typedef typename _TSeedsInterface::TSeeds TSeeds; - typedef typename _TSeedsInterface::TVertex TVertex; - - typedef std::vector< TVertex > TNeighborhood; + typedef _TTraits TTraits; + typedef typename TTraits::TFilter Superclass; + typedef typename TTraits::TMarksInterface TMarksInterface; + typedef typename TTraits::TSeedsInterface TSeedsInterface; + typedef Algorithm Self; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; + + typedef typename TTraits::TInputValue TInputValue; + typedef typename TTraits::TOutputValue TOutputValue; + typedef typename TTraits::TNeighborhood TNeighborhood; + typedef typename TTraits::TNode TNode; + typedef typename TTraits::TNodes TNodes; + typedef typename TTraits::TSeeds TSeeds; + typedef typename TTraits::TVertex TVertex; /** */ diff --git a/lib/fpa/Base/Algorithm.hxx b/lib/fpa/Base/Algorithm.hxx index 26729aa..68296be 100644 --- a/lib/fpa/Base/Algorithm.hxx +++ b/lib/fpa/Base/Algorithm.hxx @@ -7,16 +7,16 @@ #define __fpa__Base__Algorithm__hxx__ // ------------------------------------------------------------------------- -template< class _TFilter, class _TMarksInterface, class _TSeedsInterface > -fpa::Base::Algorithm< _TFilter, _TMarksInterface, _TSeedsInterface >::TEvent:: +template< class _TTraits > +fpa::Base::Algorithm< _TTraits >::TEvent:: TEvent( ) : Superclass( ) { } // ------------------------------------------------------------------------- -template< class _TFilter, class _TMarksInterface, class _TSeedsInterface > -fpa::Base::Algorithm< _TFilter, _TMarksInterface, _TSeedsInterface >::TEvent:: +template< class _TTraits > +fpa::Base::Algorithm< _TTraits >::TEvent:: TEvent( const TVertex& v, unsigned long fid, bool intoq ) : Superclass( ), Vertex( v ), @@ -26,42 +26,39 @@ TEvent( const TVertex& v, unsigned long fid, bool intoq ) } // ------------------------------------------------------------------------- -template< class _TFilter, class _TMarksInterface, class _TSeedsInterface > -fpa::Base::Algorithm< _TFilter, _TMarksInterface, _TSeedsInterface >::TEvent:: +template< class _TTraits > +fpa::Base::Algorithm< _TTraits >::TEvent:: ~TEvent( ) { } // ------------------------------------------------------------------------- -template< class _TFilter, class _TMarksInterface, class _TSeedsInterface > -const char* -fpa::Base::Algorithm< _TFilter, _TMarksInterface, _TSeedsInterface >::TEvent:: +template< class _TTraits > +const char* fpa::Base::Algorithm< _TTraits >::TEvent:: GetEventName( ) const { - return( "fpa::Base::Algorithm< _TFilter, _TMarksInterface, _TSeedsInterface >::TEvent" ); + return( "fpa::Base::Algorithm< _TTraits >::TEvent" ); } // ------------------------------------------------------------------------- -template< class _TFilter, class _TMarksInterface, class _TSeedsInterface > -bool -fpa::Base::Algorithm< _TFilter, _TMarksInterface, _TSeedsInterface >::TEvent:: +template< class _TTraits > +bool fpa::Base::Algorithm< _TTraits >::TEvent:: CheckEvent( const itk::EventObject* e ) const { return( dynamic_cast< const Self* >( e ) != NULL ); } // ------------------------------------------------------------------------- -template< class _TFilter, class _TMarksInterface, class _TSeedsInterface > -itk::EventObject* -fpa::Base::Algorithm< _TFilter, _TMarksInterface, _TSeedsInterface >::TEvent:: +template< class _TTraits > +itk::EventObject* fpa::Base::Algorithm< _TTraits >::TEvent:: MakeObject( ) const { return( new Self ); } // ------------------------------------------------------------------------- -template< class _TFilter, class _TMarksInterface, class _TSeedsInterface > -void fpa::Base::Algorithm< _TFilter, _TMarksInterface, _TSeedsInterface >:: +template< class _TTraits > +void fpa::Base::Algorithm< _TTraits >:: InvokeEvent( const itk::EventObject& e ) { TEvent a; @@ -75,8 +72,8 @@ InvokeEvent( const itk::EventObject& e ) } // ------------------------------------------------------------------------- -template< class _TFilter, class _TMarksInterface, class _TSeedsInterface > -void fpa::Base::Algorithm< _TFilter, _TMarksInterface, _TSeedsInterface >:: +template< class _TTraits > +void fpa::Base::Algorithm< _TTraits >:: InvokeEvent( const itk::EventObject& e ) const { TEvent a; @@ -90,26 +87,26 @@ InvokeEvent( const itk::EventObject& e ) const } // ------------------------------------------------------------------------- -template< class _TFilter, class _TMarksInterface, class _TSeedsInterface > -fpa::Base::Algorithm< _TFilter, _TMarksInterface, _TSeedsInterface >:: +template< class _TTraits > +fpa::Base::Algorithm< _TTraits >:: Algorithm( ) : Superclass( ), - _TMarksInterface( this ), - _TSeedsInterface( this ), + TMarksInterface( this ), + TSeedsInterface( this ), m_VisualDebug( false ) { } // ------------------------------------------------------------------------- -template< class _TFilter, class _TMarksInterface, class _TSeedsInterface > -fpa::Base::Algorithm< _TFilter, _TMarksInterface, _TSeedsInterface >:: +template< class _TTraits > +fpa::Base::Algorithm< _TTraits >:: ~Algorithm( ) { } // ------------------------------------------------------------------------- -template< class _TFilter, class _TMarksInterface, class _TSeedsInterface > -void fpa::Base::Algorithm< _TFilter, _TMarksInterface, _TSeedsInterface >:: +template< class _TTraits > +void fpa::Base::Algorithm< _TTraits >:: GenerateData( ) { this->InvokeEvent( itk::StartEvent( ) ); @@ -190,29 +187,29 @@ GenerateData( ) } // ------------------------------------------------------------------------- -template< class _TFilter, class _TMarksInterface, class _TSeedsInterface > -void fpa::Base::Algorithm< _TFilter, _TMarksInterface, _TSeedsInterface >:: +template< class _TTraits > +void fpa::Base::Algorithm< _TTraits >:: _BeforeGenerateData( ) { } // ------------------------------------------------------------------------- -template< class _TFilter, class _TMarksInterface, class _TSeedsInterface > -void fpa::Base::Algorithm< _TFilter, _TMarksInterface, _TSeedsInterface >:: +template< class _TTraits > +void fpa::Base::Algorithm< _TTraits >:: _AfterGenerateData( ) { } // ------------------------------------------------------------------------- -template< class _TFilter, class _TMarksInterface, class _TSeedsInterface > -void fpa::Base::Algorithm< _TFilter, _TMarksInterface, _TSeedsInterface >:: +template< class _TTraits > +void fpa::Base::Algorithm< _TTraits >:: _FinishOneLoop( ) { } // ------------------------------------------------------------------------- -template< class _TFilter, class _TMarksInterface, class _TSeedsInterface > -void fpa::Base::Algorithm< _TFilter, _TMarksInterface, _TSeedsInterface >:: +template< class _TTraits > +void fpa::Base::Algorithm< _TTraits >:: _QueueInit( ) { this->_QueueClear( ); diff --git a/lib/fpa/Image/Algorithm.h b/lib/fpa/Image/Algorithm.h index 58dc5ee..1c84a72 100644 --- a/lib/fpa/Image/Algorithm.h +++ b/lib/fpa/Image/Algorithm.h @@ -17,33 +17,51 @@ namespace fpa { /** */ - template< class _TInputImage, class _TOutputImage, class _TMarksInterface, class _TSeedsInterface > + template< class _TTraits > class Algorithm - : public fpa::Base::Algorithm< itk::ImageToImageFilter< _TInputImage, _TOutputImage >, _TMarksInterface, _TSeedsInterface > + : public fpa::Base::Algorithm< _TTraits > { public: - 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; - - 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; - - typedef itk::Image< TFrontId, TInputImage::ImageDimension > TMarks; + typedef _TTraits TTraits; + typedef fpa::Base::Algorithm< _TTraits > Superclass; + typedef Algorithm Self; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; + + typedef typename TTraits::TFrontId TFrontId; + typedef typename TTraits::TInputImage TInputImage; + typedef typename TTraits::TInputValue TInputValue; + typedef typename TTraits::TNeighborhood TNeighborhood; + typedef typename TTraits::TNode TNode; + typedef typename TTraits::TNodes TNodes; + typedef typename TTraits::TOutputImage TOutputImage; + typedef typename TTraits::TOutputValue TOutputValue; + typedef typename TTraits::TSeeds TSeeds; + typedef typename TTraits::TVertex TVertex; + + typedef itk::Image< TFrontId, TTraits::Dimension > TMarks; + + /* TODO + typedef _TMarksInterface TMarksInterface; + typedef _TSeedsInterface TSeedsInterface; + + typedef typename TSeedsInterface::TTraits TTraits; + typedef typename TTraits::TInputImage TInputImage; + typedef typename TTraits::TOutputImage TOutputImage; + typedef typename TTraits::TInputValue TInputValue; + typedef typename TTraits::TOutputValue TOutputValue; + typedef typename TTraits::TFrontId TFrontId; + typedef typename TTraits::TNeighborhood TNeighborhood; + typedef typename TTraits::TNode TNode; + typedef typename TTraits::TNodes TNodes; + typedef typename TTraits::TSeeds TSeeds; + typedef typename TTraits::TVertex TVertex; + typedef typename TTraits::TPoint TPoint; + + typedef itk::ImageToImageFilter< TInputImage, TOutputImage > TFilter; + typedef fpa::Base::Algorithm< TFilter, TMarksInterface, TSeedsInterface > Superclass; + typedef Algorithm Self; + */ public: itkTypeMacro( fpa::Image::Algorithm, fpa::Base::Algorithm ); diff --git a/lib/fpa/Image/Algorithm.hxx b/lib/fpa/Image/Algorithm.hxx index 0fce0d5..43ebeb0 100644 --- a/lib/fpa/Image/Algorithm.hxx +++ b/lib/fpa/Image/Algorithm.hxx @@ -7,11 +7,9 @@ #define __fpa__Image__Algorithm__hxx__ // ------------------------------------------------------------------------- -template< class _TInputImage, class _TOutputImage, class _TMarksInterface, class _TSeedsInterface > -typename -fpa::Image::Algorithm< _TInputImage, _TOutputImage, _TMarksInterface, _TSeedsInterface >:: -TMarks* -fpa::Image::Algorithm< _TInputImage, _TOutputImage, _TMarksInterface, _TSeedsInterface >:: +template< class _TTraits > +typename fpa::Image::Algorithm< _TTraits >::TMarks* +fpa::Image::Algorithm< _TTraits >:: GetMarks( ) { return( @@ -22,11 +20,9 @@ GetMarks( ) } // ------------------------------------------------------------------------- -template< class _TInputImage, class _TOutputImage, class _TMarksInterface, class _TSeedsInterface > -const typename -fpa::Image::Algorithm< _TInputImage, _TOutputImage, _TMarksInterface, _TSeedsInterface >:: -TMarks* -fpa::Image::Algorithm< _TInputImage, _TOutputImage, _TMarksInterface, _TSeedsInterface >:: +template< class _TTraits > +const typename fpa::Image::Algorithm< _TTraits >::TMarks* +fpa::Image::Algorithm< _TTraits >:: GetMarks( ) const { return( @@ -37,8 +33,8 @@ GetMarks( ) const } // ------------------------------------------------------------------------- -template< class _TInputImage, class _TOutputImage, class _TMarksInterface, class _TSeedsInterface > -fpa::Image::Algorithm< _TInputImage, _TOutputImage, _TMarksInterface, _TSeedsInterface >:: +template< class _TTraits > +fpa::Image::Algorithm< _TTraits >:: Algorithm( ) : Superclass( ), m_NeigborhoodOrder( 1 ) @@ -49,17 +45,16 @@ Algorithm( ) } // ------------------------------------------------------------------------- -template< class _TInputImage, class _TOutputImage, class _TMarksInterface, class _TSeedsInterface > -fpa::Image::Algorithm< _TInputImage, _TOutputImage, _TMarksInterface, _TSeedsInterface >:: +template< class _TTraits > +fpa::Image::Algorithm< _TTraits >:: ~Algorithm( ) { } // ------------------------------------------------------------------------- -template< class _TInputImage, class _TOutputImage, class _TMarksInterface, class _TSeedsInterface > -typename -fpa::Image::Algorithm< _TInputImage, _TOutputImage, _TMarksInterface, _TSeedsInterface >:: -TNodes fpa::Image::Algorithm< _TInputImage, _TOutputImage, _TMarksInterface, _TSeedsInterface >:: +template< class _TTraits > +typename fpa::Image::Algorithm< _TTraits >::TNodes +fpa::Image::Algorithm< _TTraits >:: _UnifySeeds( ) { const TInputImage* input = this->GetInput( ); @@ -95,9 +90,8 @@ _UnifySeeds( ) } // ------------------------------------------------------------------------- -template< class _TInputImage, class _TOutputImage, class _TMarksInterface, class _TSeedsInterface > -void -fpa::Image::Algorithm< _TInputImage, _TOutputImage, _TMarksInterface, _TSeedsInterface >:: +template< class _TTraits > +void fpa::Image::Algorithm< _TTraits >:: _ConfigureOutput( const TOutputValue& v ) { const TInputImage* in = this->GetInput( ); @@ -124,10 +118,9 @@ _ConfigureOutput( const TOutputValue& v ) } // ------------------------------------------------------------------------- -template< class _TInputImage, class _TOutputImage, class _TMarksInterface, class _TSeedsInterface > -typename -fpa::Image::Algorithm< _TInputImage, _TOutputImage, _TMarksInterface, _TSeedsInterface >:: -TNeighborhood fpa::Image::Algorithm< _TInputImage, _TOutputImage, _TMarksInterface, _TSeedsInterface >:: +template< class _TTraits > +typename fpa::Image::Algorithm< _TTraits >::TNeighborhood +fpa::Image::Algorithm< _TTraits >:: _GetNeighbors( const TVertex& v ) const { typename TInputImage::RegionType region = @@ -157,57 +150,50 @@ _GetNeighbors( const TVertex& v ) const } // ------------------------------------------------------------------------- -template< class _TInputImage, class _TOutputImage, class _TMarksInterface, class _TSeedsInterface > -typename -fpa::Image::Algorithm< _TInputImage, _TOutputImage, _TMarksInterface, _TSeedsInterface >:: -TInputValue -fpa::Image::Algorithm< _TInputImage, _TOutputImage, _TMarksInterface, _TSeedsInterface >:: +template< class _TTraits > +typename fpa::Image::Algorithm< _TTraits >::TInputValue +fpa::Image::Algorithm< _TTraits >:: _GetInputValue( const TVertex& v ) const { return( this->GetInput( )->GetPixel( v ) ); } // ------------------------------------------------------------------------- -template< class _TInputImage, class _TOutputImage, class _TMarksInterface, class _TSeedsInterface > -typename -fpa::Image::Algorithm< _TInputImage, _TOutputImage, _TMarksInterface, _TSeedsInterface >:: -TOutputValue fpa::Image::Algorithm< _TInputImage, _TOutputImage, _TMarksInterface, _TSeedsInterface >:: +template< class _TTraits > +typename fpa::Image::Algorithm< _TTraits >::TOutputValue +fpa::Image::Algorithm< _TTraits >:: _GetOutputValue( const TVertex& v ) const { return( this->GetOutput( )->GetPixel( v ) ); } // ------------------------------------------------------------------------- -template< class _TInputImage, class _TOutputImage, class _TMarksInterface, class _TSeedsInterface > -void -fpa::Image::Algorithm< _TInputImage, _TOutputImage, _TMarksInterface, _TSeedsInterface >:: +template< class _TTraits > +void fpa::Image::Algorithm< _TTraits >:: _UpdateOutputValue( TNode& n ) { this->GetOutput( )->SetPixel( n.Vertex, n.Value ); } // ------------------------------------------------------------------------- -template< class _TInputImage, class _TOutputImage, class _TMarksInterface, class _TSeedsInterface > -bool -fpa::Image::Algorithm< _TInputImage, _TOutputImage, _TMarksInterface, _TSeedsInterface >:: +template< class _TTraits > +bool fpa::Image::Algorithm< _TTraits >:: _IsMarked( const TVertex& v ) const { return( this->GetMarks( )->GetPixel( v ) > 0 ); } // ------------------------------------------------------------------------- -template< class _TInputImage, class _TOutputImage, class _TMarksInterface, class _TSeedsInterface > -unsigned long -fpa::Image::Algorithm< _TInputImage, _TOutputImage, _TMarksInterface, _TSeedsInterface >:: +template< class _TTraits > +unsigned long fpa::Image::Algorithm< _TTraits >:: _GetMark( const TVertex& v ) const { return( ( unsigned long )( this->GetMarks( )->GetPixel( v ) ) ); } // ------------------------------------------------------------------------- -template< class _TInputImage, class _TOutputImage, class _TMarksInterface, class _TSeedsInterface > -void -fpa::Image::Algorithm< _TInputImage, _TOutputImage, _TMarksInterface, _TSeedsInterface >:: +template< class _TTraits > +void fpa::Image::Algorithm< _TTraits >:: _Mark( const TVertex& v, unsigned long frontId ) { this->GetMarks( )->SetPixel( v, TFrontId( frontId ) ); diff --git a/lib/fpa/Image/DefaultTraits.h b/lib/fpa/Image/DefaultTraits.h new file mode 100644 index 0000000..c2b8295 --- /dev/null +++ b/lib/fpa/Image/DefaultTraits.h @@ -0,0 +1,69 @@ +// ========================================================================= +// @author Leonardo Florez Valencia +// @email florez-l@javeriana.edu.co +// ========================================================================= + +#ifndef __fpa__Image__DefaultTraits__h__ +#define __fpa__Image__DefaultTraits__h__ + +#include +#include +#include + +#include +#include + +namespace fpa +{ + namespace Image + { + /** + */ + template< class _TInputImage, class _TOutputImage, class _TFrontId > + class DefaultTraits + { + public: + typedef DefaultTraits Self; + typedef _TInputImage TInputImage; + typedef _TOutputImage TOutputImage; + typedef _TFrontId TFrontId; + itkStaticConstMacro( Dimension, unsigned int, TInputImage::ImageDimension ); + + typedef typename TInputImage::IndexType TVertex; + typedef typename TInputImage::PixelType TInputValue; + typedef typename TInputImage::PointType TPoint; + typedef typename TOutputImage::PixelType TOutputValue; + typedef typename TVertex::LexicographicCompare TCompare; + + typedef std::vector< TVertex > TNeighborhood; + + typedef fpa::Base::SeedsInterface< TVertex, TPoint, TInputValue, TOutputValue, TFrontId, TCompare > TSeedsInterface; + typedef fpa::Base::MarksInterfaceWithCollisions< TVertex > TMarksInterface; + typedef itk::ImageToImageFilter< TInputImage, TOutputImage > TFilter; + + typedef typename TSeedsInterface::TNode TNode; + typedef typename TSeedsInterface::TNodes TNodes; + typedef typename TSeedsInterface::TSeed TSeed; + typedef typename TSeedsInterface::TSeeds TSeeds; + + public: + itkConceptMacro( + Check_SameDimension, + ( itk::Concept::SameDimension< TInputImage::ImageDimension, TOutputImage::ImageDimension > ) + ); + + private: + // Purposely not implemented. + DefaultTraits( ); + DefaultTraits( const Self& other ); + virtual ~DefaultTraits( ); + Self& operator=( const Self& other ); + }; + + } // ecapseman + +} // ecapseman + +#endif // __fpa__Image__DefaultTraits__h__ + +// eof - $RCSfile$ diff --git a/lib/fpa/Image/Dijkstra.h b/lib/fpa/Image/Dijkstra.h index 6882bfe..d755ebf 100644 --- a/lib/fpa/Image/Dijkstra.h +++ b/lib/fpa/Image/Dijkstra.h @@ -7,11 +7,9 @@ #define __fpa__Image__Dijkstra__h__ #include -#include -#include #include +#include #include -#include namespace fpa { @@ -21,73 +19,28 @@ namespace fpa */ template< class _TInputImage, class _TOutputImage, class _TFrontId = unsigned char > class Dijkstra - : public fpa::Base::Dijkstra< fpa::Image::Algorithm< _TInputImage, _TOutputImage, fpa::Base::MarksInterfaceWithCollisions< typename _TInputImage::IndexType >, fpa::Base::SeedsInterface< typename _TInputImage::IndexType, typename _TInputImage::PointType, typename _TInputImage::PixelType, typename _TOutputImage::PixelType, _TFrontId, typename _TInputImage::IndexType::LexicographicCompare > >, fpa::Image::MinimumSpanningTree< _TInputImage::ImageDimension > > + : public fpa::Base::Dijkstra< fpa::Image::Algorithm< fpa::Image::DefaultTraits< _TInputImage, _TOutputImage, _TFrontId > >, fpa::Image::MinimumSpanningTree< _TInputImage::ImageDimension > > { public: typedef _TInputImage TInputImage; typedef _TOutputImage TOutputImage; typedef _TFrontId TFrontId; + typedef fpa::Image::MinimumSpanningTree< _TInputImage::ImageDimension > TMST; - typedef typename TInputImage::IndexType TVertex; - typedef typename TInputImage::PointType TPoint; - typedef typename TVertex::LexicographicCompare TVertexCompare; - typedef typename TInputImage::PixelType TInputValue; - typedef typename TOutputImage::PixelType TOutputValue; - - typedef fpa::Base::MarksInterfaceWithCollisions< TVertex > TMarksInterface; - typedef fpa::Base::SeedsInterface< TVertex, TPoint, TInputValue, TOutputValue, TFrontId, TVertexCompare > TSeedsInterface; - typedef fpa::Image::Algorithm< TInputImage, TOutputImage, TMarksInterface, TSeedsInterface > TAlgorithm; - typedef fpa::Image::MinimumSpanningTree< TInputImage::ImageDimension > TMST; - - typedef Dijkstra Self; + typedef fpa::Image::DefaultTraits< TInputImage, TOutputImage, TFrontId > TTraits; + typedef fpa::Image::Algorithm< TTraits > TAlgorithm; typedef fpa::Base::Dijkstra< TAlgorithm, TMST > Superclass; + typedef Dijkstra Self; typedef itk::SmartPointer< Self > Pointer; typedef itk::SmartPointer< const Self > ConstPointer; - typedef fpa::Image::Functors::Dijkstra::Function< TInputImage, TOutputValue > TWeightFunction; - public: itkNewMacro( Self ); itkTypeMacro( fpa::Image::Dijkstra, fpa::Base::Dijkstra ); protected: - Dijkstra( ) - : Superclass( ) - { - typedef fpa::Image::Functors::Dijkstra::Identity< TInputImage, TOutputValue > _TDefaultFunction; - this->SetWeightFunction( _TDefaultFunction::New( ) ); - } - virtual ~Dijkstra( ) - { - } - - virtual void _ConfigureOutput( const TOutputValue& v ) override - { - this->Superclass::_ConfigureOutput( v ); - const TInputImage* in = this->GetInput( ); - - TMST* mst = this->GetMinimumSpanningTree( ); - mst->SetLargestPossibleRegion( in->GetLargestPossibleRegion( ) ); - mst->SetRequestedRegion( in->GetRequestedRegion( ) ); - mst->SetBufferedRegion( in->GetBufferedRegion( ) ); - mst->SetSpacing( in->GetSpacing( ) ); - mst->SetOrigin( in->GetOrigin( ) ); - mst->SetDirection( in->GetDirection( ) ); - mst->Allocate( ); - - typename TMST::PixelType zero; - zero.Fill( 0 ); - mst->FillBuffer( zero ); - } - - virtual void _BeforeGenerateData( ) override - { - this->Superclass::_BeforeGenerateData( ); - TWeightFunction* wf = - dynamic_cast< TWeightFunction* >( this->GetWeightFunction( ) ); - if( wf != NULL ) - wf->SetImage( this->GetInput( ) ); - } + Dijkstra( ) : Superclass( ) { } + virtual ~Dijkstra( ) { } private: // Purposely not implemented. diff --git a/lib/fpa/Image/Mori.h b/lib/fpa/Image/Mori.h index 550864d..7e6b0e0 100644 --- a/lib/fpa/Image/Mori.h +++ b/lib/fpa/Image/Mori.h @@ -10,6 +10,7 @@ #include #include #include +#include namespace fpa { @@ -18,32 +19,58 @@ namespace fpa /** */ template< class _TInputImage, class _TOutputImage > - class Mori - : public fpa::Base::Mori< fpa::Image::Algorithm< _TInputImage, _TOutputImage, fpa::Base::MarksInterface< typename _TInputImage::IndexType >, fpa::Base::SingleSeedInterface< typename _TInputImage::IndexType, typename _TInputImage::PointType, typename _TInputImage::PixelType, typename _TOutputImage::PixelType, typename _TOutputImage::PixelType, typename _TInputImage::IndexType::LexicographicCompare > > > + class MoriTraits + : public fpa::Image::DefaultTraits< _TInputImage, _TOutputImage, typename _TOutputImage::PixelType > { public: + typedef MoriTraits Self; typedef _TInputImage TInputImage; typedef _TOutputImage TOutputImage; + typedef typename TOutputImage::PixelType TFrontId; + typedef fpa::Image::DefaultTraits< TInputImage, TOutputImage, TFrontId > Superclass; + + typedef typename Superclass::TVertex TVertex; + typedef typename Superclass::TInputValue TInputValue; + typedef typename Superclass::TPoint TPoint; + typedef typename Superclass::TOutputValue TOutputValue; + typedef typename Superclass::TCompare TCompare; + typedef typename Superclass::TNeighborhood TNeighborhood; + typedef typename Superclass::TFilter TFilter; + + typedef fpa::Base::SingleSeedInterface< TVertex, TPoint, TInputValue, TOutputValue, TFrontId, TCompare > TSeedsInterface; + typedef fpa::Base::MarksInterface< TVertex > TMarksInterface; - typedef typename TInputImage::IndexType TVertex; - typedef typename TInputImage::PointType TPoint; - typedef typename TVertex::LexicographicCompare TVertexCompare; - typedef typename TInputImage::PixelType TInputValue; - typedef typename TOutputImage::PixelType TOutputValue; - typedef typename TOutputImage::PixelType TFrontId; + typedef typename TSeedsInterface::TNode TNode; + typedef typename TSeedsInterface::TNodes TNodes; + typedef typename TSeedsInterface::TSeed TSeed; + typedef typename TSeedsInterface::TSeeds TSeeds; - typedef fpa::Base::MarksInterface< TVertex > TMarksInterface; - typedef fpa::Base::SingleSeedInterface< TVertex, TPoint, TInputValue, TOutputValue, TFrontId, TVertexCompare > TSeedsInterface; - typedef fpa::Image::Algorithm< TInputImage, TOutputImage, TMarksInterface, TSeedsInterface > TAlgorithm; + private: + // Purposely not implemented. + MoriTraits( ); + MoriTraits( const Self& other ); + virtual ~MoriTraits( ); + Self& operator=( const Self& other ); + }; + + /** + */ + template< class _TInputImage, class _TOutputImage > + class Mori + : public fpa::Base::Mori< fpa::Image::Algorithm< fpa::Image::MoriTraits< _TInputImage, _TOutputImage > > > + { + public: + typedef _TInputImage TInputImage; + typedef _TOutputImage TOutputImage; + typedef fpa::Image::MoriTraits< TInputImage, TOutputImage > TTraits; + typedef fpa::Image::Algorithm< TTraits > TAlgorithm; typedef Mori Self; typedef fpa::Base::Mori< TAlgorithm > Superclass; typedef itk::SmartPointer< Self > Pointer; typedef itk::SmartPointer< const Self > ConstPointer; - typedef typename TSeedsInterface::TNode TNode; - typedef typename TSeedsInterface::TNodes TNodes; - typedef typename TAlgorithm::TMarks TMarks; + typedef typename TAlgorithm::TMarks TMarks; public: itkNewMacro( Self ); diff --git a/lib/fpa/Image/RandomWalker.h b/lib/fpa/Image/RandomWalker.h index 5438f00..aba7d84 100644 --- a/lib/fpa/Image/RandomWalker.h +++ b/lib/fpa/Image/RandomWalker.h @@ -7,12 +7,11 @@ #define __fpa__Image__RandomWalker__h__ #include - #include #include #include +#include #include -#include namespace fpa { @@ -21,32 +20,81 @@ namespace fpa /** */ template< class _TInputImage, class _TLabelImage, class _TScalar > - class RandomWalker - : public fpa::Base::DijkstraBase< fpa::Image::Algorithm< _TInputImage, itk::Image< _TScalar, _TInputImage::ImageDimension >, fpa::Base::MarksInterface< typename _TInputImage::IndexType >, fpa::Image::LabelledSeedsInterface< typename _TInputImage::IndexType, typename _TInputImage::PointType, typename _TInputImage::PixelType, _TScalar, typename _TLabelImage::PixelType, typename _TInputImage::IndexType::LexicographicCompare > > > + class RandomWalkerTraits + : public fpa::Image::DefaultTraits< _TInputImage, itk::Image< _TScalar, _TInputImage::ImageDimension >, typename _TLabelImage::PixelType > { public: - typedef _TInputImage TInputImage; - typedef _TLabelImage TLabelImage; - typedef _TScalar TScalar; - typedef typename TInputImage::IndexType TVertex; - typedef typename TInputImage::PointType TPoint; - typedef typename TVertex::LexicographicCompare TVertexCompare; - typedef typename TInputImage::PixelType TInputValue; - typedef typename TLabelImage::PixelType TFrontId; - + typedef RandomWalkerTraits Self; + typedef _TInputImage TInputImage; + typedef _TLabelImage TLabelImage; + typedef _TScalar TScalar; + typedef typename _TLabelImage::PixelType TFrontId; typedef itk::Image< TScalar, _TInputImage::ImageDimension > TOutputImage; - typedef fpa::Base::MarksInterface< TVertex > TMarksInterface; - typedef fpa::Image::LabelledSeedsInterface< TVertex, TPoint, TInputValue, _TScalar, TFrontId, TVertexCompare > TSeedsInterface; - typedef fpa::Image::Algorithm< _TInputImage, TOutputImage, TMarksInterface, TSeedsInterface > TAlgorithm; + typedef fpa::Image::DefaultTraits< TInputImage, TOutputImage, TFrontId > Superclass; + + typedef typename Superclass::TVertex TVertex; + typedef typename Superclass::TInputValue TInputValue; + typedef typename Superclass::TPoint TPoint; + typedef typename Superclass::TOutputValue TOutputValue; + typedef typename Superclass::TCompare TCompare; + typedef typename Superclass::TNeighborhood TNeighborhood; + typedef typename Superclass::TFilter TFilter; - typedef RandomWalker Self; - typedef fpa::Base::DijkstraBase< TAlgorithm > Superclass; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; + typedef fpa::Image::LabelledSeedsInterface< TVertex, TPoint, TInputValue, TOutputValue, TFrontId, TCompare > TSeedsInterface; + typedef fpa::Base::MarksInterface< TVertex > TMarksInterface; - typedef fpa::Image::Functors::Dijkstra::Function< TInputImage, TScalar > TWeightFunction; typedef typename TSeedsInterface::TNode TNode; typedef typename TSeedsInterface::TNodes TNodes; + typedef typename TSeedsInterface::TSeed TSeed; + typedef typename TSeedsInterface::TSeeds TSeeds; + + public: + itkConceptMacro( + Check_SameDimension, + ( itk::Concept::SameDimension< TInputImage::ImageDimension, TLabelImage::ImageDimension > ) + ); + + private: + // Purposely not implemented. + RandomWalkerTraits( ); + RandomWalkerTraits( const Self& other ); + virtual ~RandomWalkerTraits( ); + Self& operator=( const Self& other ); + }; + + /** + */ + template< class _TInputImage, class _TLabelImage, class _TScalar > + class RandomWalker + : public fpa::Base::DijkstraBase< fpa::Image::Algorithm< fpa::Image::RandomWalkerTraits< _TInputImage, _TLabelImage, _TScalar > > > + /* TODO + : public fpa::Base::DijkstraBase< fpa::Image::Algorithm< _TInputImage, itk::Image< _TScalar, _TInputImage::ImageDimension >, fpa::Base::MarksInterface< typename _TInputImage::IndexType >, fpa::Image::LabelledSeedsInterface< typename _TInputImage::IndexType, typename _TInputImage::PointType, typename _TInputImage::PixelType, _TScalar, typename _TLabelImage::PixelType, typename _TInputImage::IndexType::LexicographicCompare > > > + */ + { + public: + /* TODO + typedef _TInputImage TInputImage; + typedef _TLabelImage TLabelImage; + typedef _TScalar TScalar; + typedef typename TInputImage::IndexType TVertex; + typedef typename TInputImage::PointType TPoint; + typedef typename TVertex::LexicographicCompare TVertexCompare; + typedef typename TInputImage::PixelType TInputValue; + typedef typename TLabelImage::PixelType TFrontId; + + typedef itk::Image< TScalar, _TInputImage::ImageDimension > TOutputImage; + typedef fpa::Base::MarksInterface< TVertex > TMarksInterface; + typedef fpa::Image::LabelledSeedsInterface< TVertex, TPoint, TInputValue, _TScalar, TFrontId, TVertexCompare > TSeedsInterface; + typedef fpa::Image::Algorithm< _TInputImage, TOutputImage, TMarksInterface, TSeedsInterface > TAlgorithm; + typedef RandomWalker Self; + typedef fpa::Base::DijkstraBase< TAlgorithm > Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; + + typedef fpa::Image::Functors::Dijkstra::Function< TInputImage, TScalar > TWeightFunction; + typedef typename TSeedsInterface::TNode TNode; + typedef typename TSeedsInterface::TNodes TNodes; + */ public: itkNewMacro( Self ); diff --git a/lib/fpa/Image/RegionGrow.h b/lib/fpa/Image/RegionGrow.h index 2deff2f..4d190dc 100644 --- a/lib/fpa/Image/RegionGrow.h +++ b/lib/fpa/Image/RegionGrow.h @@ -7,9 +7,8 @@ #define __fpa__Image__RegionGrow__h__ #include -#include -#include #include +#include namespace fpa { @@ -19,43 +18,27 @@ namespace fpa */ template< class _TInputImage, class _TOutputImage, class _TFrontId = unsigned char > class RegionGrow - : public fpa::Base::RegionGrow< fpa::Image::Algorithm< _TInputImage, _TOutputImage, fpa::Base::MarksInterfaceWithCollisions< typename _TInputImage::IndexType >, fpa::Base::SeedsInterface< typename _TInputImage::IndexType, typename _TInputImage::PointType, typename _TInputImage::PixelType, typename _TOutputImage::PixelType, _TFrontId, typename _TInputImage::IndexType::LexicographicCompare > > > + : public fpa::Base::RegionGrow< fpa::Image::Algorithm< fpa::Image::DefaultTraits< _TInputImage, _TOutputImage, _TFrontId > > > { public: typedef _TInputImage TInputImage; typedef _TOutputImage TOutputImage; typedef _TFrontId TFrontId; - typedef typename TInputImage::IndexType TVertex; - typedef typename TInputImage::PointType TPoint; - typedef typename TVertex::LexicographicCompare TVertexCompare; - typedef typename TInputImage::PixelType TInputValue; - typedef typename TOutputImage::PixelType TOutputValue; - - typedef fpa::Base::MarksInterfaceWithCollisions< TVertex > TMarksInterface; - typedef fpa::Base::SeedsInterface< TVertex, TPoint, TInputValue, TOutputValue, TFrontId, TVertexCompare > TSeedsInterface; - typedef fpa::Image::Algorithm< TInputImage, TOutputImage, TMarksInterface, TSeedsInterface > TAlgorithm; - - typedef RegionGrow Self; + typedef fpa::Image::DefaultTraits< TInputImage, TOutputImage, TFrontId > TTraits; + typedef fpa::Image::Algorithm< TTraits > TAlgorithm; typedef fpa::Base::RegionGrow< TAlgorithm > Superclass; + typedef RegionGrow Self; typedef itk::SmartPointer< Self > Pointer; typedef itk::SmartPointer< const Self > ConstPointer; - typedef typename TSeedsInterface::TNode TNode; - typedef typename TSeedsInterface::TNodes TNodes; - public: itkNewMacro( Self ); itkTypeMacro( fpa::Image::RegionGrow, fpa::Base::RegionGrow ); protected: - RegionGrow( ) - : Superclass( ) - { - } - virtual ~RegionGrow( ) - { - } + RegionGrow( ) : Superclass( ) { } + virtual ~RegionGrow( ) { } private: // Purposely not implemented.