#include #include #include // ------------------------------------------------------------------------- cpPluginsImageFilters::BinaryContourImageFilter:: BinaryContourImageFilter( ) : Superclass( ) { this->_AddInput( "Input" ); this->_AddOutput< cpPlugins::Image >( "Output" ); this->m_Parameters.ConfigureAsBool( "FullyConnected" ); this->m_Parameters.ConfigureAsReal( "BackgroundValue" ); this->m_Parameters.ConfigureAsReal( "ForegroundValue" ); std::vector< std::string > choices; choices.push_back( "float" ); choices.push_back( "double" ); this->m_Parameters.ConfigureAsChoices( "OutputResolution", choices ); this->m_Parameters.SetBool( "FullyConnected", false ); this->m_Parameters.SetReal( "BackgroundValue", 0 ); this->m_Parameters.SetReal( "ForegroundValue", 1 ); this->m_Parameters.SetSelectedChoice( "OutputResolution", "float" ); } // ------------------------------------------------------------------------- cpPluginsImageFilters::BinaryContourImageFilter:: ~BinaryContourImageFilter( ) { } // ------------------------------------------------------------------------- void cpPluginsImageFilters::BinaryContourImageFilter:: _GenerateData( ) { auto image = this->GetInputData< itk::DataObject >( "Input" ); cpPlugins_Image_Demangle_Pixel_AllScalars ( _GD0, image, 2 ); else cpPlugins_Image_Demangle_Pixel_AllScalars( _GD0, image, 3 ); else this->_Error( "No valid input image." ); } // ------------------------------------------------------------------------- template< class _TImage > void cpPluginsImageFilters::BinaryContourImageFilter:: _GD0( _TImage* image ) { static const unsigned int D = _TImage::ImageDimension; if( image != NULL ) { std::string out_res = this->m_Parameters.GetSelectedChoice( "OutputResolution" ); if( out_res == "float" ) this->_GD1< _TImage, itk::Image< float, D > >( image ); else // if( out_res == "double" ) this->_GD1< _TImage, itk::Image< double, D > >( image ); } else this->_Error( "No valid input image." ); } // ------------------------------------------------------------------------- template< class _TImage, class _TContourImage > void cpPluginsImageFilters::BinaryContourImageFilter:: _GD1( _TImage* image ) { typedef itk::BinaryContourImageFilter< _TImage, _TContourImage > _F; // Get parameters bool fc = this->m_Parameters.GetBool( "FullyConnected" ); double bv = this->m_Parameters.GetReal( "BackgroundValue" ); double fv = this->m_Parameters.GetReal( "ForegroundValue" ); // Configure filter _F* filter = this->_CreateITK< _F >( ); filter->SetInput( image ); filter->SetFullyConnected( fc ); filter->SetBackgroundValue( bv ); filter->SetForegroundValue( fv ); filter->Update( ); // Connect output this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) ); } // eof - $RCSfile$