-#ifndef __FPA__IMAGE__DIJKSTRA__H__
-#define __FPA__IMAGE__DIJKSTRA__H__
+// =========================================================================
+// @author Leonardo Florez Valencia
+// @email florez-l@javeriana.edu.co
+// =========================================================================
+
+#ifndef __fpa__Image__Dijkstra__h__
+#define __fpa__Image__Dijkstra__h__
-#include <itkImage.h>
-#include <itkImageFunction.h>
-#include <itkImageToImageFilter.h>
-#include <itkIndex.h>
#include <fpa/Base/Dijkstra.h>
-#include <fpa/Image/Algorithm.h>
+#include <fpa/Base/SeedsInterface.h>
+#include <fpa/Image/MarksInterface.h>
+#include <fpa/Image/Filter.h>
+#include <fpa/Image/MinimumSpanningTree.h>
+#include <fpa/Image/Functors/VertexParentBase.h>
+#include <fpa/Image/Functors/VertexIdentity.h>
namespace fpa
{
namespace Image
{
/**
- * @param I Input image type
*/
- template< class I, class C >
+ template< class _TInputImage, class _TOutputImage >
class Dijkstra
- : public Algorithm< I, fpa::Base::Dijkstra< typename I::IndexType, C, typename I::PixelType, itk::Functor::IndexLexicographicCompare< I::ImageDimension >, itk::ImageToImageFilter< I, itk::Image< C, I::ImageDimension > > > >
+ : public fpa::Base::Dijkstra< fpa::Image::Filter< _TInputImage, _TOutputImage >, fpa::Image::MarksInterface< _TInputImage::ImageDimension >, fpa::Base::SeedsInterface< typename _TInputImage::IndexType, typename _TInputImage::IndexType::LexicographicCompare >, fpa::Image::MinimumSpanningTree< _TInputImage::ImageDimension > >
{
public:
- // Standard class typdedefs
- typedef typename I::IndexType TVertex;
- typedef typename I::PixelType TVertexValue;
- typedef itk::Image< C, I::ImageDimension > TCostImage;
- typedef itk::ImageToImageFilter< I, TCostImage > TBaseFilter;
- typedef fpa::Base::Dijkstra< TVertex, C, TVertexValue, itk::Functor::IndexLexicographicCompare< I::ImageDimension >, TBaseFilter > TBaseAlgorithm;
-
- typedef Dijkstra Self;
- typedef Algorithm< I, TBaseAlgorithm > Superclass;
- typedef itk::SmartPointer< Self > Pointer;
+ // Interfaces
+ typedef fpa::Image::Filter< _TInputImage, _TOutputImage > TFilter;
+ typedef fpa::Image::MarksInterface< _TInputImage::ImageDimension > TMarksInterface;
+ typedef fpa::Base::SeedsInterface< typename _TInputImage::IndexType, typename _TInputImage::IndexType::LexicographicCompare > TSeedsInterface;
+ typedef fpa::Image::MinimumSpanningTree< _TInputImage::ImageDimension > TMST;
+
+ // Smart pointers
+ typedef Dijkstra Self;
+ typedef fpa::Base::Dijkstra< TFilter, TMarksInterface, TSeedsInterface, TMST > Superclass;
+ typedef itk::SmartPointer< Self > Pointer;
typedef itk::SmartPointer< const Self > ConstPointer;
+ typedef typename TFilter::TInputImage TInputImage;
+ typedef typename TFilter::TOutputValue TOutputValue;
+ typedef typename TFilter::TVertex TVertex;
+
public:
itkNewMacro( Self );
- itkTypeMacro( Dijkstra, fpaBaseDijkstra );
+ itkTypeMacro( fpa::Image::Dijkstra, fpa::Base::Dijkstra );
protected:
Dijkstra( )
: Superclass( )
- { }
- virtual ~Dijkstra( )
- { }
+ {
+ this->SetFunctor(
+ fpa::Image::Functors::
+ VertexIdentity< _TInputImage, typename TFilter::TOutputValue >::
+ New( )
+ );
+ }
+ virtual ~Dijkstra( ) { }
+
+ virtual void _ConfigureOutputs( const TOutputValue& init_value ) override
+ {
+ this->Superclass::_ConfigureOutputs( init_value );
+
+ typename TVertex::OffsetType o;
+ o.Fill( 0 );
+ const TInputImage* input = this->GetInput( );
+ TMST* mst = this->GetMinimumSpanningTree( );
+ mst->CopyInformation( input );
+ mst->SetBufferedRegion( input->GetRequestedRegion( ) );
+ mst->Allocate( );
+ mst->FillBuffer( o );
+ }
+
+ virtual void GenerateData( ) override
+ {
+ // Configure functors with input image
+ typedef typename TFilter::TOutputValue _TOutputValue;
+ typedef fpa::Image::Functors::VertexParentBase< _TInputImage, _TOutputValue > _TVFunc;
+ _TVFunc* vfunc =
+ dynamic_cast< _TVFunc* >( this->m_VertexFunctor.GetPointer( ) );
+ if( vfunc != NULL )
+ vfunc->SetImage( this->GetInput( ) );
+
+ // Ok, continue
+ this->Superclass::GenerateData( );
+ }
private:
- // Purposely not implemented
- Dijkstra( const Self& );
- void operator=( const Self& );
+ Dijkstra( const Self& other );
+ Self& operator=( const Self& other );
};
} // ecapseman
} // ecapseman
-#endif // __FPA__IMAGE__DIJKSTRA__H__
+#endif // __fpa__Image__Dijkstra__h__
// eof - $RCSfile$