]> Creatis software - cpPlugins.git/blobdiff - plugins/cpPluginsImageFilters/OtsuThresholdImageFilter.cxx
More bugs smashed
[cpPlugins.git] / plugins / cpPluginsImageFilters / OtsuThresholdImageFilter.cxx
index c08eb204b14a45357faedb87c725390a60059421..177d4645f219aa557cd7935680c519512073f3a4 100644 (file)
@@ -1,15 +1,17 @@
 #include <cpPluginsImageFilters/OtsuThresholdImageFilter.h>
 #include <cpPlugins/Image.h>
+#include <cpPlugins_ITKInstances/ImageFilters.h>
 
 #include <itkOtsuThresholdImageFilter.h>
-#include <itkBinaryFunctorImageFilter.hxx>
-#include <itkHistogram.hxx>
-#include <itkHistogramAlgorithmBase.hxx>
-#include <itkHistogramThresholdImageFilter.hxx>
-#include <itkImageToHistogramFilter.hxx>
-#include <itkMaskedImageToHistogramFilter.hxx>
 #include <itkOtsuMultipleThresholdsCalculator.hxx>
 #include <itkOtsuThresholdCalculator.hxx>
+/*
+  #include <itkHistogram.hxx>
+  #include <itkHistogramAlgorithmBase.hxx>
+  #include <itkHistogramThresholdImageFilter.hxx>
+  #include <itkImageToHistogramFilter.hxx>
+  #include <itkMaskedImageToHistogramFilter.hxx>
+*/
 
 // -------------------------------------------------------------------------
 cpPluginsImageFilters::OtsuThresholdImageFilter::
@@ -47,34 +49,34 @@ _GenerateData( )
 }
 
 // -------------------------------------------------------------------------
-template< class I >
+template< class _TImage >
 std::string cpPluginsImageFilters::OtsuThresholdImageFilter::
-_GD0( I* image )
+_GD0( _TImage* image )
 {
   if( image != NULL )
     return(
-      this->_GD1< I, itk::Image< unsigned char, I::ImageDimension > >( image )
+      this->_GD1< _TImage, itk::Image< unsigned char, _TImage::ImageDimension > >( image )
       );
   else
     return( "ImageFilters::OtsuThresholdImageFilter: No valid input image." );
 }
 
 // -------------------------------------------------------------------------
-template< class I, class O >
+template< class _TImage, class _TBinaryImage >
 std::string cpPluginsImageFilters::OtsuThresholdImageFilter::
-_GD1( I* image )
+_GD1( _TImage* image )
 {
-  typedef itk::OtsuThresholdImageFilter< I, O > _F;
-  typedef typename O::PixelType _OP;
+  typedef itk::OtsuThresholdImageFilter< _TImage, _TBinaryImage > _F;
+  typedef typename _TBinaryImage::PixelType _UP;
 
   // Get parameters
   unsigned int bins = this->m_Parameters.GetUint( "NumberOfHistogramBins" );
-  _OP in_val = _OP( this->m_Parameters.GetUint( "InsideValue" ) );
-  _OP out_val = _OP( this->m_Parameters.GetUint( "OutsideValue" ) );
+  _UP in_val = _UP( this->m_Parameters.GetUint( "InsideValue" ) );
+  _UP out_val = _UP( this->m_Parameters.GetUint( "OutsideValue" ) );
 
   // Configure filter
   _F* filter = this->_CreateITK< _F >( );
-  filter->SetInput( dynamic_cast< I* >( image ) );
+  filter->SetInput( image );
   filter->SetNumberOfHistogramBins( bins );
   filter->SetInsideValue( out_val ); // WARNING: these are inverted
   filter->SetOutsideValue( in_val );