]> Creatis software - cpPlugins.git/blob - plugins/ImageGenericFilters/GaussianBlurImageFilter.cxx
...
[cpPlugins.git] / plugins / ImageGenericFilters / GaussianBlurImageFilter.cxx
1 #include <ImageGenericFilters/GaussianBlurImageFilter.h>
2 #include <cpPlugins/DataObjects/Image.h>
3 #include <cpPlugins/DataObjects/Image_Demanglers.h>
4
5 #include <itkImage.h>
6 #include <itkGaussianBlurImageFunction.h>
7
8 // -------------------------------------------------------------------------
9 cpPluginsImageGenericFilters::GaussianBlurImageFilter::
10 GaussianBlurImageFilter( )
11   : Superclass( )
12 {
13   typedef cpPlugins::DataObjects::Image _TImage;
14   this->_ConfigureInput< _TImage >( "Input", true, false );
15   this->_ConfigureOutput< _TImage >( "Output" );
16
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" );
21 }
22
23 // -------------------------------------------------------------------------
24 cpPluginsImageGenericFilters::GaussianBlurImageFilter::
25 ~GaussianBlurImageFilter( )
26 {
27 }
28
29 // -------------------------------------------------------------------------
30 void cpPluginsImageGenericFilters::GaussianBlurImageFilter::
31 _GenerateData( )
32 {
33   auto o = this->GetInputData( "Input" );
34   cpPlugins_Demangle_Image_ScalarPixels_AllDims_1( o, _GD0 )
35     this->_Error( "Invalid input image." );
36 }
37
38 // -------------------------------------------------------------------------
39 template< class _TInput >
40 void cpPluginsImageGenericFilters::GaussianBlurImageFilter::
41 _GD0( _TInput* input )
42 {
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
50 }
51
52 // -------------------------------------------------------------------------
53 template< class _TInput, class _TOutputPixel >
54 void cpPluginsImageGenericFilters::GaussianBlurImageFilter::
55 _GD1( _TInput* input )
56 {
57   /* TODO
58      typedef itk::GaussianBlurImageFunction< _TInput, _TOutputPixel > _TFunction;
59      typedef itk::Image< _TOutputPixel, _TInput::ImageDimension > _TOutput;
60      typedef itk::UnaryFunctorImageFilter< _TInput, _TOutput, _TFunction > _TFilter;
61
62      auto filter = this->_CreateITK< _TFilter >( );
63      filter->SetInput( input );
64
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" )
71      );
72      filter->Update( );
73      this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) );
74   */
75 }
76
77 // eof - $RCSfile$