#include #include #include #include #include // ------------------------------------------------------------------------- fpaPlugins::ImageRegionGrow:: ImageRegionGrow( ) : Superclass( ) { typedef cpPlugins::BaseObjects::DataObject _TData; typedef cpInstances::Image _TMST; this->_ConfigureInput< _TData >( "GrowFunction", true, false ); this->m_Parameters.ConfigureAsInt( "InsideValue", 1 ); this->m_Parameters.ConfigureAsInt( "OutsideValue", 0 ); this->m_Parameters.ConfigureAsIntTypesChoices( "ResultType" ); } // ------------------------------------------------------------------------- fpaPlugins::ImageRegionGrow:: ~ImageRegionGrow( ) { } // ------------------------------------------------------------------------- void fpaPlugins::ImageRegionGrow:: _GenerateData( ) { auto o = this->GetInputData( "Input" ); cpPlugins_Demangle_Image_ScalarPixels_AllDims_1( o, _GD0 ) this->_Error( "Invalid input image." ); } // ------------------------------------------------------------------------- template< class _TImage > void fpaPlugins::ImageRegionGrow:: _GD0( _TImage* image ) { auto rtype = this->m_Parameters.GetSelectedChoice( "ResultType" ); #ifdef cpPlugins_CONFIG_INTEGER_TYPES_char if( rtype == "char" ) this->_GD1< _TImage, char >( image ); if( rtype == "uchar" ) this->_GD1< _TImage, unsigned char >( image ); #endif // cpPlugins_CONFIG_INTEGER_TYPES_char #ifdef cpPlugins_CONFIG_INTEGER_TYPES_short if( rtype == "short" ) this->_GD1< _TImage, short >( image ); if( rtype == "ushort" ) this->_GD1< _TImage, unsigned short >( image ); #endif // cpPlugins_CONFIG_INTEGER_TYPES_short #ifdef cpPlugins_CONFIG_INTEGER_TYPES_int if( rtype == "int" ) this->_GD1< _TImage, int >( image ); if( rtype == "uint" ) this->_GD1< _TImage, unsigned int >( image ); #endif // cpPlugins_CONFIG_INTEGER_TYPES_int #ifdef cpPlugins_CONFIG_INTEGER_TYPES_long if( rtype == "long" ) this->_GD1< _TImage, long >( image ); if( rtype == "ulong" ) this->_GD1< _TImage, unsigned long >( image ); #endif // cpPlugins_CONFIG_INTEGER_TYPES_long } // ------------------------------------------------------------------------- template< class _TInputImage, class _TOutputPixel > void fpaPlugins::ImageRegionGrow:: _GD1( _TInputImage* image ) { std::cout << "--------------> again <-----------------" << std::endl; typedef itk::Image< _TOutputPixel, _TInputImage::ImageDimension > _TOutputImage; typedef fpa::Image::RegionGrow< _TInputImage, _TOutputImage > _TFilter; typedef typename _TFilter::TGrowFunction _TGrow; typedef typename _TFilter::TNeighborhoodFunction _TNeighborhood; // Get functors auto neig = this->GetInputData< _TNeighborhood >( "Neighborhood" ); auto grow = this->GetInputData< _TGrow >( "GrowFunction" ); // Configure filter auto filter = this->_CreateITK< _TFilter >( ); filter->SetInput( image ); filter->SetGrowFunction( grow ); filter->SetInsideValue( this->m_Parameters.GetInt( "InsideValue" ) ); filter->SetOutsideValue( this->m_Parameters.GetInt( "OutsideValue" ) ); filter->SetStopAtOneFront( this->m_Parameters.GetBool( "StopAtOneFront" ) ); // Assign seeds auto seeds = this->GetInputData< vtkPolyData >( "Seeds" ); if( seeds != NULL ) { typename _TInputImage::PointType pnt; typename _TInputImage::IndexType idx; unsigned int dim = ( _TInputImage::ImageDimension < 3 )? _TInputImage::ImageDimension: 3; 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 ]; if( image->TransformPhysicalPointToIndex( pnt, idx ) ) filter->AddSeed( idx, 0 ); } // rof } // fi // Assign outputs filter->Update( ); this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) ); } // eof - $RCSfile$