1 #include <ImageGenericFilters/GaussianBlurImageFilter.h>
2 #include <cpPlugins/DataObjects/Image.h>
3 #include <cpPlugins/DataObjects/Image_Demanglers.h>
6 #include <itkGaussianBlurImageFunction.h>
8 // -------------------------------------------------------------------------
9 cpPluginsImageGenericFilters::GaussianBlurImageFilter::
10 GaussianBlurImageFilter( )
13 typedef cpPlugins::DataObjects::Image _TImage;
14 this->_ConfigureInput< _TImage >( "Input", true, false );
15 this->_ConfigureOutput< _TImage >( "Output" );
17 this->m_Parameters.ConfigureAsReal( "MaximumError", 1e-3 );
18 this->m_Parameters.ConfigureAsReal( "Sigma", 1 );
19 this->m_Parameters.ConfigureAsUint( "MaximumKernelWidth", 32 );
20 this->m_Parameters.ConfigureAsRealTypesChoices( "OutputResolution" );
23 // -------------------------------------------------------------------------
24 cpPluginsImageGenericFilters::GaussianBlurImageFilter::
25 ~GaussianBlurImageFilter( )
29 // -------------------------------------------------------------------------
30 void cpPluginsImageGenericFilters::GaussianBlurImageFilter::
33 auto o = this->GetInputData( "Input" );
34 cpPlugins_Demangle_Image_ScalarPixels_AllDims_1( o, _GD0 )
35 this->_Error( "Invalid input image." );
38 // -------------------------------------------------------------------------
39 template< class _TInput >
40 void cpPluginsImageGenericFilters::GaussianBlurImageFilter::
41 _GD0( _TInput* input )
43 std::string t = this->m_Parameters.GetSelectedChoice( "OutputResolution" );
44 #ifdef cpPlugins_CONFIG_REAL_TYPES_float
45 if( t == "float" ) this->_GD1< _TInput, float >( input );
46 #endif // cpPlugins_CONFIG_REAL_TYPES_float
47 #ifdef cpPlugins_CONFIG_REAL_TYPES_double
48 if( t == "double" ) this->_GD1< _TInput, double >( input );
49 #endif // cpPlugins_CONFIG_REAL_TYPES_double
52 // -------------------------------------------------------------------------
53 template< class _TInput, class _TOutputPixel >
54 void cpPluginsImageGenericFilters::GaussianBlurImageFilter::
55 _GD1( _TInput* input )
58 typedef itk::GaussianBlurImageFunction< _TInput, _TOutputPixel > _TFunction;
59 typedef itk::Image< _TOutputPixel, _TInput::ImageDimension > _TOutput;
60 typedef itk::UnaryFunctorImageFilter< _TInput, _TOutput, _TFunction > _TFilter;
62 auto filter = this->_CreateITK< _TFilter >( );
63 filter->SetInput( input );
65 typename _TFunction::ErrorArrayType e;
66 e.Fill( this->m_Parameters.GetReal( "MaximumError" ) );
67 filter->GetFunctor( ).SetMaximumError( e );
68 filter->GetFunctor( ).SetSigma( this->m_Parameters.GetReal( "Sigma" ) );
69 filter->GetFunctor( ).SetMaximumKernelWidth(
70 this->m_Parameters.GetUint( "MaximumKernelWidth" )
73 this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) );