#include #include #include #include #include #include #include #include // ------------------------------------------------------------------------- cpPluginsImageDistanceMaps::SignedMaurerDistanceMapImageFilter:: SignedMaurerDistanceMapImageFilter( ) : Superclass( ) { this->_ConfigureInput< cpPlugins::DataObjects::Image >( "Input", true, false ); this->_ConfigureOutput< cpPlugins::DataObjects::Image >( "Output" ); this->m_Parameters.ConfigureAsReal( "BackgroundValue" ); this->m_Parameters.ConfigureAsBool( "InsideIsPositive" ); this->m_Parameters.ConfigureAsBool( "SquaredDistance" ); this->m_Parameters.ConfigureAsBool( "UseImageSpacing" ); std::vector< std::string > choices; choices.push_back( "float" ); choices.push_back( "double" ); this->m_Parameters.ConfigureAsChoices( "OutputResolution", choices ); this->m_Parameters.SetReal( "BackgroundValue", 0 ); this->m_Parameters.SetBool( "InsideIsPositive", true ); this->m_Parameters.SetBool( "SquaredDistance", false ); this->m_Parameters.SetBool( "UseImageSpacing", true ); this->m_Parameters.SetSelectedChoice( "OutputResolution", "float" ); } // ------------------------------------------------------------------------- cpPluginsImageDistanceMaps::SignedMaurerDistanceMapImageFilter:: ~SignedMaurerDistanceMapImageFilter( ) { } // ------------------------------------------------------------------------- void cpPluginsImageDistanceMaps::SignedMaurerDistanceMapImageFilter:: _GenerateData( ) { auto o = this->GetInputData( "Input" ); cpPlugins_Demangle_ImageScalars( o, _GD0, 2 ); else cpPlugins_Demangle_ImageScalars( o, _GD0, 3 ); else this->_Error( "Invalid input image." ); } // ------------------------------------------------------------------------- template< class _TImage > void cpPluginsImageDistanceMaps::SignedMaurerDistanceMapImageFilter:: _GD0( _TImage* image ) { typedef itk::Image< float, _TImage::ImageDimension > _TFDmap; typedef itk::Image< double, _TImage::ImageDimension > _TDDmap; std::string out_res = this->m_Parameters.GetSelectedChoice( "OutputResolution" ); if( out_res == "float" ) this->_GD1< _TImage, _TFDmap >( image ); else if( out_res == "double" ) this->_GD1< _TImage, _TDDmap >( image ); else this->_Error( "Output resolution not supported." ); } // ------------------------------------------------------------------------- template< class _TImage, class _TDMap > void cpPluginsImageDistanceMaps::SignedMaurerDistanceMapImageFilter:: _GD1( _TImage* image ) { typedef itk::SignedMaurerDistanceMapImageFilter< _TImage, _TDMap > _TFilter; // Get parameters double bv = this->m_Parameters.GetReal( "BackgroundValue" ); bool pi = this->m_Parameters.GetBool( "InsideIsPositive" ); bool sd = this->m_Parameters.GetBool( "SquaredDistance" ); bool us = this->m_Parameters.GetBool( "UseImageSpacing" ); // Configure filter _TFilter* filter = this->_CreateITK< _TFilter >( ); filter->SetInput( image ); filter->SetBackgroundValue( ( typename _TImage::PixelType )( bv ) ); filter->SetInsideIsPositive( pi ); filter->SetSquaredDistance( sd ); filter->SetUseImageSpacing( us ); filter->Update( ); // Connect output this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) ); } // eof - $RCSfile$