]> Creatis software - cpPlugins.git/blob - plugins/ImageFilters/GaussianDensityImageFilter.cxx
...
[cpPlugins.git] / plugins / ImageFilters / GaussianDensityImageFilter.cxx
1 #include <plugins/ImageFilters/GaussianDensityImageFilter.h>
2 #include <cpPlugins/Image.h>
3 #include <cpExtensions/Algorithms/IterativeGaussianModelEstimator.h>
4 #include <cpExtensions/Algorithms/GaussianDensityImageFilter.h>
5
6 // -------------------------------------------------------------------------
7 cpPluginsImageFilters::GaussianDensityImageFilter::
8 GaussianDensityImageFilter( )
9   : Superclass( )
10 {
11   this->_AddInput( "Image" );
12   this->_AddInput( "Estimator" );
13   this->_AddOutput< cpPlugins::Image >( "Output" );
14
15   /* TODO
16      this->m_Parameters.ConfigureAsReal( "LowerThresholdValue" );
17      this->m_Parameters.ConfigureAsReal( "UpperThresholdValue" );
18      this->m_Parameters.ConfigureAsUint( "InsideValue" );
19      this->m_Parameters.ConfigureAsUint( "OutsideValue" );
20
21      this->m_Parameters.SetReal( "LowerThresholdValue", 0 );
22      this->m_Parameters.SetReal( "UpperThresholdValue", 10000 );
23      this->m_Parameters.SetReal( "InsideValue", 1 );
24      this->m_Parameters.SetReal( "OutsideValue", 0 );
25      this->m_Parameters.SetSelectedChoice( "OutputResolution", "unsigned char" );
26   */
27 }
28
29 // -------------------------------------------------------------------------
30 cpPluginsImageFilters::GaussianDensityImageFilter::
31 ~GaussianDensityImageFilter( )
32 {
33 }
34
35 // -------------------------------------------------------------------------
36 void cpPluginsImageFilters::GaussianDensityImageFilter::
37 _GenerateData( )
38 {
39   auto image = this->GetInputData< itk::DataObject >( "Image" );
40   cpPlugins_Image_Demangle_Pixel_AllScalars     ( _GD0, image, 2 );
41   else cpPlugins_Image_Demangle_Pixel_AllScalars( _GD0, image, 3 );
42   else this->_Error( "No valid input image." );
43 }
44
45 // -------------------------------------------------------------------------
46 template< class _TImage >
47 void cpPluginsImageFilters::GaussianDensityImageFilter::
48 _GD0( _TImage* image )
49 {
50   static const unsigned int Dim = 1;
51   typedef cpExtensions::Algorithms::IterativeGaussianModelEstimator< float, Dim > _TFloatEst;
52   typedef cpExtensions::Algorithms::IterativeGaussianModelEstimator< double, Dim > _TDoubleEst;
53
54   auto float_est = this->GetInputData< _TFloatEst >( "Estimator" );
55   auto double_est = this->GetInputData< _TDoubleEst >( "Estimator" );
56   if( float_est  != NULL )
57     this->_GD1( image, float_est );
58   else if( double_est != NULL )
59     this->_GD1( image, double_est );
60   else
61     this->_Error( "Invalid gaussian model estimator." );
62 }
63
64 // -------------------------------------------------------------------------
65 template< class _TImage, class _TEstimator >
66 void cpPluginsImageFilters::GaussianDensityImageFilter::
67 _GD1( _TImage* image, _TEstimator* estimator )
68 {
69   typedef
70     cpExtensions::Algorithms::GaussianDensityImageFilter< _TImage, _TEstimator >
71     _TFilter;
72   
73   auto filter = this->_CreateITK< _TFilter >( );
74   filter->SetInput( image );
75   filter->SetEstimator( estimator );
76   filter->Update( );
77   this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) );
78 }
79
80 // eof - $RCSfile$