#include "RegionGrow.h" #include #include #include // ------------------------------------------------------------------------- fpaPlugins_ImageAlgorithms::RegionGrow:: RegionGrow( ) : Superclass( ) { typedef cpPlugins::Pipeline::DataObject _TFunctor; typedef cpInstances::DataObjects::Image _TMST; this->_ConfigureInput< _TFunctor >( "GrowFunction", true, false ); this->m_Parameters.ConfigureAsInt( "InsideValue", 1 ); this->m_Parameters.ConfigureAsInt( "OutsideValue", 0 ); this->m_Parameters.ConfigureAsIntTypesChoices( "ResultType" ); } // ------------------------------------------------------------------------- fpaPlugins_ImageAlgorithms::RegionGrow:: ~RegionGrow( ) { } // ------------------------------------------------------------------------- void fpaPlugins_ImageAlgorithms::RegionGrow:: _GenerateData( ) { auto o = this->GetInputData( "Input" ); cpPlugins_Demangle_Image_ScalarPixels_AllDims_1( o, _GD0 ) this->_Error( "Invalid input image." ); } // ------------------------------------------------------------------------- template< class _TImage > void fpaPlugins_ImageAlgorithms::RegionGrow:: _GD0( _TImage* image ) { auto rtype = this->m_Parameters.GetSelectedChoice( "ResultType" ); if( rtype == "char" ) this->_GD1< _TImage, char >( image ); else if( rtype == "uchar" ) this->_GD1< _TImage, unsigned char >( image ); else if( rtype == "short" ) this->_GD1< _TImage, short >( image ); else if( rtype == "ushort" ) this->_GD1< _TImage, unsigned short >( image ); else if( rtype == "int" ) this->_GD1< _TImage, int >( image ); else if( rtype == "uint" ) this->_GD1< _TImage, unsigned int >( image ); else if( rtype == "long" ) this->_GD1< _TImage, long >( image ); else if( rtype == "ulong" ) this->_GD1< _TImage, unsigned long >( image ); else this->_GD1< _TImage, char >( image ); } // ------------------------------------------------------------------------- template< class _TInputImage, class _TOutputPixel > void fpaPlugins_ImageAlgorithms::RegionGrow:: _GD1( _TInputImage* image ) { typedef cpPlugins::Pipeline::Functor _TFunctor; typedef itk::Image< _TOutputPixel, _TInputImage::ImageDimension > _TOutputImage; typedef fpa::Image::RegionGrow< _TInputImage, _TOutputImage > _TFilter; 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, ( typename _TOutputImage::PixelType )( 0 ) ); filter->Update( ); this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) ); } // eof - $RCSfile$