X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=plugins%2FImageAlgorithms%2FRegionGrow.cxx;h=bd0fc747d0afa3ca78e6c049c30693e2d42ad1e4;hb=d93ab4fea6dbc791560451ecdc4bf7555d8cf11d;hp=e1aff3e3effc67bfea2eef7da2dd1e8fee73b2b3;hpb=40fb0405cfef444001429f8ba49c407ce9168a94;p=FrontAlgorithms.git diff --git a/plugins/ImageAlgorithms/RegionGrow.cxx b/plugins/ImageAlgorithms/RegionGrow.cxx index e1aff3e..bd0fc74 100644 --- a/plugins/ImageAlgorithms/RegionGrow.cxx +++ b/plugins/ImageAlgorithms/RegionGrow.cxx @@ -1,29 +1,31 @@ -#include +#include "RegionGrow.h" +#include #include #include // ------------------------------------------------------------------------- -fpaPluginsImageAlgorithms::RegionGrow:: +fpaPlugins_ImageAlgorithms::RegionGrow:: RegionGrow( ) : Superclass( ) { - typedef cpPlugins::Pipeline::DataObject _TData; + typedef cpPlugins::Pipeline::DataObject _TFunctor; + typedef cpInstances::DataObjects::Image _TMST; - this->_ConfigureInput< _TData >( "GrowFunction", true, false ); + this->_ConfigureInput< _TFunctor >( "GrowFunction", true, false ); this->m_Parameters.ConfigureAsInt( "InsideValue", 1 ); this->m_Parameters.ConfigureAsInt( "OutsideValue", 0 ); this->m_Parameters.ConfigureAsIntTypesChoices( "ResultType" ); } // ------------------------------------------------------------------------- -fpaPluginsImageAlgorithms::RegionGrow:: +fpaPlugins_ImageAlgorithms::RegionGrow:: ~RegionGrow( ) { } // ------------------------------------------------------------------------- -void fpaPluginsImageAlgorithms::RegionGrow:: +void fpaPlugins_ImageAlgorithms::RegionGrow:: _GenerateData( ) { auto o = this->GetInputData( "Input" ); @@ -33,7 +35,7 @@ _GenerateData( ) // ------------------------------------------------------------------------- template< class _TImage > -void fpaPluginsImageAlgorithms::RegionGrow:: +void fpaPlugins_ImageAlgorithms::RegionGrow:: _GD0( _TImage* image ) { auto rtype = this->m_Parameters.GetSelectedChoice( "ResultType" ); @@ -50,27 +52,34 @@ _GD0( _TImage* image ) // ------------------------------------------------------------------------- template< class _TInputImage, class _TOutputPixel > -void fpaPluginsImageAlgorithms::RegionGrow:: +void fpaPlugins_ImageAlgorithms::RegionGrow:: _GD1( _TInputImage* image ) { - typedef - itk::Image< _TOutputPixel, _TInputImage::ImageDimension > - _TOutputImage; + typedef cpPlugins::Pipeline::Functor _TFunctor; + typedef itk::Image< _TOutputPixel, _TInputImage::ImageDimension > _TOutputImage; typedef fpa::Image::RegionGrow< _TInputImage, _TOutputImage > _TFilter; - typedef typename _TFilter::TGrowFunction _TGrow; - - _TOutputPixel i_val = _TOutputPixel( this->m_Parameters.GetInt( "InsideValue" ) ); - _TOutputPixel o_val = _TOutputPixel( this->m_Parameters.GetInt( "OutsideValue" ) ); + typedef typename _TFilter::TGrowFunction _TGrowFunction; + // Create filter auto filter = this->_CreateITK< _TFilter >( ); std::vector< typename _TInputImage::IndexType > seeds; this->_ConfigureFilter( filter, image, seeds ); + + // Instantiate functors + auto growfunc = this->GetInputData< _TFunctor >( "GrowFunction" ); + if( growfunc != NULL ) + { + growfunc->Instantiate( filter ); + auto growfunc_functor = growfunc->GetFunctor< _TGrowFunction >( ); + if( growfunc_functor != NULL ) + filter->SetGrowFunction( growfunc_functor ); + + } // fi + + // Finish filter's configuration filter->ClearSeeds( ); for( auto seed : seeds ) - filter->AddSeed( seed, i_val ); - filter->SetGrowFunction( this->GetInputData< _TGrow >( "GrowFunction" ) ); - filter->SetInsideValue( i_val ); - filter->SetOutsideValue( o_val ); + filter->AddSeed( seed, ( typename _TOutputImage::PixelType )( 0 ) ); filter->Update( ); this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) ); }