X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=plugins%2FPlugins%2FSkeletonFilter.cxx;h=6e9102af78ef042b51205586418a471a518e8db1;hb=3895259354d50760187c84e5a23807f6336fbbdf;hp=f00a0bfb9e07c266d0643cf085be4ee868d0aab6;hpb=81e5245951244bd6df71c1069f24516aca486f61;p=FrontAlgorithms.git diff --git a/plugins/Plugins/SkeletonFilter.cxx b/plugins/Plugins/SkeletonFilter.cxx index f00a0bf..6e9102a 100644 --- a/plugins/Plugins/SkeletonFilter.cxx +++ b/plugins/Plugins/SkeletonFilter.cxx @@ -1,27 +1,25 @@ -#include -#include -#include +#include +#include +#include +#include + #include -#include -#include +#include +#include // ------------------------------------------------------------------------- fpaPlugins::SkeletonFilter:: SkeletonFilter( ) : Superclass( ) { - typedef cpPlugins::DataObjects::Image _TImage; - typedef cpPlugins::DataObjects::Skeleton _TSkeleton; + typedef cpInstances::Image _TImage; + typedef cpInstances::Skeleton _TSkeleton; + typedef cpPlugins::BaseObjects::DataObject _TData; - this->_ConfigureInput< _TImage >( "DistanceMap", true, false ); - this->_ConfigureInput< _TImage >( "CostMap", true, false ); - this->_ConfigureInput< _TImage >( "MST", true, false ); + this->_ConfigureInput< _TImage >( "Input", true, false ); + this->_ConfigureInput< _TData >( "Seeds", true, false ); this->_ConfigureOutput< _TSkeleton >( "Skeleton" ); this->_ConfigureOutput< _TImage >( "Marks" ); - /* TODO - this->_ConfigureOutput< _TMesh >( "EndPoints" ); - this->_ConfigureOutput< _TMesh >( "Bifurcations" ); - */ } // ------------------------------------------------------------------------- @@ -34,85 +32,46 @@ fpaPlugins::SkeletonFilter:: void fpaPlugins::SkeletonFilter:: _GenerateData( ) { - auto o = this->GetInputData( "DistanceMap" ); - cpPlugins_Demangle_ImageScalars_Dims( o, _GD0 ); - else this->_Error( "Invalid input image." ); + auto o = this->GetInputData( "Input" ); + cpPlugins_Demangle_Image_RealPixels_AllDims_1( o, _GD0 ) + this->_Error( "Invalid input image." ); } // ------------------------------------------------------------------------- -template< class _TDistanceMap > +template< class _TImage > void fpaPlugins::SkeletonFilter:: -_GD0( _TDistanceMap* dmap ) +_GD0( _TImage* image ) { - auto cmap = this->GetInputData< _TDistanceMap >( "CostMap" ); - if( cmap != NULL ) - this->_GD1( dmap, cmap ); - else - this->_Error( "Temporary error: invalid cost map." ); -} - -// ------------------------------------------------------------------------- -template< class _TDistanceMap, class _TCostMap > -void fpaPlugins::SkeletonFilter:: -_GD1( _TDistanceMap* dmap, _TCostMap* cmap ) -{ - typedef fpa::Image::SkeletonFilter< _TDistanceMap, _TCostMap > _TFilter; - typedef typename _TFilter::TMST _TMST; - - auto mst = this->GetInputData< _TMST >( "MST" ); - if( mst == NULL ) - this->_Error( "Invalid MST." ); - + typedef fpa::Image::SkeletonFilter< _TImage > _TFilter; auto filter = this->_CreateITK< _TFilter >( ); - filter->SetDistanceMap( dmap ); - filter->SetCostMap( cmap ); - filter->SetMinimumSpanningTree( mst ); - filter->Update( ); - this->GetOutput( "Skeleton" )->SetITK( filter->GetSkeleton( ) ); - this->GetOutput( "Marks" )->SetITK( filter->GetMarks( ) ); - - - /* TODO - auto ep = filter->GetEndPoints( ); - auto bi = filter->GetBifurcations( ); + filter->SetInput( image ); - auto ep_pd = this->GetOutputData< vtkPolyData >( "EndPoints" ); - if( ep_pd == NULL ) - { - auto points = vtkSmartPointer< vtkPoints >::New( ); - auto verts = vtkSmartPointer< vtkCellArray >::New( ); - auto lines = vtkSmartPointer< vtkCellArray >::New( ); - auto polys = vtkSmartPointer< vtkCellArray >::New( ); - auto strips = vtkSmartPointer< vtkCellArray >::New( ); - auto pd = vtkSmartPointer< vtkPolyData >::New( ); - pd->SetPoints( points ); - pd->SetVerts( verts ); - pd->SetLines( lines ); - pd->SetPolys( polys ); - pd->SetStrips( strips ); + auto seeds = this->GetInputData< vtkPolyData >( "Seeds" ); + if( seeds != NULL ) + { + typename _TImage::PointType pnt; + typename _TImage::IndexType idx; + unsigned int dim = + ( _TImage::ImageDimension < 3 )? _TImage::ImageDimension: 3; - this->GetOutput( "EndPoints" )->SetVTK( pd ); - ep_pd = this->GetOutputData< vtkPolyData >( "EndPoints" ); + for( int i = 0; i < seeds->GetNumberOfPoints( ); ++i ) + { + double buf[ 3 ]; + seeds->GetPoint( i, buf ); + pnt.Fill( 0 ); + for( unsigned int d = 0; d < dim; ++d ) + pnt[ d ] = buf[ d ]; - } // fi + if( image->TransformPhysicalPointToIndex( pnt, idx ) ) + filter->AddSeed( idx, 0 ); - for( auto iIt = ep.begin( ); iIt != ep.end( ); ++iIt ) - { - typename _TCostMap::PointType p; - cmap->TransformIndexToPhysicalPoint( *iIt, p ); + } // rof - if( _TCostMap::ImageDimension == 1 ) - ep_pd->GetPoints( )->InsertNextPoint( p[ 0 ], 0, 0 ); - else if( _TCostMap::ImageDimension == 2 ) - ep_pd->GetPoints( )->InsertNextPoint( p[ 0 ], p[ 1 ], 0 ); - else if( _TCostMap::ImageDimension > 2 ) - ep_pd->GetPoints( )->InsertNextPoint( p[ 0 ], p[ 1 ], p[ 2 ] ); + } // fi - ep_pd->GetVerts( )->InsertNextCell( 1 ); - ep_pd->GetVerts( )->InsertCellPoint( ep_pd->GetNumberOfPoints( ) - 1 ); - - } // rof - */ + filter->Update( ); + this->GetOutput( "Skeleton" )->SetITK( filter->GetSkeleton( ) ); + this->GetOutput( "Marks" )->SetITK( filter->GetMarks( ) ); } // eof - $RCSfile$