#include "GradientBaseImageFunctionSource.h" #include #include // ------------------------------------------------------------------------- fpaPlugins::GradientBaseImageFunctionSource:: GradientBaseImageFunctionSource( ) : Superclass( ) { this->_AddInput( "Input" ); this->_AddOutput< cpPlugins::Image >( "Output" ); std::vector< std::string > choices; choices.push_back( "Gulsun&Tek" ); choices.push_back( "Flux" ); choices.push_back( "MFlux" ); this->m_Parameters.ConfigureAsChoices( "FunctionType", choices ); this->m_Parameters.SetSelectedChoice( "FunctionType", "Gulsun&Tek" ); this->m_Parameters.ConfigureAsReal( "MinRadius" ); this->m_Parameters.ConfigureAsReal( "MaxRadius" ); this->m_Parameters.ConfigureAsUint( "ProfileSampling" ); this->m_Parameters.ConfigureAsUint( "RadialSampling" ); this->m_Parameters.SetReal( "MinRadius", 0 ); this->m_Parameters.SetReal( "MaxRadius", 1 ); this->m_Parameters.SetUint( "ProfileSampling", 4 ); this->m_Parameters.SetUint( "RadialSampling", 10 ); } // ------------------------------------------------------------------------- fpaPlugins::GradientBaseImageFunctionSource:: ~GradientBaseImageFunctionSource( ) { } // ------------------------------------------------------------------------- std::string fpaPlugins::GradientBaseImageFunctionSource:: _GenerateData( ) { auto image = this->GetInputData( "Input" )->GetITK< itk::DataObject >( ); std::string cpPlugin_Image_Demangle_VectorPixel_AllFloats( r, _GD0, image, itk::CovariantVector, 2 ); if( r != "" ) cpPlugin_Image_Demangle_VectorPixel_AllFloats( r, _GD0, image, itk::CovariantVector, 3 ); return( r ); } // ------------------------------------------------------------------------- template< class _TImage > std::string fpaPlugins::GradientBaseImageFunctionSource:: _GD0( _TImage* image ) { typedef fpa::Image::Functors::GulsunTekMedialness< _TImage > _TGT; typedef fpa::Image::Functors::FluxMedialness< _TImage > _TFl; typedef fpa::Image::Functors::MFluxMedialness< _TImage > _TMFl; if( image == NULL ) return( "GradientBaseImageFunctionSource: Invalid input image." ); auto ft = this->m_Parameters.GetSelectedChoice( "FunctionType" ); if ( ft == "Gulsun&Tek" ) return( this->_GD1< _TImage, _TGT >( image ) ); else if( ft == "Flux" ) return( this->_GD1< _TImage, _TFl >( image ) ); else if( ft == "MFlux" ) return( this->_GD1< _TImage, _TMFl >( image ) ); else return( "GradientBaseImageFunctionSource: Invalid function type." ); } // ------------------------------------------------------------------------- template< class _TImage, class _TFunction > std::string fpaPlugins::GradientBaseImageFunctionSource:: _GD1( _TImage* image ) { typedef itk::Image< typename _TFunction::TOutput, _TImage::ImageDimension > _TOutImage; typedef cpExtensions::Algorithms::ImageFunctionFilter< _TImage, _TOutImage, _TFunction > _TFilter; _TFilter* filter = this->_CreateITK< _TFilter >( ); filter->SetInput( image ); _TFunction* function = filter->GetFunction( ); if( function == NULL ) { filter->SetFunction( _TFunction::New( ) ); function = filter->GetFunction( ); } // fi function->SetMinRadius( this->m_Parameters.GetReal( "MinRadius" ) ); function->SetMaxRadius( this->m_Parameters.GetReal( "MaxRadius" ) ); /* function->SetProfileSampling( this->m_Parameters.GetUint( "ProfileSampling" ) ); function->SetRadialSampling( this->m_Parameters.GetUint( "RadialSampling" ) ); */ filter->Update( ); // Connect output and finish this->GetOutputData( "Output" )->SetITK( filter->GetOutput( ) ); return( "" ); } // eof - $RCSfile$