#include #include #include // ------------------------------------------------------------------------- fpaPluginsImageAlgorithms::MoriRegionGrow:: MoriRegionGrow( ) : Superclass( ) { typedef cpPlugins::Pipeline::DataObject _TData; typedef cpInstances::DataObjects::Image _TImage; this->_ConfigureInput< _TImage >( "Input", true, false ); this->_ConfigureInput< _TData >( "Seed", true, false ); this->_ConfigureOutput< _TImage >( "Output" ); this->_ConfigureOutput< _TImage >( "AuxiliaryOutput" ); this->m_Parameters.ConfigureAsInt( "InsideValue", 1 ); this->m_Parameters.ConfigureAsInt( "OutsideValue", 0 ); this->m_Parameters.ConfigureAsReal( "Step", 1 ); this->m_Parameters.ConfigureAsReal( "Lower", 0 ); this->m_Parameters.ConfigureAsReal( "Upper", 1 ); this->m_Parameters.ConfigureAsIntTypesChoices( "ResultType" ); } // ------------------------------------------------------------------------- fpaPluginsImageAlgorithms::MoriRegionGrow:: ~MoriRegionGrow( ) { } // ------------------------------------------------------------------------- void fpaPluginsImageAlgorithms::MoriRegionGrow:: _GenerateData( ) { auto o = this->GetInputData( "Input" ); cpPlugins_Demangle_Image_ScalarPixels_AllDims_1( o, _GD0 ) this->_Error( "Invalid input image." ); } // ------------------------------------------------------------------------- template< class _TImage > void fpaPluginsImageAlgorithms::MoriRegionGrow:: _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 fpaPluginsImageAlgorithms::MoriRegionGrow:: _GD1( _TInputImage* image ) { typedef itk::Image< _TOutputPixel, _TInputImage::ImageDimension > _TOutputImage; typedef fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage > _TFilter; auto filter = this->_CreateITK< _TFilter >( ); filter->SetInput( image ); filter->SetInsideValue( this->m_Parameters.GetInt( "InsideValue" ) ); filter->SetOutsideValue( this->m_Parameters.GetInt( "OutsideValue" ) ); filter->SetStep( this->m_Parameters.GetReal( "Step" ) ); filter->SetLower( this->m_Parameters.GetReal( "Lower" ) ); filter->SetUpper( this->m_Parameters.GetReal( "Upper" ) ); // Assign seed auto seeds = this->GetInputData< vtkPolyData >( "Seed" ); if( seeds != NULL ) { typename _TInputImage::PointType pnt; typename _TInputImage::IndexType idx; unsigned int dim = ( _TInputImage::ImageDimension < 3 )? _TInputImage::ImageDimension: 3; if( seeds->GetNumberOfPoints( ) > 0 ) { double buf[ 3 ]; seeds->GetPoint( 0, buf ); pnt.Fill( 0 ); for( unsigned int d = 0; d < dim; ++d ) pnt[ d ] = buf[ d ]; if( image->TransformPhysicalPointToIndex( pnt, idx ) ) filter->SetSeed( idx ); } else this->_Error( "No given seeds." ); } else this->_Error( "No given seeds." ); filter->Update( ); this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) ); this->GetOutput( "AuxiliaryOutput" )->SetITK( filter->GetAuxiliaryImage( ) ); } // eof - $RCSfile$