1 #include "GradientBaseImageFunctionSource.h"
3 #include <cpPlugins/Image.h>
4 #include <fpa_Instances/Functors.h>
6 // -------------------------------------------------------------------------
7 fpaPlugins::GradientBaseImageFunctionSource::
8 GradientBaseImageFunctionSource( )
11 this->_AddInput( "Input" );
12 this->_AddOutput< cpPlugins::Image >( "Output" );
14 std::vector< std::string > choices;
15 choices.push_back( "Gulsun&Tek" );
16 choices.push_back( "Flux" );
17 choices.push_back( "MFlux" );
18 this->m_Parameters.ConfigureAsChoices( "FunctionType", choices );
19 this->m_Parameters.SetSelectedChoice( "FunctionType", "Gulsun&Tek" );
21 this->m_Parameters.ConfigureAsReal( "MinRadius" );
22 this->m_Parameters.ConfigureAsReal( "MaxRadius" );
23 this->m_Parameters.ConfigureAsUint( "ProfileSampling" );
24 this->m_Parameters.ConfigureAsUint( "RadialSampling" );
25 this->m_Parameters.SetReal( "MinRadius", 0 );
26 this->m_Parameters.SetReal( "MaxRadius", 1 );
27 this->m_Parameters.SetUint( "ProfileSampling", 4 );
28 this->m_Parameters.SetUint( "RadialSampling", 10 );
31 // -------------------------------------------------------------------------
32 fpaPlugins::GradientBaseImageFunctionSource::
33 ~GradientBaseImageFunctionSource( )
37 // -------------------------------------------------------------------------
38 std::string fpaPlugins::GradientBaseImageFunctionSource::
41 auto image = this->GetInputData( "Input" )->GetITK< itk::DataObject >( );
42 std::string cpPlugin_Image_Demangle_VectorPixel_AllFloats( r, _GD0, image, itk::CovariantVector, 2 );
43 if( r != "" ) cpPlugin_Image_Demangle_VectorPixel_AllFloats( r, _GD0, image, itk::CovariantVector, 3 );
47 // -------------------------------------------------------------------------
48 template< class _TImage >
49 std::string fpaPlugins::GradientBaseImageFunctionSource::
50 _GD0( _TImage* image )
52 typedef fpa::Image::Functors::GulsunTekMedialness< _TImage > _TGT;
53 typedef fpa::Image::Functors::FluxMedialness< _TImage > _TFl;
54 typedef fpa::Image::Functors::MFluxMedialness< _TImage > _TMFl;
57 return( "GradientBaseImageFunctionSource: Invalid input image." );
59 auto ft = this->m_Parameters.GetSelectedChoice( "FunctionType" );
60 if ( ft == "Gulsun&Tek" ) return( this->_GD1< _TImage, _TGT >( image ) );
61 else if( ft == "Flux" ) return( this->_GD1< _TImage, _TFl >( image ) );
62 else if( ft == "MFlux" ) return( this->_GD1< _TImage, _TMFl >( image ) );
64 return( "GradientBaseImageFunctionSource: Invalid function type." );
67 // -------------------------------------------------------------------------
68 template< class _TImage, class _TFunction >
69 std::string fpaPlugins::GradientBaseImageFunctionSource::
70 _GD1( _TImage* image )
72 typedef itk::Image< typename _TFunction::TOutput, _TImage::ImageDimension > _TOutImage;
73 typedef cpExtensions::Algorithms::ImageFunctionFilter< _TImage, _TOutImage, _TFunction > _TFilter;
75 _TFilter* filter = this->_CreateITK< _TFilter >( );
76 filter->SetInput( image );
77 _TFunction* function = filter->GetFunction( );
78 if( function == NULL )
80 filter->SetFunction( _TFunction::New( ) );
81 function = filter->GetFunction( );
84 function->SetMinRadius( this->m_Parameters.GetReal( "MinRadius" ) );
85 function->SetMaxRadius( this->m_Parameters.GetReal( "MaxRadius" ) );
87 function->SetProfileSampling( this->m_Parameters.GetUint( "ProfileSampling" ) );
88 function->SetRadialSampling( this->m_Parameters.GetUint( "RadialSampling" ) );
93 // Connect output and finish
94 this->GetOutputData( "Output" )->SetITK( filter->GetOutput( ) );