#include <cpPlugins/Plugins/OtsuThresholdImageFilter.h>
#include <cpPlugins/Interface/Image.h>
-#include <complex>
-
-#define ITK_MANUAL_INSTANTIATION
-#include <itkImage.h>
-
-#include <itkCovariantVector.h>
-#include <itkDiffusionTensor3D.h>
-#include <itkPoint.h>
-#include <itkRGBPixel.h>
-#include <itkRGBAPixel.h>
-#include <itkSymmetricSecondRankTensor.h>
-#include <itkVector.h>
-
-#undef ITK_MANUAL_INSTANTIATION
#include <itkOtsuThresholdImageFilter.h>
// -------------------------------------------------------------------------
this->_MakeOutput< cpPlugins::Interface::Image >( 0 );
using namespace cpPlugins::Interface;
- this->m_DefaultParameters.Configure( Parameters::Uint, "NumberOfHistogramBins" );
+ this->m_DefaultParameters.Configure(
+ Parameters::Uint, "NumberOfHistogramBins"
+ );
this->m_DefaultParameters.Configure( Parameters::Real, "InsideValue" );
this->m_DefaultParameters.Configure( Parameters::Real, "OutsideValue" );
this->m_DefaultParameters.SetValueAsUint( "NumberOfHistogramBins", 100 );
std::string cpPlugins::Plugins::OtsuThresholdImageFilter::
_GenerateData( )
{
- itk::DataObject* i = this->m_Inputs[ 0 ]->GetITKDataObject( );
- return( this->_DemangleImageDimension( i ) );
-}
+ cpPlugins::Interface::Image* image =
+ this->_Input< cpPlugins::Interface::Image >( 0 );
+ if( image == NULL )
+ return( "OtsuThresholdImageFilter: No input image." );
-// -------------------------------------------------------------------------
-namespace cpPlugins
-{
- namespace Plugins
- {
- cpPlugins_Image_Demangle_Methods_Code_Only_Scalars(
- OtsuThresholdImageFilter, _DemangleInput
- );
- }
+ itk::DataObject* itk_image = NULL;
+ std::string r = "";
+ cpPlugins_Image_Input_Demangle_Dimension_AllScalarTypes(
+ 2, image, itk_image, r, _DemangleOutput
+ );
+ else cpPlugins_Image_Input_Demangle_Dimension_AllScalarTypes(
+ 3, image, itk_image, r, _DemangleOutput
+ );
+ else cpPlugins_Image_Input_Demangle_Dimension_AllScalarTypes(
+ 4, image, itk_image, r, _DemangleOutput
+ );
+ else r = "OtsuThresholdImageFilter: Input image type not supported.";
+ return( r );
}
// -------------------------------------------------------------------------
template< class I >
std::string cpPlugins::Plugins::OtsuThresholdImageFilter::
-_DemangleInput( itk::DataObject* image )
+_DemangleOutput( itk::DataObject* image )
{
return(
this->_RealGD< I, itk::Image< unsigned char, I::ImageDimension > >(
// -------------------------------------------------------------------------
template< class I, class O >
-std::string cpPlugins::Plugins::OtsuThresholdImageFilter::
+inline std::string cpPlugins::Plugins::OtsuThresholdImageFilter::
_RealGD( itk::DataObject* image )
{
typedef itk::OtsuThresholdImageFilter< I, O > _F;
typedef typename O::PixelType _OP;
- unsigned int bins = this->m_Parameters.GetValueAsUint( "NumberOfHistogramBins" );
- _OP in = _OP( this->m_Parameters.GetValueAsReal( "InsideValue" ) );
- _OP out = _OP( this->m_Parameters.GetValueAsReal( "OutsideValue" ) );
+ // Get parameters
+ unsigned int bins =
+ this->m_Parameters.GetValueAsUint( "NumberOfHistogramBins" );
+ _OP in_val = _OP( this->m_Parameters.GetValueAsReal( "InsideValue" ) );
+ _OP out_val = _OP( this->m_Parameters.GetValueAsReal( "OutsideValue" ) );
+ // Configure filter
_F* filter = dynamic_cast< _F* >( this->m_RealProcessObject.GetPointer( ) );
if( filter == NULL )
{
} // fi
filter->SetInput( dynamic_cast< I* >( image ) );
filter->SetNumberOfHistogramBins( bins );
- filter->SetInsideValue( in );
- filter->SetOutsideValue( out );
+ filter->SetInsideValue( in_val );
+ filter->SetOutsideValue( out_val );
filter->Update( );
- this->m_Outputs[ 0 ]->SetITKDataObject( filter->GetOutput( ) );
-
- return( "" );
+
+ // Connect output
+ cpPlugins::Interface::Image* out =
+ this->_Output< cpPlugins::Interface::Image >( 0 );
+ if( out != NULL )
+ {
+ out->SetITKImage< O >( filter->GetOutput( ) );
+ return( "" );
+ }
+ else
+ return( "OtsuThresholdImageFilter: output not correctly created." );
}
// eof - $RCSfile$