#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( ) { } // ------------------------------------------------------------------------- void fpaPlugins::GradientBaseImageFunctionSource:: _GenerateData( ) { auto image = this->GetInputData< itk::DataObject >( "Input" ); cpPlugins_Image_Demangle_VectorPixel_AllFloats ( _GD0, image, CovariantVector, 2 ); else cpPlugins_Image_Demangle_VectorPixel_AllFloats( _GD0, image, CovariantVector, 3 ); else this->_Error( "Invalid input image." ); } // ------------------------------------------------------------------------- template< class _TImage > void 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; auto ft = this->m_Parameters.GetSelectedChoice( "FunctionType" ); if ( ft == "Gulsun&Tek" ) this->_GD1< _TImage, _TGT >( image ); else if( ft == "Flux" ) this->_GD1< _TImage, _TFl >( image ); else if( ft == "MFlux" ) this->_GD1< _TImage, _TMFl >( image ); else this->_Error( "Invalid function type." ); } // ------------------------------------------------------------------------- template< class _TImage, class _TFunction > void 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->GetOutput( "Output" )->SetITK( filter->GetOutput( ) ); } // eof - $RCSfile$