1 #include <cpPluginsImageFilters/HistogramThresholdImageFilter.h>
2 #include <cpPlugins/Image.h>
3 #include <cpPlugins_ITKInstances/ImageFilters.h>
5 #include <itkHistogramThresholdImageFilter.h>
6 #include <itkHistogramThresholdImageFilter.hxx>
7 #include <itkBinaryFunctorImageFilter.hxx>
9 // -------------------------------------------------------------------------
10 cpPluginsImageFilters::HistogramThresholdImageFilter::
11 HistogramThresholdImageFilter( )
14 this->_AddInput( "Input" );
15 this->_AddInput( "Calculator" );
16 this->_AddInput( "Mask", false );
17 this->_AddOutput< cpPlugins::Image >( "Output" );
19 this->m_Parameters.ConfigureAsUint( "NumberOfHistogramBins" );
20 this->m_Parameters.ConfigureAsBool( "AutoMinimumMaximum" );
21 this->m_Parameters.ConfigureAsBool( "MaskOutput" );
22 this->m_Parameters.ConfigureAsReal( "MaskValue" );
23 this->m_Parameters.ConfigureAsReal( "Threshold" );
25 this->m_Parameters.SetUint( "NumberOfHistogramBins", 256 );
26 this->m_Parameters.SetBool( "AutoMinimumMaximum", true );
27 this->m_Parameters.SetBool( "MaskOutput", false );
28 this->m_Parameters.SetReal( "MaskValue", 1 );
29 this->m_Parameters.SetReal( "Threshold", 0 );
32 // -------------------------------------------------------------------------
33 cpPluginsImageFilters::HistogramThresholdImageFilter::
34 ~HistogramThresholdImageFilter( )
38 // -------------------------------------------------------------------------
39 std::string cpPluginsImageFilters::HistogramThresholdImageFilter::
42 auto image = this->GetInputData( "Input" )->GetITK< itk::DataObject >( );
43 std::string cpPlugin_Image_Demangle_Pixel_AllScalars( r, _GD0, image, 1 );
44 if( r != "" ) cpPlugin_Image_Demangle_Pixel_AllScalars( r, _GD0, image, 2 );
45 if( r != "" ) cpPlugin_Image_Demangle_Pixel_AllScalars( r, _GD0, image, 3 );
46 if( r != "" ) cpPlugin_Image_Demangle_Pixel_AllScalars( r, _GD0, image, 4 );
50 // -------------------------------------------------------------------------
51 template< class _TImage >
52 std::string cpPluginsImageFilters::HistogramThresholdImageFilter::
53 _GD0( _TImage* image )
57 this->_GD1< _TImage, itk::Image< unsigned char, _TImage::ImageDimension > >( image )
61 "ImageFilters::HistogramThresholdImageFilter: No valid input image."
65 // -------------------------------------------------------------------------
66 template< class _TImage, class _TBinaryImage >
67 std::string cpPluginsImageFilters::HistogramThresholdImageFilter::
68 _GD1( _TImage* image )
70 typedef itk::HistogramThresholdImageFilter< _TImage, _TBinaryImage > _F;
71 typedef typename _TImage::PixelType _TP;
76 _F* filter = this->_CreateITK< _F >( );
77 filter->SetInput( image );
81 this->GetOutputData( "Output" )->SetITK( filter->GetOutput( ) );
82 return( "HistogramThresholdImage: not complete yet." );