1 #include "BinaryErodeImageFilter.h"
2 #include <cpPlugins/Interface/Image.h>
4 #include <itkBinaryErodeImageFilter.h>
6 #include <itkBinaryBallStructuringElement.h>
8 // -------------------------------------------------------------------------
9 cpPlugins::BasicFilters::BinaryErodeImageFilter::
10 BinaryErodeImageFilter( )
13 this->_AddInput( "Input" );
14 this->_AddOutput< cpPlugins::Interface::Image >( "Output" );
16 this->m_Parameters->ConfigureAsUint( "Radius" );
17 this->m_Parameters->SetUint( "Radius", 2 );
20 // -------------------------------------------------------------------------
21 cpPlugins::BasicFilters::BinaryErodeImageFilter::
22 ~BinaryErodeImageFilter( )
26 // -------------------------------------------------------------------------
27 std::string cpPlugins::BasicFilters::BinaryErodeImageFilter::
30 auto image = this->GetInputData< cpPlugins::Interface::Image >( "Input" );
31 itk::DataObject* itk_image = NULL;
33 cpPlugins_Image_Demangle_AllScalarTypes( 2, image, itk_image, r, _GD0 );
34 else cpPlugins_Image_Demangle_AllScalarTypes( 3, image, itk_image, r, _GD0 );
35 else cpPlugins_Image_Demangle_AllScalarTypes( 4, image, itk_image, r, _GD0 );
36 else r = "BinaryErodeImageFilter: Input image type not supported.";
40 // -------------------------------------------------------------------------
42 std::string cpPlugins::BasicFilters::BinaryErodeImageFilter::
43 _GD0( itk::DataObject* image )
46 this->_RealGD< I, itk::Image< unsigned char, I::ImageDimension > >(
52 // -------------------------------------------------------------------------
53 template< class I, class O >
54 inline std::string cpPlugins::BasicFilters::BinaryErodeImageFilter::
55 _RealGD( itk::DataObject* image )
57 //typedef itk::Image<I, I::ImageDimension> ImageType;
58 typedef itk::BinaryBallStructuringElement< typename I::PixelType, I::ImageDimension> StructuringElementType;
59 typedef itk::BinaryErodeImageFilter< I, O, StructuringElementType > _F;
60 typedef typename _F::RadiusType _RT;
64 rad_val.Fill( this->m_Parameters->GetUint( "Radius" ) );
68 StructuringElementType structuringElement;
69 structuringElement.SetRadius( rad_val );
70 structuringElement.CreateStructuringElement( );
72 _F* filter = this->_CreateITK< _F >( );
73 filter->SetInput( dynamic_cast< I* >( image ) );
74 filter->SetKernel( structuringElement );
78 auto out = this->GetOutputData< cpPlugins::Interface::Image >( "Output" );
79 out->SetITK( filter->GetOutput( ) );