1 #include <cpPluginsImageFilters/GaussianDensityImageFilter.h>
2 #include <cpPlugins/Image.h>
3 #include <cpExtensions/Algorithms/IterativeGaussianModelEstimator.h>
4 #include <cpExtensions/Algorithms/GaussianDensityImageFilter.h>
6 // -------------------------------------------------------------------------
7 cpPluginsImageFilters::GaussianDensityImageFilter::
8 GaussianDensityImageFilter( )
11 this->_AddInput( "Image" );
12 this->_AddInput( "Estimator" );
13 this->_AddOutput< cpPlugins::Image >( "Output" );
16 this->m_Parameters.ConfigureAsReal( "LowerThresholdValue" );
17 this->m_Parameters.ConfigureAsReal( "UpperThresholdValue" );
18 this->m_Parameters.ConfigureAsUint( "InsideValue" );
19 this->m_Parameters.ConfigureAsUint( "OutsideValue" );
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" );
29 // -------------------------------------------------------------------------
30 cpPluginsImageFilters::GaussianDensityImageFilter::
31 ~GaussianDensityImageFilter( )
35 // -------------------------------------------------------------------------
36 void cpPluginsImageFilters::GaussianDensityImageFilter::
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." );
45 // -------------------------------------------------------------------------
46 template< class _TImage >
47 void cpPluginsImageFilters::GaussianDensityImageFilter::
48 _GD0( _TImage* image )
50 static const unsigned int Dim = 1;
51 typedef cpExtensions::Algorithms::IterativeGaussianModelEstimator< float, Dim > _TFloatEst;
52 typedef cpExtensions::Algorithms::IterativeGaussianModelEstimator< double, Dim > _TDoubleEst;
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 );
61 this->_Error( "Invalid gaussian model estimator." );
64 // -------------------------------------------------------------------------
65 template< class _TImage, class _TEstimator >
66 void cpPluginsImageFilters::GaussianDensityImageFilter::
67 _GD1( _TImage* image, _TEstimator* estimator )
70 cpExtensions::Algorithms::GaussianDensityImageFilter< _TImage, _TEstimator >
73 auto filter = this->_CreateITK< _TFilter >( );
74 filter->SetInput( image );
75 filter->SetEstimator( estimator );
77 this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) );