X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=plugins%2FImageAlgorithms%2FSkeletonFilter.cxx;h=274dc651717e25bae44bb62a4fd88cdefcdeb74e;hb=d5fe8fd4bac61fafea412c358323ad90fe2b034b;hp=03689aa5e023bf9e66ea97912bb9ee1c31cb9ccd;hpb=40fb0405cfef444001429f8ba49c407ce9168a94;p=FrontAlgorithms.git diff --git a/plugins/ImageAlgorithms/SkeletonFilter.cxx b/plugins/ImageAlgorithms/SkeletonFilter.cxx index 03689aa..274dc65 100644 --- a/plugins/ImageAlgorithms/SkeletonFilter.cxx +++ b/plugins/ImageAlgorithms/SkeletonFilter.cxx @@ -1,80 +1,81 @@ -#include +#include "SkeletonFilter.h" #include #include -#include - -/* TODO - #include - #include -*/ - // ------------------------------------------------------------------------- -fpaPluginsImageAlgorithms::SkeletonFilter:: +fpaPlugins_ImageAlgorithms::SkeletonFilter:: SkeletonFilter( ) : Superclass( ) { + typedef cpPlugins::Pipeline::DataObject _TData; typedef cpInstances::DataObjects::Image _TImage; typedef cpInstances::DataObjects::Skeleton _TSkeleton; - typedef cpPlugins::Pipeline::DataObject _TData; this->_ConfigureInput< _TImage >( "Input", true, false ); this->_ConfigureInput< _TData >( "Seeds", true, false ); - this->_ConfigureOutput< _TSkeleton >( "Skeleton" ); - this->_ConfigureOutput< _TImage >( "Marks" ); + this->_ConfigureOutput< _TSkeleton >( "Output" ); } // ------------------------------------------------------------------------- -fpaPluginsImageAlgorithms::SkeletonFilter:: +fpaPlugins_ImageAlgorithms::SkeletonFilter:: ~SkeletonFilter( ) { } // ------------------------------------------------------------------------- -void fpaPluginsImageAlgorithms::SkeletonFilter:: +void fpaPlugins_ImageAlgorithms::SkeletonFilter:: _GenerateData( ) { - auto o = this->GetInputData( "Input" ); - cpPlugins_Demangle_Image_RealPixels_AllDims_1( o, _GD0 ) - this->_Error( "Invalid input image." ); + /* TODO + typedef fpa::Image::MinimumSpanningTree< 2 > _TMST2; + typedef fpa::Image::MinimumSpanningTree< 3 > _TMST3; + + auto mst2 = this->GetInputData< _TMST2 >( "MST" ); + auto mst3 = this->GetInputData< _TMST3 >( "MST" ); + if ( mst2 != NULL ) this->_GD0( mst2 ); + else if( mst3 != NULL ) this->_GD0( mst3 ); + else this->_Error( "Invalid input spanning tree." ); + */ } // ------------------------------------------------------------------------- template< class _TImage > -void fpaPluginsImageAlgorithms::SkeletonFilter:: +void fpaPlugins_ImageAlgorithms::SkeletonFilter:: _GD0( _TImage* image ) { /* TODO - typedef fpa::Image::SkeletonFilter< _TImage > _TFilter; - auto filter = this->_CreateITK< _TFilter >( ); - filter->SetInput( image ); + typedef typename _TMST::IndexType _TIndex; + typedef typename _TMST::TPath _TPath; - auto seeds = this->GetInputData< vtkPolyData >( "Seeds" ); - if( seeds != NULL ) + // Get seeds + std::vector< _TIndex > seeds; + auto points = this->GetInputData< vtkPolyData >( "Seeds" ); + if( points != NULL ) { - typename _TImage::PointType pnt; - typename _TImage::IndexType idx; - unsigned int dim = - ( _TImage::ImageDimension < 3 )? _TImage::ImageDimension: 3; + if( points->GetNumberOfPoints( ) < 2 ) + this->_Error( "Not enough seeds (<2)." ); - for( int i = 0; i < seeds->GetNumberOfPoints( ); ++i ) + typename _TMST::PointType pnt; + typename _TMST::IndexType idx; + unsigned int dim = + ( _TMST::ImageDimension < 3 )? _TMST::ImageDimension: 3; + for( unsigned int i = 0; i < 2; ++i ) { double buf[ 3 ]; - seeds->GetPoint( i, buf ); + points->GetPoint( i, buf ); pnt.Fill( 0 ); for( unsigned int d = 0; d < dim; ++d ) pnt[ d ] = buf[ d ]; - - if( image->TransformPhysicalPointToIndex( pnt, idx ) ) - filter->AddSeed( idx, 0 ); + if( mst->TransformPhysicalPointToIndex( pnt, idx ) ) + seeds.push_back( idx ); } // rof } // fi - filter->Update( ); - this->GetOutput( "Skeleton" )->SetITK( filter->GetSkeleton( ) ); - this->GetOutput( "Marks" )->SetITK( filter->GetMarks( ) ); + typename _TPath::Pointer path; + mst->GetPath( path, seeds[ 0 ], seeds[ 1 ] ); + this->GetOutput( "Output" )->SetITK( path ); */ }