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>
8 #include <itkImageToHistogramFilter.hxx>
9 #include <itkMaskedImageToHistogramFilter.hxx>
10 #include <itkBinaryThresholdImageFilter.hxx>
12 // -------------------------------------------------------------------------
13 cpPluginsImageFilters::HistogramThresholdImageFilter::
14 HistogramThresholdImageFilter( )
17 this->_AddInput( "Input" );
18 this->_AddInput( "Calculator" );
19 this->_AddInput( "Mask", false );
20 this->_AddOutput< cpPlugins::Image >( "Output" );
22 this->m_Parameters.ConfigureAsUint( "NumberOfHistogramBins" );
23 this->m_Parameters.ConfigureAsBool( "AutoMinimumMaximum" );
24 this->m_Parameters.ConfigureAsBool( "MaskOutput" );
25 this->m_Parameters.ConfigureAsReal( "MaskValue" );
26 this->m_Parameters.ConfigureAsReal( "Threshold" );
28 this->m_Parameters.SetUint( "NumberOfHistogramBins", 256 );
29 this->m_Parameters.SetBool( "AutoMinimumMaximum", true );
30 this->m_Parameters.SetBool( "MaskOutput", false );
31 this->m_Parameters.SetReal( "MaskValue", 1 );
32 this->m_Parameters.SetReal( "Threshold", 0 );
35 // -------------------------------------------------------------------------
36 cpPluginsImageFilters::HistogramThresholdImageFilter::
37 ~HistogramThresholdImageFilter( )
41 // -------------------------------------------------------------------------
42 std::string cpPluginsImageFilters::HistogramThresholdImageFilter::
45 auto image = this->GetInputData( "Input" )->GetITK< itk::DataObject >( );
46 std::string cpPlugin_Image_Demangle_Pixel_AllScalars( r, _GD0, image, 1 );
47 if( r != "" ) cpPlugin_Image_Demangle_Pixel_AllScalars( r, _GD0, image, 2 );
48 if( r != "" ) cpPlugin_Image_Demangle_Pixel_AllScalars( r, _GD0, image, 3 );
49 if( r != "" ) cpPlugin_Image_Demangle_Pixel_AllScalars( r, _GD0, image, 4 );
53 // -------------------------------------------------------------------------
54 template< class _TImage >
55 std::string cpPluginsImageFilters::HistogramThresholdImageFilter::
56 _GD0( _TImage* image )
59 return( this->_GD1< _TImage, unsigned char >( image ) );
62 "ImageFilters::HistogramThresholdImageFilter: No valid input image."
66 // -------------------------------------------------------------------------
67 template< class _TImage, class _TBinaryPixel >
68 std::string cpPluginsImageFilters::HistogramThresholdImageFilter::
69 _GD1( _TImage* image )
71 typedef itk::Image< _TBinaryPixel, _TImage::ImageDimension > _TBinaryImage;
72 typedef itk::HistogramThresholdImageFilter< _TImage, _TBinaryImage > _TFilter;
77 _TFilter* filter = this->_CreateITK< _TFilter >( );
78 filter->SetInput( image );
82 this->GetOutputData( "Output" )->SetITK( filter->GetOutput( ) );
83 return( "HistogramThresholdImage: not complete yet." );