#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( ) { } // ------------------------------------------------------------------------- std::string cpPluginsImageFilters::BinaryContourImageFilter:: _GenerateData( ) { auto image = this->GetInputData( "Input" )->GetITK< itk::DataObject >( ); std::string cpPlugin_Image_Demangle_Pixel_AllScalars( r, _GD0, image, 2 ); if( r != "" ) cpPlugin_Image_Demangle_Pixel_AllScalars( r, _GD0, image, 3 ); return( r ); } // ------------------------------------------------------------------------- template< class _TImage > std::string cpPluginsImageFilters::BinaryContourImageFilter:: _GD0( _TImage* image ) { if( image != NULL ) { std::string out_res = this->m_Parameters.GetSelectedChoice( "OutputResolution" ); if( out_res == "float" ) return( this->_GD1< _TImage, itk::Image< float, _TImage::ImageDimension > >( image ) ); else // if( out_res == "double" ) return( this->_GD1< _TImage, itk::Image< double, _TImage::ImageDimension > >( image ) ); } else return( "ImageFilters::BinaryContourImageFilter: No valid input image." ); } // ------------------------------------------------------------------------- template< class _TImage, class _TContourImage > std::string 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->GetOutputData( "Output" )->SetITK( filter->GetOutput( ) ); return( "" ); } // eof - $RCSfile$