+## =========================================================================
+## @author Leonardo Florez Valencia
+## @email florez-l@javeriana.edu.co
+## =========================================================================
+
cmake_minimum_required(VERSION 3.0)
## ========================
## == Find needed packages and dependencies ==
## ===========================================
-find_package(ivq CONFIG REQUIRED)
+find_package(ITK CONFIG REQUIRED)
+include(${ITK_USE_FILE})
+if(ITKVtkGlue_LOADED)
+ find_package(VTK CONFIG REQUIRED)
+ include(${VTK_USE_FILE})
+endif(ITKVtkGlue_LOADED)
## =========================
## == Installation values ==
## == Build different parts ==
## ===========================
-subdirs(appli lib tests)
+subdirs(lib tests)
## ===============================
## == Global installation rules ==
+## =========================================================================
+## @author Leonardo Florez Valencia
+## @email florez-l@javeriana.edu.co
+## =========================================================================
+
@PACKAGE_INIT@
include("${CMAKE_CURRENT_LIST_DIR}/@targets_export_name@.cmake")
## == Find needed packages and dependencies ==
## ===========================================
-find_package(ivq CONFIG REQUIRED)
+set(ITK_DIR @ITK_DIR@)
+find_package(ITK CONFIG REQUIRED)
+include(${ITK_USE_FILE})
+if(ITKVtkGlue_LOADED)
+ set(VTK_DIR @VTK_DIR@)
+ find_package(VTK CONFIG REQUIRED)
+ include(${VTK_USE_FILE})
+endif(ITKVtkGlue_LOADED)
## eof - $RCSfile$
+++ /dev/null
-
-include_directories(
- ${CMAKE_CURRENT_SOURCE_DIR}
- ${CMAKE_CURRENT_BINARY_DIR}
- )
-subdirs(fpa)
-
-## eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Base__Algorithm__h__
-#define __fpa__Base__Algorithm__h__
-
-#include <fpa/Config.h>
-
-#include <itkObject.h>
-#include <itkEventObject.h>
-
-namespace fpa
-{
- namespace Base
- {
- /**
- */
- template< class _TTraits >
- class Algorithm
- : public _TTraits::TFilter,
- public _TTraits::TMarksInterface,
- public _TTraits::TSeedsInterface
- {
- public:
- 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;
-
- /**
- */
- class TEvent
- : public itk::EventObject
- {
- public:
- typedef TEvent Self;
- typedef itk::EventObject Superclass;
-
- public:
- TEvent( );
- TEvent( const TVertex& v, unsigned long fid, bool intoq );
- virtual ~TEvent( );
- virtual const char* GetEventName( ) const override;
- virtual bool CheckEvent( const itk::EventObject* e ) const override;
- virtual itk::EventObject* MakeObject( ) const override;
-
- private:
- // Purposely not implemented.
- Self& operator=( const Self& other );
-
- public:
- TVertex Vertex;
- unsigned long FrontId;
- bool IntoQueue;
- };
-
- public:
- itkTypeMacro( fpa::Base::Algorithm, _TFilter );
-
- itkBooleanMacro( VisualDebug );
-
- itkGetConstMacro( InitValue, TOutputValue );
- itkGetConstMacro( VisualDebug, bool );
-
- itkSetMacro( InitValue, TOutputValue );
- itkSetMacro( VisualDebug, bool );
-
- public:
- virtual void InvokeEvent( const itk::EventObject& e );
- virtual void InvokeEvent( const itk::EventObject& e ) const;
-
- protected:
- Algorithm( );
- virtual ~Algorithm( );
-
- virtual void GenerateData( ) override;
- virtual void _BeforeGenerateData( );
- virtual void _AfterGenerateData( );
- virtual void _FinishOneLoop( );
-
- virtual void _QueueInit( );
-
- virtual void _ConfigureOutput( const TOutputValue& v ) = 0;
- virtual TNeighborhood _GetNeighbors( const TVertex& v ) const = 0;
- virtual TInputValue _GetInputValue( const TVertex& v ) const = 0;
- virtual TOutputValue _GetOutputValue( const TVertex& v ) const = 0;
-
- virtual void _ComputeOutputValue( TNode& n ) = 0;
- virtual void _UpdateOutputValue( TNode& n ) = 0;
- virtual void _QueueClear( ) = 0;
- virtual void _QueuePush( const TNode& node ) = 0;
- virtual unsigned long _QueueSize( ) const = 0;
- virtual TNode _QueuePop( ) = 0;
-
- private:
- // Purposely not implemented
- Algorithm( const Self& other );
- Self& operator=( const Self& other );
-
- protected:
- bool m_VisualDebug;
- TOutputValue m_InitValue;
- };
-
- } // ecapseman
-
-} // ecapseman
-
-#ifndef ITK_MANUAL_INSTANTIATION
-# include <fpa/Base/Algorithm.hxx>
-#endif // ITK_MANUAL_INSTANTIATION
-
-#endif // __fpa__Base__Algorithm__h__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Base__Algorithm__hxx__
-#define __fpa__Base__Algorithm__hxx__
-
-// -------------------------------------------------------------------------
-template< class _TTraits >
-fpa::Base::Algorithm< _TTraits >::TEvent::
-TEvent( )
- : Superclass( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TTraits >
-fpa::Base::Algorithm< _TTraits >::TEvent::
-TEvent( const TVertex& v, unsigned long fid, bool intoq )
- : Superclass( ),
- Vertex( v ),
- FrontId( fid ),
- IntoQueue( intoq )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TTraits >
-fpa::Base::Algorithm< _TTraits >::TEvent::
-~TEvent( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TTraits >
-const char* fpa::Base::Algorithm< _TTraits >::TEvent::
-GetEventName( ) const
-{
- return( "fpa::Base::Algorithm< _TTraits >::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 _TTraits >
-itk::EventObject* fpa::Base::Algorithm< _TTraits >::TEvent::
-MakeObject( ) const
-{
- return( new Self );
-}
-
-// -------------------------------------------------------------------------
-template< class _TTraits >
-void fpa::Base::Algorithm< _TTraits >::
-InvokeEvent( const itk::EventObject& e )
-{
- TEvent a;
- if( a.CheckEvent( &e ) )
- {
- if( this->m_VisualDebug )
- this->Superclass::InvokeEvent( e );
- }
- else
- this->Superclass::InvokeEvent( e );
-}
-
-// -------------------------------------------------------------------------
-template< class _TTraits >
-void fpa::Base::Algorithm< _TTraits >::
-InvokeEvent( const itk::EventObject& e ) const
-{
- TEvent a;
- if( a.CheckEvent( &e ) )
- {
- if( this->m_VisualDebug )
- this->Superclass::InvokeEvent( e );
- }
- else
- this->Superclass::InvokeEvent( e );
-}
-
-// -------------------------------------------------------------------------
-template< class _TTraits >
-fpa::Base::Algorithm< _TTraits >::
-Algorithm( )
- : Superclass( ),
- TMarksInterface( this ),
- TSeedsInterface( this ),
- m_VisualDebug( false )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TTraits >
-fpa::Base::Algorithm< _TTraits >::
-~Algorithm( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TTraits >
-void fpa::Base::Algorithm< _TTraits >::
-GenerateData( )
-{
- this->InvokeEvent( itk::StartEvent( ) );
-
- // Init objects
- this->_BeforeGenerateData( );
- this->_ConfigureOutput( this->m_InitValue );
- this->_InitMarks( this->GetSeeds( ).size( ) );
- TNodes seeds = this->_UnifySeeds( );
- this->_PrepareSeeds( seeds );
-
- // Init queue
- this->_QueueInit( );
- typename TNodes::const_iterator sIt = seeds.begin( );
- for( ; sIt != seeds.end( ); ++sIt )
- {
- this->_QueuePush( *sIt );
- this->InvokeEvent( TEvent( sIt->Vertex, sIt->FrontId, true ) );
-
- } // rof
-
- // Main loop
- while( this->_QueueSize( ) > 0 )
- {
- // Get next candidate
- TNode node = this->_QueuePop( );
- this->InvokeEvent( TEvent( node.Vertex, node.FrontId, false ) );
- if( !( this->_IsMarked( node.Vertex ) ) )
- {
- // Update output value and mark vertex
- this->_UpdateOutputValue( node );
- this->_Mark( node.Vertex, node.FrontId );
-
- // The actual node was effectively marked?
- if( node.FrontId > 0 )
- {
- // Add neighborhood
- TNeighborhood neighbors = this->_GetNeighbors( node.Vertex );
- typename TNeighborhood::const_iterator nIt = neighbors.begin( );
- bool coll = false;
- while( nIt != neighbors.end( ) && !coll )
- {
- if( this->_IsMarked( *nIt ) )
- {
- // Invoke stop at collisions
- if( this->_Collisions( node.Vertex, *nIt ) )
- {
- this->_QueueClear( );
- coll = true;
-
- } // fi
- }
- else
- {
- TNode nnode;
- nnode.Vertex = *nIt;
- nnode.Parent = node.Vertex;
- nnode.FrontId = node.FrontId;
- this->_ComputeOutputValue( nnode );
- this->_QueuePush( nnode );
- this->InvokeEvent( TEvent( nnode.Vertex, nnode.FrontId, true ) );
-
- } // fi
- ++nIt;
-
- } // elihw
-
- } // fi
-
- } // fi
- this->_FinishOneLoop( );
-
- } // elihw
-
- // Finish
- this->_AfterGenerateData( );
- this->InvokeEvent( itk::EndEvent( ) );
-}
-
-// -------------------------------------------------------------------------
-template< class _TTraits >
-void fpa::Base::Algorithm< _TTraits >::
-_BeforeGenerateData( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TTraits >
-void fpa::Base::Algorithm< _TTraits >::
-_AfterGenerateData( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TTraits >
-void fpa::Base::Algorithm< _TTraits >::
-_FinishOneLoop( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TTraits >
-void fpa::Base::Algorithm< _TTraits >::
-_QueueInit( )
-{
- this->_QueueClear( );
-}
-
-#endif // __fpa__Base__Algorithm__hxx__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Base__Dijkstra__h__
-#define __fpa__Base__Dijkstra__h__
-
-#include <fpa/Base/DijkstraBase.h>
-
-namespace fpa
-{
- namespace Base
- {
- /**
- */
- template< class _TAlgorithm, class _TMST >
- class Dijkstra
- : public fpa::Base::DijkstraBase< _TAlgorithm >
- {
- public:
- typedef Dijkstra Self;
- typedef fpa::Base::DijkstraBase< _TAlgorithm > Superclass;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
-
- typedef _TMST TMST;
-
- typedef typename Superclass::TNode TNode;
- typedef typename Superclass::TNodes TNodes;
- typedef typename Superclass::TInputValue TInputValue;
- typedef typename Superclass::TOutputValue TOutputValue;
- typedef typename Superclass::TFrontId TFrontId;
- typedef typename Superclass::TVertex TVertex;
- typedef typename Superclass::TSeeds TSeeds;
-
- typedef typename Superclass::TQueue TQueue;
- typedef typename Superclass::TQueueOrder TQueueOrder;
- typedef typename Superclass::TWeightFunction TWeightFunction;
-
- public:
- TMST* GetMinimumSpanningTree( );
- const TMST* GetMinimumSpanningTree( ) const;
-
- protected:
- Dijkstra( );
- virtual ~Dijkstra( );
-
- virtual void _AfterGenerateData( ) override;
- virtual void _UpdateOutputValue( TNode& n ) override;
-
- private:
- // Purposely not implemented.
- Dijkstra( const Self& other );
- Self& operator=( const Self& other );
-
- protected:
- unsigned int m_MSTIdx;
- };
-
- } // ecapseman
-
-} // ecapseman
-
-#ifndef ITK_MANUAL_INSTANTIATION
-# include <fpa/Base/Dijkstra.hxx>
-#endif // ITK_MANUAL_INSTANTIATION
-
-#endif // __fpa__Base__Dijkstra__h__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Base__Dijkstra__hxx__
-#define __fpa__Base__Dijkstra__hxx__
-
-// -------------------------------------------------------------------------
-template< class _TAlgorithm, class _TMST >
-typename fpa::Base::Dijkstra< _TAlgorithm, _TMST >::
-TMST* fpa::Base::Dijkstra< _TAlgorithm, _TMST >::
-GetMinimumSpanningTree( )
-{
- return(
- dynamic_cast< TMST* >(
- this->itk::ProcessObject::GetOutput( this->m_MSTIdx )
- )
- );
-}
-
-// -------------------------------------------------------------------------
-template< class _TAlgorithm, class _TMST >
-const typename fpa::Base::Dijkstra< _TAlgorithm, _TMST >::
-TMST* fpa::Base::Dijkstra< _TAlgorithm, _TMST >::
-GetMinimumSpanningTree( ) const
-{
- return(
- dynamic_cast< const TMST* >(
- this->itk::ProcessObject::GetOutput( this->m_MSTIdx )
- )
- );
-}
-
-// -------------------------------------------------------------------------
-template< class _TAlgorithm, class _TMST >
-fpa::Base::Dijkstra< _TAlgorithm, _TMST >::
-Dijkstra( )
- : Superclass( )
-{
- this->m_MSTIdx = this->GetNumberOfRequiredOutputs( );
- this->itk::ProcessObject::SetNumberOfRequiredOutputs( this->m_MSTIdx + 1 );
- this->SetNthOutput( this->m_MSTIdx, TMST::New( ) );
-}
-
-// -------------------------------------------------------------------------
-template< class _TAlgorithm, class _TMST >
-fpa::Base::Dijkstra< _TAlgorithm, _TMST >::
-~Dijkstra( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TAlgorithm, class _TMST >
-void fpa::Base::Dijkstra< _TAlgorithm, _TMST >::
-_AfterGenerateData( )
-{
- this->Superclass::_AfterGenerateData( );
-
- TMST* mst = this->GetMinimumSpanningTree( );
- mst->ClearSeeds( );
- mst->SetCollisions( this->m_Collisions );
-
- const TSeeds& seeds = this->GetSeeds( );
- typename TSeeds::const_iterator sIt = seeds.begin( );
- for( ; sIt != seeds.end( ); ++sIt )
- {
- if( sIt->IsUnified )
- mst->AddSeed( sIt->Vertex );
-
- } // rof
-}
-
-// -------------------------------------------------------------------------
-template< class _TAlgorithm, class _TMST >
-void fpa::Base::Dijkstra< _TAlgorithm, _TMST >::
-_UpdateOutputValue( TNode& n )
-{
- this->Superclass::_UpdateOutputValue( n );
- this->GetMinimumSpanningTree( )->SetParent( n.Vertex, n.Parent );
-}
-
-#endif // __fpa__Base__Dijkstra__hxx__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Base__DijkstraBase__h__
-#define __fpa__Base__DijkstraBase__h__
-
-#include <vector>
-
-#include <itkConceptChecking.h>
-#include <fpa/Base/Functors/Dijkstra/Function.h>
-
-namespace fpa
-{
- namespace Base
- {
- /**
- */
- template< class _TAlgorithm >
- class DijkstraBase
- : public _TAlgorithm
- {
- public:
- typedef DijkstraBase Self;
- typedef _TAlgorithm Superclass;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
-
- typedef typename _TAlgorithm::TNode TNode;
- typedef typename _TAlgorithm::TNodes TNodes;
- typedef typename _TAlgorithm::TInputValue TInputValue;
- typedef typename _TAlgorithm::TOutputValue TOutputValue;
- typedef typename _TAlgorithm::TVertex TVertex;
-
- typedef std::vector< TNode > TQueue;
- struct TQueueOrder
- {
- bool operator()( const TNode& a, const TNode& b ) const
- {
- return( b.Value < a.Value );
- }
- };
- typedef fpa::Base::Functors::Dijkstra::Function< TVertex, TOutputValue > TWeightFunction;
-
- public:
- itkConceptMacro(
- Check_TOutputValue,
- ( itk::Concept::IsFloatingPoint< TOutputValue > )
- );
-
- public:
- itkGetObjectMacro( WeightFunction, TWeightFunction );
- itkSetObjectMacro( WeightFunction, TWeightFunction );
-
- public:
- virtual itk::ModifiedTimeType GetMTime( ) const override;
-
- protected:
- DijkstraBase( );
- virtual ~DijkstraBase( );
-
- virtual void _ComputeOutputValue( TNode& n ) override;
- virtual void _QueueClear( ) override;
- virtual TNode _QueuePop( ) override;
- virtual void _QueuePush( const TNode& node ) override;
- virtual unsigned long _QueueSize( ) const override;
- virtual void _PrepareSeeds( TNodes& nodes ) override;
-
- private:
- // Purposely not implemented.
- DijkstraBase( const Self& other );
- Self& operator=( const Self& other );
-
- protected:
- typename TWeightFunction::Pointer m_WeightFunction;
-
- TQueue m_Queue;
- TQueueOrder m_QueueOrder;
- };
-
- } // ecapseman
-
-} // ecapseman
-
-#ifndef ITK_MANUAL_INSTANTIATION
-# include <fpa/Base/DijkstraBase.hxx>
-#endif // ITK_MANUAL_INSTANTIATION
-
-#endif // __fpa__Base__DijkstraBase__h__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Base__DijkstraBase__hxx__
-#define __fpa__Base__DijkstraBase__hxx__
-
-#include <algorithm>
-#include <limits>
-
-// -------------------------------------------------------------------------
-template< class _TAlgorithm >
-itk::ModifiedTimeType fpa::Base::DijkstraBase< _TAlgorithm >::
-GetMTime( ) const
-{
- itk::ModifiedTimeType t = this->Superclass::GetMTime( );
- if( this->m_WeightFunction.IsNotNull( ) )
- {
- itk::ModifiedTimeType q = this->m_WeightFunction->GetMTime( );
- t = ( q < t )? q: t;
-
- } // fi
- return( t );
-}
-
-// -------------------------------------------------------------------------
-template< class _TAlgorithm >
-fpa::Base::DijkstraBase< _TAlgorithm >::
-DijkstraBase( )
- : Superclass( )
-{
- this->SetInitValue( std::numeric_limits< TOutputValue >::max( ) );
-}
-
-// -------------------------------------------------------------------------
-template< class _TAlgorithm >
-fpa::Base::DijkstraBase< _TAlgorithm >::
-~DijkstraBase( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TAlgorithm >
-void fpa::Base::DijkstraBase< _TAlgorithm >::
-_ComputeOutputValue( TNode& n )
-{
- TOutputValue c = this->m_WeightFunction->Evaluate( n.Vertex, n.Parent );
- n.Value = c + this->_GetOutputValue( n.Parent );
-}
-
-// -------------------------------------------------------------------------
-template< class _TAlgorithm >
-void fpa::Base::DijkstraBase< _TAlgorithm >::
-_QueueClear( )
-{
- this->m_Queue.clear( );
-}
-
-// -------------------------------------------------------------------------
-template< class _TAlgorithm >
-typename fpa::Base::DijkstraBase< _TAlgorithm >::
-TNode fpa::Base::DijkstraBase< _TAlgorithm >::
-_QueuePop( )
-{
- std::pop_heap(
- this->m_Queue.begin( ), this->m_Queue.end( ), this->m_QueueOrder
- );
- TNode n = this->m_Queue.back( );
- this->m_Queue.pop_back( );
- return( n );
-}
-
-// -------------------------------------------------------------------------
-template< class _TAlgorithm >
-void fpa::Base::DijkstraBase< _TAlgorithm >::
-_QueuePush( const TNode& node )
-{
- bool push_needed = ( node.Parent == node.Vertex );
- push_needed |= !( node.Value < this->_GetOutputValue( node.Parent ) );
- if( push_needed )
- {
- this->m_Queue.push_back( node );
- std::push_heap(
- this->m_Queue.begin( ), this->m_Queue.end( ), this->m_QueueOrder
- );
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-template< class _TAlgorithm >
-unsigned long fpa::Base::DijkstraBase< _TAlgorithm >::
-_QueueSize( ) const
-{
- return( this->m_Queue.size( ) );
-}
-
-// -------------------------------------------------------------------------
-template< class _TAlgorithm >
-void fpa::Base::DijkstraBase< _TAlgorithm >::
-_PrepareSeeds( TNodes& nodes )
-{
- typename TNodes::iterator nIt = nodes.begin( );
- for( ; nIt != nodes.end( ); ++nIt )
- nIt->Value = TOutputValue( 0 );
-}
-
-#endif // __fpa__Base__DijkstraBase__hxx__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Base__Functors__Dijkstra__Function__h__
-#define __fpa__Base__Functors__Dijkstra__Function__h__
-
-#include <itkObject.h>
-
-namespace fpa
-{
- namespace Base
- {
- namespace Functors
- {
- namespace Dijkstra
- {
- /**
- */
- template< class _TVertex, class _TOutputValue >
- class Function
- : public itk::Object
- {
- public:
- typedef Function Self;
- typedef itk::Object Superclass;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
-
- public:
- itkTypeMacro( fpa::Base::Functors::Dijkstra::Function, itk::Object );
-
- public:
- virtual _TOutputValue Evaluate(
- const _TVertex& v, const _TVertex& p
- ) const = 0;
-
- protected:
- Function( )
- : Superclass( )
- {
- }
- virtual ~Function( )
- {
- }
-
- private:
- // Purposely not implemented
- Function( const Self& other );
- Self& operator=( const Self& other );
- };
-
- } // ecapseman
-
- } // ecapseman
-
- } // ecapseman
-
-} // ecapseman
-
-#endif // __fpa__Base__Functors__Dijkstra__Function__h__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Base__Functors__RegionGrow__BinaryThreshold__h__
-#define __fpa__Base__Functors__RegionGrow__BinaryThreshold__h__
-
-#include <limits>
-#include <itkFunctionBase.h>
-
-namespace fpa
-{
- namespace Base
- {
- namespace Functors
- {
- namespace RegionGrow
- {
- /**
- */
- template< class _TValue >
- class BinaryThreshold
- : public itk::FunctionBase< _TValue, bool >
- {
- public:
- typedef BinaryThreshold Self;
- typedef itk::FunctionBase< _TValue, bool > Superclass;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
-
- public:
- itkNewMacro( Self );
- itkTypeMacro(
- fpa::Base::Functors::RegionGrow::BinaryThreshold,
- itk::FunctionBase
- );
-
- itkBooleanMacro( Strict );
-
- itkGetConstMacro( Lower, _TValue );
- itkGetConstMacro( Upper, _TValue );
- itkGetConstMacro( Strict, bool );
-
- itkSetMacro( Lower, _TValue );
- itkSetMacro( Upper, _TValue );
- itkSetMacro( Strict, bool );
-
- public:
- virtual bool Evaluate( const _TValue& input ) const override
- {
- if( this->m_Strict )
- return( this->m_Lower < input && input < this->m_Upper );
- else
- return( this->m_Lower <= input && input <= this->m_Upper );
- }
-
- protected:
- BinaryThreshold( )
- : Superclass( ),
- m_Strict( true )
- {
- this->m_Upper = std::numeric_limits< _TValue >::max( );
- if( std::numeric_limits< _TValue >::is_integer )
- this->m_Lower = std::numeric_limits< _TValue >::min( );
- else
- this->m_Lower = -this->m_Upper;
- }
-
- virtual ~BinaryThreshold( )
- {
- }
-
- private:
- // Purposely not implemented
- BinaryThreshold( const Self& other );
- Self& operator=( const Self& other );
-
- protected:
- _TValue m_Lower;
- _TValue m_Upper;
- bool m_Strict;
- };
-
- } // ecapseman
-
- } // ecapseman
-
- } // ecapseman
-
-} // ecapseman
-
-#endif // __fpa__Base__Functors__RegionGrow__BinaryThreshold__h__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Base__Functors__RegionGrow__Tautology__h__
-#define __fpa__Base__Functors__RegionGrow__Tautology__h__
-
-#include <itkFunctionBase.h>
-
-namespace fpa
-{
- namespace Base
- {
- namespace Functors
- {
- namespace RegionGrow
- {
- /**
- */
- template< class _TValue >
- class Tautology
- : public itk::FunctionBase< _TValue, bool >
- {
- public:
- typedef Tautology Self;
- typedef itk::FunctionBase< _TValue, bool > Superclass;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
-
- public:
- itkNewMacro( Self );
- itkTypeMacro(
- fpa::Base::Functors::RegionGrow::Tautology,
- itk::FunctionBase
- );
-
- public:
- virtual bool Evaluate( const _TValue& input ) const override
- {
- return( true );
- }
-
- protected:
- Tautology( )
- : Superclass( )
- {
- }
- virtual ~Tautology( )
- {
- }
-
- private:
- // Purposely not implemented
- Tautology( const Self& other );
- Self& operator=( const Self& other );
- };
-
- } // ecapseman
-
- } // ecapseman
-
- } // ecapseman
-
-} // ecapseman
-
-#endif // __fpa__Base__Functors__RegionGrow__Tautology__h__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Base__Graph__h__
-#define __fpa__Base__Graph__h__
-
-#include <map>
-#include <set>
-#include <vector>
-#include <itkDataObject.h>
-#include <itkObjectFactory.h>
-
-namespace fpa
-{
- namespace Base
- {
- /** \brief A generic graph with templated index types.
- *
- * @param _TVertex Vertex type.
- * @param _TCost Cost type.
- * @param _TIndex Index type (it should be a strict weak ordering type).
- */
- template< class _TVertex, class _TCost, class _TIndex = unsigned long, class _TIndexCompare = std::less< _TIndex > >
- class Graph
- : public itk::DataObject
- {
- public:
- typedef Graph Self;
- typedef itk::DataObject Superclass;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
-
- typedef _TVertex TVertex;
- typedef _TCost TCost;
- typedef _TIndex TIndex;
- typedef _TIndexCompare TIndexCompare;
-
- // Base types
- typedef std::map< TIndex, TVertex, TIndexCompare > TVertices;
- typedef std::vector< TCost > TEdges;
- typedef std::map< TIndex, TEdges, TIndexCompare > TMatrixRow;
- typedef std::map< TIndex, TMatrixRow, TIndexCompare > TMatrix;
-
- public:
- itkNewMacro( Self );
- itkTypeMacro( Graph, itk::DataObject );
-
- public:
- /*! \brief Iterators over vertices.
- * These allow you to iterate over all of graph's vertices.
- *
- * Typical iteration should be done as:
- *
- * TGraph g;
- * ...
- * TGraph::TVertices::[const_]iterator vIt = g.BeginVertices( );
- * for( ; vIt != g.EndVertices( ); ++vIt )
- * {
- * vIt->first; --> this is the vertex's index <--
- * vIt->second; --> this is the vertex's value <--
- * }
- */
- inline typename TVertices::iterator BeginVertices( )
- { return( this->m_Vertices.begin( ) ); }
- inline typename TVertices::iterator EndVertices( )
- { return( this->m_Vertices.end( ) ); }
- inline typename TVertices::const_iterator BeginVertices( ) const
- { return( this->m_Vertices.begin( ) ); }
- inline typename TVertices::const_iterator EndVertices( ) const
- { return( this->m_Vertices.end( ) ); }
-
- /*! \brief Iterators over edges.
- * These allow you to iterate over all of graph's edges.
- *
- * Typical iteration should be done as:
- *
- * TGraph g;
- * ...
- * TGraph::TMatrix::[const_]iterator mIt = g.BeginEdgesRows( );
- * for( ; mIt != g.EndEdgesRows( ); ++mIt )
- * {
- * mIt->first; --> this is the row index. <--
- * TGraph::TMatrixRow::[const_]iterator rIt = mIt->second.begin( );
- * for( ; rIt != mIt->second.end( ); ++rIt )
- * {
- * rIt->first; --> this is the column index.
- * TGraph::TEdges::[const_]iterator eIt = rIt->second.begin( );
- * for( ; eIt != rIt->second.end( ); ++eIt )
- * *eIt; --> this is the cost between mIt->first and rIt->first
- * }
- * }
- */
- inline typename TMatrix::iterator BeginEdgesRows( )
- { return( this->m_Matrix.begin( ) ); }
- inline typename TMatrix::iterator EndEdgetsRows( )
- { return( this->m_Matrix.end( ) ); }
- inline typename TMatrix::const_iterator BeginEdgesRows( ) const
- { return( this->m_Matrix.begin( ) ); }
- inline typename TMatrix::const_iterator EndEdgesRows( ) const
- { return( this->m_Matrix.end( ) ); }
-
- /*! \brief Clear all vertices and edges.
- */
- void Clear( );
-
- /*! \brief Clear all edges.
- */
- inline void ClearEdges( )
- { this->m_Matrix.clear( ); }
-
- /*! \brief Vertex manipulation methods.
- * Names are self-explanatory.
- */
- inline bool HasVertexIndex( const TIndex& i ) const
- { return( this->m_Vertices.find( i ) != this->m_Vertices.end( ) ); }
- inline void SetVertex( const TIndex& index, TVertex& vertex )
- { this->m_Vertices[ index ] = vertex; }
- inline TVertex& GetVertex( const TIndex& index )
- { return( this->m_Vertices[ index ] ); }
- inline const TVertex& GetVertex( const TIndex& index ) const
- { return( this->m_Vertices[ index ] ); }
- bool RenameVertex( const TIndex& old_index, const TIndex& new_index );
- void RemoveVertex( const TIndex& index );
-
- /*! \brief Edge manipulation methods.
- * Names are self-explanatory.
- */
- inline void AddEdge( const TIndex& orig, const TIndex& dest, const TCost& cost )
- { this->m_Matrix[ orig ][ dest ].push_back( cost ); }
- TEdges& GetEdges( const TIndex& orig, const TIndex& dest );
- const TEdges& GetEdges( const TIndex& orig, const TIndex& dest ) const;
- bool HasEdge( const TIndex& orig, const TIndex& dest ) const;
- void RemoveEdge( const TIndex& orig, const TIndex& dest, const TCost& cost );
- void RemoveEdges( const TIndex& orig, const TIndex& dest );
-
- /*! \brief Returns graph's sinks.
- *
- * A sink is a special vertex which does not have any "exiting" edges.
- *
- * @return Sinks ordered by their index.
- */
- std::set< TIndex, TIndexCompare > GetSinks( ) const;
-
- protected:
- Graph( );
- virtual ~Graph( );
-
- private:
- // Purposely not implemented
- Graph( const Self& other );
- Self& operator=( const Self& other );
-
- protected:
- TVertices m_Vertices;
- TMatrix m_Matrix;
- };
-
- } // ecapseman
-
-} // ecapseman
-
-#ifndef ITK_MANUAL_INSTANTIATION
-# include <fpa/Base/Graph.hxx>
-#endif // ITK_MANUAL_INSTANTIATION
-
-#endif // __fpa__Base__Graph__h__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Base__Graph__hxx__
-#define __fpa__Base__Graph__hxx__
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _TCost, class _TIndex, class _TIndexCompare >
-void fpa::Base::Graph< _TVertex, _TCost, _TIndex, _TIndexCompare >::
-Clear( )
-{
- this->m_Vertices.clear( );
- this->m_Matrix.clear( );
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _TCost, class _TIndex, class _TIndexCompare >
-bool fpa::Base::Graph< _TVertex, _TCost, _TIndex, _TIndexCompare >::
-RenameVertex( const TIndex& old_index, const TIndex& new_index )
-{
- typename TVertices::iterator old_v = this->m_Vertices.find( old_index );
- typename TVertices::iterator new_v = this->m_Vertices.find( new_index );
- if( old_v != this->m_Vertices.end( ) && new_v == this->m_Vertices.end( ) )
- {
- // Replace vertex
- this->m_Vertices[ new_index ] = old_v->second;
- this->m_Vertices.erase( old_index );
-
- // Duplicate edges
- typename TMatrix::iterator mIt = this->m_Matrix.begin( );
- typename TMatrix::iterator found_row = this->m_Matrix.end( );
- for( ; mIt != this->m_Matrix.end( ); ++mIt )
- {
- if( mIt->first == old_index )
- found_row = mIt;
-
- typename TMatrixRow::iterator rIt = mIt->second.begin( );
- for( ; rIt != mIt->second.end( ); ++rIt )
- {
- if( mIt->first == old_index )
- this->m_Matrix[ new_index ][ rIt->first ] = rIt->second;
- else if( rIt->first == old_index )
- this->m_Matrix[ mIt->first ][ new_index ] = rIt->second;
-
- } // rof
-
- } // rof
-
- // Delete old edges
- if( found_row != this->m_Matrix.end( ) )
- this->m_Matrix.erase( found_row );
-
- mIt = this->m_Matrix.begin( );
- for( ; mIt != this->m_Matrix.end( ); ++mIt )
- {
- typename TMatrixRow::iterator rIt = mIt->second.begin( );
- while( rIt != mIt->second.end( ) )
- {
- if( rIt->first == old_index )
- {
- mIt->second.erase( rIt );
- rIt = mIt->second.begin( );
- }
- else
- ++rIt;
-
- } // elihw
-
- } // rof
- return( true );
- }
- else
- return( false );
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _TCost, class _TIndex, class _TIndexCompare >
-void fpa::Base::Graph< _TVertex, _TCost, _TIndex, _TIndexCompare >::
-RemoveVertex( const TIndex& index )
-{
- typename TVertices::iterator i = this->m_Vertices.find( index );
- if( i != this->m_Vertices.end( ) )
- {
- // Delete vertex
- this->m_Vertices.erase( i );
-
- // Delete edges starting from given vertex
- typename TMatrix::iterator mIt = this->m_Matrix.find( index );
- if( mIt != this->m_Matrix.end( ) )
- this->m_Matrix.erase( mIt );
-
- // Delete edges arriving to given vertex
- mIt = this->m_Matrix.begin( );
- for( ; mIt != this->m_Matrix.end( ); ++mIt )
- {
- typename TMatrixRow::iterator rIt = mIt->second.begin( );
- while( rIt != mIt->second.end( ) )
- {
- if( rIt->first == index )
- {
- mIt->second.erase( rIt );
- rIt = mIt->second.begin( );
- }
- else
- ++rIt;
-
- } // elihw
-
- } // rof
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _TCost, class _TIndex, class _TIndexCompare >
-typename
-fpa::Base::Graph< _TVertex, _TCost, _TIndex, _TIndexCompare >::
-TEdges&
-fpa::Base::Graph< _TVertex, _TCost, _TIndex, _TIndexCompare >::
-GetEdges( const TIndex& orig, const TIndex& dest )
-{
- static TEdges null_edges;
- typename TMatrix::iterator o = this->m_Matrix.find( orig );
- if( o != this->m_Matrix.find( orig ) )
- {
- typename TMatrixRow::iterator d = o->second.find( dest );
- if( d == o->second.end( ) )
- {
- null_edges.clear( );
- return( null_edges );
- }
- else
- return( d->second );
- }
- else
- {
- null_edges.clear( );
- return( null_edges );
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _TCost, class _TIndex, class _TIndexCompare >
-const typename
-fpa::Base::Graph< _TVertex, _TCost, _TIndex, _TIndexCompare >::
-TEdges&
-fpa::Base::Graph< _TVertex, _TCost, _TIndex, _TIndexCompare >::
-GetEdges( const TIndex& orig, const TIndex& dest ) const
-{
- static const TEdges null_edges;
- typename TMatrix::iterator o = this->m_Matrix.find( orig );
- if( o != this->m_Matrix.find( orig ) )
- {
- typename TMatrixRow::iterator d = o->second.find( dest );
- if( d == o->second.end( ) )
- return( null_edges );
- else
- return( d->second );
- }
- else
- return( null_edges );
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _TCost, class _TIndex, class _TIndexCompare >
-bool fpa::Base::Graph< _TVertex, _TCost, _TIndex, _TIndexCompare >::
-HasEdge( const TIndex& orig, const TIndex& dest ) const
-{
- typename TMatrix::const_iterator mIt = this->m_Matrix.find( orig );
- if( mIt != this->m_Matrix.end( ) )
- return( mIt->second.find( dest ) != mIt->second.end( ) );
- else
- return( false );
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _TCost, class _TIndex, class _TIndexCompare >
-void fpa::Base::Graph< _TVertex, _TCost, _TIndex, _TIndexCompare >::
-RemoveEdge( const TIndex& orig, const TIndex& dest, const TCost& cost )
-{
- typename TMatrix::iterator m = this->m_Matrix.find( orig );
- if( m != this->m_Matrix.end( ) )
- {
- typename TMatrixRow::iterator r = m->second.find( dest );
- if( r != m->second.end( ) )
- {
- typename TEdges::iterator e = r->second.end( );
- for(
- typename TEdges::iterator i = r->second.begin( );
- i != r->second.end( ) && e == r->second.end( );
- ++i
- )
- if( *i == cost )
- e = i;
- if( e != r->second.end( ) )
- {
- r->second.erase( e );
- if( r->second.size( ) == 0 )
- {
- m->second.erase( r );
- if( m->second.size( ) == 0 )
- this->m_Matrix.erase( m );
-
- } // fi
-
- } // fi
-
- } // fi
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _TCost, class _TIndex, class _TIndexCompare >
-void fpa::Base::Graph< _TVertex, _TCost, _TIndex, _TIndexCompare >::
-RemoveEdges( const TIndex& orig, const TIndex& dest )
-{
- typename TMatrix::iterator m = this->m_Matrix.find( orig );
- if( m != this->m_Matrix.end( ) )
- {
- typename TMatrixRow::iterator r = m->second.find( dest );
- if( r != m->second.end( ) )
- {
- m->second.erase( r );
- if( m->second.size( ) == 0 )
- this->m_Matrix.erase( m );
-
- } // fi
-
- } // fi
-
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _TCost, class _TIndex, class _TIndexCompare >
-std::set< _TIndex, _TIndexCompare >
-fpa::Base::Graph< _TVertex, _TCost, _TIndex, _TIndexCompare >::
-GetSinks( ) const
-{
- std::set< _TIndex, _TIndexCompare > sinks;
-
- typename TVertices::iterator vIt = this->m_Vertices.begin( );
- for( ; vIt != this->m_Vertices.end( ); ++vIt )
- sinks.insert( vIt->first );
- typename TMatrix::iterator mIt = this->m_Matrix.begin( );
- for( ; mIt != this->m_Matrix.end( ); ++mIt )
- sinks.erase( mIt->first );
-
- return( sinks );
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _TCost, class _TIndex, class _TIndexCompare >
-fpa::Base::Graph< _TVertex, _TCost, _TIndex, _TIndexCompare >::
-Graph( )
- : Superclass( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _TCost, class _TIndex, class _TIndexCompare >
-fpa::Base::Graph< _TVertex, _TCost, _TIndex, _TIndexCompare >::
-~Graph( )
-{
-}
-
-#endif // __fpa__Base__Graph__hxx__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Base__MarksInterface__h__
-#define __fpa__Base__MarksInterface__h__
-
-#include <itkProcessObject.h>
-
-namespace fpa
-{
- namespace Base
- {
- /**
- */
- template< class _TVertex >
- class MarksInterface
- {
- public:
- typedef _TVertex TVertex;
- typedef MarksInterface Self;
-
- protected:
- MarksInterface( itk::ProcessObject* filter );
- virtual ~MarksInterface( );
-
- virtual bool _IsMarked( const TVertex& v ) const = 0;
- virtual unsigned long _GetMark( const TVertex& v ) const = 0;
- virtual void _Mark( const TVertex& v, unsigned long frontId ) = 0;
-
- virtual void _InitMarks( unsigned long nSeeds );
- virtual bool _Collisions( const TVertex& a, const TVertex& b );
-
- protected:
- unsigned int m_NumberOfSeeds;
- itk::ProcessObject* m_Filter;
- };
-
- } // ecapseman
-
-} // ecapseman
-
-#ifndef ITK_MANUAL_INSTANTIATION
-# include <fpa/Base/MarksInterface.hxx>
-#endif // ITK_MANUAL_INSTANTIATION
-
-#endif // __fpa__Base__MarksInterface__h__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Base__MarksInterface__hxx__
-#define __fpa__Base__MarksInterface__hxx__
-
-// -------------------------------------------------------------------------
-template< class _TVertex >
-fpa::Base::MarksInterface< _TVertex >::
-MarksInterface( itk::ProcessObject* filter )
- : m_NumberOfSeeds( 0 ),
- m_Filter( filter )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex >
-fpa::Base::MarksInterface< _TVertex >::
-~MarksInterface( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex >
-void fpa::Base::MarksInterface< _TVertex >::
-_InitMarks( unsigned long nSeeds )
-{
- this->m_NumberOfSeeds = nSeeds;
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex >
-bool fpa::Base::MarksInterface< _TVertex >::
-_Collisions( const TVertex& a, const TVertex& b )
-{
- return( false );
-}
-
-#endif // __fpa__Base__MarksInterface__hxx__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Base__MarksInterfaceWithCollisions__h__
-#define __fpa__Base__MarksInterfaceWithCollisions__h__
-
-#include <fpa/Base/MarksInterface.h>
-#include <utility>
-#include <vector>
-
-namespace fpa
-{
- namespace Base
- {
- /**
- */
- template< class _TVertex >
- class MarksInterfaceWithCollisions
- : public fpa::Base::MarksInterface< _TVertex >
- {
- public:
- typedef _TVertex TVertex;
- typedef MarksInterfaceWithCollisions Self;
- typedef fpa::Base::MarksInterface< TVertex > Superclass;
-
- // Minigraph to represent collisions
- typedef std::pair< TVertex, bool > TCollision;
- typedef std::vector< TCollision > TCollisionsRow;
- typedef std::vector< TCollisionsRow > TCollisions;
-
- public:
- bool StopAtOneFront( ) const;
- void StopAtOneFrontOn( );
- void StopAtOneFrontOff( );
- void SetStopAtOneFront( bool v );
-
- protected:
- MarksInterfaceWithCollisions( itk::ProcessObject* filter );
- virtual ~MarksInterfaceWithCollisions( );
-
- virtual void _InitMarks( unsigned long nSeeds ) override;
- virtual bool _Collisions( const TVertex& a, const TVertex& b ) override;
-
- protected:
- bool m_StopAtOneFront;
- TCollisions m_Collisions;
- unsigned int m_NumberOfFronts;
- };
-
- } // ecapseman
-
-} // ecapseman
-
-#ifndef ITK_MANUAL_INSTANTIATION
-# include <fpa/Base/MarksInterfaceWithCollisions.hxx>
-#endif // ITK_MANUAL_INSTANTIATION
-
-#endif // __fpa__Base__MarksInterfaceWithCollisions__h__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Base__MarksInterfaceWithCollisions__hxx__
-#define __fpa__Base__MarksInterfaceWithCollisions__hxx__
-
-#include <queue>
-
-// -------------------------------------------------------------------------
-template< class _TVertex >
-bool fpa::Base::MarksInterfaceWithCollisions< _TVertex >::
-StopAtOneFront( ) const
-{
- return( this->m_StopAtOneFront );
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex >
-void fpa::Base::MarksInterfaceWithCollisions< _TVertex >::
-StopAtOneFrontOn( )
-{
- this->SetStopAtOneFront( true );
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex >
-void fpa::Base::MarksInterfaceWithCollisions< _TVertex >::
-StopAtOneFrontOff( )
-{
- this->SetStopAtOneFront( false );
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex >
-void fpa::Base::MarksInterfaceWithCollisions< _TVertex >::
-SetStopAtOneFront( bool v )
-{
- if( this->m_StopAtOneFront != v )
- {
- this->m_StopAtOneFront = v;
- if( this->m_Filter != NULL )
- this->m_Filter->Modified( );
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex >
-fpa::Base::MarksInterfaceWithCollisions< _TVertex >::
-MarksInterfaceWithCollisions( itk::ProcessObject* filter )
- : Superclass( filter ),
- m_StopAtOneFront( false ),
- m_NumberOfFronts( 0 )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex >
-fpa::Base::MarksInterfaceWithCollisions< _TVertex >::
-~MarksInterfaceWithCollisions( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex >
-void fpa::Base::MarksInterfaceWithCollisions< _TVertex >::
-_InitMarks( unsigned long nSeeds )
-{
- this->Superclass::_InitMarks( nSeeds );
- this->m_NumberOfFronts = nSeeds;
- TCollision coll( TVertex( ), false );
- TCollisionsRow row( this->m_NumberOfFronts, coll );
- this->m_Collisions.clear( );
- this->m_Collisions.resize( this->m_NumberOfFronts, row );
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex >
-bool fpa::Base::MarksInterfaceWithCollisions< _TVertex >::
-_Collisions( const TVertex& a, const TVertex& b )
-{
- unsigned long ma = this->_GetMark( a );
- unsigned long mb = this->_GetMark( b );
- if( ma == mb || ma == 0 || mb == 0 )
- return( false );
-
- // Mark collision, if it is new
- ma--; mb--;
- bool ret = false;
- bool exists = this->m_Collisions[ ma ][ mb ].second;
- exists &= this->m_Collisions[ mb ][ ma ].second;
- if( !exists )
- {
- this->m_Collisions[ ma ][ mb ].first = a;
- this->m_Collisions[ ma ][ mb ].second = true;
- this->m_Collisions[ mb ][ ma ].first = b;
- this->m_Collisions[ mb ][ ma ].second = true;
-
- // Update number of fronts
- unsigned long count = 0;
- std::vector< bool > m( this->m_NumberOfSeeds, false );
- std::queue< unsigned long > q;
- q.push( 0 );
- while( !q.empty( ) )
- {
- unsigned long f = q.front( );
- q.pop( );
-
- if( m[ f ] )
- continue;
- m[ f ] = true;
- count++;
-
- for( unsigned int n = 0; n < this->m_NumberOfSeeds; ++n )
- if( this->m_Collisions[ f ][ n ].second && !m[ n ] )
- q.push( n );
-
- } // elihw
- this->m_NumberOfFronts = this->m_NumberOfSeeds - count + 1;
-
- } // fi
- return(
- this->m_StopAtOneFront &&
- this->m_NumberOfSeeds > 1 &&
- this->m_NumberOfFronts == 1
- );
-}
-
-#endif // __fpa__Base__MarksInterfaceWithCollisions__hxx__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Base__MinimumSpanningTree__h__
-#define __fpa__Base__MinimumSpanningTree__h__
-
-#include <vector>
-
-namespace fpa
-{
- namespace Base
- {
- /**
- */
- template< class _TVertex, class _Superclass >
- class MinimumSpanningTree
- : public _Superclass
- {
- public:
- typedef MinimumSpanningTree Self;
- typedef _Superclass Superclass;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
-
- typedef _TVertex TVertex;
- typedef std::pair< TVertex, bool > TCollision;
- typedef std::vector< TCollision > TCollisionsRow;
- typedef std::vector< TCollisionsRow > TCollisions;
- typedef std::vector< TVertex > TVertices;
-
- protected:
- typedef std::vector< unsigned long > _TRow;
- typedef std::vector< _TRow > _TMatrix;
-
- public:
- itkTypeMacro( fpa::Base::MinimumSpanningTree, _Superclass );
-
- public:
- const TCollisions& GetCollisions( ) const;
- void SetCollisions( const TCollisions& collisions );
-
- void ClearSeeds( );
- void AddSeed( const TVertex& seed );
-
- virtual TVertex GetParent( const TVertex& v ) const = 0;
- virtual void SetParent( const TVertex& v, const TVertex& p ) = 0;
-
- virtual TVertices GetPath( const TVertex& a ) const;
- virtual TVertices GetPath( const TVertex& a, const TVertex& b ) const;
-
- protected:
- MinimumSpanningTree( );
- virtual ~MinimumSpanningTree( );
-
- private:
- MinimumSpanningTree( const Self& other );
- Self& operator=( const Self& other );
-
- protected:
- TCollisions m_Collisions;
- _TMatrix m_FrontPaths;
- std::vector< TVertex > m_Seeds;
- };
-
- } // ecapseman
-
-} // ecapseman
-
-#ifndef ITK_MANUAL_INSTANTIATION
-# include <fpa/Base/MinimumSpanningTree.hxx>
-#endif // ITK_MANUAL_INSTANTIATION
-
-#endif // __fpa__Base__MinimumSpanningTree__h__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Base__MinimumSpanningTree__hxx__
-#define __fpa__Base__MinimumSpanningTree__hxx__
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _Superclass >
-const typename fpa::Base::MinimumSpanningTree< _TVertex, _Superclass >::
-TCollisions& fpa::Base::MinimumSpanningTree< _TVertex, _Superclass >::
-GetCollisions( ) const
-{
- return( this->m_Collisions );
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _Superclass >
-void fpa::Base::MinimumSpanningTree< _TVertex, _Superclass >::
-SetCollisions( const TCollisions& collisions )
-{
- static const unsigned long _inf =
- std::numeric_limits< unsigned long >::max( );
- if( this->m_Collisions == collisions )
- return;
-
- this->m_Collisions = collisions;
-
- // Prepare a front graph
- unsigned long N = this->m_Collisions.size( );
- _TMatrix dist( N, _TRow( N, _inf ) );
- this->m_FrontPaths = dist;
- for( unsigned long i = 0; i < N; ++i )
- {
- for( unsigned long j = 0; j < N; ++j )
- {
- if( this->m_Collisions[ i ][ j ].second )
- {
- dist[ i ][ j ] = 1;
- dist[ j ][ i ] = 1;
- this->m_FrontPaths[ i ][ j ] = j;
- this->m_FrontPaths[ j ][ i ] = i;
-
- } // fi
-
- } // rof
- dist[ i ][ i ] = 0;
- this->m_FrontPaths[ i ][ i ] = i;
-
- } // rof
-
- // Use Floyd-Warshall to compute all possible paths between fronts
- for( unsigned long k = 0; k < N; ++k )
- {
- for( unsigned long i = 0; i < N; ++i )
- {
- for( unsigned long j = 0; j < N; ++j )
- {
- // WARNING: you don't want a numeric overflow!!!
- unsigned long dik = dist[ i ][ k ];
- unsigned long dkj = dist[ k ][ j ];
- unsigned long sum = _inf;
- if( dik < _inf && dkj < _inf )
- sum = dik + dkj;
-
- // Ok, continue Floyd-Warshall
- if( sum < dist[ i ][ j ] )
- {
- dist[ i ][ j ] = sum;
- this->m_FrontPaths[ i ][ j ] = this->m_FrontPaths[ i ][ k ];
-
- } // fi
-
- } // rof
-
- } // rof
-
- } // rof
- this->Modified( );
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _Superclass >
-void fpa::Base::MinimumSpanningTree< _TVertex, _Superclass >::
-ClearSeeds( )
-{
- this->m_Seeds.clear( );
- this->Modified( );
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _Superclass >
-void fpa::Base::MinimumSpanningTree< _TVertex, _Superclass >::
-AddSeed( const _TVertex& seed )
-{
- this->m_Seeds.push_back( seed );
- this->Modified( );
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _Superclass >
-typename fpa::Base::MinimumSpanningTree< _TVertex, _Superclass >::
-TVertices fpa::Base::MinimumSpanningTree< _TVertex, _Superclass >::
-GetPath( const _TVertex& a ) const
-{
- TVertices vertices;
- _TVertex it = a;
- _TVertex p = this->GetParent( it );
- while( it != p )
- {
- vertices.push_back( it );
- it = p;
- p = this->GetParent( it );
-
- } // elihw
- vertices.push_back( it );
- return( vertices );
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _Superclass >
-typename fpa::Base::MinimumSpanningTree< _TVertex, _Superclass >::
-TVertices fpa::Base::MinimumSpanningTree< _TVertex, _Superclass >::
-GetPath( const _TVertex& a, const _TVertex& b ) const
-{
- static const unsigned long _inf =
- std::numeric_limits< unsigned long >::max( );
-
- TVertices vertices;
- TVertices pa = this->GetPath( a );
- TVertices pb = this->GetPath( b );
- if( pa.size( ) > 0 && pb.size( ) > 0 )
- {
- // Find front identifiers
- unsigned long ia = _inf, ib = _inf;
- unsigned long N = this->m_Seeds.size( );
- for( unsigned long i = 0; i < N; ++i )
- {
- if( this->m_Seeds[ i ] == pa[ pa.size( ) - 1 ] )
- ia = i;
- if( this->m_Seeds[ i ] == pb[ pb.size( ) - 1 ] )
- ib = i;
-
- } // rof
-
- // Check if there is a front-jump between given seeds
- if( ia != ib )
- {
- // Compute front path
- std::vector< long > fpath;
- fpath.push_back( ia );
- while( ia != ib )
- {
- ia = this->m_FrontPaths[ ia ][ ib ];
- fpath.push_back( ia );
-
- } // elihw
-
- // Continue only if both fronts are connected
- unsigned int N = fpath.size( );
- if( N > 0 )
- {
- // First path: from start vertex to first collision
- vertices = this->GetPath(
- a, this->m_Collisions[ fpath[ 0 ] ][ fpath[ 1 ] ].first
- );
-
- // Intermediary paths
- for( unsigned int i = 1; i < N - 1; ++i )
- {
- TVertices ipath =
- this->GetPath(
- this->m_Collisions[ fpath[ i - 1 ] ][ fpath[ i ] ].first,
- this->m_Collisions[ fpath[ i + 1 ] ][ fpath[ i ] ].first
- );
- for( long id = 0; id < ipath.size( ); ++id )
- vertices.push_back( ipath[ id ] );
-
- } // rof
-
- // Final path: from last collision to end point
- TVertices lpath =
- this->GetPath(
- this->m_Collisions[ fpath[ N - 1 ] ][ fpath[ N - 2 ] ].first, b
- );
- for( long id = 0; id < lpath.size( ); ++id )
- vertices.push_back( lpath[ id ] );
-
- } // fi
- }
- else
- {
- // Ignore common part: find common ancestor
- long aIt = pa.size( ) - 1;
- long bIt = pb.size( ) - 1;
- bool cont = true;
- while( aIt >= 0 && bIt >= 0 && cont )
- {
- cont = ( pa[ aIt ] == pb[ bIt ] );
- aIt--;
- bIt--;
-
- } // elihw
- aIt++;
- bIt++;
-
- // Glue both parts
- for( long cIt = 0; cIt <= aIt; ++cIt )
- vertices.push_back( pa[ cIt ] );
- for( ; bIt >= 0; --bIt )
- vertices.push_back( pb[ bIt ] );
-
- } // fi
-
- } // fi
- return( vertices );
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _Superclass >
-fpa::Base::MinimumSpanningTree< _TVertex, _Superclass >::
-MinimumSpanningTree( )
- : Superclass( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _Superclass >
-fpa::Base::MinimumSpanningTree< _TVertex, _Superclass >::
-~MinimumSpanningTree( )
-{
-}
-
-#endif // __fpa__Base__MinimumSpanningTree__hxx__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Base__Mori__h__
-#define __fpa__Base__Mori__h__
-
-#include <deque>
-#include <set>
-#include <itkConceptChecking.h>
-#include <itkFunctionBase.h>
-
-#include <ivq/ITK/PeakDetector.h>
-#include <fpa/Base/Functors/RegionGrow/BinaryThreshold.h>
-
-namespace fpa
-{
- namespace Base
- {
- /**
- */
- template< class _TAlgorithm >
- class Mori
- : public _TAlgorithm
- {
- public:
- typedef Mori Self;
- typedef _TAlgorithm Superclass;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
-
- typedef typename _TAlgorithm::TNode TNode;
- typedef typename _TAlgorithm::TNodes TNodes;
- typedef typename _TAlgorithm::TInputValue TInputValue;
- typedef typename _TAlgorithm::TOutputValue TOutputValue;
- typedef typename _TAlgorithm::TFrontId TFrontId;
- typedef typename _TAlgorithm::TVertex TVertex;
-
- typedef std::deque< TNode > TQueue;
- typedef std::set< TInputValue > TThresholds;
-
- typedef ivq::ITK::PeakDetector TPeakDetector;
- typedef TPeakDetector::TPeak TPeak;
-
- typedef fpa::Base::Functors::RegionGrow::BinaryThreshold< TInputValue > TPredicate;
-
- public:
- itkConceptMacro(
- Check_TOutputValue,
- ( itk::Concept::IsUnsignedInteger< TOutputValue > )
- );
-
- itkGetConstMacro( InsideValue, TOutputValue );
- itkSetMacro( InsideValue, TOutputValue );
-
- itkGetConstMacro( MinimumThreshold, TInputValue );
- itkSetMacro( MinimumThreshold, TInputValue );
-
- public:
- virtual itk::ModifiedTimeType GetMTime( ) const override;
-
- TOutputValue GetOutsideValue( ) const;
- void SetOutsideValue( const TOutputValue& v );
-
- unsigned long GetSignalKernelSize( ) const;
- double GetSignalThreshold( ) const;
- double GetSignalInfluence( ) const;
-
- void SetSignalKernelSize( unsigned long k );
- void SetSignalThreshold( double t );
- void SetSignalInfluence( double i );
-
- void ClearThresholds( );
- void AddThreshold( const TInputValue& thr );
- void SetThresholds(
- const TInputValue& init,
- const TInputValue& end,
- const TInputValue& delta
- );
- const TThresholds& GetThresholds( ) const;
- unsigned long GetNumberOfEvaluatedThresholds( ) const;
- TInputValue GetOptimumThreshold( ) const;
- void GetSignalValues(
- unsigned long i, double& x, double& y, TPeak& p
- ) const;
-
- protected:
- Mori( );
- virtual ~Mori( );
-
- virtual void _BeforeGenerateData( ) override;
- virtual void _FinishOneLoop( ) override;
- virtual void _ComputeOutputValue( TNode& n ) override;
- virtual void _UpdateOutputValue( TNode& n ) override;
- virtual void _QueueClear( ) override;
- virtual TNode _QueuePop( ) override;
- virtual void _QueuePush( const TNode& node ) override;
- virtual unsigned long _QueueSize( ) const override;
- virtual void _PrepareSeeds( TNodes& nodes ) override;
-
- private:
- // Purposely not implemented.
- Mori( const Self& other );
- Self& operator=( const Self& other );
-
- protected:
- typename TPredicate::Pointer m_Predicate;
-
- TOutputValue m_InsideValue;
- TInputValue m_MinimumThreshold;
- TThresholds m_Thresholds;
- typename TThresholds::const_iterator m_CurrThr;
-
- TQueue m_Queues[ 2 ];
- unsigned int m_CurrQueue;
- double m_CurrCount;
-
- TPeakDetector m_PeakDetector;
- };
-
- } // ecapseman
-
-} // ecapseman
-
-#ifndef ITK_MANUAL_INSTANTIATION
-# include <fpa/Base/Mori.hxx>
-#endif // ITK_MANUAL_INSTANTIATION
-
-#endif // __fpa__Base__Mori__h__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Base__Mori__hxx__
-#define __fpa__Base__Mori__hxx__
-
-// -------------------------------------------------------------------------
-template< class _TAlgorithm >
-itk::ModifiedTimeType fpa::Base::Mori< _TAlgorithm >::
-GetMTime( ) const
-{
- itk::ModifiedTimeType t = this->Superclass::GetMTime( );
- itk::ModifiedTimeType q = this->m_Predicate->GetMTime( );
- return( ( q < t )? q: t );
-}
-
-// -------------------------------------------------------------------------
-template< class _TAlgorithm >
-typename fpa::Base::Mori< _TAlgorithm >::
-TOutputValue fpa::Base::Mori< _TAlgorithm >::
-GetOutsideValue( ) const
-{
- return( this->GetInitValue( ) );
-}
-
-// -------------------------------------------------------------------------
-template< class _TAlgorithm >
-void fpa::Base::Mori< _TAlgorithm >::
-SetOutsideValue( const TOutputValue& v )
-{
- this->SetInitValue( v );
-}
-
-// -------------------------------------------------------------------------
-template< class _TAlgorithm >
-unsigned long fpa::Base::Mori< _TAlgorithm >::
-GetSignalKernelSize( ) const
-{
- return( this->m_PeakDetector.GetKernelSize( ) );
-}
-
-// -------------------------------------------------------------------------
-template< class _TAlgorithm >
-double fpa::Base::Mori< _TAlgorithm >::
-GetSignalThreshold( ) const
-{
- return( this->m_PeakDetector.GetThreshold( ) );
-}
-
-// -------------------------------------------------------------------------
-template< class _TAlgorithm >
-double fpa::Base::Mori< _TAlgorithm >::
-GetSignalInfluence( ) const
-{
- return( this->m_PeakDetector.GetInfluence( ) );
-}
-
-// -------------------------------------------------------------------------
-template< class _TAlgorithm >
-void fpa::Base::Mori< _TAlgorithm >::
-SetSignalKernelSize( unsigned long k )
-{
- this->m_PeakDetector.SetKernelSize( k );
- this->Modified( );
-}
-
-// -------------------------------------------------------------------------
-template< class _TAlgorithm >
-void fpa::Base::Mori< _TAlgorithm >::
-SetSignalThreshold( double t )
-{
- this->m_PeakDetector.SetThreshold( t );
- this->Modified( );
-}
-
-// -------------------------------------------------------------------------
-template< class _TAlgorithm >
-void fpa::Base::Mori< _TAlgorithm >::
-SetSignalInfluence( double i )
-{
- this->m_PeakDetector.SetInfluence( i );
- this->Modified( );
-}
-
-// -------------------------------------------------------------------------
-template< class _TAlgorithm >
-void fpa::Base::Mori< _TAlgorithm >::
-ClearThresholds( )
-{
- this->m_Thresholds.clear( );
- this->Modified( );
-}
-
-// -------------------------------------------------------------------------
-template< class _TAlgorithm >
-void fpa::Base::Mori< _TAlgorithm >::
-AddThreshold( const TInputValue& thr )
-{
- if( this->m_Thresholds.insert( thr ).second )
- this->Modified( );
-}
-
-// -------------------------------------------------------------------------
-template< class _TAlgorithm >
-void fpa::Base::Mori< _TAlgorithm >::
-SetThresholds(
- const TInputValue& init,
- const TInputValue& end,
- const TInputValue& delta
- )
-{
- for( TInputValue thr = init; thr <= end; thr += delta )
- this->AddThreshold( thr );
-}
-
-// -------------------------------------------------------------------------
-template< class _TAlgorithm >
-const typename fpa::Base::Mori< _TAlgorithm >::
-TThresholds& fpa::Base::Mori< _TAlgorithm >::
-GetThresholds( ) const
-{
- return( this->m_Thresholds );
-}
-
-// -------------------------------------------------------------------------
-template< class _TAlgorithm >
-unsigned long fpa::Base::Mori< _TAlgorithm >::
-GetNumberOfEvaluatedThresholds( ) const
-{
- return( this->m_PeakDetector.GetNumberOfSamples( ) );
-}
-
-// -------------------------------------------------------------------------
-template< class _TAlgorithm >
-typename fpa::Base::Mori< _TAlgorithm >::
-TInputValue fpa::Base::Mori< _TAlgorithm >::
-GetOptimumThreshold( ) const
-{
- TInputValue thr = TInputValue( 0 );
- unsigned long n = this->m_PeakDetector.GetNumberOfSamples( );
- if( n > 1 )
- thr = TInputValue( this->m_PeakDetector.GetXValues( )[ n - 2 ] );
- return( thr );
-}
-
-// -------------------------------------------------------------------------
-template< class _TAlgorithm >
-void fpa::Base::Mori< _TAlgorithm >::
-GetSignalValues( unsigned long i, double& x, double& y, TPeak& p ) const
-{
- if( i < this->m_PeakDetector.GetNumberOfSamples( ) )
- {
- x = this->m_PeakDetector.GetXValues( )[ i ];
- y = this->m_PeakDetector.GetYValues( )[ i ];
- p = this->m_PeakDetector.GetPeaks( )[ i ];
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-template< class _TAlgorithm >
-fpa::Base::Mori< _TAlgorithm >::
-Mori( )
- : Superclass( ),
- m_InsideValue( TOutputValue( 1 ) )
-{
- this->SetInitValue( TOutputValue( 0 ) );
- this->m_Predicate = TPredicate::New( );
- this->m_Predicate->StrictOff( );
- if( std::numeric_limits< TInputValue >::is_integer )
- this->m_MinimumThreshold = std::numeric_limits< TInputValue >::min( );
- else
- this->m_MinimumThreshold = -std::numeric_limits< TInputValue >::max( );
- this->m_PeakDetector.SetKernelSize( 20 );
- this->m_PeakDetector.SetThreshold( 500 );
- this->m_PeakDetector.SetInfluence( 0.5 );
-}
-
-// -------------------------------------------------------------------------
-template< class _TAlgorithm >
-fpa::Base::Mori< _TAlgorithm >::
-~Mori( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TAlgorithm >
-void fpa::Base::Mori< _TAlgorithm >::
-_BeforeGenerateData( )
-{
- this->Superclass::_BeforeGenerateData( );
-
- // Prepare queues
- this->_QueueClear( );
- this->m_CurrQueue = 0;
-
- // Prepare iteration over all thresholds
- this->m_CurrThr = this->m_Thresholds.begin( );
- this->m_Predicate->SetLower( *( this->m_CurrThr ) );
- this->m_CurrThr++;
- this->m_Predicate->SetUpper( *( this->m_CurrThr ) );
-
- // Prepare counting signal
- this->m_CurrCount = double( 0 );
- this->m_PeakDetector.Clear( );
-}
-
-// -------------------------------------------------------------------------
-template< class _TAlgorithm >
-void fpa::Base::Mori< _TAlgorithm >::
-_FinishOneLoop( )
-{
- if( this->m_Queues[ this->m_CurrQueue ].size( ) == 0 )
- {
- // Update peak detector
- TPeak p = this->m_PeakDetector.AddValue(
- *this->m_CurrThr, this->m_CurrCount
- );
- this->m_CurrThr++;
- this->m_CurrQueue = ( this->m_CurrQueue + 1 ) % 2;
- if( this->m_CurrThr != this->m_Thresholds.end( ) )
- {
- // Update predicate and counting value
- this->m_Predicate->SetUpper( *( this->m_CurrThr ) );
- this->m_CurrCount = double( 0 );
-
- // Peak detected? -> stop!
- if(
- p == TPeakDetector::PosPeak &&
- this->m_MinimumThreshold < *( this->m_CurrThr )
- )
- this->_QueueClear( );
- }
- else
- this->_QueueClear( );
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-template< class _TAlgorithm >
-void fpa::Base::Mori< _TAlgorithm >::
-_ComputeOutputValue( TNode& n )
-{
- // Do nothing!!!
-}
-
-// -------------------------------------------------------------------------
-template< class _TAlgorithm >
-void fpa::Base::Mori< _TAlgorithm >::
-_UpdateOutputValue( TNode& n )
-{
- TInputValue value = this->_GetInputValue( n.Vertex );
- bool inside = this->m_Predicate->Evaluate( value );
- if( !inside )
- {
- n.Value = this->m_InitValue;
- n.FrontId++;
- this->m_Queues[ ( this->m_CurrQueue + 1 ) % 2 ].push_back( n );
- n.FrontId = 0;
- }
- else
- {
- n.Value = this->m_InsideValue;
- this->m_CurrCount += double( 1 );
-
- } // fi
- this->Superclass::_UpdateOutputValue( n );
-}
-
-// -------------------------------------------------------------------------
-template< class _TAlgorithm >
-void fpa::Base::Mori< _TAlgorithm >::
-_QueueClear( )
-{
- this->m_Queues[ 0 ].clear( );
- this->m_Queues[ 1 ].clear( );
-}
-
-// -------------------------------------------------------------------------
-template< class _TAlgorithm >
-typename fpa::Base::Mori< _TAlgorithm >::
-TNode fpa::Base::Mori< _TAlgorithm >::
-_QueuePop( )
-{
- TNode n = this->m_Queues[ this->m_CurrQueue ].front( );
- this->m_Queues[ this->m_CurrQueue ].pop_front( );
- return( n );
-}
-
-// -------------------------------------------------------------------------
-template< class _TAlgorithm >
-void fpa::Base::Mori< _TAlgorithm >::
-_QueuePush( const TNode& node )
-{
- this->m_Queues[ this->m_CurrQueue ].push_back( node );
-}
-
-// -------------------------------------------------------------------------
-template< class _TAlgorithm >
-unsigned long fpa::Base::Mori< _TAlgorithm >::
-_QueueSize( ) const
-{
- return( this->m_Queues[ this->m_CurrQueue ].size( ) );
-}
-
-// -------------------------------------------------------------------------
-template< class _TAlgorithm >
-void fpa::Base::Mori< _TAlgorithm >::
-_PrepareSeeds( TNodes& nodes )
-{
- typename TNodes::iterator nIt = nodes.begin( );
- for( ; nIt != nodes.end( ); ++nIt )
- nIt->Value = this->m_InitValue;
-}
-
-#endif // __fpa__Base__Mori__hxx__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Base__RegionGrow__h__
-#define __fpa__Base__RegionGrow__h__
-
-#include <deque>
-
-#include <itkConceptChecking.h>
-#include <itkFunctionBase.h>
-
-namespace fpa
-{
- namespace Base
- {
- /**
- */
- template< class _TAlgorithm >
- class RegionGrow
- : public _TAlgorithm
- {
- public:
- typedef RegionGrow Self;
- typedef _TAlgorithm Superclass;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
-
- typedef typename _TAlgorithm::TNode TNode;
- typedef typename _TAlgorithm::TNodes TNodes;
- typedef typename _TAlgorithm::TInputValue TInputValue;
- typedef typename _TAlgorithm::TOutputValue TOutputValue;
- typedef typename _TAlgorithm::TFrontId TFrontId;
- typedef typename _TAlgorithm::TVertex TVertex;
-
- typedef std::deque< TNode > TQueue;
- typedef itk::FunctionBase< TInputValue, bool > TValuePredicate;
- typedef itk::FunctionBase< TVertex, bool > TVertexPredicate;
-
- public:
- itkConceptMacro(
- Check_TOutputValue,
- ( itk::Concept::IsUnsignedInteger< TOutputValue > )
- );
-
- public:
- itkGetObjectMacro( ValuePredicate, TValuePredicate );
- itkGetObjectMacro( VertexPredicate, TVertexPredicate );
- itkGetConstMacro( InsideValue, TOutputValue );
-
- itkSetMacro( InsideValue, TOutputValue );
-
- public:
- virtual itk::ModifiedTimeType GetMTime( ) const override;
- virtual TOutputValue GetOutsideValue( ) const;
- virtual void SetOutsideValue( const TOutputValue& v );
-
- void SetPredicate( TValuePredicate* p );
- void SetPredicate( TVertexPredicate* p );
-
- protected:
- RegionGrow( );
- virtual ~RegionGrow( );
-
- virtual void _ComputeOutputValue( TNode& n ) override;
- virtual void _UpdateOutputValue( TNode& n ) override;
- virtual void _QueueClear( ) override;
- virtual TNode _QueuePop( ) override;
- virtual void _QueuePush( const TNode& node ) override;
- virtual unsigned long _QueueSize( ) const override;
- virtual void _PrepareSeeds( TNodes& nodes ) override;
-
- private:
- // Purposely not implemented.
- RegionGrow( const Self& other );
- Self& operator=( const Self& other );
-
- protected:
- typename TValuePredicate::Pointer m_ValuePredicate;
- typename TVertexPredicate::Pointer m_VertexPredicate;
-
- TOutputValue m_InsideValue;
-
- TQueue m_Queue;
- };
-
- } // ecapseman
-
-} // ecapseman
-
-#ifndef ITK_MANUAL_INSTANTIATION
-# include <fpa/Base/RegionGrow.hxx>
-#endif // ITK_MANUAL_INSTANTIATION
-
-#endif // __fpa__Base__RegionGrow__h__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Base__RegionGrow__hxx__
-#define __fpa__Base__RegionGrow__hxx__
-
-// -------------------------------------------------------------------------
-template< class _TAlgorithm >
-itk::ModifiedTimeType fpa::Base::RegionGrow< _TAlgorithm >::
-GetMTime( ) const
-{
- itk::ModifiedTimeType t = this->Superclass::GetMTime( );
- if( this->m_ValuePredicate.IsNotNull( ) )
- {
- itk::ModifiedTimeType q = this->m_ValuePredicate->GetMTime( );
- t = ( q < t )? q: t;
-
- } // fi
- if( this->m_VertexPredicate.IsNotNull( ) )
- {
- itk::ModifiedTimeType q = this->m_VertexPredicate->GetMTime( );
- t = ( q < t )? q: t;
-
- } // fi
-
- return( t );
-}
-
-// -------------------------------------------------------------------------
-template< class _TAlgorithm >
-typename fpa::Base::RegionGrow< _TAlgorithm >::
-TOutputValue fpa::Base::RegionGrow< _TAlgorithm >::
-GetOutsideValue( ) const
-{
- return( this->GetInitValue( ) );
-}
-
-// -------------------------------------------------------------------------
-template< class _TAlgorithm >
-void fpa::Base::RegionGrow< _TAlgorithm >::
-SetOutsideValue( const TOutputValue& v )
-{
- this->SetInitValue( v );
-}
-
-// -------------------------------------------------------------------------
-template< class _TAlgorithm >
-void fpa::Base::RegionGrow< _TAlgorithm >::
-SetPredicate( TValuePredicate* p )
-{
- if( this->m_ValuePredicate.GetPointer( ) != p )
- {
- this->m_ValuePredicate = p;
- this->Modified( );
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-template< class _TAlgorithm >
-void fpa::Base::RegionGrow< _TAlgorithm >::
-SetPredicate( TVertexPredicate* p )
-{
- if( this->m_VertexPredicate.GetPointer( ) != p )
- {
- this->m_VertexPredicate = p;
- this->Modified( );
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-template< class _TAlgorithm >
-fpa::Base::RegionGrow< _TAlgorithm >::
-RegionGrow( )
- : Superclass( ),
- m_InsideValue( TOutputValue( 1 ) )
-{
- this->SetInitValue( TOutputValue( 0 ) );
-}
-
-// -------------------------------------------------------------------------
-template< class _TAlgorithm >
-fpa::Base::RegionGrow< _TAlgorithm >::
-~RegionGrow( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TAlgorithm >
-void fpa::Base::RegionGrow< _TAlgorithm >::
-_ComputeOutputValue( TNode& n )
-{
- // Do nothing!!!
-}
-
-// -------------------------------------------------------------------------
-template< class _TAlgorithm >
-void fpa::Base::RegionGrow< _TAlgorithm >::
-_UpdateOutputValue( TNode& n )
-{
- TInputValue value = this->_GetInputValue( n.Vertex );
- bool inside = false;
- if( this->m_ValuePredicate.IsNotNull( ) )
- inside = this->m_ValuePredicate->Evaluate( value );
- if( this->m_VertexPredicate.IsNotNull( ) )
- inside &= this->m_VertexPredicate->Evaluate( n.Vertex );
- if( !inside )
- {
- n.Value = this->m_InitValue;
- n.FrontId = 0;
- }
- else
- n.Value = this->m_InsideValue;
- this->Superclass::_UpdateOutputValue( n );
-}
-
-// -------------------------------------------------------------------------
-template< class _TAlgorithm >
-void fpa::Base::RegionGrow< _TAlgorithm >::
-_QueueClear( )
-{
- this->m_Queue.clear( );
-}
-
-// -------------------------------------------------------------------------
-template< class _TAlgorithm >
-typename fpa::Base::RegionGrow< _TAlgorithm >::
-TNode fpa::Base::RegionGrow< _TAlgorithm >::
-_QueuePop( )
-{
- TNode n = this->m_Queue.front( );
- this->m_Queue.pop_front( );
- return( n );
-}
-
-// -------------------------------------------------------------------------
-template< class _TAlgorithm >
-void fpa::Base::RegionGrow< _TAlgorithm >::
-_QueuePush( const TNode& node )
-{
- this->m_Queue.push_back( node );
-}
-
-// -------------------------------------------------------------------------
-template< class _TAlgorithm >
-unsigned long fpa::Base::RegionGrow< _TAlgorithm >::
-_QueueSize( ) const
-{
- return( this->m_Queue.size( ) );
-}
-
-// -------------------------------------------------------------------------
-template< class _TAlgorithm >
-void fpa::Base::RegionGrow< _TAlgorithm >::
-_PrepareSeeds( TNodes& nodes )
-{
- typename TNodes::iterator nIt = nodes.begin( );
- for( ; nIt != nodes.end( ); ++nIt )
- nIt->Value = this->m_InitValue;
-}
-
-#endif // __fpa__Base__RegionGrow__hxx__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Base__SeedsInterface__h__
-#define __fpa__Base__SeedsInterface__h__
-
-#include <functional>
-#include <set>
-#include <vector>
-
-#include <itkConceptChecking.h>
-#include <itkProcessObject.h>
-
-namespace fpa
-{
- namespace Base
- {
- /**
- */
- template< class _TVertex, class _TPoint, class _TInputValue, class _TOutputValue, class _TFrontId, class _TCompare = std::greater< _TVertex > >
- class SeedsInterface
- {
- public:
- itkConceptMacro(
- Check_TFrontId,
- ( itk::Concept::IsUnsignedInteger< _TFrontId > )
- );
-
- public:
- typedef _TVertex TVertex;
- typedef _TPoint TPoint;
- typedef _TInputValue TInputValue;
- typedef _TOutputValue TOutputValue;
- typedef _TFrontId TFrontId;
- typedef _TCompare TCompare;
- typedef SeedsInterface Self;
-
- struct TSeed
- {
- TVertex Vertex;
- TPoint Point;
- bool IsPoint;
- bool IsUnified;
- TFrontId FrontId;
- TSeed( )
- : IsUnified( false ),
- FrontId( TFrontId( 0 ) )
- { }
- };
- typedef std::vector< TSeed > TSeeds;
-
- struct TNode
- {
- TVertex Vertex;
- TVertex Parent;
- TFrontId FrontId;
-
- // Hack to hide the fact that seed values need to be initialized
- mutable TOutputValue Value;
- };
- struct TNodeCompare
- {
- bool operator()( const TNode& a, const TNode& b ) const
- {
- TCompare cmp;
- return( cmp( a.Vertex, b.Vertex ) );
- }
- };
- typedef std::set< TNode, TNodeCompare > TNodes;
-
- public:
- TSeeds& GetSeeds( );
- const TSeeds& GetSeeds( ) const;
-
- virtual void AddSeed( const TVertex& seed );
- virtual void AddSeed( const TPoint& seed );
- virtual void ClearSeeds( );
-
- protected:
- SeedsInterface( itk::ProcessObject* filter );
- virtual ~SeedsInterface( );
-
- virtual TNodes _UnifySeeds( ) = 0;
- virtual void _PrepareSeeds( TNodes& nodes ) = 0;
-
- protected:
- TSeeds m_Seeds;
- itk::ProcessObject* m_Filter;
- };
-
- } // ecapseman
-
-} // ecapseman
-
-#ifndef ITK_MANUAL_INSTANTIATION
-# include <fpa/Base/SeedsInterface.hxx>
-#endif // ITK_MANUAL_INSTANTIATION
-
-#endif // __fpa__Base__SeedsInterface__h__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Base__SeedsInterface__hxx__
-#define __fpa__Base__SeedsInterface__hxx__
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _TPoint, class _TInputValue, class _TOutputValue, class _TFrontId, class _TCompare >
-typename
-fpa::Base::SeedsInterface< _TVertex, _TPoint, _TInputValue, _TOutputValue, _TFrontId, _TCompare >::
-TSeeds&
-fpa::Base::SeedsInterface< _TVertex, _TPoint, _TInputValue, _TOutputValue, _TFrontId, _TCompare >::
-GetSeeds( )
-{
- return( this->m_Seeds );
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _TPoint, class _TInputValue, class _TOutputValue, class _TFrontId, class _TCompare >
-const typename
-fpa::Base::SeedsInterface< _TVertex, _TPoint, _TInputValue, _TOutputValue, _TFrontId, _TCompare >::
-TSeeds&
-fpa::Base::SeedsInterface< _TVertex, _TPoint, _TInputValue, _TOutputValue, _TFrontId, _TCompare >::
-GetSeeds( ) const
-{
- return( this->m_Seeds );
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _TPoint, class _TInputValue, class _TOutputValue, class _TFrontId, class _TCompare >
-void
-fpa::Base::SeedsInterface< _TVertex, _TPoint, _TInputValue, _TOutputValue, _TFrontId, _TCompare >::
-AddSeed( const TVertex& seed )
-{
- TSeed s;
- s.Vertex = seed;
- s.IsPoint = false;
- this->m_Seeds.push_back( s );
- if( this->m_Filter != NULL )
- this->m_Filter->Modified( );
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _TPoint, class _TInputValue, class _TOutputValue, class _TFrontId, class _TCompare >
-void
-fpa::Base::SeedsInterface< _TVertex, _TPoint, _TInputValue, _TOutputValue, _TFrontId, _TCompare >::
-AddSeed( const TPoint& seed )
-{
- TSeed s;
- s.Point = seed;
- s.IsPoint = true;
- this->m_Seeds.push_back( s );
- if( this->m_Filter != NULL )
- this->m_Filter->Modified( );
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _TPoint, class _TInputValue, class _TOutputValue, class _TFrontId, class _TCompare >
-void
-fpa::Base::SeedsInterface< _TVertex, _TPoint, _TInputValue, _TOutputValue, _TFrontId, _TCompare >::
-ClearSeeds( )
-{
- if( this->m_Seeds.size( ) > 0 )
- {
- this->m_Seeds.clear( );
- if( this->m_Filter != NULL )
- this->m_Filter->Modified( );
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _TPoint, class _TInputValue, class _TOutputValue, class _TFrontId, class _TCompare >
-fpa::Base::SeedsInterface< _TVertex, _TPoint, _TInputValue, _TOutputValue, _TFrontId, _TCompare >::
-SeedsInterface( itk::ProcessObject* filter )
- : m_Filter( filter )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _TPoint, class _TInputValue, class _TOutputValue, class _TFrontId, class _TCompare >
-fpa::Base::SeedsInterface< _TVertex, _TPoint, _TInputValue, _TOutputValue, _TFrontId, _TCompare >::
-~SeedsInterface( )
-{
- this->m_Seeds.clear( );
-}
-
-#endif // __fpa__Base__SeedsInterface__hxx__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Base__SingleSeedInterface__h__
-#define __fpa__Base__SingleSeedInterface__h__
-
-#include <functional>
-#include <set>
-#include <vector>
-
-#include <itkConceptChecking.h>
-#include <itkProcessObject.h>
-
-namespace fpa
-{
- namespace Base
- {
- /**
- */
- template< class _TVertex, class _TPoint, class _TInputValue, class _TOutputValue, class _TFrontId, class _TCompare = std::greater< _TVertex > >
- class SingleSeedInterface
- {
- public:
- itkConceptMacro(
- Check_TFrontId,
- ( itk::Concept::IsUnsignedInteger< _TFrontId > )
- );
-
- public:
- typedef _TVertex TVertex;
- typedef _TPoint TPoint;
- typedef _TInputValue TInputValue;
- typedef _TOutputValue TOutputValue;
- typedef _TFrontId TFrontId;
- typedef _TCompare TCompare;
- typedef SingleSeedInterface Self;
-
- struct TSeed
- {
- TVertex Vertex;
- TPoint Point;
- bool IsPoint;
- bool IsUnified;
- TFrontId FrontId;
- TSeed( )
- : IsUnified( false ),
- FrontId( TFrontId( 0 ) )
- { }
- };
- typedef std::vector< TSeed > TSeeds;
-
- struct TNode
- {
- TVertex Vertex;
- TVertex Parent;
- TFrontId FrontId;
-
- // Hack to hide the fact that seed values need to be initialized
- mutable TOutputValue Value;
- };
- struct TNodeCompare
- {
- bool operator()( const TNode& a, const TNode& b ) const
- {
- TCompare cmp;
- return( cmp( a.Vertex, b.Vertex ) );
- }
- };
- typedef std::set< TNode, TNodeCompare > TNodes;
-
- public:
- TSeeds& GetSeeds( );
- const TSeeds& GetSeeds( ) const;
-
- virtual void SetSeed( const TVertex& seed );
- virtual void SetSeed( const TPoint& seed );
-
- protected:
- SingleSeedInterface( itk::ProcessObject* filter );
- virtual ~SingleSeedInterface( );
-
- virtual TNodes _UnifySeeds( ) = 0;
- virtual void _PrepareSeeds( TNodes& nodes ) = 0;
-
- protected:
- TSeeds m_Seeds;
- itk::ProcessObject* m_Filter;
- };
-
- } // ecapseman
-
-} // ecapseman
-
-#ifndef ITK_MANUAL_INSTANTIATION
-# include <fpa/Base/SingleSeedInterface.hxx>
-#endif // ITK_MANUAL_INSTANTIATION
-
-#endif // __fpa__Base__SingleSeedInterface__h__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Base__SingleSeedInterface__hxx__
-#define __fpa__Base__SingleSeedInterface__hxx__
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _TPoint, class _TInputValue, class _TOutputValue, class _TFrontId, class _TCompare >
-typename
-fpa::Base::SingleSeedInterface< _TVertex, _TPoint, _TInputValue, _TOutputValue, _TFrontId, _TCompare >::
-TSeeds&
-fpa::Base::SingleSeedInterface< _TVertex, _TPoint, _TInputValue, _TOutputValue, _TFrontId, _TCompare >::
-GetSeeds( )
-{
- return( this->m_Seeds );
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _TPoint, class _TInputValue, class _TOutputValue, class _TFrontId, class _TCompare >
-const typename
-fpa::Base::SingleSeedInterface< _TVertex, _TPoint, _TInputValue, _TOutputValue, _TFrontId, _TCompare >::
-TSeeds&
-fpa::Base::SingleSeedInterface< _TVertex, _TPoint, _TInputValue, _TOutputValue, _TFrontId, _TCompare >::
-GetSeeds( ) const
-{
- return( this->m_Seeds );
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _TPoint, class _TInputValue, class _TOutputValue, class _TFrontId, class _TCompare >
-void
-fpa::Base::SingleSeedInterface< _TVertex, _TPoint, _TInputValue, _TOutputValue, _TFrontId, _TCompare >::
-SetSeed( const TVertex& seed )
-{
- TSeed s;
- s.Vertex = seed;
- s.IsPoint = false;
- this->m_Seeds[ 0 ] = s;
- if( this->m_Filter != NULL )
- this->m_Filter->Modified( );
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _TPoint, class _TInputValue, class _TOutputValue, class _TFrontId, class _TCompare >
-void
-fpa::Base::SingleSeedInterface< _TVertex, _TPoint, _TInputValue, _TOutputValue, _TFrontId, _TCompare >::
-SetSeed( const TPoint& seed )
-{
- TSeed s;
- s.Point = seed;
- s.IsPoint = true;
- this->m_Seeds[ 0 ] = s;
- if( this->m_Filter != NULL )
- this->m_Filter->Modified( );
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _TPoint, class _TInputValue, class _TOutputValue, class _TFrontId, class _TCompare >
-fpa::Base::SingleSeedInterface< _TVertex, _TPoint, _TInputValue, _TOutputValue, _TFrontId, _TCompare >::
-SingleSeedInterface( itk::ProcessObject* filter )
- : m_Filter( filter )
-{
- this->m_Seeds = TSeeds( 1 );
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _TPoint, class _TInputValue, class _TOutputValue, class _TFrontId, class _TCompare >
-fpa::Base::SingleSeedInterface< _TVertex, _TPoint, _TInputValue, _TOutputValue, _TFrontId, _TCompare >::
-~SingleSeedInterface( )
-{
- this->m_Seeds.clear( );
-}
-
-#endif // __fpa__Base__SingleSeedInterface__hxx__
-
-// eof - $RCSfile$
+++ /dev/null
-
-## =====================
-## == Get source code ==
-## =====================
-
-configure_file(Version.cxx.in "${CMAKE_CURRENT_BINARY_DIR}/Version.cxx" @ONLY)
-configure_file(Config.h.in "${CMAKE_CURRENT_BINARY_DIR}/Config.h" @ONLY)
-file(GLOB_RECURSE _base_src "${CMAKE_CURRENT_SOURCE_DIR}/Base/*.cxx")
-file(GLOB_RECURSE _base_hdr "${CMAKE_CURRENT_SOURCE_DIR}/Base/*.h")
-file(GLOB_RECURSE _base_hrc "${CMAKE_CURRENT_SOURCE_DIR}/Base/*.hxx")
-file(GLOB_RECURSE _image_src "${CMAKE_CURRENT_SOURCE_DIR}/Image/*.cxx")
-file(GLOB_RECURSE _image_hdr "${CMAKE_CURRENT_SOURCE_DIR}/Image/*.h")
-file(GLOB_RECURSE _image_hrc "${CMAKE_CURRENT_SOURCE_DIR}/Image/*.hxx")
-
-file(GLOB_RECURSE _generic_src "${CMAKE_CURRENT_SOURCE_DIR}/Generic/*.cxx")
-file(GLOB_RECURSE _generic_hdr "${CMAKE_CURRENT_SOURCE_DIR}/Generic/*.h")
-file(GLOB_RECURSE _generic_hrc "${CMAKE_CURRENT_SOURCE_DIR}/Generic/*.hxx")
-
-
-set(_src
- ${_base_src} ${_image_src} ${_generic_src}
- "${CMAKE_CURRENT_BINARY_DIR}/Version.cxx"
- )
-set(
- _hdr
- ${_base_hdr} ${_image_hdr} ${_generic_hdr}
- "${CMAKE_CURRENT_BINARY_DIR}/Config.h"
- )
-set(_hrc ${_base_hrc} ${_image_hrc} ${_generic_hrc})
-
-## =====================
-## == Compile library ==
-## =====================
-
-add_library(fpa SHARED ${_src} ${_hdr} ${_hrc})
-generate_export_header(fpa)
-set_property(TARGET fpa PROPERTY VERSION ${prj_VERSION})
-set_property(TARGET fpa PROPERTY SOVERSION ${prj_SHORT_VERSION})
-set_property(
- TARGET fpa PROPERTY INTERFACE_fpa_MAJOR_VERSION ${prj_MAJ_VERSION}
- )
-set_property(
- TARGET fpa APPEND PROPERTY COMPATIBLE_INTERFACE_STRING ${prj_MAJ_VERSION}
- )
-target_link_libraries(fpa PUBLIC ${VTK_LIBRARIES} ${ITK_LIBRARIES})
-
-## ========================
-## == Installation rules ==
-## ========================
-
-install(
- TARGETS fpa
- EXPORT "${targets_export_name}"
- LIBRARY DESTINATION "lib"
- ARCHIVE DESTINATION "lib"
- RUNTIME DESTINATION "bin"
- INCLUDES DESTINATION "${include_install_dir}"
- )
-install(
- DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
- DESTINATION "${include_install_dir}"
- FILES_MATCHING PATTERN "*.h"
- )
-install(
- DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
- DESTINATION "${include_install_dir}"
- FILES_MATCHING PATTERN "*.hxx"
- )
-install(
- FILES "${CMAKE_CURRENT_BINARY_DIR}/fpa_export.h"
- DESTINATION "${include_install_dir}/fpa"
- )
-install(
- FILES "${CMAKE_CURRENT_BINARY_DIR}/Config.h"
- DESTINATION "${include_install_dir}/fpa"
- )
-
-## eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Config__h__
-#define __fpa__Config__h__
-
-#define VTK_FOUND @VTK_FOUND@
-#if VTK_FOUND == 1
-# define USE_VTK
-#else
-# undef USE_VTK
-#endif
-
-#define ivq_FOUND @ivq_FOUND@
-#if ivq_FOUND == 1
-# define USE_ivq
-#else
-# undef USE_ivq
-#endif
-
-#endif // __fpa__Config__h__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Image__Algorithm__h__
-#define __fpa__Image__Algorithm__h__
-
-#include <itkImage.h>
-#include <itkImageToImageFilter.h>
-
-#include <fpa/Base/Algorithm.h>
-
-namespace fpa
-{
- namespace Image
- {
- /**
- */
- template< class _TTraits >
- class Algorithm
- : public fpa::Base::Algorithm< _TTraits >
- {
- public:
- 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 );
-
- itkGetConstMacro( NeigborhoodOrder, unsigned int );
- itkSetMacro( NeigborhoodOrder, unsigned int );
-
- public:
- TMarks* GetMarks( );
- const TMarks* GetMarks( ) const;
-
- protected:
- Algorithm( );
- virtual ~Algorithm( );
-
- 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( TNode& n ) override;
- virtual bool _IsMarked( const TVertex& v ) const override;
- virtual unsigned long _GetMark( const TVertex& v ) const override;
- virtual void _Mark( const TVertex& v, unsigned long frontId ) override;
-
- private:
- // Purposely not implemented.
- Algorithm( const Self& other );
- Self& operator=( const Self& other );
-
- protected:
- unsigned long m_MarksIdx;
- unsigned int m_NeigborhoodOrder;
- };
-
- } // ecapseman
-
-} // ecapseman
-
-#ifndef ITK_MANUAL_INSTANTIATION
-# include <fpa/Image/Algorithm.hxx>
-#endif // ITK_MANUAL_INSTANTIATION
-
-#endif // __fpa__Image__Algorithm__h__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Image__Algorithm__hxx__
-#define __fpa__Image__Algorithm__hxx__
-
-// -------------------------------------------------------------------------
-template< class _TTraits >
-typename fpa::Image::Algorithm< _TTraits >::TMarks*
-fpa::Image::Algorithm< _TTraits >::
-GetMarks( )
-{
- return(
- dynamic_cast< TMarks* >(
- this->itk::ProcessObject::GetOutput( this->m_MarksIdx )
- )
- );
-}
-
-// -------------------------------------------------------------------------
-template< class _TTraits >
-const typename fpa::Image::Algorithm< _TTraits >::TMarks*
-fpa::Image::Algorithm< _TTraits >::
-GetMarks( ) const
-{
- return(
- dynamic_cast< const TMarks* >(
- this->itk::ProcessObject::GetOutput( this->m_MarksIdx )
- )
- );
-}
-
-// -------------------------------------------------------------------------
-template< class _TTraits >
-fpa::Image::Algorithm< _TTraits >::
-Algorithm( )
- : Superclass( ),
- m_NeigborhoodOrder( 1 )
-{
- this->m_MarksIdx = this->GetNumberOfRequiredOutputs( );
- this->itk::ProcessObject::SetNumberOfRequiredOutputs( this->m_MarksIdx + 1 );
- this->SetNthOutput( this->m_MarksIdx, TMarks::New( ) );
-}
-
-// -------------------------------------------------------------------------
-template< class _TTraits >
-fpa::Image::Algorithm< _TTraits >::
-~Algorithm( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TTraits >
-typename fpa::Image::Algorithm< _TTraits >::TNodes
-fpa::Image::Algorithm< _TTraits >::
-_UnifySeeds( )
-{
- const TInputImage* input = this->GetInput( );
- typename TInputImage::RegionType region = input->GetRequestedRegion( );
- TSeeds& seeds = this->GetSeeds( );
- TNodes nodes;
-
- typename TSeeds::iterator sIt = seeds.begin( );
- for( ; sIt != seeds.end( ); ++sIt )
- {
- TNode node;
- if( sIt->IsPoint )
- input->TransformPhysicalPointToIndex( sIt->Point, sIt->Vertex );
- else
- input->TransformIndexToPhysicalPoint( sIt->Vertex, sIt->Point );
- if( region.IsInside( sIt->Vertex ) )
- {
- sIt->IsUnified = true;
- node.Vertex = sIt->Vertex;
- node.Parent = node.Vertex;
- if( sIt->FrontId == 0 )
- node.FrontId = nodes.size( ) + 1;
- else
- node.FrontId = sIt->FrontId;
- nodes.insert( node );
- }
- else
- sIt->IsUnified = false;
-
- } // rof
-
- return( nodes );
-}
-
-// -------------------------------------------------------------------------
-template< class _TTraits >
-void fpa::Image::Algorithm< _TTraits >::
-_ConfigureOutput( const TOutputValue& v )
-{
- const TInputImage* in = this->GetInput( );
-
- TOutputImage* out = this->GetOutput( );
- out->SetLargestPossibleRegion( in->GetLargestPossibleRegion( ) );
- out->SetRequestedRegion( in->GetRequestedRegion( ) );
- out->SetBufferedRegion( in->GetBufferedRegion( ) );
- out->SetSpacing( in->GetSpacing( ) );
- out->SetOrigin( in->GetOrigin( ) );
- out->SetDirection( in->GetDirection( ) );
- out->Allocate( );
- out->FillBuffer( v );
-
- TMarks* marks = this->GetMarks( );
- marks->SetLargestPossibleRegion( in->GetLargestPossibleRegion( ) );
- marks->SetRequestedRegion( in->GetRequestedRegion( ) );
- marks->SetBufferedRegion( in->GetBufferedRegion( ) );
- marks->SetSpacing( in->GetSpacing( ) );
- marks->SetOrigin( in->GetOrigin( ) );
- marks->SetDirection( in->GetDirection( ) );
- marks->Allocate( );
- marks->FillBuffer( TFrontId( 0 ) );
-}
-
-// -------------------------------------------------------------------------
-template< class _TTraits >
-typename fpa::Image::Algorithm< _TTraits >::TNeighborhood
-fpa::Image::Algorithm< _TTraits >::
-_GetNeighbors( const TVertex& v ) const
-{
- typename TInputImage::RegionType region =
- this->GetInput( )->GetRequestedRegion( );
- TNeighborhood neighborhood;
- if( this->m_NeigborhoodOrder != 1 )
- {
- // TODO
- }
- else
- {
- for( unsigned int d = 0; d < TInputImage::ImageDimension; ++d )
- {
- for( int s = -1; s <= 1; s += 2 )
- {
- TVertex n = v;
- n[ d ] += s;
- if( region.IsInside( n ) )
- neighborhood.push_back( n );
-
- } // rof
-
- } // rof
-
- } // fi
- return( neighborhood );
-}
-
-// -------------------------------------------------------------------------
-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 _TTraits >
-typename fpa::Image::Algorithm< _TTraits >::TOutputValue
-fpa::Image::Algorithm< _TTraits >::
-_GetOutputValue( const TVertex& v ) const
-{
- return( this->GetOutput( )->GetPixel( v ) );
-}
-
-// -------------------------------------------------------------------------
-template< class _TTraits >
-void fpa::Image::Algorithm< _TTraits >::
-_UpdateOutputValue( TNode& n )
-{
- this->GetOutput( )->SetPixel( n.Vertex, n.Value );
-}
-
-// -------------------------------------------------------------------------
-template< class _TTraits >
-bool fpa::Image::Algorithm< _TTraits >::
-_IsMarked( const TVertex& v ) const
-{
- return( this->GetMarks( )->GetPixel( v ) > 0 );
-}
-
-// -------------------------------------------------------------------------
-template< class _TTraits >
-unsigned long fpa::Image::Algorithm< _TTraits >::
-_GetMark( const TVertex& v ) const
-{
- return( ( unsigned long )( this->GetMarks( )->GetPixel( v ) ) );
-}
-
-// -------------------------------------------------------------------------
-template< class _TTraits >
-void fpa::Image::Algorithm< _TTraits >::
-_Mark( const TVertex& v, unsigned long frontId )
-{
- this->GetMarks( )->SetPixel( v, TFrontId( frontId ) );
-}
-
-#endif // __fpa__Image__Algorithm__hxx__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Image__DefaultTraits__h__
-#define __fpa__Image__DefaultTraits__h__
-
-#include <vector>
-#include <itkConceptChecking.h>
-#include <itkImageToImageFilter.h>
-
-#include <fpa/Base/MarksInterfaceWithCollisions.h>
-#include <fpa/Base/SeedsInterface.h>
-
-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$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Image__Dijkstra__h__
-#define __fpa__Image__Dijkstra__h__
-
-#include <fpa/Base/Dijkstra.h>
-#include <fpa/Image/Algorithm.h>
-#include <fpa/Image/DefaultTraits.h>
-#include <fpa/Image/MinimumSpanningTree.h>
-#include <fpa/Image/Functors/Dijkstra/Function.h>
-
-namespace fpa
-{
- namespace Image
- {
- /**
- */
- template< class _TInputImage, class _TOutputImage, class _TFrontId = unsigned char >
- class Dijkstra
- : 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 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 typename Superclass::TOutputValue TOutputValue;
- typedef typename Superclass::TVertex TVertex;
-
- typedef fpa::Image::Functors::Dijkstra::Function< TInputImage, TOutputValue > TWeightFunction;
-
- public:
- itkNewMacro( Self );
- itkTypeMacro( fpa::Image::Dijkstra, fpa::Base::Dijkstra );
-
- protected:
- Dijkstra( );
- virtual ~Dijkstra( );
-
- virtual void _BeforeGenerateData( ) override;
- virtual void _ConfigureOutput( const TOutputValue& v ) override;
-
- private:
- // Purposely not implemented.
- Dijkstra( const Self& other );
- Self& operator=( const Self& other );
- };
-
- } // ecapseman
-
-} // ecapseman
-
-#ifndef ITK_MANUAL_INSTANTIATION
-# include <fpa/Image/Dijkstra.hxx>
-#endif // ITK_MANUAL_INSTANTIATION
-
-#endif // __fpa__Image__Dijkstra__h__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Image__Dijkstra__hxx__
-#define __fpa__Image__Dijkstra__hxx__
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage, class _TFrontId >
-fpa::Image::Dijkstra< _TInputImage, _TOutputImage, _TFrontId >::
-Dijkstra( )
- : Superclass( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage, class _TFrontId >
-fpa::Image::Dijkstra< _TInputImage, _TOutputImage, _TFrontId >::
-~Dijkstra( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage, class _TFrontId >
-void fpa::Image::Dijkstra< _TInputImage, _TOutputImage, _TFrontId >::
-_BeforeGenerateData( )
-{
- this->Superclass::_BeforeGenerateData( );
- TWeightFunction* wf =
- dynamic_cast< TWeightFunction* >( this->GetWeightFunction( ) );
- if( wf != NULL )
- wf->SetImage( this->GetInput( ) );
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage, class _TFrontId >
-void fpa::Image::Dijkstra< _TInputImage, _TOutputImage, _TFrontId >::
-_ConfigureOutput( const TOutputValue& v )
-{
- 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 TVertex::OffsetType o;
- o.Fill( 0 );
- mst->FillBuffer( o );
-}
-
-#endif // __fpa__Image__Dijkstra__hxx__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Image__ExtractAxisFilter__h__
-#define __fpa__Image__ExtractAxisFilter__h__
-
-#include <itkProcessObject.h>
-#include <itkImageToImageFilter.h>
-
-#include <fpa/Image/Dijkstra.h>
-#include <fpa/Image/PolyLineParametricPath.h>
-
-namespace fpa
-{
- namespace Image
- {
- /**
- */
- template< class _TInputImage, class _TScalar >
- class ExtractAxisFilter
- : public itk::ProcessObject
- {
- public:
- typedef ExtractAxisFilter Self;
- typedef itk::ProcessObject Superclass;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
-
- typedef _TInputImage TInputImage;
- typedef _TScalar TScalar;
- typedef typename TInputImage::IndexType TIndex;
- typedef typename TInputImage::PointType TPoint;
-
- itkStaticConstMacro(
- Dimension,
- unsigned int,
- TInputImage::ImageDimension
- );
-
- typedef itk::Image< TScalar, Self::Dimension > TScalarImage;
- typedef itk::ImageToImageFilter< TInputImage, TScalarImage > TCenterness;
-
- typedef fpa::Image::PolyLineParametricPath< Self::Dimension > TPath;
- typedef fpa::Image::Dijkstra< TScalarImage, TScalarImage > TDijkstra;
-
- public:
- itkNewMacro( Self );
- itkTypeMacro( fpa::Image::ExtractAxisFilter, fpa::Image::Dijkstra );
-
- itkGetConstObjectMacro( Centerness, TCenterness );
- itkGetObjectMacro( Centerness, TCenterness );
- itkSetObjectMacro( Centerness, TCenterness );
-
- itkGetConstMacro( StartIndex, TIndex );
- itkSetMacro( StartIndex, TIndex );
-
- itkGetConstMacro( EndIndex, TIndex );
- itkSetMacro( EndIndex, TIndex );
-
- public:
- virtual itk::ModifiedTimeType GetMTime( ) const override;
-
- virtual void AddSeed( const TIndex& seed );
- virtual void AddSeed( const TPoint& seed );
- virtual void ClearSeeds( );
-
- void SetInput( TInputImage* input );
- TInputImage* GetInput( );
- const TInputImage* GetInput( ) const;
-
- TPath* GetOutput( );
- const TPath* GetOutput( ) const;
-
- protected:
- ExtractAxisFilter( );
- virtual ~ExtractAxisFilter( );
-
- virtual void GenerateData( ) override;
-
- private:
- // Purposely not implemented.
- ExtractAxisFilter( const Self& other );
- Self& operator=( const Self& other );
-
- protected:
- typename TCenterness::Pointer m_Centerness;
- typename TDijkstra::Pointer m_Dijkstra;
-
- TIndex m_StartIndex;
- TIndex m_EndIndex;
- };
-
- } // ecapseman
-
-} // ecapseman
-
-#ifndef ITK_MANUAL_INSTANTIATION
-# include <fpa/Image/ExtractAxisFilter.hxx>
-#endif // ITK_MANUAL_INSTANTIATION
-
-#endif // __fpa__Image__ExtractAxisFilter__h__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Image__ExtractAxisFilter__hxx__
-#define __fpa__Image__ExtractAxisFilter__hxx__
-
-#include <itkSignedMaurerDistanceMapImageFilter.h>
-#include <fpa/Image/Functors/Dijkstra/Invert.h>
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TScalar >
-itk::ModifiedTimeType
-fpa::Image::ExtractAxisFilter< _TInputImage, _TScalar >::
-GetMTime( ) const
-{
- itk::ModifiedTimeType a = this->Superclass::GetMTime( );
- itk::ModifiedTimeType b = this->m_Centerness->GetMTime( );
- itk::ModifiedTimeType c = this->m_Dijkstra->GetMTime( );
- a = ( a < b )? a: b;
- return( ( a < c )? a: c );
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TScalar >
-void fpa::Image::ExtractAxisFilter< _TInputImage, _TScalar >::
-AddSeed( const TIndex& seed )
-{
- this->m_Dijkstra->AddSeed( seed );
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TScalar >
-void fpa::Image::ExtractAxisFilter< _TInputImage, _TScalar >::
-AddSeed( const TPoint& seed )
-{
- this->m_Dijkstra->AddSeed( seed );
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TScalar >
-void fpa::Image::ExtractAxisFilter< _TInputImage, _TScalar >::
-ClearSeeds( )
-{
- this->m_Dijkstra->ClearSeeds( );
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TScalar >
-void fpa::Image::ExtractAxisFilter< _TInputImage, _TScalar >::
-SetInput( TInputImage* input )
-{
- this->Superclass::SetNthInput( 0, input );
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TScalar >
-typename fpa::Image::ExtractAxisFilter< _TInputImage, _TScalar >::
-TInputImage* fpa::Image::ExtractAxisFilter< _TInputImage, _TScalar >::
-GetInput( )
-{
- return( dynamic_cast< TInputImage* >( this->Superclass::GetInput( 0 ) ) );
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TScalar >
-const typename fpa::Image::ExtractAxisFilter< _TInputImage, _TScalar >::
-TInputImage* fpa::Image::ExtractAxisFilter< _TInputImage, _TScalar >::
-GetInput( ) const
-{
- return(
- dynamic_cast< const TInputImage* >( this->Superclass::GetInput( 0 ) )
- );
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TScalar >
-typename fpa::Image::ExtractAxisFilter< _TInputImage, _TScalar >::
-TPath* fpa::Image::ExtractAxisFilter< _TInputImage, _TScalar >::
-GetOutput( )
-{
- return( dynamic_cast< TPath* >( this->Superclass::GetOutput( 0 ) ) );
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TScalar >
-const typename fpa::Image::ExtractAxisFilter< _TInputImage, _TScalar >::
-TPath* fpa::Image::ExtractAxisFilter< _TInputImage, _TScalar >::
-GetOutput( ) const
-{
- return( dynamic_cast< const TPath* >( this->Superclass::GetOutput( 0 ) ) );
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TScalar >
-fpa::Image::ExtractAxisFilter< _TInputImage, _TScalar >::
-ExtractAxisFilter( )
- : Superclass( )
-{
- // I/O configuration
- this->SetNumberOfRequiredInputs( 1 );
- this->SetNumberOfRequiredOutputs( 1 );
- this->SetNthOutput( 0, TPath::New( ) );
-
- // Prepare weight function
- typedef fpa::Image::Functors::Dijkstra::Invert< TScalarImage, TScalar > _TWeight;
- typename _TWeight::Pointer weight = _TWeight::New( );
- weight->SetAlpha( 1 );
- weight->SetBeta( 1 );
-
- // Filters
- typedef itk::SignedMaurerDistanceMapImageFilter< TInputImage, TScalarImage > _TDefaultCenterness;
- typename _TDefaultCenterness::Pointer dc = _TDefaultCenterness::New( );
- dc->InsideIsPositiveOn( );
- dc->SquaredDistanceOn( );
- dc->UseImageSpacingOn( );
- this->m_Centerness = dc;
-
- // Axis extractor
- this->m_Dijkstra = TDijkstra::New( );
- this->m_Dijkstra->SetWeightFunction( weight );
- this->m_Dijkstra->StopAtOneFront( );
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TScalar >
-fpa::Image::ExtractAxisFilter< _TInputImage, _TScalar >::
-~ExtractAxisFilter( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TScalar >
-void fpa::Image::ExtractAxisFilter< _TInputImage, _TScalar >::
-GenerateData( )
-{
- // Execute minipipeline
- this->m_Centerness->SetInput( this->GetInput( ) );
- this->m_Dijkstra->SetInput( this->m_Centerness->GetOutput( ) );
- this->m_Dijkstra->Update( );
-
- // Extract axis
- typename TPath::Pointer out = this->GetOutput( );
- this->m_Dijkstra->GetMinimumSpanningTree( )->GetPolyLineParametricPath(
- out, this->m_StartIndex, this->m_EndIndex
- );
-}
-
-#endif // __fpa__Image__ExtractAxisFilter__hxx__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Image__Functors__Dijkstra__Function__h__
-#define __fpa__Image__Functors__Dijkstra__Function__h__
-
-#include <fpa/Base/Functors/Dijkstra/Function.h>
-
-namespace fpa
-{
- namespace Image
- {
- namespace Functors
- {
- namespace Dijkstra
- {
- /**
- */
- template< class _TInputImage, class _TOutputValue >
- class Function
- : public fpa::Base::Functors::Dijkstra::Function< typename _TInputImage::IndexType, _TOutputValue >
- {
- public:
- typedef typename _TInputImage::IndexType TVertex;
- typedef Function Self;
- typedef fpa::Base::Functors::Dijkstra::Function< TVertex, _TOutputValue > Superclass;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
-
- public:
- itkTypeMacro(
- fpa::Image::Functors::Dijkstra::Function,
- fpa::Base::Functors::Dijkstra::Function
- );
-
- itkGetConstObjectMacro( Image, _TInputImage );
- itkSetConstObjectMacro( Image, _TInputImage );
-
- protected:
- Function( )
- : Superclass( )
- {
- }
- virtual ~Function( )
- {
- }
-
- private:
- // Purposely not implemented
- Function( const Self& other );
- Self& operator=( const Self& other );
-
- protected:
- typename _TInputImage::ConstPointer m_Image;
- };
-
- } // ecapseman
-
- } // ecapseman
-
- } // ecapseman
-
-} // ecapseman
-
-#endif // __fpa__Image__Functors__Dijkstra__Function__h__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Image__Functors__Dijkstra__Gaussian__h__
-#define __fpa__Image__Functors__Dijkstra__Gaussian__h__
-
-#include <cmath>
-#include <fpa/Image/Functors/Dijkstra/Function.h>
-
-namespace fpa
-{
- namespace Image
- {
- namespace Functors
- {
- namespace Dijkstra
- {
- /**
- * w_{i,j}=\left(\exp\left(\left(\frac{w_{i}-w_{j}}{\beta}\right)^{2}\right)-1\right)^{\alpha}
- */
- template< class _TInputImage, class _TOutputValue >
- class Gaussian
- : public fpa::Image::Functors::Dijkstra::Function< _TInputImage, _TOutputValue >
- {
- public:
- typedef Gaussian Self;
- typedef fpa::Image::Functors::Dijkstra::Function< _TInputImage, _TOutputValue > Superclass;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
-
- typedef typename Superclass::TVertex TVertex;
-
- public:
- itkNewMacro( Self );
- itkTypeMacro(
- fpa::Image::Functors::Dijkstra::Gaussian,
- fpa::Image::Functors::Dijkstra::Function
- );
-
- itkGetConstMacro( Alpha, double );
- itkSetMacro( Alpha, double );
-
- itkGetConstMacro( Beta, double );
- itkSetMacro( Beta, double );
-
- public:
- virtual _TOutputValue Evaluate(
- const TVertex& v, const TVertex& p
- ) const override
- {
- double d = double( this->m_Image->GetPixel( v ) );
- d -= double( this->m_Image->GetPixel( p ) );
- d /= this->m_Beta;
- d = std::exp( d * d ) - double( 1 );
- return( _TOutputValue( std::pow( d, this->m_Alpha ) ) );
- }
-
- protected:
- Gaussian( )
- : Superclass( ),
- m_Alpha( double( 1 ) ),
- m_Beta( double( 1 ) )
- {
- }
- virtual ~Gaussian( )
- {
- }
-
- private:
- // Purposely not implemented
- Gaussian( const Self& other );
- Self& operator=( const Self& other );
-
- protected:
- double m_Alpha;
- double m_Beta;
- };
-
- } // ecapseman
-
- } // ecapseman
-
- } // ecapseman
-
-} // ecapseman
-
-#endif // __fpa__Image__Functors__Dijkstra__Gaussian__h__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Image__Functors__Dijkstra__Identity__h__
-#define __fpa__Image__Functors__Dijkstra__Identity__h__
-
-#include <fpa/Image/Functors/Dijkstra/Function.h>
-
-namespace fpa
-{
- namespace Image
- {
- namespace Functors
- {
- namespace Dijkstra
- {
- /**
- */
- template< class _TInputImage, class _TOutputValue >
- class Identity
- : public fpa::Image::Functors::Dijkstra::Function< _TInputImage, _TOutputValue >
- {
- public:
- typedef Identity Self;
- typedef fpa::Image::Functors::Dijkstra::Function< _TInputImage, _TOutputValue > Superclass;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
-
- typedef typename Superclass::TVertex TVertex;
-
- public:
- itkNewMacro( Self );
- itkTypeMacro(
- fpa::Image::Functors::Dijkstra::Identity,
- fpa::Image::Functors::Dijkstra::Function
- );
-
- public:
- virtual _TOutputValue Evaluate(
- const TVertex& v, const TVertex& p
- ) const override
- {
- return( _TOutputValue( this->m_Image->GetPixel( v ) ) );
- }
-
- protected:
- Identity( )
- : Superclass( )
- {
- }
- virtual ~Identity( )
- {
- }
-
- private:
- // Purposely not implemented
- Identity( const Self& other );
- Self& operator=( const Self& other );
- };
-
- } // ecapseman
-
- } // ecapseman
-
- } // ecapseman
-
-} // ecapseman
-
-#endif // __fpa__Image__Functors__Dijkstra__Identity__h__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Image__Functors__Dijkstra__Invert__h__
-#define __fpa__Image__Functors__Dijkstra__Invert__h__
-
-#include <cmath>
-#include <fpa/Image/Functors/Dijkstra/Function.h>
-
-namespace fpa
-{
- namespace Image
- {
- namespace Functors
- {
- namespace Dijkstra
- {
- /**
- */
- template< class _TInputImage, class _TOutputValue >
- class Invert
- : public fpa::Image::Functors::Dijkstra::Function< _TInputImage, _TOutputValue >
- {
- public:
- typedef Invert Self;
- typedef fpa::Image::Functors::Dijkstra::Function< _TInputImage, _TOutputValue > Superclass;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
-
- typedef typename Superclass::TVertex TVertex;
-
- public:
- itkNewMacro( Self );
- itkTypeMacro(
- fpa::Image::Functors::Dijkstra::Invert,
- fpa::Image::Functors::Dijkstra::Function
- );
-
- itkGetConstMacro( Alpha, double );
- itkGetConstMacro( Beta, double );
-
- itkSetMacro( Alpha, double );
- itkSetMacro( Beta, double );
-
- public:
- virtual _TOutputValue Evaluate(
- const TVertex& v, const TVertex& p
- ) const override
- {
- double a = double( this->m_Image->GetPixel( v ) );
- double d = this->m_Alpha;
- d += std::pow( double( a ), this->m_Beta );
- double x = -1;
- if( std::fabs( d ) > double( 0 ) )
- x =
- double( 1 ) /
- ( this->m_Alpha + std::pow( double( a ), this->m_Beta ) );
- return( _TOutputValue( x ) );
- }
-
- protected:
- Invert( )
- : Superclass( ),
- m_Alpha( double( 1 ) ),
- m_Beta( double( 1 ) )
- {
- }
- virtual ~Invert( )
- {
- }
-
- private:
- // Purposely not implemented
- Invert( const Self& other );
- Self& operator=( const Self& other );
-
- protected:
- double m_Alpha;
- double m_Beta;
- };
-
- } // ecapseman
-
- } // ecapseman
-
- } // ecapseman
-
-} // ecapseman
-
-#endif // __fpa__Image__Functors__Dijkstra__Invert__h__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Image__LabelledSeedsInterface__h__
-#define __fpa__Image__LabelledSeedsInterface__h__
-
-#include <fpa/Base/SeedsInterface.h>
-
-#include <itkImage.h>
-
-namespace fpa
-{
- namespace Image
- {
- /**
- */
- template< class _TVertex, class _TPoint, class _TInputValue, class _TOutputValue, class _TFrontId, class _TCompare = std::greater< _TVertex > >
- class LabelledSeedsInterface
- : public fpa::Base::SeedsInterface< _TVertex, _TPoint, _TInputValue, _TOutputValue, _TFrontId, _TCompare >
- {
- public:
- typedef _TVertex TVertex;
- typedef _TPoint TPoint;
- typedef _TInputValue TInputValue;
- typedef _TOutputValue TOutputValue;
- typedef _TFrontId TFrontId;
- typedef _TCompare TCompare;
- typedef LabelledSeedsInterface Self;
- typedef fpa::Base::SeedsInterface< TVertex, TPoint, TInputValue, TOutputValue, TFrontId, TCompare > Superclass;
-
- typedef typename Superclass::TNode TNode;
- typedef typename Superclass::TNodeCompare TNodeCompare;
- typedef typename Superclass::TSeeds TSeeds;
-
- typedef itk::Image< TFrontId, TVertex::Dimension > TLabelImage;
-
- public:
- virtual void AddSeed( const TVertex& seed ) override;
- virtual void AddSeed( const TPoint& seed ) override;
-
- const TLabelImage* GetLabels( ) const;
- void SetLabels( const TLabelImage* image );
-
- protected:
- LabelledSeedsInterface( itk::ProcessObject* filter );
- virtual ~LabelledSeedsInterface( );
-
- protected:
- typename TLabelImage::ConstPointer m_LabelImage;
- };
-
- } // ecapseman
-
-} // ecapseman
-
-#ifndef ITK_MANUAL_INSTANTIATION
-# include <fpa/Image/LabelledSeedsInterface.hxx>
-#endif // ITK_MANUAL_INSTANTIATION
-
-#endif // __fpa__Image__LabelledSeedsInterface__h__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Image__LabelledSeedsInterface__hxx__
-#define __fpa__Image__LabelledSeedsInterface__hxx__
-
-#include <sstream>
-#include <itkExceptionObject.h>
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _TPoint, class _TInputValue, class _TOutputValue, class _TFrontId, class _TCompare >
-void
-fpa::Image::LabelledSeedsInterface< _TVertex, _TPoint, _TInputValue, _TOutputValue, _TFrontId, _TCompare >::
-AddSeed( const TVertex& seed )
-{
- std::ostringstream msg;
- msg << "itk::ERROR: fpa::Image::LabelledSeedsInterface (" << this
- << "): \"AddSeed( const TVertex& seed )\" is not valid for this class. "
- << "Use \"SetLabels( TLabelImage* labels )\" instead.";
- ::itk::ExceptionObject e(
- __FILE__, __LINE__, msg.str( ).c_str( ), ITK_LOCATION
- );
- throw e;
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _TPoint, class _TInputValue, class _TOutputValue, class _TFrontId, class _TCompare >
-void
-fpa::Image::LabelledSeedsInterface< _TVertex, _TPoint, _TInputValue, _TOutputValue, _TFrontId, _TCompare >::
-AddSeed( const TPoint& seed )
-{
- std::ostringstream msg;
- msg << "itk::ERROR: fpa::Image::LabelledSeedsInterface (" << this
- << "): \"AddSeed( const TPoint& seed )\" is not valid for this class. "
- << "Use \"SetLabels( TLabelImage* labels )\" instead.";
- ::itk::ExceptionObject e(
- __FILE__, __LINE__, msg.str( ).c_str( ), ITK_LOCATION
- );
- throw e;
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _TPoint, class _TInputValue, class _TOutputValue, class _TFrontId, class _TCompare >
-const typename
-fpa::Image::LabelledSeedsInterface< _TVertex, _TPoint, _TInputValue, _TOutputValue, _TFrontId, _TCompare >::
-TLabelImage*
-fpa::Image::LabelledSeedsInterface< _TVertex, _TPoint, _TInputValue, _TOutputValue, _TFrontId, _TCompare >::
-GetLabels( ) const
-{
- return( this->m_LabelImage );
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _TPoint, class _TInputValue, class _TOutputValue, class _TFrontId, class _TCompare >
-void fpa::Image::LabelledSeedsInterface< _TVertex, _TPoint, _TInputValue, _TOutputValue, _TFrontId, _TCompare >::
-SetLabels( const TLabelImage* image )
-{
- this->m_LabelImage = image;
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _TPoint, class _TInputValue, class _TOutputValue, class _TFrontId, class _TCompare >
-fpa::Image::LabelledSeedsInterface< _TVertex, _TPoint, _TInputValue, _TOutputValue, _TFrontId, _TCompare >::
-LabelledSeedsInterface( itk::ProcessObject* filter )
- : Superclass( filter )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _TPoint, class _TInputValue, class _TOutputValue, class _TFrontId, class _TCompare >
-fpa::Image::LabelledSeedsInterface< _TVertex, _TPoint, _TInputValue, _TOutputValue, _TFrontId, _TCompare >::
-~LabelledSeedsInterface( )
-{
-}
-
-#endif // __fpa__Image__LabelledSeedsInterface__hxx__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Image__MinimumSpanningTree__h__
-#define __fpa__Image__MinimumSpanningTree__h__
-
-#include <fpa/Base/MinimumSpanningTree.h>
-#include <itkImage.h>
-#include <fpa/Image/PolyLineParametricPath.h>
-
-namespace fpa
-{
- namespace Image
- {
- /**
- */
- template< unsigned int _VDim >
- class MinimumSpanningTree
- : public fpa::Base::MinimumSpanningTree< itk::Index< _VDim >, itk::Image< itk::Offset< _VDim >, _VDim > >
- {
- public:
- typedef itk::Index< _VDim > TVertex;
- typedef itk::Image< itk::Offset< _VDim >, _VDim > TBaseImage;
-
- typedef MinimumSpanningTree Self;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
- typedef fpa::Base::MinimumSpanningTree< TVertex, TBaseImage > Superclass;
-
- typedef typename Superclass::TCollision TCollision;
- typedef typename Superclass::TCollisionsRow TCollisionsRow;
- typedef typename Superclass::TCollisions TCollisions;
- typedef typename Superclass::TVertices TVertices;
-
- typedef fpa::Image::PolyLineParametricPath< _VDim > TPolyLineParametricPath;
-
- public:
- itkNewMacro( Self );
- itkTypeMacro(
- fpa::Image::MinimumSpanningTree,
- fpa::Base::MinimumSpanningTree
- );
-
- public:
- virtual TVertex GetParent( const TVertex& v ) const override;
- virtual void SetParent( const TVertex& v, const TVertex& p ) override;
-
- void GetPolyLineParametricPath(
- typename TPolyLineParametricPath::Pointer& path,
- const TVertex& a
- ) const;
- void GetPolyLineParametricPath(
- typename TPolyLineParametricPath::Pointer& path,
- const TVertex& a, const TVertex& b
- ) const;
-
- protected:
- MinimumSpanningTree( );
- virtual ~MinimumSpanningTree( );
-
- private:
- MinimumSpanningTree( const Self& other );
- Self& operator=( const Self& other );
- };
-
- } // ecapseman
-
-} // ecapseman
-
-#ifndef ITK_MANUAL_INSTANTIATION
-# include <fpa/Image/MinimumSpanningTree.hxx>
-#endif // ITK_MANUAL_INSTANTIATION
-
-#endif // __fpa__Image__MinimumSpanningTree__h__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Image__MinimumSpanningTree__hxx__
-#define __fpa__Image__MinimumSpanningTree__hxx__
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-typename fpa::Image::MinimumSpanningTree< _VDim >::
-TVertex fpa::Image::MinimumSpanningTree< _VDim >::
-GetParent( const TVertex& v ) const
-{
- return( v + this->GetPixel( v ) );
-}
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-void fpa::Image::MinimumSpanningTree< _VDim >::
-SetParent( const TVertex& v, const TVertex& p )
-{
- this->SetPixel( v, p - v );
-}
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-void fpa::Image::MinimumSpanningTree< _VDim >::
-GetPolyLineParametricPath(
- typename TPolyLineParametricPath::Pointer& path,
- const TVertex& a
- ) const
-{
- TVertices v = this->GetPath( a );
- if( path.IsNull( ) )
- path = TPolyLineParametricPath::New( );
- path->SetReferenceImage( this );
- typename TVertices::const_iterator vIt = v.begin( );
- for( ; vIt != v.end( ); ++vIt )
- path->AddVertex( *vIt );
-}
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-void fpa::Image::MinimumSpanningTree< _VDim >::
-GetPolyLineParametricPath(
- typename TPolyLineParametricPath::Pointer& path,
- const TVertex& a, const TVertex& b
- ) const
-{
- TVertices v = this->GetPath( a, b );
- if( path.IsNull( ) )
- path = TPolyLineParametricPath::New( );
- path->SetReferenceImage( this );
- typename TVertices::const_iterator vIt = v.begin( );
- for( ; vIt != v.end( ); ++vIt )
- path->AddVertex( *vIt );
-}
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-fpa::Image::MinimumSpanningTree< _VDim >::
-MinimumSpanningTree( )
- : Superclass( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-fpa::Image::MinimumSpanningTree< _VDim >::
-~MinimumSpanningTree( )
-{
-}
-
-#endif // __fpa__Image__MinimumSpanningTree__hxx__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Image__Mori__h__
-#define __fpa__Image__Mori__h__
-
-#include <fpa/Base/Mori.h>
-#include <fpa/Base/MarksInterface.h>
-#include <fpa/Base/SingleSeedInterface.h>
-#include <fpa/Image/Algorithm.h>
-#include <fpa/Image/DefaultTraits.h>
-
-namespace fpa
-{
- namespace Image
- {
- /**
- */
- template< class _TInputImage, class _TOutputImage >
- 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 TSeedsInterface::TNode TNode;
- typedef typename TSeedsInterface::TNodes TNodes;
- typedef typename TSeedsInterface::TSeed TSeed;
- typedef typename TSeedsInterface::TSeeds TSeeds;
-
- 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 TAlgorithm::TMarks TMarks;
-
- public:
- itkNewMacro( Self );
- itkTypeMacro( fpa::Image::Mori, fpa::Base::Mori );
-
- public:
- TOutputImage* GetThresholdedOutput( );
- const TOutputImage* GetThresholdedOutput( ) const;
-
- protected:
- Mori( );
- virtual ~Mori( );
-
- virtual void _AfterGenerateData( ) override;
-
- private:
- // Purposely not implemented.
- Mori( const Self& other );
- Self& operator=( const Self& other );
-
- protected:
- unsigned long m_ThresholdedOutputIdx;
- };
-
- } // ecapseman
-
-} // ecapseman
-
-#ifndef ITK_MANUAL_INSTANTIATION
-# include <fpa/Image/Mori.hxx>
-#endif // ITK_MANUAL_INSTANTIATION
-
-#endif // __fpa__Image__Mori__h__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Image__Mori__hxx__
-#define __fpa__Image__Mori__hxx__
-
-#include <itkBinaryThresholdImageFilter.h>
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage >
-typename fpa::Image::Mori< _TInputImage, _TOutputImage >::
-TOutputImage* fpa::Image::Mori< _TInputImage, _TOutputImage >::
-GetThresholdedOutput( )
-{
- return(
- dynamic_cast< TOutputImage* >(
- this->itk::ProcessObject::GetOutput( this->m_ThresholdedOutputIdx )
- )
- );
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage >
-const typename fpa::Image::Mori< _TInputImage, _TOutputImage >::
-TOutputImage* fpa::Image::Mori< _TInputImage, _TOutputImage >::
-GetThresholdedOutput( ) const
-{
- return(
- dynamic_cast< const TOutputImage* >(
- this->itk::ProcessObject::GetOutput( this->m_ThresholdedOutputIdx )
- )
- );
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage >
-fpa::Image::Mori< _TInputImage, _TOutputImage >::
-Mori( )
- : Superclass( )
-{
- this->m_ThresholdedOutputIdx = this->GetNumberOfRequiredOutputs( );
- this->itk::ProcessObject::SetNumberOfRequiredOutputs(
- this->m_ThresholdedOutputIdx + 1
- );
- this->SetNthOutput( this->m_ThresholdedOutputIdx, TOutputImage::New( ) );
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage >
-fpa::Image::Mori< _TInputImage, _TOutputImage >::
-~Mori( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage >
-void fpa::Image::Mori< _TInputImage, _TOutputImage >::
-_AfterGenerateData( )
-{
- typedef itk::BinaryThresholdImageFilter< TMarks, TOutputImage > _TFilter;
-
- this->Superclass::_AfterGenerateData( );
-
- typename _TFilter::Pointer filter = _TFilter::New( );
- filter->SetInput( this->GetMarks( ) );
- filter->SetInsideValue( this->GetInsideValue( ) );
- filter->SetOutsideValue( this->GetOutsideValue( ) );
- filter->SetLowerThreshold( 1 );
- filter->SetUpperThreshold( this->GetNumberOfEvaluatedThresholds( ) - 1 );
- filter->Update( );
- this->GetThresholdedOutput( )->Graft( filter->GetOutput( ) );
-}
-
-#endif // __fpa__Image__Mori__hxx__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Image__PathsToImageFilter__h__
-#define __fpa__Image__PathsToImageFilter__h__
-
-#include <itkRGBAPixel.h>
-#include <itkImageToImageFilter.h>
-#include <vector>
-
-namespace fpa
-{
- namespace Image
- {
- /**
- */
- template< class _TMST, class _TOutputPixelValue >
- class PathsToImageFilter
- : public itk::ImageToImageFilter< _TMST, itk::Image< itk::RGBAPixel< _TOutputPixelValue >, _TMST::ImageDimension > >
- {
- public:
- typedef _TMST TMST;
- typedef _TOutputPixelValue TOutputPixelValue;
- typedef itk::RGBAPixel< TOutputPixelValue > TOutputPixel;
- typedef itk::Image< TOutputPixel, TMST::ImageDimension > TOutputImage;
-
- typedef PathsToImageFilter Self;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
- typedef itk::ImageToImageFilter< TMST, TOutputImage > Superclass;
-
- typedef typename TMST::IndexType TIndex;
- struct TPathData
- {
- TIndex Start;
- TIndex End;
- TOutputPixelValue Red;
- TOutputPixelValue Green;
- TOutputPixelValue Blue;
- };
- typedef std::vector< TPathData > TPaths;
-
- public:
- itkNewMacro( Self );
- itkTypeMacro(
- fpa::Image::PathsToImageFilter,
- itk::ImageToImageFilter
- );
-
- public:
- void AddPath(
- const TIndex& start, const TIndex& end,
- const TOutputPixelValue& r = TOutputPixelValue( 1 ),
- const TOutputPixelValue& g = TOutputPixelValue( 0 ),
- const TOutputPixelValue& b = TOutputPixelValue( 0 )
- );
-
- protected:
- PathsToImageFilter( );
- virtual ~PathsToImageFilter( );
-
- virtual void GenerateData( ) override;
-
- private:
- PathsToImageFilter( const Self& other );
- Self& operator=( const Self& other );
-
- protected:
- TPaths m_Paths;
- };
-
- } // ecapseman
-
-} // ecapseman
-
-#ifndef ITK_MANUAL_INSTANTIATION
-# include <fpa/Image/PathsToImageFilter.hxx>
-#endif // ITK_MANUAL_INSTANTIATION
-
-#endif // __fpa__Image__PathsToImageFilter__h__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Image__PathsToImageFilter__hxx__
-#define __fpa__Image__PathsToImageFilter__hxx__
-
-// -------------------------------------------------------------------------
-template< class _TMST, class _TOutputPixelValue >
-void fpa::Image::PathsToImageFilter< _TMST, _TOutputPixelValue >::
-AddPath(
- const TIndex& start, const TIndex& end,
- const TOutputPixelValue& r,
- const TOutputPixelValue& g,
- const TOutputPixelValue& b
- )
-{
- if( start != end )
- {
- TPathData d;
- d.Start = start;
- d.End = end;
- d.Red = r;
- d.Green = g;
- d.Blue = b;
- this->m_Paths.push_back( d );
- this->Modified( );
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-template< class _TMST, class _TOutputPixelValue >
-fpa::Image::PathsToImageFilter< _TMST, _TOutputPixelValue >::
-PathsToImageFilter( )
- : Superclass( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TMST, class _TOutputPixelValue >
-fpa::Image::PathsToImageFilter< _TMST, _TOutputPixelValue >::
-~PathsToImageFilter( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TMST, class _TOutputPixelValue >
-void fpa::Image::PathsToImageFilter< _TMST, _TOutputPixelValue >::
-GenerateData( )
-{
- TOutputPixel color;
- color.Fill( 0 );
-
- const TMST* mst = this->GetInput( );
- TOutputImage* output = this->GetOutput( );
- output->SetBufferedRegion( mst->GetBufferedRegion( ) );
- output->Allocate( );
- output->FillBuffer( color );
-
- typename TPaths::const_iterator d = this->m_Paths.begin( );
- for( ; d != this->m_Paths.end( ); ++d )
- {
- typename TMST::TVertices path = mst->GetPath( d->Start, d->End );
- color[ 0 ] = d->Red;
- color[ 1 ] = d->Green;
- color[ 2 ] = d->Blue;
- color[ 3 ] = std::numeric_limits< TOutputPixelValue >::max( );
- typename TMST::TVertices::const_iterator i = path.begin( );
- for( ; i != path.end( ); ++i )
- output->SetPixel( *i, color );
-
- } // rof
-}
-
-#endif // __fpa__Image__PathsToImageFilter__hxx__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Image__PolyLineParametricPath__h__
-#define __fpa__Image__PolyLineParametricPath__h__
-
-#include <itkPolyLineParametricPath.h>
-#include <itkImageBase.h>
-
-namespace fpa
-{
- namespace Image
- {
- /**
- */
- template< unsigned int _VDim >
- class PolyLineParametricPath
- : public itk::PolyLineParametricPath< _VDim >
- {
- public:
- typedef PolyLineParametricPath Self;
- typedef itk::PolyLineParametricPath< _VDim > Superclass;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
-
- typedef itk::ImageBase< _VDim > TImageBase;
- typedef typename TImageBase::SpacingType TSpacing;
- typedef typename TImageBase::PointType TPoint;
- typedef typename TImageBase::DirectionType TDirection;
- typedef typename Superclass::ContinuousIndexType TContinuousIndex;
- typedef typename TContinuousIndex::IndexType TIndex;
-
- public:
- itkNewMacro( Self );
- itkTypeMacro( PolyLineParametricPath, itk::PolyLineParametricPath );
-
- itkGetConstReferenceMacro( Spacing, TSpacing );
- itkGetConstReferenceMacro( Origin, TPoint );
- itkGetConstReferenceMacro( Direction, TDirection );
- itkGetConstReferenceMacro( InverseDirection, TDirection );
-
- itkSetMacro( Origin, TPoint );
-
- public:
- unsigned long GetSize( ) const;
- TContinuousIndex GetContinuousVertex( unsigned long i ) const;
- TIndex GetVertex( unsigned long i ) const;
- TPoint GetPoint( unsigned long i ) const;
-
- virtual void SetSpacing( const TSpacing& spac );
- virtual void SetSpacing( const double spac[ _VDim ] );
- virtual void SetSpacing( const float spac[ _VDim ] );
- virtual void SetOrigin( const double ori[ _VDim ] );
- virtual void SetOrigin( const float ori[ _VDim ] );
- virtual void SetDirection( const TDirection& dir );
-
- template< class _TRefImage >
- inline void SetReferenceImage( const _TRefImage* image )
- {
- this->SetSpacing( image->GetSpacing( ) );
- this->SetOrigin( image->GetOrigin( ) );
- this->SetDirection( image->GetDirection( ) );
- }
-
- virtual void Graft( itk::DataObject* o );
-
- protected:
- PolyLineParametricPath( );
- virtual ~PolyLineParametricPath( );
-
- virtual void _ComputeIndexToPhysicalPointMatrices( );
-
- private:
- // Purposely not implemented
- PolyLineParametricPath( const Self& other );
- Self& operator=( const Self& other );
-
- protected:
- TSpacing m_Spacing;
- TPoint m_Origin;
- TDirection m_Direction;
- TDirection m_InverseDirection;
- TDirection m_IndexToPhysicalPoint;
- TDirection m_PhysicalPointToIndex;
- };
-
- } // ecapseman
-
-} // ecapseman
-
-#ifndef ITK_MANUAL_INSTANTIATION
-# include <fpa/Image/PolyLineParametricPath.hxx>
-#endif // ITK_MANUAL_INSTANTIATION
-
-#endif // __fpa__Image__PolyLineParametricPath__h__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Image__PolyLineParametricPath__hxx__
-#define __fpa__Image__PolyLineParametricPath__hxx__
-
-#include <itkMath.h>
-#include <itkNumericTraits.h>
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-unsigned long fpa::Image::PolyLineParametricPath< _VDim >::
-GetSize( ) const
-{
- return( this->GetVertexList( )->Size( ) );
-}
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-typename fpa::Image::PolyLineParametricPath< _VDim >::
-TContinuousIndex
-fpa::Image::PolyLineParametricPath< _VDim >::
-GetContinuousVertex( unsigned long i ) const
-{
- return( this->GetVertexList( )->GetElement( i ) );
-}
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-typename fpa::Image::PolyLineParametricPath< _VDim >::
-TIndex fpa::Image::PolyLineParametricPath< _VDim >::
-GetVertex( unsigned long i ) const
-{
- TContinuousIndex cidx = this->GetContinuousVertex( i );
- TIndex idx;
- for( unsigned int d = 0; d < _VDim; ++d )
- idx[ d ] = cidx[ d ];
- return( idx );
-}
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-typename fpa::Image::PolyLineParametricPath< _VDim >::
-TPoint fpa::Image::PolyLineParametricPath< _VDim >::
-GetPoint( unsigned long i ) const
-{
- typedef typename TPoint::CoordRepType _TCoordRep;
- TPoint pnt;
- TContinuousIndex idx = this->GetVertex( i );
- for( unsigned int r = 0; r < _VDim; ++r )
- {
- _TCoordRep sum = itk::NumericTraits< _TCoordRep >::ZeroValue( );
- for( unsigned int c = 0; c < _VDim; ++c )
- sum += this->m_IndexToPhysicalPoint( r, c ) * idx[ c ];
- pnt[ r ] = sum + this->m_Origin[ r ];
-
- } // rof
- return( pnt );
-}
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-void fpa::Image::PolyLineParametricPath< _VDim >::
-SetSpacing( const TSpacing& spac )
-{
- if( this->m_Spacing != spac )
- {
- this->m_Spacing = spac;
- this->_ComputeIndexToPhysicalPointMatrices( );
- this->Modified( );
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-void fpa::Image::PolyLineParametricPath< _VDim >::
-SetSpacing( const double spac[ _VDim ] )
-{
- this->SetSpacing( TSpacing( spac ) );
-}
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-void fpa::Image::PolyLineParametricPath< _VDim >::
-SetSpacing( const float spac[ _VDim ] )
-{
- TSpacing s;
- for( unsigned int d = 0; d < _VDim; ++d )
- s[ d ] = spac[ d ];
- this->SetSpacing( s );
-}
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-void fpa::Image::PolyLineParametricPath< _VDim >::
-SetOrigin( const double ori[ _VDim ] )
-{
- this->SetOrigin( TPoint( ori ) );
-}
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-void fpa::Image::PolyLineParametricPath< _VDim >::
-SetOrigin( const float ori[ _VDim ] )
-{
- this->SetOrigin( TPoint( ori ) );
-}
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-void fpa::Image::PolyLineParametricPath< _VDim >::
-SetDirection( const TDirection& dir )
-{
- bool modified = false;
- for( unsigned int r = 0; r < _VDim; r++ )
- {
- for( unsigned int c = 0; c < _VDim; c++ )
- {
- if(
- itk::Math::NotExactlyEquals(
- this->m_Direction[ r ][ c ], dir[ r ][ c ]
- )
- )
- {
- this->m_Direction[ r ][ c ] = dir[ r ][ c ];
- modified = true;
- } // fi
-
- } // rof
-
- } // rof
- if( modified )
- {
- this->_ComputeIndexToPhysicalPointMatrices( );
- this->m_InverseDirection = this->m_Direction.GetInverse( );
- this->Modified( );
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-void fpa::Image::PolyLineParametricPath< _VDim >::
-Graft( itk::DataObject* o )
-{
- this->Superclass::Graft( o );
- Self* other = dynamic_cast< Self* >( o );
- if( other != NULL )
- {
- this->m_DefaultInputStepSize = other->m_DefaultInputStepSize;
- this->Initialize( );
- for( unsigned long i = 0; i < other->GetSize( ); ++i )
- this->AddVertex( other->GetContinuousVertex( i ) );
- this->m_Spacing = other->m_Spacing;
- this->m_Origin = other->m_Origin;
- this->m_Direction = other->m_Direction;
- this->m_InverseDirection = other->m_InverseDirection;
- this->m_IndexToPhysicalPoint = other->m_IndexToPhysicalPoint;
- this->m_PhysicalPointToIndex = other->m_PhysicalPointToIndex;
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-fpa::Image::PolyLineParametricPath< _VDim >::
-PolyLineParametricPath( )
- : Superclass( )
-{
- this->m_Spacing.Fill( 1.0 );
- this->m_Origin.Fill( 0.0 );
- this->m_Direction.SetIdentity( );
- this->m_InverseDirection.SetIdentity( );
- this->m_IndexToPhysicalPoint.SetIdentity( );
- this->m_PhysicalPointToIndex.SetIdentity( );
-}
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-fpa::Image::PolyLineParametricPath< _VDim >::
-~PolyLineParametricPath( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-void fpa::Image::PolyLineParametricPath< _VDim >::
-_ComputeIndexToPhysicalPointMatrices( )
-{
- TDirection scale;
- scale.Fill( 0.0 );
- for( unsigned int i = 0; i < _VDim; i++ )
- {
- if( this->m_Spacing[ i ] == 0.0 )
- itkExceptionMacro(
- "A spacing of 0 is not allowed: Spacing is " << this->m_Spacing
- );
- scale[ i ][ i ] = this->m_Spacing[ i ];
-
- } // rof
-
- if( vnl_determinant( this->m_Direction.GetVnlMatrix( ) ) == 0.0 )
- itkExceptionMacro(
- << "Bad direction, determinant is 0. Direction is "
- << this->m_Direction
- );
- this->m_IndexToPhysicalPoint = this->m_Direction * scale;
- this->m_PhysicalPointToIndex = this->m_IndexToPhysicalPoint.GetInverse( );
- this->Modified( );
-}
-
-#endif // __fpa__Image__PolyLineParametricPath__hxx__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Image__PolyLineParametricPathToPolyDataFilter__h__
-#define __fpa__Image__PolyLineParametricPathToPolyDataFilter__h__
-
-#include <fpa/Config.h>
-
-#ifdef USE_VTK
-# include <vtkPolyDataAlgorithm.h>
-#endif // USE_VTK
-
-namespace fpa
-{
- namespace Image
- {
- /**
- */
- template< class _TPolyLineParametricPath >
- class PolyLineParametricPathToPolyDataFilter
-#ifdef USE_VTK
- : public vtkPolyDataAlgorithm
-#endif // USE_VTK
- {
- public:
- typedef PolyLineParametricPathToPolyDataFilter Self;
- typedef _TPolyLineParametricPath TPolyLineParametricPath;
-
- public:
-#ifdef USE_VTK
- vtkTypeMacro(
- PolyLineParametricPathToPolyDataFilter,
- vtkPolyDataAlgorithm
- );
-#endif // USE_VTK
-
- public:
- static Self* New( );
-
- const TPolyLineParametricPath* GetInput( ) const;
- void SetInput( const TPolyLineParametricPath* path );
-
- protected:
- PolyLineParametricPathToPolyDataFilter( );
- virtual ~PolyLineParametricPathToPolyDataFilter( );
-
-#ifdef USE_VTK
- int RequestData(
- vtkInformation* information,
- vtkInformationVector** input,
- vtkInformationVector* output
- );
- int RequestInformation(
- vtkInformation* information,
- vtkInformationVector** input,
- vtkInformationVector* output
- );
-#endif // USE_VTK
-
- private:
- // Purposely not implemented
- PolyLineParametricPathToPolyDataFilter( const Self& );
- void operator=( const Self& );
-
- protected:
- const TPolyLineParametricPath* m_PolyLineParametricPath;
- };
-
- } // ecapseman
-
-} // ecapseman
-
-#ifndef ITK_MANUAL_INSTANTIATION
-# include <fpa/Image/PolyLineParametricPathToPolyDataFilter.hxx>
-#endif // ITK_MANUAL_INSTANTIATION
-
-#endif // __fpa__Image__PolyLineParametricPathToPolyDataFilter__h__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Image__PolyLineParametricPathToPolyDataFilter__hxx__
-#define __fpa__Image__PolyLineParametricPathToPolyDataFilter__hxx__
-
-#ifdef USE_VTK
-# include <vtkCellArray.h>
-# include <vtkInformation.h>
-# include <vtkInformationVector.h>
-# include <vtkPointData.h>
-# include <vtkUnsignedIntArray.h>
-# include <vtkSmartPointer.h>
-#endif // USE_VTK
-
-// -------------------------------------------------------------------------
-template< class _TPolyLineParametricPath >
-typename fpa::Image::PolyLineParametricPathToPolyDataFilter< _TPolyLineParametricPath >::
-Self* fpa::Image::PolyLineParametricPathToPolyDataFilter< _TPolyLineParametricPath >::
-New( )
-{
- return( new Self( ) );
-}
-
-// -------------------------------------------------------------------------
-template< class _TPolyLineParametricPath >
-const typename
-fpa::Image::PolyLineParametricPathToPolyDataFilter< _TPolyLineParametricPath >::
-TPolyLineParametricPath* fpa::Image::PolyLineParametricPathToPolyDataFilter< _TPolyLineParametricPath >::
-GetInput( ) const
-{
- return( this->m_PolyLineParametricPath );
-}
-
-// -------------------------------------------------------------------------
-template< class _TPolyLineParametricPath >
-void fpa::Image::PolyLineParametricPathToPolyDataFilter< _TPolyLineParametricPath >::
-SetInput( const TPolyLineParametricPath* path )
-{
- if( this->m_PolyLineParametricPath != path )
- {
- this->m_PolyLineParametricPath = path;
-#ifdef USE_VTK
- this->Modified( );
-#endif // USE_VTK
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-template< class _TPolyLineParametricPath >
-fpa::Image::PolyLineParametricPathToPolyDataFilter< _TPolyLineParametricPath >::
-PolyLineParametricPathToPolyDataFilter( )
-#ifdef USE_VTK
- : vtkPolyDataAlgorithm( ),
- m_PolyLineParametricPath( NULL )
-#endif // USE_VTK
-{
-#ifdef USE_VTK
- this->SetNumberOfInputPorts( 0 );
-#endif // USE_VTK
-}
-
-// -------------------------------------------------------------------------
-template< class _TPolyLineParametricPath >
-fpa::Image::PolyLineParametricPathToPolyDataFilter< _TPolyLineParametricPath >::
-~PolyLineParametricPathToPolyDataFilter( )
-{
-}
-
-#ifdef USE_VTK
-// -------------------------------------------------------------------------
-template< class _TPolyLineParametricPath >
-int fpa::Image::PolyLineParametricPathToPolyDataFilter< _TPolyLineParametricPath >::
-RequestData(
- vtkInformation* information,
- vtkInformationVector** input,
- vtkInformationVector* output
- )
-{
- static const unsigned int dim = TPolyLineParametricPath::PathDimension;
- if( this->m_PolyLineParametricPath == NULL )
- return( 0 );
-
- // Get output
- vtkInformation* info = output->GetInformationObject( 0 );
- vtkPolyData* out = vtkPolyData::SafeDownCast(
- info->Get( vtkDataObject::DATA_OBJECT( ) )
- );
-
- // Prepare data
- out->SetPoints( vtkSmartPointer< vtkPoints >::New( ) );
- out->SetVerts( vtkSmartPointer< vtkCellArray >::New( ) );
- out->SetLines( vtkSmartPointer< vtkCellArray >::New( ) );
- out->SetPolys( vtkSmartPointer< vtkCellArray >::New( ) );
- out->SetStrips( vtkSmartPointer< vtkCellArray >::New( ) );
- vtkSmartPointer< vtkUnsignedIntArray > darray =
- vtkSmartPointer< vtkUnsignedIntArray >::New( );
- darray->SetNumberOfComponents( 1 );
- out->GetPointData( )->SetScalars( darray );
- vtkPoints* points = out->GetPoints( );
- vtkCellArray* lines = out->GetLines( );
-
- // Assign all data
- const TPolyLineParametricPath* path = this->GetInput( );
- for( unsigned long i = 0; i < path->GetSize( ); ++i )
- {
- auto pnt = path->GetPoint( i );
- if( dim == 1 )
- points->InsertNextPoint( pnt[ 0 ], 0, 0 );
- else if( dim == 2 )
- points->InsertNextPoint( pnt[ 0 ], pnt[ 1 ], 0 );
- else
- points->InsertNextPoint( pnt[ 0 ], pnt[ 1 ], pnt[ 2 ] );
- darray->InsertNextTuple1( double( i ) );
- if( i > 0 )
- {
- lines->InsertNextCell( 2 );
- lines->InsertCellPoint( points->GetNumberOfPoints( ) - 2 );
- lines->InsertCellPoint( points->GetNumberOfPoints( ) - 1 );
-
- } // fi
-
- } // rof
- return( 1 );
-}
-
-// -------------------------------------------------------------------------
-template< class _TPolyLineParametricPath >
-int fpa::Image::PolyLineParametricPathToPolyDataFilter< _TPolyLineParametricPath >::
-RequestInformation(
- vtkInformation* information,
- vtkInformationVector** input,
- vtkInformationVector* output
- )
-{
- return( 1 );
-}
-#endif // USE_VTK
-
-#endif // __fpa__Image__PolyLineParametricPathToPolyDataFilterFilter__hxx__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Image__RandomWalker__h__
-#define __fpa__Image__RandomWalker__h__
-
-#include <itkImage.h>
-#include <fpa/Base/DijkstraBase.h>
-#include <fpa/Base/MarksInterface.h>
-#include <fpa/Image/Algorithm.h>
-#include <fpa/Image/DefaultTraits.h>
-#include <fpa/Image/LabelledSeedsInterface.h>
-#include <fpa/Image/Functors/Dijkstra/Function.h>
-
-namespace fpa
-{
- namespace Image
- {
- /**
- */
- template< class _TInputImage, class _TLabelImage, class _TScalar >
- class RandomWalkerTraits
- : public fpa::Image::DefaultTraits< _TInputImage, itk::Image< _TScalar, _TInputImage::ImageDimension >, typename _TLabelImage::PixelType >
- {
- public:
- 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::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::Image::LabelledSeedsInterface< TVertex, TPoint, TInputValue, TOutputValue, TFrontId, TCompare > TSeedsInterface;
- typedef fpa::Base::MarksInterface< TVertex > TMarksInterface;
-
- 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 > > >
- {
- public:
- typedef _TInputImage TInputImage;
- typedef _TLabelImage TLabelImage;
- typedef _TScalar TScalar;
-
- typedef fpa::Image::RandomWalkerTraits< TInputImage, TLabelImage, TScalar > TTraits;
- typedef fpa::Image::Algorithm< TTraits > TAlgorithm;
- typedef fpa::Base::DijkstraBase< TAlgorithm > Superclass;
- typedef RandomWalker Self;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
-
- typedef typename TTraits::TNode TNode;
- typedef typename TTraits::TNodes TNodes;
- typedef typename TTraits::TSeed TSeed;
- typedef typename TTraits::TVertex TVertex;
-
- typedef fpa::Image::Functors::Dijkstra::Function< TInputImage, TScalar > TWeightFunction;
-
- public:
- itkNewMacro( Self );
- itkTypeMacro( fpa::Image::RandomWalker, fpa::Base::RandomWalker );
-
- public:
- virtual itk::ModifiedTimeType GetMTime( ) const override;
-
- protected:
- RandomWalker( );
- virtual ~RandomWalker( );
-
- virtual void _BeforeGenerateData( ) override;
- virtual TNodes _UnifySeeds( ) override;
-
- private:
- // Purposely not implemented.
- RandomWalker( const Self& other );
- Self& operator=( const Self& other );
- };
-
- } // ecapseman
-
-} // ecapseman
-
-#ifndef ITK_MANUAL_INSTANTIATION
-# include <fpa/Image/RandomWalker.hxx>
-#endif // ITK_MANUAL_INSTANTIATION
-
-#endif // __fpa__Image__RandomWalker__h__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Image__RandomWalker__hxx__
-#define __fpa__Image__RandomWalker__hxx__
-
-#include <sstream>
-
-#include <itkImageRegionConstIteratorWithIndex.h>
-#include <itkExceptionObject.h>
-
-#include <fpa/Image/Functors/Dijkstra/Gaussian.h>
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TLabelImage, class _TScalar >
-itk::ModifiedTimeType
-fpa::Image::RandomWalker< _TInputImage, _TLabelImage, _TScalar >::
-GetMTime( ) const
-{
- const TLabelImage* labels = this->GetLabels( );
- itk::ModifiedTimeType t = this->Superclass::GetMTime( );
- if( labels != NULL )
- {
- itk::ModifiedTimeType q = labels->GetMTime( );
- t = ( q < t )? q: t;
-
- } // fi
- return( t );
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TLabelImage, class _TScalar >
-fpa::Image::RandomWalker< _TInputImage, _TLabelImage, _TScalar >::
-RandomWalker( )
- : Superclass( )
-{
- typedef fpa::Image::Functors::Dijkstra::Gaussian< TInputImage, TScalar > _TDefaultFunction;
- this->SetWeightFunction( _TDefaultFunction::New( ) );
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TLabelImage, class _TScalar >
-fpa::Image::RandomWalker< _TInputImage, _TLabelImage, _TScalar >::
-~RandomWalker( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TLabelImage, class _TScalar >
-void fpa::Image::RandomWalker< _TInputImage, _TLabelImage, _TScalar >::
-_BeforeGenerateData( )
-{
- this->Superclass::_BeforeGenerateData( );
- TWeightFunction* wf =
- dynamic_cast< TWeightFunction* >( this->GetWeightFunction( ) );
- if( wf != NULL )
- wf->SetImage( this->GetInput( ) );
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TLabelImage, class _TScalar >
-typename fpa::Image::RandomWalker< _TInputImage, _TLabelImage, _TScalar >::
-TNodes fpa::Image::RandomWalker< _TInputImage, _TLabelImage, _TScalar >::
-_UnifySeeds( )
-{
- this->m_Seeds.clear( );
- const TLabelImage* lbl = this->GetLabels( );
- if( lbl == NULL )
- {
- std::ostringstream msg;
- msg << "itk::ERROR: fpa::Image::RandomWalker (" << this
- << "): Labelled image not defined.";
- ::itk::ExceptionObject e(
- __FILE__, __LINE__, msg.str( ).c_str( ), ITK_LOCATION
- );
- throw e;
-
- } // fi
-
- // Iterate over labels
- typename TLabelImage::RegionType reg = lbl->GetRequestedRegion( );
- itk::ImageRegionConstIteratorWithIndex< TLabelImage > lIt( lbl, reg );
- for( lIt.GoToBegin( ); !lIt.IsAtEnd( ); ++lIt )
- {
- if( lIt.Get( ) > 0 )
- {
- bool is_seed = false;
- for( unsigned int d = 0; d < TLabelImage::ImageDimension; ++d )
- {
- for( int s = -1; s <= 1; s += 2 )
- {
- TVertex neigh = lIt.GetIndex( );
- neigh[ d ] += s;
- if( reg.IsInside( neigh ) )
- is_seed |= ( lbl->GetPixel( neigh ) == 0 );
-
- } // rof
-
- } // rof
-
- if( !is_seed )
- {
- TNode node;
- node.Vertex = lIt.GetIndex( );
- node.Parent = lIt.GetIndex( );
- node.FrontId = lIt.Get( );
- node.Value = TScalar( 0 );
- this->_Mark( node.Vertex, node.FrontId );
- this->_UpdateOutputValue( node );
- }
- else
- {
- TSeed seed;
- seed.Vertex = lIt.GetIndex( );
- seed.IsPoint = false;
- seed.FrontId = lIt.Get( );
- this->m_Seeds.push_back( seed );
-
- } // fi
-
- } // fi
-
- } // rof
-
- // Ok, finish initialization
- return( this->Superclass::_UnifySeeds( ) );
-}
-
-#endif // __fpa__Image__RandomWalker__hxx__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Image__RegionGrow__h__
-#define __fpa__Image__RegionGrow__h__
-
-#include <fpa/Base/RegionGrow.h>
-#include <fpa/Image/Algorithm.h>
-#include <fpa/Image/DefaultTraits.h>
-
-namespace fpa
-{
- namespace Image
- {
- /**
- */
- template< class _TInputImage, class _TOutputImage, class _TFrontId = unsigned char >
- class RegionGrow
- : public fpa::Base::RegionGrow< fpa::Image::Algorithm< fpa::Image::DefaultTraits< _TInputImage, _TOutputImage, _TFrontId > > >
- {
- public:
- typedef _TInputImage TInputImage;
- typedef _TOutputImage TOutputImage;
- typedef _TFrontId TFrontId;
-
- 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;
-
- public:
- itkNewMacro( Self );
- itkTypeMacro( fpa::Image::RegionGrow, fpa::Base::RegionGrow );
-
- protected:
- RegionGrow( ) : Superclass( ) { }
- virtual ~RegionGrow( ) { }
-
- private:
- // Purposely not implemented.
- RegionGrow( const Self& other );
- Self& operator=( const Self& other );
- };
-
- } // ecapseman
-
-} // ecapseman
-
-#endif // __fpa__Image__RegionGrow__h__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Image__Skeleton__h__
-#define __fpa__Image__Skeleton__h__
-
-#include <vector>
-#include <fpa/Base/Graph.h>
-#include <fpa/Image/PolyLineParametricPath.h>
-
-namespace fpa
-{
- namespace Image
- {
- /**
- */
- template< unsigned int _VDim >
- class Skeleton
- : public fpa::Base::Graph< typename fpa::Image::PolyLineParametricPath< _VDim >::TIndex, typename fpa::Image::PolyLineParametricPath< _VDim >::Pointer, typename fpa::Image::PolyLineParametricPath< _VDim >::TIndex, typename fpa::Image::PolyLineParametricPath< _VDim >::TIndex::LexicographicCompare >
- {
- public:
- typedef fpa::Image::PolyLineParametricPath< _VDim > TPath;
- typedef typename TPath::TIndex TIndex;
- typedef typename TIndex::LexicographicCompare TIndexCompare;
- typedef typename TPath::Pointer TPathPointer;
-
- itkStaticConstMacro( Dimension, unsigned int, _VDim );
-
- typedef fpa::Base::Graph< TIndex, TPathPointer, TIndex, TIndexCompare > Superclass;
- typedef Skeleton Self;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
-
- public:
- itkNewMacro( Self );
- itkTypeMacro( Skeleton, fpa::Image::Graph );
-
- public:
- void AddBranch( TPath* path );
- const TPath* GetBranch( const TIndex& a, const TIndex& b ) const;
-
- std::vector< TIndex > GetEndPoints( ) const;
- std::vector< TIndex > GetBifurcations( ) const;
-
- protected:
- Skeleton( );
- virtual ~Skeleton( );
-
- private:
- // Purposely not implemented
- Skeleton( const Self& other );
- Self& operator=( const Self& other );
- };
-
- } // ecapseman
-
-} // ecapseman
-
-#ifndef ITK_MANUAL_INSTANTIATION
-# include <fpa/Image/Skeleton.hxx>
-#endif // ITK_MANUAL_INSTANTIATION
-
-#endif // __fpa__Image__Skeleton__h__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Image__Skeleton__hxx__
-#define __fpa__Image__Skeleton__hxx__
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-void fpa::Image::Skeleton< _VDim >::
-AddBranch( TPath* path )
-{
- // Check inputs
- if( path == NULL )
- return;
- unsigned long size = path->GetSize( );
- if( size == 0 )
- return;
- TIndex a = path->GetVertex( 0 );
- TIndex b = path->GetVertex( size - 1 );
- if( this->HasEdge( a, b ) )
- return;
-
- // Add path
- this->SetVertex( a, a );
- this->SetVertex( b, b );
- this->AddEdge( a, b, path );
- this->AddEdge( b, a, path );
- this->Modified( );
-}
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-const typename fpa::Image::Skeleton< _VDim >::
-TPath* fpa::Image::Skeleton< _VDim >::
-GetBranch( const TIndex& a, const TIndex& b ) const
-{
- static const TPath* null_path = NULL;
- if( this->HasEdge( a, b ) )
- return( this->GetEdges( a, b ).front( ) );
- else
- return( null_path );
-}
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-std::vector< typename fpa::Image::Skeleton< _VDim >::TIndex >
-fpa::Image::Skeleton< _VDim >::
-GetEndPoints( ) const
-{
- std::vector< TIndex > res;
- typename Superclass::TMatrix::const_iterator mIt = this->BeginEdgesRows( );
- for( ; mIt != this->EndEdgesRows( ); ++mIt )
- {
- unsigned long count = mIt->second.size( );
- if( count == 1 )
- res.push_back( mIt->first );
-
- } // rof
- return( res );
-}
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-std::vector< typename fpa::Image::Skeleton< _VDim >::TIndex >
-fpa::Image::Skeleton< _VDim >::
-GetBifurcations( ) const
-{
- std::vector< TIndex > res;
- typename Superclass::TMatrix::const_iterator mIt = this->BeginEdgesRows( );
- for( ; mIt != this->EndEdgesRows( ); ++mIt )
- {
- unsigned long count = mIt->second.size( );
- if( count > 1 )
- res.push_back( mIt->first );
-
- } // rof
- return( res );
-}
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-fpa::Image::Skeleton< _VDim >::
-Skeleton( )
- : Superclass( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-fpa::Image::Skeleton< _VDim >::
-~Skeleton( )
-{
-}
-
-#endif // __fpa__Image__Skeleton__hxx__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Image__SkeletonFilter__h__
-#define __fpa__Image__SkeletonFilter__h__
-
-#include <map>
-
-#include <itkProcessObject.h>
-#include <itkSignedMaurerDistanceMapImageFilter.h>
-
-#include <fpa/Image/Dijkstra.h>
-#include <fpa/Image/Skeleton.h>
-
-namespace fpa
-{
- namespace Image
- {
- /**
- */
- template< class _TInputImage, class _TDistanceMap = itk::SignedMaurerDistanceMapImageFilter< _TInputImage, itk::Image< double, _TInputImage::ImageDimension > > >
- class SkeletonFilter
- : public itk::ProcessObject
- {
- public:
- typedef SkeletonFilter Self;
- typedef itk::ProcessObject Superclass;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
-
- typedef _TInputImage TInputImage;
- typedef _TDistanceMap TDistanceMap;
- itkStaticConstMacro(
- Dimension,
- unsigned int,
- TInputImage::ImageDimension
- );
-
- typedef typename TDistanceMap::OutputImageType TOutputImage;
- typedef typename TInputImage::IndexType TIndex;
- typedef typename TOutputImage::PixelType TScalar;
-
- typedef fpa::Image::Skeleton< Self::Dimension > TSkeleton;
-
- protected:
- typedef std::multimap< TScalar, TIndex > _TSkeletonQueue;
-
- /**
- */
- class _TDijkstra
- : public fpa::Image::Dijkstra< TOutputImage, TOutputImage >
- {
- public:
- typedef _TDijkstra Self;
- typedef fpa::Image::Dijkstra< TOutputImage, TOutputImage > Superclass;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
-
- typedef typename Superclass::TNode TNode;
- typedef typename Superclass::TMST TMST;
-
- public:
- itkNewMacro( Self );
- itkTypeMacro( _TDijkstra, fpa::Image::Dijkstra );
-
- itkGetConstReferenceMacro( SkeletonQueue, _TSkeletonQueue );
-
- protected:
- _TDijkstra( );
- virtual ~_TDijkstra( );
-
- virtual void _BeforeGenerateData( ) override;
- virtual void _UpdateOutputValue( TNode& n ) override;
-
- private:
- // Purposely not implemented
- _TDijkstra( const Self& other );
- Self& operator=( const Self& other );
-
- protected:
- _TSkeletonQueue m_SkeletonQueue;
- };
- typedef typename _TDijkstra::TMST _TMST;
-
- public:
- itkNewMacro( Self );
- itkTypeMacro( fpa::Image::SkeletonFilter, fpa::Image::Dijkstra );
-
- itkBooleanMacro( SeedFromMaximumDistance );
- itkGetConstMacro( SeedFromMaximumDistance, bool );
- itkSetMacro( SeedFromMaximumDistance, bool );
-
- itkGetConstObjectMacro( DistanceMap, TDistanceMap );
- itkGetObjectMacro( DistanceMap, TDistanceMap );
-
- itkGetConstMacro( Seed, TIndex );
- itkSetMacro( Seed, TIndex );
-
- public:
- virtual itk::ModifiedTimeType GetMTime( ) const override;
-
- void SetInput( TInputImage* input );
- TInputImage* GetInput( );
- const TInputImage* GetInput( ) const;
-
- TSkeleton* GetOutput( );
- const TSkeleton* GetOutput( ) const;
-
- protected:
- SkeletonFilter( );
- virtual ~SkeletonFilter( );
-
- virtual void GenerateData( ) override;
-
- template< class _TMarksPointer >
- void _MarkSphere(
- _TMarksPointer& marks,
- const TOutputImage* dmap,
- const TIndex& center
- );
-
- void _EndPoints(
- std::vector< TIndex >& end_points,
- const TOutputImage* dmap,
- const _TMST* mst,
- const _TSkeletonQueue& queue
- );
-
- private:
- // Purposely not implemented.
- SkeletonFilter( const Self& other );
- Self& operator=( const Self& other );
-
- protected:
- typename TDistanceMap::Pointer m_DistanceMap;
- bool m_SeedFromMaximumDistance;
- TIndex m_Seed;
- };
-
- } // ecapseman
-
-} // ecapseman
-
-#ifndef ITK_MANUAL_INSTANTIATION
-# include <fpa/Image/SkeletonFilter.hxx>
-#endif // ITK_MANUAL_INSTANTIATION
-
-#endif // __fpa__Image__SkeletonFilter__h__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Image__SkeletonFilter__hxx__
-#define __fpa__Image__SkeletonFilter__hxx__
-
-#include <itkImage.h>
-#include <itkImageRegionIteratorWithIndex.h>
-#include <itkMinimumMaximumImageCalculator.h>
-#include <fpa/Image/Functors/Dijkstra/Invert.h>
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TDistanceMap >
-fpa::Image::SkeletonFilter< _TInputImage, _TDistanceMap >::_TDijkstra::
-_TDijkstra( )
- : Superclass( )
-{
- // Prepare weight function
- typedef fpa::Image::Functors::Dijkstra::Invert< TOutputImage, TScalar > _TWeight;
- typename _TWeight::Pointer weight = _TWeight::New( );
- weight->SetAlpha( 1 );
- weight->SetBeta( 1 );
- this->SetWeightFunction( weight );
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TDistanceMap >
-fpa::Image::SkeletonFilter< _TInputImage, _TDistanceMap >::_TDijkstra::
-~_TDijkstra( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TDistanceMap >
-void fpa::Image::SkeletonFilter< _TInputImage, _TDistanceMap >::_TDijkstra::
-_BeforeGenerateData( )
-{
- this->Superclass::_BeforeGenerateData( );
- this->m_SkeletonQueue.clear( );
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TDistanceMap >
-void fpa::Image::SkeletonFilter< _TInputImage, _TDistanceMap >::_TDijkstra::
-_UpdateOutputValue( TNode& n )
-{
- typedef typename _TSkeletonQueue::value_type _TSkeletonQueueValue;
-
- this->Superclass::_UpdateOutputValue( n );
- double d = double( this->GetInput( )->GetPixel( n.Vertex ) );
- if( d >= double( 0 ) )
- {
- // Update skeleton candidates
- d += double( 1e-5 );
- double v = double( n.Value ) / ( d * d );
- this->m_SkeletonQueue.insert( _TSkeletonQueueValue( v, n.Vertex ) );
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TDistanceMap >
-itk::ModifiedTimeType
-fpa::Image::SkeletonFilter< _TInputImage, _TDistanceMap >::
-GetMTime( ) const
-{
- itk::ModifiedTimeType t = this->Superclass::GetMTime( );
- itk::ModifiedTimeType q = this->m_DistanceMap->GetMTime( );
- return( ( q < t )? q: t );
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TDistanceMap >
-void fpa::Image::SkeletonFilter< _TInputImage, _TDistanceMap >::
-SetInput( TInputImage* input )
-{
- this->Superclass::SetNthInput( 0, input );
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TDistanceMap >
-typename fpa::Image::SkeletonFilter< _TInputImage, _TDistanceMap >::
-TInputImage* fpa::Image::SkeletonFilter< _TInputImage, _TDistanceMap >::
-GetInput( )
-{
- return( dynamic_cast< TInputImage* >( this->Superclass::GetInput( 0 ) ) );
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TDistanceMap >
-const typename fpa::Image::SkeletonFilter< _TInputImage, _TDistanceMap >::
-TInputImage* fpa::Image::SkeletonFilter< _TInputImage, _TDistanceMap >::
-GetInput( ) const
-{
- return(
- dynamic_cast< const TInputImage* >( this->Superclass::GetInput( 0 ) )
- );
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TDistanceMap >
-typename fpa::Image::SkeletonFilter< _TInputImage, _TDistanceMap >::
-TSkeleton* fpa::Image::SkeletonFilter< _TInputImage, _TDistanceMap >::
-GetOutput( )
-{
- return( dynamic_cast< TSkeleton* >( this->Superclass::GetOutput( 0 ) ) );
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TDistanceMap >
-const typename fpa::Image::SkeletonFilter< _TInputImage, _TDistanceMap >::
-TSkeleton* fpa::Image::SkeletonFilter< _TInputImage, _TDistanceMap >::
-GetOutput( ) const
-{
- return(
- dynamic_cast< const TSkeleton* >( this->Superclass::GetOutput( 0 ) )
- );
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TDistanceMap >
-fpa::Image::SkeletonFilter< _TInputImage, _TDistanceMap >::
-SkeletonFilter( )
- : Superclass( ),
- m_SeedFromMaximumDistance( false )
-{
- this->SetNumberOfRequiredInputs( 1 );
- this->SetNumberOfRequiredOutputs( 1 );
- this->SetNthOutput( 0, TSkeleton::New( ) );
-
- this->m_DistanceMap = TDistanceMap::New( );
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TDistanceMap >
-fpa::Image::SkeletonFilter< _TInputImage, _TDistanceMap >::
-~SkeletonFilter( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TDistanceMap >
-void fpa::Image::SkeletonFilter< _TInputImage, _TDistanceMap >::
-GenerateData( )
-{
- // Update distance map
- this->m_DistanceMap->SetInput( this->GetInput( ) );
- this->m_DistanceMap->Update( );
-
- // Correct seed
- if( this->m_SeedFromMaximumDistance )
- {
- typedef itk::MinimumMaximumImageCalculator< TOutputImage > _TMinMax;
- typename _TMinMax::Pointer minmax = _TMinMax::New( );
- minmax->SetImage( this->m_DistanceMap->GetOutput( ) );
- minmax->Compute( );
- this->m_Seed = minmax->GetIndexOfMaximum( );
-
- } // fi
-
- // Compute MST
- typename _TDijkstra::Pointer dijkstra = _TDijkstra::New( );
- dijkstra->SetInput( this->m_DistanceMap->GetOutput( ) );
- dijkstra->AddSeed( this->m_Seed );
- dijkstra->Update( );
-
- // Compute end-points
- const _TMST* mst = dijkstra->GetMinimumSpanningTree( );
- std::vector< TIndex > end_points;
- this->_EndPoints(
- end_points, this->m_DistanceMap->GetOutput( ),
- mst, dijkstra->GetSkeletonQueue( )
- );
-
- // Compute symbolic branches
- typedef std::map< TIndex, TIndex, typename TIndex::LexicographicCompare > _TTags;
- _TTags tags, branches;
- typename std::vector< TIndex >::const_iterator eIt = end_points.begin( );
- for( ; eIt != end_points.end( ); ++eIt )
- {
- // Tag path
- TIndex it = *eIt;
- TIndex p = mst->GetParent( it );
- typename _TTags::iterator bIt = tags.end( );
- while( it != p && bIt == tags.end( ) )
- {
- typename _TTags::iterator tIt = tags.find( it );
- if( tIt != tags.end( ) )
- {
- // Ok, a bifurcation point has been found
- // branch1: tIt->second <-> it (ok)
- branches[ tIt->second ] = it;
-
- // branch2: *eit <-> it (ok)
- branches[ *eIt ] = it;
-
- // branch3: it <-> until next bifurcation
- bIt = tIt;
- }
- else
- tags[ it ] = *eIt;
- it = p;
- p = mst->GetParent( it );
-
- } // elihw
- if( bIt != tags.end( ) )
- {
- TIndex pTag = bIt->second;
- TIndex nTag = bIt->first;
- it = bIt->first;
- p = it;
- while( tags[ it ] == pTag )
- {
- tags[ it ] = nTag;
- p = it;
- it = mst->GetParent( it );
-
- } // elihw
- tags[ it ] = nTag;
- branches[ bIt->first ] = p;
- }
- else
- {
- tags[ it ] = *eIt;
- branches[ *eIt ] = it;
-
- } // fi
-
- } // rof
-
- // Fill full branches
- typedef typename _TMST::TVertices _TVertices;
- typedef typename TSkeleton::TPath _TPath;
-
- TSkeleton* sk = this->GetOutput( );
- typename _TTags::const_iterator bIt = branches.begin( );
- for( ; bIt != branches.end( ); ++bIt )
- {
- _TVertices v = mst->GetPath( bIt->first, bIt->second );
- typename _TPath::Pointer path = _TPath::New( );
- path->SetReferenceImage( this->GetInput( ) );
- typename _TVertices::const_reverse_iterator vIt = v.rbegin( );
- for( ; vIt != v.rend( ); ++vIt )
- path->AddVertex( *vIt );
- sk->AddBranch( path );
-
- } // rof
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TDistanceMap >
-template< class _TMarksPointer >
-void fpa::Image::SkeletonFilter< _TInputImage, _TDistanceMap >::
-_MarkSphere(
- _TMarksPointer& marks, const TOutputImage* dmap, const TIndex& center
- )
-{
- typedef typename _TMarksPointer::ObjectType _TMarks;
- typedef itk::ImageRegionIteratorWithIndex< _TMarks > _TMarksIt;
-
- static const double _eps = std::sqrt( double( Self::Dimension + 1 ) );
- typename _TMarks::SpacingType spac = dmap->GetSpacing( );
- typename _TMarks::RegionType region = dmap->GetRequestedRegion( );
-
- typename _TMarks::PointType cnt;
- dmap->TransformIndexToPhysicalPoint( center, cnt );
- double r = double( dmap->GetPixel( center ) ) * _eps;
-
- TIndex i0, i1;
- for( unsigned int d = 0; d < Self::Dimension; ++d )
- {
- long off = long( std::ceil( r / double( spac[ d ] ) ) );
- if( off < 3 )
- off = 3;
- i0[ d ] = center[ d ] - off;
- i1[ d ] = center[ d ] + off;
-
- if( i0[ d ] < region.GetIndex( )[ d ] )
- i0[ d ] = region.GetIndex( )[ d ];
-
- if( i1[ d ] >= region.GetIndex( )[ d ] + region.GetSize( )[ d ] )
- i1[ d ] = region.GetIndex( )[ d ] + region.GetSize( )[ d ] - 1;
-
- } // rof
-
- typename _TMarks::SizeType size;
- for( unsigned int d = 0; d < Self::Dimension; ++d )
- size[ d ] = i1[ d ] - i0[ d ] + 1;
-
- typename _TMarks::RegionType neighRegion;
- neighRegion.SetIndex( i0 );
- neighRegion.SetSize( size );
-
- _TMarksIt mIt( marks, neighRegion );
- for( mIt.GoToBegin( ); !mIt.IsAtEnd( ); ++mIt )
- mIt.Set( true );
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TDistanceMap >
-void fpa::Image::SkeletonFilter< _TInputImage, _TDistanceMap >::
-_EndPoints(
- std::vector< TIndex >& end_points,
- const TOutputImage* dmap,
- const _TMST* mst,
- const _TSkeletonQueue& queue
- )
-{
- typedef typename _TSkeletonQueue::value_type _TSkeletonQueueValue;
-
- // Some values
- typedef itk::Image< bool, Self::Dimension > _TMarks;
- typename _TMarks::Pointer marks = _TMarks::New( );
- marks->SetLargestPossibleRegion( mst->GetLargestPossibleRegion( ) );
- marks->SetRequestedRegion( mst->GetRequestedRegion( ) );
- marks->SetBufferedRegion( mst->GetBufferedRegion( ) );
- marks->SetSpacing( mst->GetSpacing( ) );
- marks->SetOrigin( mst->GetOrigin( ) );
- marks->SetDirection( mst->GetDirection( ) );
- marks->Allocate( );
- marks->FillBuffer( false );
-
- // Get candidates in maximum to minimum iteration
- typename _TSkeletonQueue::const_reverse_iterator nIt = queue.rbegin( );
- for( ; nIt != queue.rend( ); ++nIt )
- {
- // Mark it and update end-points
- if( !( marks->GetPixel( nIt->second ) ) )
- {
- marks->SetPixel( nIt->second, true );
- end_points.push_back( nIt->second );
-
- // Mark path
- TIndex it = nIt->second;
- TIndex p = mst->GetParent( it );
- while( it != p )
- {
- this->_MarkSphere( marks, dmap, it );
- it = p;
- p = mst->GetParent( it );
-
- } // elihw
- this->_MarkSphere( marks, dmap, it );
-
- } // fi
-
- } // rof
-}
-
-#endif // __fpa__Image__SkeletonFilter__hxx__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Image__SkeletonReader__h__
-#define __fpa__Image__SkeletonReader__h__
-
-#include <itkProcessObject.h>
-
-namespace fpa
-{
- namespace Image
- {
- /**
- */
- template< class _TSkeleton >
- class SkeletonReader
- : public itk::ProcessObject
- {
- public:
- // Basic types
- typedef SkeletonReader Self;
- typedef itk::ProcessObject Superclass;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
-
- typedef _TSkeleton TSkeleton;
-
- public:
- itkNewMacro( Self );
- itkTypeMacro( SkeletonReader, itk::ProcessObject );
-
- itkGetConstMacro( FileName, std::string );
- itkSetMacro( FileName, std::string );
-
- public:
- TSkeleton* GetOutput( );
- TSkeleton* GetOutput( unsigned int i );
-
- virtual void GraftOutput( itk::DataObject* out );
- virtual void GraftOutput(
- const typename Superclass::DataObjectIdentifierType& key,
- itk::DataObject* out
- );
- virtual void GraftNthOutput( unsigned int i, itk::DataObject* out );
- virtual itk::DataObject::Pointer MakeOutput(
- itk::ProcessObject::DataObjectPointerArraySizeType i
- ) override;
-
- virtual void Update( ) override
- { this->GenerateData( ); }
-
- protected:
- SkeletonReader( );
- virtual ~SkeletonReader( );
-
- virtual void GenerateData( ) override;
-
- // Do nothing
- virtual void GenerateOutputInformation( ) override
- { }
-
- private:
- // Purposely not implemented
- SkeletonReader( const Self& );
- void operator=( const Self& );
-
- protected:
- std::string m_FileName;
- };
-
- } // ecapseman
-
-} // ecapseman
-
-#ifndef ITK_MANUAL_INSTANTIATION
-# include <fpa/Image/SkeletonReader.hxx>
-#endif // ITK_MANUAL_INSTANTIATION
-
-#endif // __fpa__Image__SkeletonReader__h__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Image__SkeletonReader__hxx__
-#define __fpa__Image__SkeletonReader__hxx__
-
-// -------------------------------------------------------------------------
-template< class _TSkeleton >
-_TSkeleton* fpa::Image::SkeletonReader< _TSkeleton >::
-GetOutput( )
-{
- return(
- itkDynamicCastInDebugMode< TSkeleton* >( this->GetPrimaryOutput( ) )
- );
-}
-
-// -------------------------------------------------------------------------
-template< class _TSkeleton >
-_TSkeleton* fpa::Image::SkeletonReader< _TSkeleton >::
-GetOutput( unsigned int i )
-{
- return(
- itkDynamicCastInDebugMode< TSkeleton* >(
- this->itk::ProcessObject::GetOutput( i )
- )
- );
-}
-
-// -------------------------------------------------------------------------
-template< class _TSkeleton >
-void fpa::Image::SkeletonReader< _TSkeleton >::
-GraftOutput( itk::DataObject* out )
-{
- this->GraftNthOutput( 0, out );
-}
-
-// -------------------------------------------------------------------------
-template< class _TSkeleton >
-void fpa::Image::SkeletonReader< _TSkeleton >::
-GraftOutput(
- const typename Superclass::DataObjectIdentifierType& key,
- itk::DataObject* out
- )
-{
- if( out == NULL )
- {
- itkExceptionMacro(
- << "Requested to graft output that is a NULL pointer"
- );
-
- } // fi
- itk::DataObject* output = this->itk::ProcessObject::GetOutput( key );
- output->Graft( out );
-}
-
-// -------------------------------------------------------------------------
-template< class _TSkeleton >
-void fpa::Image::SkeletonReader< _TSkeleton >::
-GraftNthOutput( unsigned int i, itk::DataObject* out )
-{
- if( i >= this->GetNumberOfIndexedOutputs( ) )
- {
- itkExceptionMacro(
- << "Requested to graft output " << i
- << " but this filter only has "
- << this->GetNumberOfIndexedOutputs( )
- << " indexed Outputs."
- );
-
- } // fi
- this->GraftOutput( this->MakeNameFromOutputIndex( i ), out );
-}
-
-// -------------------------------------------------------------------------
-template< class _TSkeleton >
-itk::DataObject::Pointer
-fpa::Image::SkeletonReader< _TSkeleton >::
-MakeOutput( itk::ProcessObject::DataObjectPointerArraySizeType i )
-{
- return( TSkeleton::New( ).GetPointer( ) );
-}
-
-// -------------------------------------------------------------------------
-template< class _TSkeleton >
-fpa::Image::SkeletonReader< _TSkeleton >::
-SkeletonReader( )
- : Superclass( )
-{
- typename TSkeleton::Pointer out =
- static_cast< TSkeleton* >( this->MakeOutput( 0 ).GetPointer( ) );
- this->itk::ProcessObject::SetNumberOfRequiredInputs( 0 );
- this->itk::ProcessObject::SetNumberOfRequiredOutputs( 1 );
- this->itk::ProcessObject::SetNthOutput( 0, out.GetPointer( ) );
-}
-
-// -------------------------------------------------------------------------
-template< class _TSkeleton >
-fpa::Image::SkeletonReader< _TSkeleton >::
-~SkeletonReader( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TSkeleton >
-void fpa::Image::SkeletonReader< _TSkeleton >::
-GenerateData( )
-{
- typedef typename TSkeleton::TPath _TPath;
- typedef typename _TPath::TIndex _TIndex;
- typedef typename _TPath::TSpacing _TSpacing;
- typedef typename _TPath::TPoint _TPoint;
- typedef typename _TPath::TDirection _TDirection;
-
- std::string buffer;
- std::ifstream file_stream( this->m_FileName.c_str( ) );
- if( !file_stream )
- {
- itkExceptionMacro(
- << "Error reading skeleton from \"" << this->m_FileName << "\""
- );
- return;
-
- } // fi
- file_stream.seekg( 0, std::ios::end );
- buffer.reserve( ( unsigned int )( file_stream.tellg( ) ) );
- file_stream.seekg( 0, std::ios::beg );
- buffer.assign(
- ( std::istreambuf_iterator< char >( file_stream ) ),
- std::istreambuf_iterator< char >( )
- );
- file_stream.close( );
-
- std::istringstream in( buffer );
- unsigned int dim;
- in >> dim;
- if( dim != TSkeleton::Dimension )
- {
- itkExceptionMacro(
- << "Mismatched skeletons dimension: " << dim
- << " != " << TSkeleton::Dimension
- );
- return;
-
- } // fi
-
- // Read spatial parameters
- _TSpacing spa;
- _TDirection dir;
- _TPoint ori;
- for( unsigned int d = 0; d < dim; ++d )
- in >> spa[ d ];
- for( unsigned int d = 0; d < dim; ++d )
- for( unsigned int e = 0; e < dim; ++e )
- in >> dir[ d ][ e ];
- for( unsigned int d = 0; d < dim; ++d )
- in >> ori[ d ];
-
- // Read end-points, just to ignore
- unsigned int n;
- in >> n;
- for( unsigned int i = 0; i < n; ++i )
- {
- _TIndex idx;
- for( unsigned int d = 0; d < dim; ++d )
- in >> idx[ d ];
-
- } // rof
-
- // Read bifurcations, just to ignore
- in >> n;
- for( unsigned int i = 0; i < n; ++i )
- {
- _TIndex idx;
- for( unsigned int d = 0; d < dim; ++d )
- in >> idx[ d ];
-
- } // rof
-
- // Read paths
- TSkeleton* out = this->GetOutput( );
- unsigned int nPaths;
- in >> nPaths;
- for( unsigned int p = 0; p < nPaths; ++p )
- {
- typename _TPath::Pointer path = _TPath::New( );
- path->SetSpacing( spa );
- path->SetOrigin( ori );
- path->SetDirection( dir );
-
- unsigned long pathSize;
- in >> pathSize;
- for( unsigned long id = 0; id < pathSize; ++id )
- {
- _TIndex idx;
- for( unsigned int d = 0; d < dim; ++d )
- in >> idx[ d ];
- path->AddVertex( idx );
-
- } // rof
- out->AddBranch( path );
-
- } // rof
-}
-
-#endif // __fpa__Image__SkeletonReader__hxx__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Image__SkeletonToPolyDataFilter__h__
-#define __fpa__Image__SkeletonToPolyDataFilter__h__
-
-#include <fpa/Config.h>
-
-#ifdef USE_VTK
-# include <vtkPolyDataAlgorithm.h>
-#endif // USE_VTK
-
-namespace fpa
-{
- namespace Image
- {
- /**
- */
- template< class _TSkeleton >
- class SkeletonToPolyDataFilter
-#ifdef USE_VTK
- : public vtkPolyDataAlgorithm
-#endif // USE_VTK
- {
- public:
- typedef SkeletonToPolyDataFilter Self;
- typedef _TSkeleton TSkeleton;
-
- public:
-#ifdef USE_VTK
- vtkTypeMacro( SkeletonToPolyDataFilter, vtkPolyDataAlgorithm );
-#endif // USE_VTK
-
- public:
- static Self* New( );
-
- const TSkeleton* GetInput( ) const;
- void SetInput( const TSkeleton* sk );
-
- protected:
- SkeletonToPolyDataFilter( );
- virtual ~SkeletonToPolyDataFilter( );
-
-#ifdef USE_VTK
- int RequestData(
- vtkInformation* information,
- vtkInformationVector** input,
- vtkInformationVector* output
- );
- int RequestInformation(
- vtkInformation* information,
- vtkInformationVector** input,
- vtkInformationVector* output
- );
-#endif // USE_VTK
-
- private:
- // Purposely not implemented
- SkeletonToPolyDataFilter( const Self& );
- void operator=( const Self& );
-
- protected:
- const TSkeleton* m_Skeleton;
- };
-
- } // ecapseman
-
-} // ecapseman
-
-#ifndef ITK_MANUAL_INSTANTIATION
-# include <fpa/Image/SkeletonToPolyDataFilter.hxx>
-#endif // ITK_MANUAL_INSTANTIATION
-
-#endif // __fpa__Image__SkeletonToPolyDataFilter__h__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Image__SkeletonToPolyDataFilter__hxx__
-#define __fpa__Image__SkeletonToPolyDataFilter__hxx__
-
-#ifdef USE_VTK
-# include <vtkCellArray.h>
-# include <vtkInformation.h>
-# include <vtkInformationVector.h>
-# include <vtkPointData.h>
-# include <vtkUnsignedIntArray.h>
-# include <vtkSmartPointer.h>
-#endif // USE_VTK
-
-// -------------------------------------------------------------------------
-template< class _TSkeleton >
-typename fpa::Image::SkeletonToPolyDataFilter< _TSkeleton >::
-Self* fpa::Image::SkeletonToPolyDataFilter< _TSkeleton >::
-New( )
-{
- return( new Self( ) );
-}
-
-// -------------------------------------------------------------------------
-template< class _TSkeleton >
-const typename
-fpa::Image::SkeletonToPolyDataFilter< _TSkeleton >::
-TSkeleton* fpa::Image::SkeletonToPolyDataFilter< _TSkeleton >::
-GetInput( ) const
-{
- return( this->m_Skeleton );
-}
-
-// -------------------------------------------------------------------------
-template< class _TSkeleton >
-void fpa::Image::SkeletonToPolyDataFilter< _TSkeleton >::
-SetInput( const TSkeleton* sk )
-{
- if( this->m_Skeleton != sk )
- {
- this->m_Skeleton = sk;
-#ifdef USE_VTK
- this->Modified( );
-#endif // USE_VTK
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-template< class _TSkeleton >
-fpa::Image::SkeletonToPolyDataFilter< _TSkeleton >::
-SkeletonToPolyDataFilter( )
-#ifdef USE_VTK
- : vtkPolyDataAlgorithm( ),
- m_Skeleton( NULL )
-#endif // USE_VTK
-{
-#ifdef USE_VTK
- this->SetNumberOfInputPorts( 0 );
-#endif // USE_VTK
-}
-
-// -------------------------------------------------------------------------
-template< class _TSkeleton >
-fpa::Image::SkeletonToPolyDataFilter< _TSkeleton >::
-~SkeletonToPolyDataFilter( )
-{
-}
-
-#ifdef USE_VTK
-// -------------------------------------------------------------------------
-template< class _TSkeleton >
-int fpa::Image::SkeletonToPolyDataFilter< _TSkeleton >::
-RequestData(
- vtkInformation* information,
- vtkInformationVector** input,
- vtkInformationVector* output
- )
-{
- typedef typename _TSkeleton::TPath _TPath;
- static const unsigned int dim = _TPath::PathDimension;
-
- if( this->m_Skeleton == NULL )
- return( 0 );
-
- // Get output
- vtkInformation* info = output->GetInformationObject( 0 );
- vtkPolyData* out = vtkPolyData::SafeDownCast(
- info->Get( vtkDataObject::DATA_OBJECT( ) )
- );
-
- // Prepare data
- out->SetPoints( vtkSmartPointer< vtkPoints >::New( ) );
- out->SetVerts( vtkSmartPointer< vtkCellArray >::New( ) );
- out->SetLines( vtkSmartPointer< vtkCellArray >::New( ) );
- out->SetPolys( vtkSmartPointer< vtkCellArray >::New( ) );
- out->SetStrips( vtkSmartPointer< vtkCellArray >::New( ) );
- vtkSmartPointer< vtkUnsignedIntArray > darray =
- vtkSmartPointer< vtkUnsignedIntArray >::New( );
- darray->SetNumberOfComponents( 1 );
- out->GetPointData( )->SetScalars( darray );
- vtkPoints* points = out->GetPoints( );
- vtkCellArray* lines = out->GetLines( );
-
- // Assign all data
- unsigned int dcount = 0;
- typename TSkeleton::TMatrix::const_iterator mIt = this->m_Skeleton->BeginEdgesRows( );
- for( ; mIt != this->m_Skeleton->EndEdgesRows( ); ++mIt )
- {
- // TODO: mIt->first; --> this is the row index. <--
- typename TSkeleton::TMatrixRow::const_iterator rIt = mIt->second.begin( );
- for( ; rIt != mIt->second.end( ); ++rIt )
- {
- // TODO: rIt->first; --> this is the column index.
- typename TSkeleton::TEdges::const_iterator eIt = rIt->second.begin( );
- for( ; eIt != rIt->second.end( ); ++eIt )
- {
- _TPath* path = *eIt;
- for( unsigned long i = 0; i < path->GetSize( ); ++i )
- {
- auto pnt = path->GetPoint( i );
- if( dim == 1 )
- points->InsertNextPoint( pnt[ 0 ], 0, 0 );
- else if( dim == 2 )
- points->InsertNextPoint( pnt[ 0 ], pnt[ 1 ], 0 );
- else
- points->InsertNextPoint( pnt[ 0 ], pnt[ 1 ], pnt[ 2 ] );
- darray->InsertNextTuple1( double( dcount ) );
- if( i > 0 )
- {
- lines->InsertNextCell( 2 );
- lines->InsertCellPoint( points->GetNumberOfPoints( ) - 2 );
- lines->InsertCellPoint( points->GetNumberOfPoints( ) - 1 );
-
- } // fi
-
- } // rof
- dcount++;
-
- } // rof
-
- } // rof
-
- } // rof
- return( 1 );
-}
-
-// -------------------------------------------------------------------------
-template< class _TSkeleton >
-int fpa::Image::SkeletonToPolyDataFilter< _TSkeleton >::
-RequestInformation(
- vtkInformation* information,
- vtkInformationVector** input,
- vtkInformationVector* output
- )
-{
- return( 1 );
-}
-#endif // USE_VTK
-
-#endif // __fpa__Image__SkeletonToPolyDataFilterFilter__hxx__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Image__SkeletonWriter__h__
-#define __fpa__Image__SkeletonWriter__h__
-
-#include <itkProcessObject.h>
-
-namespace fpa
-{
- namespace Image
- {
- /**
- */
- template< class _TSkeleton >
- class SkeletonWriter
- : public itk::ProcessObject
- {
- public:
- // Basic types
- typedef SkeletonWriter Self;
- typedef itk::ProcessObject Superclass;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
-
- typedef _TSkeleton TSkeleton;
- typedef typename TSkeleton::TEdges TEdges;
- typedef typename TSkeleton::TMatrix TMatrix;
- typedef typename TSkeleton::TMatrixRow TMatrixRow;
- typedef typename TSkeleton::TPath TPath;
- typedef typename TSkeleton::TVertex TVertex;
-
- public:
- itkNewMacro( Self );
- itkTypeMacro( SkeletonWriter, itk::ProcessObject );
-
- itkGetConstMacro( FileName, std::string );
- itkSetMacro( FileName, std::string );
-
- public:
- const TSkeleton* GetInput( ) const;
- void SetInput( const TSkeleton* skeleton );
- virtual void Update( ) override;
-
- protected:
- SkeletonWriter( );
- virtual ~SkeletonWriter( );
-
- virtual void GenerateData( ) override;
-
- private:
- // Purposely not implemented
- SkeletonWriter( const Self& );
- void operator=( const Self& );
-
- protected:
- std::string m_FileName;
- };
-
- } // ecapseman
-
-} // ecapseman
-
-#ifndef ITK_MANUAL_INSTANTIATION
-# include <fpa/Image/SkeletonWriter.hxx>
-#endif // ITK_MANUAL_INSTANTIATION
-
-#endif // __fpa__Image__SkeletonWriter__h__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Image__SkeletonWriter__hxx__
-#define __fpa__Image__SkeletonWriter__hxx__
-
-#include <fstream>
-
-// -------------------------------------------------------------------------
-template< class _TSkeleton >
-const _TSkeleton* fpa::Image::SkeletonWriter< _TSkeleton >::
-GetInput( ) const
-{
- return(
- dynamic_cast< const TSkeleton* >(
- this->itk::ProcessObject::GetInput( 0 )
- )
- );
-}
-
-// -------------------------------------------------------------------------
-template< class _TSkeleton >
-void fpa::Image::SkeletonWriter< _TSkeleton >::
-SetInput( const _TSkeleton* skeleton )
-{
- this->itk::ProcessObject::SetNthInput(
- 0, const_cast< TSkeleton* >( skeleton )
- );
-}
-
-// -------------------------------------------------------------------------
-template< class _TSkeleton >
-void fpa::Image::SkeletonWriter< _TSkeleton >::
-Update( )
-{
- TSkeleton* input = const_cast< TSkeleton* >( this->GetInput( ) );
- if( input != NULL )
- {
- input->UpdateOutputInformation( );
- input->UpdateOutputData( );
- this->GenerateData( );
- this->ReleaseInputs( );
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-template< class _TSkeleton >
-fpa::Image::SkeletonWriter< _TSkeleton >::
-SkeletonWriter( )
- : Superclass( ),
- m_FileName( "" )
-{
- this->SetNumberOfRequiredInputs( 1 );
-}
-
-// -------------------------------------------------------------------------
-template< class _TSkeleton >
-fpa::Image::SkeletonWriter< _TSkeleton >::
-~SkeletonWriter( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TSkeleton >
-void fpa::Image::SkeletonWriter< _TSkeleton >::
-GenerateData( )
-{
- const TSkeleton* sk = this->GetInput( );
- typename TMatrix::const_iterator mIt = sk->BeginEdgesRows( );
- typename TMatrixRow::const_iterator rIt = mIt->second.begin( );
- typename TEdges::const_iterator eIt = rIt->second.begin( );
- const TPath* path = *eIt;
-
- // Write base information
- std::stringstream out1, out2;
- out1 << TSkeleton::Dimension << std::endl;
- typename TPath::TSpacing spa = path->GetSpacing( );
- for( unsigned int d = 0; d < TSkeleton::Dimension; ++d )
- out1 << spa[ d ] << " ";
- out1 << std::endl;
- typename TPath::TDirection dir = path->GetDirection( );
- for( unsigned int d = 0; d < TSkeleton::Dimension; ++d )
- for( unsigned int e = 0; e < TSkeleton::Dimension; ++e )
- out1 << dir[ d ][ e ] << " ";
- out1 << std::endl;
- typename TPath::TPoint ori = path->GetOrigin( );
- for( unsigned int d = 0; d < TSkeleton::Dimension; ++d )
- out1 << ori[ d ] << " ";
- out1 << std::endl;
-
- // End points
- std::vector< TVertex > end_points = sk->GetEndPoints( );
- out1 << end_points.size( ) << std::endl;
- typename std::vector< TVertex >::const_iterator epIt = end_points.begin( );
- for( ; epIt != end_points.end( ); ++epIt )
- {
- for( unsigned int d = 0; d < TSkeleton::Dimension; ++d )
- out1 << ( *epIt )[ d ] << " ";
- out1 << std::endl;
-
- } // rof
-
- // Bifurcations
- std::vector< TVertex > bifurcations = sk->GetBifurcations( );
- out1 << bifurcations.size( ) << std::endl;
- typename std::vector< TVertex >::const_iterator bIt = bifurcations.begin( );
- for( ; bIt != bifurcations.end( ); ++bIt )
- {
- for( unsigned int d = 0; d < TSkeleton::Dimension; ++d )
- out1 << ( *bIt )[ d ] << " ";
- out1 << std::endl;
-
- } // rof
-
- // Write paths
- unsigned long pathCount = 0;
- mIt = sk->BeginEdgesRows( );
- for( ; mIt != sk->EndEdgesRows( ); ++mIt )
- {
- typename TMatrixRow::const_iterator rIt = mIt->second.begin( );
- for( ; rIt != mIt->second.end( ); ++rIt )
- {
- typename TEdges::const_iterator eIt = rIt->second.begin( );
- for( ; eIt != rIt->second.end( ); ++eIt )
- {
- TPath* path = *eIt;
- pathCount++;
- unsigned int size = path->GetSize( );
- out2 << size << std::endl;
- for( unsigned int i = 0; i < path->GetSize( ); ++i )
- {
- TVertex v = path->GetVertex( i );
- for( unsigned int d = 0; d < TSkeleton::Dimension; ++d )
- out2 << v[ d ] << " ";
-
- } // rof
- out2 << std::endl;
-
- } // rof
-
- } // rof
-
- } // rof
- out1 << pathCount << std::endl << out2.str( );
-
- // Real write
- std::ofstream file_stream( this->m_FileName.c_str( ), std::ofstream::binary );
- if( !file_stream )
- itkExceptionMacro(
- << "Unable to write skeleton to \""
- << this->m_FileName
- << "\""
- );
- file_stream.write( out1.str( ).c_str( ), out1.str( ).size( ) );
-}
-
-#endif // __fpa__Image__SkeletonWriter__hxx__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Image__VisualDebugger__h__
-#define __fpa__Image__VisualDebugger__h__
-
-#include <fpa/Config.h>
-
-#include <vector>
-
-#include <itkCommand.h>
-#include <itkImage.h>
-#include <itkRGBAPixel.h>
-
-#ifdef USE_ivq
-#include <itkImageToVTKImageFilter.h>
-#endif // USE_ivq
-
-class vtkRenderer;
-class vtkRenderWindowInteractor;
-
-namespace fpa
-{
- namespace Image
- {
- /**
- */
- template< class _TFilter >
- class VisualDebugger
- : public itk::Command
- {
- public:
- typedef VisualDebugger Self;
- typedef itk::Command Superclass;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
-
- typedef _TFilter TFilter;
- typedef typename TFilter::TInputImage TImage;
-
- typedef itk::RGBAPixel< unsigned char > TLabel;
- typedef itk::Image< TLabel, TImage::ImageDimension > TLabels;
-#ifdef USE_ivq
- typedef itk::ImageToVTKImageFilter< TLabels > TVTKLabels;
-#endif // USE_ivq
-
- public:
- itkTypeMacro( fpa::Image::VisualDebugger, itk::Command );
-
- itkGetConstObjectMacro( Labels, TLabels );
-
- public:
- void SetVisualization(
- vtkRenderer* renderer, vtkRenderWindowInteractor* iren
- );
- virtual void Execute(
- itk::Object* caller, const itk::EventObject& event
- ) override;
- virtual void Execute(
- const itk::Object* caller, const itk::EventObject& event
- ) override;
-
- virtual void Render( ) = 0;
- virtual void StartVisualization( ) = 0;
- virtual void EndVisualization( ) = 0;
-
- protected:
- VisualDebugger( );
- virtual ~VisualDebugger( );
-
- private:
- // Purposely not implemented.
- VisualDebugger( const Self& other );
- Self& operator=( const Self& other );
-
- protected:
- std::vector< TLabel > m_Colors;
- typename TLabels::Pointer m_Labels;
-#ifdef USE_ivq
- vtkRenderer* m_Renderer;
- vtkRenderWindowInteractor* m_Interactor;
- typename TVTKLabels::Pointer m_VTKLabels;
-#endif // USE_ivq
- };
-
- } // ecapseman
-
-} // ecapseman
-
-#ifndef ITK_MANUAL_INSTANTIATION
-# include <fpa/Image/VisualDebugger.hxx>
-#endif // ITK_MANUAL_INSTANTIATION
-
-#endif // __fpa__Image__VisualDebugger__h__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Image__VisualDebugger__hxx__
-#define __fpa__Image__VisualDebugger__hxx__
-
-// -------------------------------------------------------------------------
-template< class _TFilter >
-void fpa::Image::VisualDebugger< _TFilter >::
-SetVisualization( vtkRenderer* renderer, vtkRenderWindowInteractor* iren )
-{
-#ifdef USE_ivq
- this->m_Renderer = renderer;
- this->m_Interactor = iren;
- this->Modified( );
-#endif // USE_ivq
-}
-
-// -------------------------------------------------------------------------
-template< class _TFilter >
-void fpa::Image::VisualDebugger< _TFilter >::
-Execute( itk::Object* caller, const itk::EventObject& event )
-{
- this->Execute( const_cast< const itk::Object* >( caller ), event );
-}
-
-// -------------------------------------------------------------------------
-template< class _TFilter >
-void fpa::Image::VisualDebugger< _TFilter >::
-Execute( const itk::Object* caller, const itk::EventObject& event )
-{
- typedef itk::StartEvent _TStart;
- typedef itk::EndEvent _TEnd;
- typedef typename _TFilter::TEvent _TEvent;
-
- // Check validity
- const TFilter* filter = dynamic_cast< const TFilter* >( caller );
- if( filter == NULL )
- return;
-
- // Get correct event type
- const _TEvent* ev_fpa = dynamic_cast< const _TEvent* >( &event );
- const _TStart* ev_start = dynamic_cast< const _TStart* >( &event );
- const _TEnd* ev_end = dynamic_cast< const _TEnd* >( &event );
- if( ev_fpa != NULL )
- {
- if( this->m_Labels.IsNotNull( ) )
- {
- TLabel new_color;
- if( ev_fpa->IntoQueue )
- new_color = this->m_Colors[ this->m_Colors.size( ) - 2 ];
- else
- new_color =
- this->m_Colors[
- ( ev_fpa->FrontId - 1 ) % ( this->m_Colors.size( ) - 2 )
- ];
- TLabel old_color = this->m_Labels->GetPixel( ev_fpa->Vertex );
- if( !( new_color == old_color ) )
- {
- this->m_Labels->SetPixel( ev_fpa->Vertex, new_color );
- this->m_VTKLabels->Modified( );
- this->Render( );
-
- } // fi
-
- } // fi
- }
- else if( ev_start != NULL )
- {
- const TImage* image = filter->GetInput( );
- this->m_Labels = TLabels::New( );
- this->m_Labels->
- SetLargestPossibleRegion( image->GetLargestPossibleRegion( ) );
- this->m_Labels->SetRequestedRegion( image->GetRequestedRegion( ) );
- this->m_Labels->SetBufferedRegion( image->GetBufferedRegion( ) );
- this->m_Labels->SetOrigin( image->GetOrigin( ) );
- this->m_Labels->SetSpacing( image->GetSpacing( ) );
- this->m_Labels->SetDirection( image->GetDirection( ) );
- this->m_Labels->Allocate( );
- this->m_Labels->FillBuffer( this->m_Colors.back( ) );
-#ifdef USE_ivq
- this->m_VTKLabels = TVTKLabels::New( );
- this->m_VTKLabels->SetInput( this->m_Labels );
- this->m_VTKLabels->Update( );
- this->StartVisualization( );
-#endif // USE_ivq
- }
- else if( ev_end != NULL )
- {
- this->EndVisualization( );
- this->m_Labels = NULL;
- this->m_VTKLabels = NULL;
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-template< class _TFilter >
-fpa::Image::VisualDebugger< _TFilter >::
-VisualDebugger( )
- : Superclass( )
-{
- unsigned char colors[ 8 ][ 4 ] =
- {
- { 255, 0, 0, 128 },
- { 0, 255, 0, 128 },
- { 0, 0, 255, 128 },
- { 0, 255, 255, 128 },
- { 255, 0, 255, 128 },
- { 255, 255, 0, 128 },
- { 255, 128, 64, 255 },
- { 0, 0, 0, 0 }
- };
- for( unsigned int i = 0; i < 8; ++i )
- this->m_Colors.push_back( TLabel( colors[ i ] ) );
-
-#ifdef USE_ivq
- this->m_Renderer = NULL;
- this->m_Interactor = NULL;
-#endif // USE_ivq
-}
-
-// -------------------------------------------------------------------------
-template< class _TFilter >
-fpa::Image::VisualDebugger< _TFilter >::
-~VisualDebugger( )
-{
-}
-
-#endif // __fpa__Image__VisualDebugger__h__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Image__VisualDebugger2D__h__
-#define __fpa__Image__VisualDebugger2D__h__
-
-#include <fpa/Image/VisualDebugger.h>
-#ifdef USE_ivq
-#include <vtkSmartPointer.h>
-#include <ivq/VTK/ImageActor.h>
-#endif // USE_ivq
-
-namespace fpa
-{
- namespace Image
- {
- /**
- */
- template< class _TFilter >
- class VisualDebugger2D
- : public fpa::Image::VisualDebugger< _TFilter >
- {
- public:
- typedef VisualDebugger2D Self;
- typedef fpa::Image::VisualDebugger< _TFilter > Superclass;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
-
- typedef typename Superclass::TFilter TFilter;
- typedef typename Superclass::TImage TImage;
- typedef typename Superclass::TLabel TLabel;
- typedef typename Superclass::TLabels TLabels;
-#ifdef USE_ivq
- typedef typename Superclass::TVTKLabels TVTKLabels;
- typedef ivq::VTK::ImageActor TImageActor;
-#endif // USE_ivq
-
- public:
- itkNewMacro( Self );
- itkTypeMacro( fpa::Image::VisualDebugger2D, fpa::Image::VisualDebugger );
-
- public:
- virtual void Render( ) override;
- virtual void StartVisualization( ) override;
- virtual void EndVisualization( ) override;
-
- protected:
- VisualDebugger2D( );
- virtual ~VisualDebugger2D( );
-
- private:
- // Purposely not implemented.
- VisualDebugger2D( const Self& other );
- Self& operator=( const Self& other );
-
- protected:
-#ifdef USE_ivq
- vtkSmartPointer< TImageActor > m_Actor;
- unsigned long m_NumberOfPixels;
- unsigned long m_RenderCount;
-#endif // USE_ivq
- };
-
- } // ecapseman
-
-} // ecapseman
-
-#ifndef ITK_MANUAL_INSTANTIATION
-# include <fpa/Image/VisualDebugger2D.hxx>
-#endif // ITK_MANUAL_INSTANTIATION
-
-#endif // __fpa__Image__VisualDebugger2D__h__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Image__VisualDebugger2D__hxx__
-#define __fpa__Image__VisualDebugger2D__hxx__
-
-#include <vtkRenderer.h>
-#include <vtkRenderWindowInteractor.h>
-
-// -------------------------------------------------------------------------
-template< class _TFilter >
-void fpa::Image::VisualDebugger2D< _TFilter >::
-Render( )
-{
-#ifdef USE_ivq
- if( this->m_Renderer == NULL || this->m_Interactor == NULL )
- return;
- this->m_Actor->Modified( );
- this->m_RenderCount = ( this->m_RenderCount + 1 ) % this->m_NumberOfPixels;
- if( this->m_RenderCount == 0 )
- this->m_Interactor->Render( );
-#endif // USE_ivq
-}
-
-// -------------------------------------------------------------------------
-template< class _TFilter >
-void fpa::Image::VisualDebugger2D< _TFilter >::
-StartVisualization( )
-{
-#ifdef USE_ivq
- if( this->m_Renderer == NULL || this->m_Interactor == NULL )
- return;
- this->m_Actor = vtkSmartPointer< TImageActor >::New( );
- this->m_Actor->SetInputData( this->m_VTKLabels->GetOutput( ) );
- this->m_Actor->Update( );
- this->m_Renderer->AddViewProp( this->m_Actor );
-
- this->m_NumberOfPixels =
- double(
- this->m_VTKLabels->GetInput( )->
- GetRequestedRegion( ).GetNumberOfPixels( )
- ) * 0.005;
- this->m_RenderCount = 0;
-
-#endif // USE_ivq
-}
-
-// -------------------------------------------------------------------------
-template< class _TFilter >
-void fpa::Image::VisualDebugger2D< _TFilter >::
-EndVisualization( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TFilter >
-fpa::Image::VisualDebugger2D< _TFilter >::
-VisualDebugger2D( )
- : Superclass( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TFilter >
-fpa::Image::VisualDebugger2D< _TFilter >::
-~VisualDebugger2D( )
-{
-}
-
-#endif // __fpa__Image__VisualDebugger2D__hxx__
-
-// eof - $RCSfile$
+++ /dev/null
-
-#include <fpa/fpa_export.h>
-#include <string>
-
-std::string FPA_EXPORT version( ) { return( "@prj_VER@" ); }
-
-// eof - $RCSfile$
+++ /dev/null
-option(fpa_BUILD_TESTS "Build command line tests." OFF)
-if(fpa_BUILD_TESTS)
- include_directories(
- ${PROJECT_SOURCE_DIR}/lib
- ${PROJECT_BINARY_DIR}/lib
- )
- subdirs(image)
-endif(fpa_BUILD_TESTS)
-
-## eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__tests__image__BaseFunctions__h__
-#define __fpa__tests__image__BaseFunctions__h__
-
-#include <cstdarg>
-#include <string>
-
-#include <itkImageFileReader.h>
-#include <itkImageFileWriter.h>
-
-#include <fpa/Config.h>
-/* TODO
- #ifdef USE_ivq
- # include <itkImageToVTKImageFilter.h>
- # include <itkVTKImageToImageFilter.h>
- # include <vtkSmartPointer.h>
- # include <vtkRenderWindow.h>
- # include <ivq/VTK/ImageViewer.h>
- # include <ivq/VTK/BrushWidget.h>
- # include <ivq/VTK/SeedWidgetOverImageActor.h>
- # include <fpa/Image/VisualDebugger2D.h>
- #endif // USE_ivq
-*/
-
-namespace fpa
-{
- namespace tests
- {
- namespace image
- {
- // -------------------------------------------------------------------
- template< class _TPointer >
- void CreateImage(
- _TPointer& img,
- const typename _TPointer::ObjectType::PixelType& zero,
- ...
- )
- {
- typedef typename _TPointer::ObjectType _TImage;
-
- va_list vl;
- va_start( vl, zero );
-
- typename _TImage::SizeType size;
- for( unsigned int d = 0; d < _TImage::ImageDimension; ++d )
- size[ d ] = va_arg( vl, int );
-
- typename _TImage::SpacingType spac;
- for( unsigned int d = 0; d < _TImage::ImageDimension; ++d )
- spac[ d ] = va_arg( vl, double );
-
- img = _TImage::New( );
- img->SetRegions( size );
- img->SetSpacing( spac );
- img->Allocate( );
- img->FillBuffer( zero );
-
- va_end( vl );
- }
-
- // -------------------------------------------------------------------
- template< class _TPointer >
- std::string Read( _TPointer& img, const std::string& fname )
- {
- typedef typename _TPointer::ObjectType _TImage;
- typedef itk::ImageFileReader< _TImage > _TReader;
-
- typename _TReader::Pointer reader = _TReader::New( );
- reader->SetFileName( fname );
- try
- {
- reader->Update( );
- }
- catch( std::exception& err )
- {
- return( err.what( ) );
-
- } // ytr
- img = reader->GetOutput( );
- img->DisconnectPipeline( );
- return( "" );
- }
-
- // -------------------------------------------------------------------
- template< class _TImage >
- std::string Write( const _TImage* img, const std::string& fname )
- {
- typedef itk::ImageFileWriter< _TImage > _TWriter;
-
- typename _TWriter::Pointer writer = _TWriter::New( );
- writer->SetInput( img );
- writer->SetFileName( fname );
- try
- {
- writer->Update( );
- }
- catch( std::exception& err )
- {
- return( err.what( ) );
-
- } // ytr
- return( "" );
- }
-
- // -------------------------------------------------------------------
- /* TODO
- #ifdef USE_ivq
- template< class _TFilter >
- class Viewer
- {
- public:
- typedef _TFilter TFilter;
- typedef typename _TFilter::TInputImage TInputImage;
-
- public:
- Viewer( const TInputImage* image )
- {
- this->m_VTKInputImage = TVTKInputImage::New( );
- this->m_VTKInputImage->SetInput( image );
- this->m_VTKInputImage->Update( );
-
- this->m_Viewer = vtkSmartPointer< ivq::VTK::ImageViewer >::New( );
- this->m_Viewer->SetInputData( this->m_VTKInputImage->GetOutput( ) );
- }
-
- virtual ~Viewer( )
- {
- }
-
- void ActivateSeedWidget( )
- {
- this->m_SeedWidget =
- vtkSmartPointer< ivq::VTK::SeedWidgetOverImageActor >::New( );
- this->m_SeedWidget->SetActor( this->m_Viewer->GetImageActor( ) );
- this->m_SeedWidget->SetInteractor(
- this->m_Viewer->GetRenderWindow( )->GetInteractor( )
- );
- }
-
- void ActivateBrushWidget( )
- {
- this->m_BrushWidget =
- vtkSmartPointer< ivq::VTK::BrushWidget >::New( );
- this->m_BrushWidget->SetImageActor( this->m_Viewer->GetImageActor( ) );
- this->m_BrushWidget->SetInteractor(
- this->m_Viewer->GetRenderWindow( )->GetInteractor( )
- );
- }
-
- void Show( )
- {
- this->m_Viewer->Render( );
- this->m_Viewer->ResetCamera( );
- this->m_Viewer->Initialize( );
- this->m_Viewer->Render( );
- if( this->m_SeedWidget.GetPointer( ) != NULL )
- this->m_SeedWidget->EnabledOn( );
- if( this->m_BrushWidget.GetPointer( ) != NULL )
- this->m_BrushWidget->EnabledOn( );
- this->m_Viewer->Start( );
- if( this->m_SeedWidget.GetPointer( ) != NULL )
- this->m_SeedWidget->EnabledOff( );
- if( this->m_BrushWidget.GetPointer( ) != NULL )
- this->m_BrushWidget->EnabledOff( );
- }
-
- void AssociateSeedsTo( TFilter* filter )
- {
- if( this->m_SeedWidget.GetPointer( ) != NULL )
- {
- const ivq::VTK::SeedWidgetOverImageActor::TSeeds& wdg_seeds =
- this->m_SeedWidget->GetSeeds( );
- ivq::VTK::SeedWidgetOverImageActor::TSeeds::const_iterator wsIt;
- for( wsIt = wdg_seeds.begin( ); wsIt != wdg_seeds.end( ); ++wsIt )
- {
- typename TInputImage::PointType pnt;
- for( unsigned int i = 0; i < wsIt->second.size( ); i += 3 )
- {
- pnt[ 0 ] = wsIt->second[ i ];
- pnt[ 1 ] = wsIt->second[ i + 1 ];
-
- typename TInputImage::IndexType idx;
- filter->GetInput( )->TransformPhysicalPointToIndex( pnt, idx );
- filter->AddSeed( idx );
-
- } // rof
-
- } // rof
-
- } // fi
- }
-
- void AssociateLabelsTo( TFilter* filter )
- {
- if( this->m_BrushWidget.GetPointer( ) != NULL )
- {
- typedef typename TFilter::TLabelImage _TLabelImage;
- typedef itk::VTKImageToImageFilter< _TLabelImage > TITKImage;
- typename TITKImage::Pointer itk_image = TITKImage::New( );
- itk_image->SetInput( this->m_BrushWidget->GetCanvas( ) );
- itk_image->Update( );
- filter->SetLabels( itk_image->GetOutput( ) );
-
- } // fi
- }
-
- void ObserveFilter( TFilter* filter )
- {
- typedef fpa::Image::VisualDebugger2D< TFilter > _TDeb;
- typedef typename TFilter::TEvent _TEvent;
- typename _TDeb::Pointer deb = _TDeb::New( );
- deb->SetVisualization(
- this->m_Viewer->GetRenderer( ),
- this->m_Viewer->GetRenderWindow( )->GetInteractor( )
- );
- this->m_Observer1 = filter->AddObserver( itk::StartEvent( ), deb );
- this->m_Observer2 = filter->AddObserver( itk::EndEvent( ), deb );
- this->m_Observer3 = filter->AddObserver( _TEvent( ), deb );
- filter->VisualDebugOn( );
- }
-
- protected:
- typedef itk::ImageToVTKImageFilter< TInputImage > TVTKInputImage;
- typename TVTKInputImage::Pointer m_VTKInputImage;
- vtkSmartPointer< ivq::VTK::ImageViewer > m_Viewer;
- vtkSmartPointer< ivq::VTK::SeedWidgetOverImageActor > m_SeedWidget;
- vtkSmartPointer< ivq::VTK::BrushWidget > m_BrushWidget;
- unsigned long m_Observer1;
- unsigned long m_Observer2;
- unsigned long m_Observer3;
- };
- #endif // USE_ivq
- */
-
- } // ecapseman
-
- } // ecapseman
-
-} // ecapseman
-
-
-#endif // __fpa__tests__image__BaseFunctions__h__
-
-// eof - $RCSfile$
+++ /dev/null
-set(_pfx test_fpa_image_)
-set(
- _examples
- RegionGrow_Tautology
- RegionGrow_BinaryThreshold
- MoriSegmentation
- Dijkstra_Identity
- Dijkstra_Gaussian
- RandomWalker
- SkeletonFilter
- SkeletonToPolyData
- )
-foreach(_e ${_examples})
- add_executable(${_pfx}${_e} ${_e}.cxx)
- target_link_libraries(${_pfx}${_e} ivq::ivq fpa)
-endforeach(_e)
-
-## eof - $RCSfile$
+++ /dev/null
-#include "BaseFunctions.h"
-#include <itkImage.h>
-#include <fpa/Image/Dijkstra.h>
-#include <fpa/Image/Functors/Dijkstra/Gaussian.h>
-
-// -------------------------------------------------------------------------
-const unsigned int Dim = 3;
-typedef short TPixel;
-typedef float TScalar;
-
-typedef itk::Image< TPixel, Dim > TInputImage;
-typedef itk::Image< TScalar, Dim > TScalarImage;
-typedef fpa::Image::Dijkstra< TInputImage, TScalarImage > TFilter;
-typedef fpa::Image::Functors::Dijkstra::Gaussian< TInputImage, TScalar > TWeight;
-
-// -------------------------------------------------------------------------
-int main( int argc, char* argv[] )
-{
- // Get arguments
- if( argc < 7 )
- {
- std::cerr
- << "Usage: " << argv[ 0 ]
- << " input_image output_image output_marks alpha beta"
- << " stop_at_one_front ..."
- << std::endl;
- return( 1 );
-
- } // fi
- std::string input_image_filename = argv[ 1 ];
- std::string output_image_filename = argv[ 2 ];
- std::string output_marks_filename = argv[ 3 ];
- double alpha = std::atoi( argv[ 4 ] );
- double beta = std::atoi( argv[ 5 ] );
- bool stop_at_one_front = ( argv[ 6 ][ 0 ] == '1' );
-
- // Create image
- TInputImage::Pointer image;
- std::string err0 = fpa::tests::image::Read( image, input_image_filename );
- if( err0 != "" )
- {
- std::cerr << "Error caught: " << err0 << std::endl;
- return( 1 );
-
- } // fi
-
- // Prepare weight
- TWeight::Pointer weight = TWeight::New( );
- weight->SetAlpha( alpha );
- weight->SetBeta( beta );
-
- // Prepare filter
- TFilter::Pointer filter = TFilter::New( );
- filter->SetInput( image );
- filter->SetWeightFunction( weight );
- filter->SetStopAtOneFront( stop_at_one_front );
-
- // Get all seeds
- for( int i = 7; i < argc; i += 3 )
- {
- if( i + 1 < argc )
- {
- TInputImage::IndexType seed;
- seed[ 0 ] = std::atoi( argv[ i ] );
- seed[ 1 ] = std::atoi( argv[ i + 1 ] );
- seed[ 2 ] = std::atoi( argv[ i + 2 ] );
- filter->AddSeed( seed );
-
- } // fi
-
- } // rof
-
- // Execute filter
- filter->Update( );
-
- // Save results
- std::string err1 =
- fpa::tests::image::Write( filter->GetOutput( ), output_image_filename );
- std::string err2 =
- fpa::tests::image::Write( filter->GetMarks( ), output_marks_filename );
- if( err1 != "" ) std::cerr << "Error caught: " << err1 << std::endl;
- if( err2 != "" ) std::cerr << "Error caught: " << err2 << std::endl;
-
- return( 0 );
-}
-
-// eof - $RCSfile$
+++ /dev/null
-#include "BaseFunctions.h"
-#include <itkImage.h>
-#include <fpa/Image/Dijkstra.h>
-#include <fpa/Image/Functors/Dijkstra/Identity.h>
-
-// -------------------------------------------------------------------------
-const unsigned int Dim = 2;
-typedef unsigned char TPixel;
-typedef float TScalar;
-
-typedef itk::Image< TPixel, Dim > TInputImage;
-typedef itk::Image< TScalar, Dim > TScalarImage;
-typedef fpa::Image::Dijkstra< TInputImage, TScalarImage > TFilter;
-typedef fpa::Image::Functors::Dijkstra::Identity< TInputImage, TScalar > TWeight;
-
-// -------------------------------------------------------------------------
-int main( int argc, char* argv[] )
-{
- // Get arguments
- if( argc < 5 )
- {
- std::cerr
- << "Usage: " << argv[ 0 ]
- << " output_image output_marks width height ..."
- << std::endl;
- return( 1 );
-
- } // fi
- std::string output_image_filename = argv[ 1 ];
- std::string output_marks_filename = argv[ 2 ];
- int width = std::atoi( argv[ 3 ] );
- int height = std::atoi( argv[ 4 ] );
-
- // Create image
- TInputImage::Pointer image;
- fpa::tests::image::CreateImage( image, 1, width, height, 1.0, 1.0 );
-
- // Prepare weight
- TWeight::Pointer weight = TWeight::New( );
-
- // Prepare filter
- TFilter::Pointer filter = TFilter::New( );
- filter->SetInput( image );
- filter->SetWeightFunction( weight );
-
- // Get all seeds
- for( int i = 5; i < argc; i += 2 )
- {
- if( i + 1 < argc )
- {
- TInputImage::IndexType seed;
- seed[ 0 ] = std::atoi( argv[ i ] );
- seed[ 1 ] = std::atoi( argv[ i + 1 ] );
- filter->AddSeed( seed );
-
- } // fi
-
- } // rof
-
- // Execute filter
- filter->Update( );
-
- // Save results
- std::string err1 =
- fpa::tests::image::Write( filter->GetOutput( ), output_image_filename );
- std::string err2 =
- fpa::tests::image::Write( filter->GetMarks( ), output_marks_filename );
- if( err1 != "" ) std::cerr << err1 << std::endl;
- if( err2 != "" ) std::cerr << err2 << std::endl;
-
- return( 0 );
-}
-
-// eof - $RCSfile$
+++ /dev/null
-#include "BaseFunctions.h"
-#include <chrono>
-#include <itkImage.h>
-#include <fpa/Image/Mori.h>
-
-// -------------------------------------------------------------------------
-const unsigned int Dim = 3;
-typedef short TPixel;
-typedef unsigned short TLabel;
-
-typedef itk::Image< TPixel, Dim > TInputImage;
-typedef itk::Image< TLabel, Dim > TLabelImage;
-typedef fpa::Image::Mori< TInputImage, TLabelImage > TFilter;
-
-// -------------------------------------------------------------------------
-int main( int argc, char* argv[] )
-{
- // Get arguments
- if( argc < 9 + Dim )
- {
- std::cerr
- << "Usage: " << argv[ 0 ]
- << " input_image output_image output_marks output_signal"
- << " init_threshold end_threshold delta [index/point] seed"
- << std::endl;
- return( 1 );
-
- } // fi
- std::string input_image_filename = argv[ 1 ];
- std::string output_image_filename = argv[ 2 ];
- std::string output_marks_filename = argv[ 3 ];
- std::string output_signal_filename = argv[ 4 ];
- TPixel init_threshold = std::atoi( argv[ 5 ] );
- TPixel end_threshold = std::atoi( argv[ 6 ] );
- TPixel delta = std::atoi( argv[ 7 ] );
- std::string seed_type = argv[ 8 ];
-
- TInputImage::IndexType iseed;
- TInputImage::PointType pseed;
- for( unsigned int i = 0; i < Dim; ++i )
- {
- if( seed_type == "index" )
- iseed[ i ] = std::atoi( argv[ 9 + i ] );
- else
- pseed[ i ] = std::atof( argv[ 9 + i ] );
-
- } // rof
-
- // Create image
- TInputImage::Pointer input_image;
- std::string err0 =
- fpa::tests::image::Read( input_image, input_image_filename );
- if( err0 != "" ) std::cerr << err0 << std::endl;
-
- // Prepare filter
- TFilter::Pointer filter = TFilter::New( );
- filter->SetInput( input_image );
- if( seed_type == "index" )
- filter->SetSeed( iseed );
- else
- filter->SetSeed( pseed );
- filter->SetThresholds( init_threshold, end_threshold, delta );
- filter->SetInsideValue( 255 );
- filter->SetOutsideValue( 0 );
- filter->SetSignalKernelSize( 20 );
- filter->SetSignalThreshold( 500 );
- filter->SetSignalInfluence( 0.5 );
- filter->SetMinimumThreshold( -850 );
-
- // Execute filter
- std::chrono::time_point< std::chrono::high_resolution_clock > tstart, tend;
- tstart = std::chrono::high_resolution_clock::now( );
- filter->Update( );
- tend = std::chrono::high_resolution_clock::now( );
- std::chrono::duration< double > telapsed = tend - tstart;
-
- // Save results
- std::string err1 =
- fpa::tests::image::Write( filter->GetThresholdedOutput( ), output_image_filename );
- std::string err2 =
- fpa::tests::image::Write( filter->GetMarks( ), output_marks_filename );
- if( err1 != "" ) std::cerr << err1 << std::endl;
- if( err2 != "" ) std::cerr << err2 << std::endl;
-
- std::ofstream osignal( output_signal_filename.c_str( ) );
- unsigned long nThr = filter->GetNumberOfEvaluatedThresholds( );
- for( unsigned long i = 0; i < nThr; ++i )
- {
- double x, y;
- TFilter::TPeak p;
- filter->GetSignalValues( i, x, y, p );
- osignal << x << " " << y << std::endl;
-
- } // rof
- osignal.close( );
-
- std::cout
- << "------------------------------------------------------" << std::endl
- << "Elapsed time: " << telapsed.count( ) << " s" << std::endl
- << "Optimum threshold: " << filter->GetOptimumThreshold( ) << std::endl
- << "Number of evaluated thresholds: " << nThr << std::endl
- << "------------------------------------------------------"
- << std::endl;
-
- return( 0 );
-}
-
-// eof - $RCSfile$
+++ /dev/null
-#include "BaseFunctions.h"
-#include <itkImage.h>
-#include <fpa/Image/RandomWalker.h>
-#include <fpa/Image/Functors/Dijkstra/Gaussian.h>
-
-// -------------------------------------------------------------------------
-const unsigned int Dim = 2;
-typedef short TPixel;
-typedef unsigned char TLabel;
-typedef float TScalar;
-
-typedef itk::Image< TPixel, Dim > TInputImage;
-typedef itk::Image< TLabel, Dim > TLabelImage;
-typedef fpa::Image::RandomWalker< TInputImage, TLabelImage, TScalar > TFilter;
-typedef fpa::Image::Functors::Dijkstra::Gaussian< TInputImage, TScalar > TWeight;
-
-// -------------------------------------------------------------------------
-int main( int argc, char* argv[] )
-{
- // Get arguments
- if( argc < 6 )
- {
- std::cerr
- << "Usage: " << argv[ 0 ]
- << " input_image labels_image output_image output_costs"
- << " beta"
- << std::endl;
- return( 1 );
-
- } // fi
- std::string input_image_filename = argv[ 1 ];
- std::string labels_image_filename = argv[ 2 ];
- std::string output_image_filename = argv[ 3 ];
- std::string output_costs_filename = argv[ 4 ];
- double beta = std::atof( argv[ 5 ] );
-
- // Read image
- TInputImage::Pointer image;
- std::string err0 = fpa::tests::image::Read( image, input_image_filename );
- if( err0 != "" )
- {
- std::cerr << "Error caught: " << err0 << std::endl;
- return( 1 );
-
- } // fi
-
- // Read label
- TLabelImage::Pointer labels;
- std::string err1 = fpa::tests::image::Read( labels, labels_image_filename );
- if( err1 != "" )
- {
- std::cerr << "Error caught: " << err1 << std::endl;
- return( 1 );
-
- } // fi
-
- // Prepare weight
- TWeight::Pointer weight = TWeight::New( );
- weight->SetBeta( beta );
-
- // Prepare filter
- TFilter::Pointer filter = TFilter::New( );
- filter->SetInput( image );
- filter->SetWeightFunction( weight );
- filter->SetLabels( labels );
-
- // Execute filter
- try
- {
- filter->Update( );
- }
- catch( std::exception& err )
- {
- std::cerr << "Error caught: " << err.what( ) << std::endl;
- return( 1 );
-
- } // yrt
-
- // Save results
- std::string err2 =
- fpa::tests::image::Write( filter->GetMarks( ), output_image_filename );
- std::string err3 =
- fpa::tests::image::Write( filter->GetOutput( ), output_costs_filename );
- if( err2 != "" ) std::cerr << "Error caught: " << err2 << std::endl;
- if( err3 != "" ) std::cerr << "Error caught: " << err3 << std::endl;
-
- return( 0 );
-}
-
-// eof - $RCSfile$
+++ /dev/null
-#include "BaseFunctions.h"
-#include <itkImage.h>
-#include <fpa/Image/RegionGrow.h>
-#include <fpa/Base/Functors/RegionGrow/BinaryThreshold.h>
-
-// -------------------------------------------------------------------------
-const unsigned int Dim = 3;
-typedef short TInputPixel;
-typedef unsigned char TOutputPixel;
-
-typedef itk::Image< TInputPixel, Dim > TInputImage;
-typedef itk::Image< TOutputPixel, Dim > TOutputImage;
-typedef fpa::Image::RegionGrow< TInputImage, TOutputImage > TFilter;
-typedef fpa::Base::Functors::RegionGrow::BinaryThreshold< TInputPixel > TPredicate;
-
-// -------------------------------------------------------------------------
-int main( int argc, char* argv[] )
-{
- // Get arguments
- if( argc < 8 + Dim )
- {
- std::cerr
- << "Usage: " << argv[ 0 ]
- << " input_image output_image output_marks"
- << " lower upper strict [index/point] ..."
- << std::endl;
- return( 1 );
-
- } // fi
- std::string input_image_filename = argv[ 1 ];
- std::string output_image_filename = argv[ 2 ];
- std::string output_marks_filename = argv[ 3 ];
- TInputPixel lower = TInputPixel( std::atof( argv[ 4 ] ) );
- TInputPixel upper = TInputPixel( std::atof( argv[ 5 ] ) );
- bool strict = ( argv[ 6 ][ 0 ] == '1' );
- std::string seeds_type = argv[ 7 ];
-
- // Create image
- TInputImage::Pointer input_image;
- std::string err0 =
- fpa::tests::image::Read( input_image, input_image_filename );
- if( err0 != "" ) std::cerr << err0 << std::endl;
-
- // Prepare predicate
- TPredicate::Pointer predicate = TPredicate::New( );
- predicate->SetLower( lower );
- predicate->SetUpper( upper );
- predicate->SetStrict( strict );
-
- // Prepare filter
- TFilter::Pointer filter = TFilter::New( );
- filter->SetInput( input_image );
- filter->SetPredicate( predicate );
- filter->SetInsideValue( 255 );
- filter->SetOutsideValue( 0 );
-
- // Get all seeds
- for( int i = 8; i < argc; i += Dim )
- {
- if( seeds_type == "index" )
- {
- TInputImage::IndexType seed;
- for( unsigned int d = 0; d < Dim; ++d )
- seed[ d ] = std::atoi( argv[ i + d ] );
- filter->AddSeed( seed );
- }
- else
- {
- TInputImage::PointType seed;
- for( unsigned int d = 0; d < Dim; ++d )
- seed[ d ] = std::atof( argv[ i + d ] );
- filter->AddSeed( seed );
-
- } // fi
- } // rof
-
- // Execute filter
- filter->Update( );
-
- // Save results
- std::string err1 =
- fpa::tests::image::Write( filter->GetOutput( ), output_image_filename );
- std::string err2 =
- fpa::tests::image::Write( filter->GetMarks( ), output_marks_filename );
- if( err1 != "" ) std::cerr << err1 << std::endl;
- if( err2 != "" ) std::cerr << err2 << std::endl;
-
- return( 0 );
-}
-
-// eof - $RCSfile$
+++ /dev/null
-#include "BaseFunctions.h"
-#include <itkImage.h>
-#include <fpa/Image/RegionGrow.h>
-#include <fpa/Base/Functors/RegionGrow/Tautology.h>
-
-// -------------------------------------------------------------------------
-const unsigned int Dim = 2;
-typedef unsigned char TPixel;
-
-typedef itk::Image< TPixel, Dim > TImage;
-typedef fpa::Image::RegionGrow< TImage, TImage > TFilter;
-typedef fpa::Base::Functors::RegionGrow::Tautology< TPixel > TPredicate;
-
-// -------------------------------------------------------------------------
-int main( int argc, char* argv[] )
-{
- // Get arguments
- if( argc < 5 )
- {
- std::cerr
- << "Usage: " << argv[ 0 ]
- << " output_image output_marks width height ..."
- << std::endl;
- return( 1 );
-
- } // fi
- std::string output_image_filename = argv[ 1 ];
- std::string output_marks_filename = argv[ 2 ];
- int width = std::atoi( argv[ 3 ] );
- int height = std::atoi( argv[ 4 ] );
-
- // Create image
- TImage::Pointer image;
- fpa::tests::image::CreateImage( image, 0, width, height, 1.0, 1.0 );
-
- // Prepare predicate
- TPredicate::Pointer predicate = TPredicate::New( );
-
- // Prepare filter
- TFilter::Pointer filter = TFilter::New( );
- filter->SetInput( image );
- filter->SetPredicate( predicate );
- filter->SetInsideValue( 255 );
- filter->SetOutsideValue( 0 );
-
- // Get all seeds
- for( int i = 5; i < argc; i += 2 )
- {
- if( i + 1 < argc )
- {
- TImage::IndexType seed;
- seed[ 0 ] = std::atoi( argv[ i ] );
- seed[ 1 ] = std::atoi( argv[ i + 1 ] );
- filter->AddSeed( seed );
-
- } // fi
-
- } // rof
-
- // Execute filter
- filter->Update( );
-
- // Save results
- std::string err1 =
- fpa::tests::image::Write( filter->GetOutput( ), output_image_filename );
- std::string err2 =
- fpa::tests::image::Write( filter->GetMarks( ), output_marks_filename );
- if( err1 != "" ) std::cerr << err1 << std::endl;
- if( err2 != "" ) std::cerr << err2 << std::endl;
-
- return( 0 );
-}
-
-// eof - $RCSfile$
+++ /dev/null
-#include "BaseFunctions.h"
-#include <itkImage.h>
-#include <fpa/Image/SkeletonFilter.h>
-#include <fpa/Image/SkeletonWriter.h>
-
-// -------------------------------------------------------------------------
-const unsigned int Dim = 3;
-typedef short TPixel;
-
-typedef itk::Image< TPixel, Dim > TInputImage;
-typedef fpa::Image::SkeletonFilter< TInputImage > TFilter;
-
-// -------------------------------------------------------------------------
-int main( int argc, char* argv[] )
-{
- // Get arguments
- if( argc < 3 )
- {
- std::cerr
- << "Usage: " << argv[ 0 ]
- << " input_image output_skeleton ..."
- << std::endl;
- return( 1 );
-
- } // fi
- std::string input_image_filename = argv[ 1 ];
- std::string output_skeleton_filename = argv[ 2 ];
-
- // Read image
- TInputImage::Pointer image;
- std::string err1 = fpa::tests::image::Read( image, input_image_filename );
- if( err1 != "" )
- {
- std::cerr << "Error caught: " << err1 << std::endl;
- return( 1 );
-
- } // fi
-
- // Prepare filter
- TFilter::Pointer filter = TFilter::New( );
- filter->SetInput( image );
-
- // Configure seed
- if( argc == 6 )
- {
- TInputImage::PointType pnt;
- pnt[ 0 ] = std::atof( argv[ 3 ] );
- pnt[ 1 ] = std::atof( argv[ 4 ] );
- pnt[ 2 ] = std::atof( argv[ 5 ] );
-
- TInputImage::IndexType seed;
- image->TransformPhysicalPointToIndex( pnt, seed );
-
- filter->SeedFromMaximumDistanceOff( );
- filter->SetSeed( seed );
- }
- else
- filter->SeedFromMaximumDistanceOn( );
-
- // Configure distance map
- filter->GetDistanceMap( )->InsideIsPositiveOn( );
- filter->GetDistanceMap( )->SquaredDistanceOff( );
- filter->GetDistanceMap( )->UseImageSpacingOn( );
-
- // Update
- filter->Update( );
-
- // Save results
- fpa::Image::SkeletonWriter< TFilter::TSkeleton >::Pointer writer =
- fpa::Image::SkeletonWriter< TFilter::TSkeleton >::New( );
- writer->SetInput( filter->GetOutput( ) );
- writer->SetFileName( output_skeleton_filename );
- try
- {
- writer->Update( );
- }
- catch( std::exception& err )
- {
- std::cerr << "Error caught: " << err.what( ) << std::endl;
- return( 1 );
-
- } // yrt
- return( 0 );
-}
-
-// eof - $RCSfile$
+++ /dev/null
-
-#include <vtkPolyDataWriter.h>
-#include <vtkSmartPointer.h>
-
-#include <fpa/Image/Skeleton.h>
-#include <fpa/Image/SkeletonReader.h>
-#include <fpa/Image/SkeletonToPolyDataFilter.h>
-
-// -------------------------------------------------------------------------
-const unsigned int Dim = 3;
-typedef fpa::Image::Skeleton< Dim > TSkeleton;
-typedef fpa::Image::SkeletonToPolyDataFilter< TSkeleton > TFilter;
-
-// -------------------------------------------------------------------------
-int main( int argc, char* argv[] )
-{
-#ifdef USE_VTK
- // Get arguments
- if( argc < 3 )
- {
- std::cerr
- << "Usage: " << argv[ 0 ]
- << " input_skeleton output_polydata"
- << std::endl;
- return( 1 );
-
- } // fi
- std::string input_skeleton_filename = argv[ 1 ];
- std::string output_polydata_filename = argv[ 2 ];
-
- fpa::Image::SkeletonReader< TSkeleton >::Pointer reader =
- fpa::Image::SkeletonReader< TSkeleton >::New( );
- reader->SetFileName( input_skeleton_filename );
- try
- {
- reader->Update( );
- }
- catch( std::exception& err )
- {
- std::cerr << "Error caught: " << err.what( ) << std::endl;
- return( 1 );
-
- } // yrt
-
- vtkSmartPointer< TFilter > filter = vtkSmartPointer< TFilter >::New( );
- filter->SetInput( reader->GetOutput( ) );
-
- vtkSmartPointer< vtkPolyDataWriter > writer =
- vtkSmartPointer< vtkPolyDataWriter >::New( );
- writer->SetInputConnection( filter->GetOutputPort( ) );
- writer->SetFileName( output_polydata_filename.c_str( ) );
- writer->Update( );
-
- return( 0 );
-#else // USE_VTK
- std::cerr
- << "Error: FrontAlgorithms was compiled without VTK support."
- << std::endl;
- return( 1 );
-#endif // USE_VTK
-}
-
-// eof - $RCSfile$