#include #include #include #include #include // ------------------------------------------------------------------------- cpPluginsImageGradientFilters::GulsunTekImageFilter:: GulsunTekImageFilter( ) : Superclass( ) { typedef cpPlugins::DataObjects::Image _TImage; this->_ConfigureInput< _TImage >( "Input", true, false ); this->_ConfigureInput< _TImage >( "Mask", false, false ); this->_ConfigureOutput< _TImage >( "Output" ); this->m_Parameters.ConfigureAsReal( "MinRadius", 0 ); this->m_Parameters.ConfigureAsReal( "MaxRadius", 1 ); this->m_Parameters.ConfigureAsUint( "ProfileSampling", 4 ); this->m_Parameters.ConfigureAsUint( "RadialSampling", 10 ); } // ------------------------------------------------------------------------- cpPluginsImageGradientFilters::GulsunTekImageFilter:: ~GulsunTekImageFilter( ) { } // ------------------------------------------------------------------------- void cpPluginsImageGradientFilters::GulsunTekImageFilter:: _GenerateData( ) { auto o = this->GetInputData( "Input" ); cpPlugins_Demangle_Image_CovariantVectorPixels_AllDims_1( o, _GD0 ) this->_Error( "Invalid input image." ); } // ------------------------------------------------------------------------- template< class _TImage > void cpPluginsImageGradientFilters::GulsunTekImageFilter:: _GD0( _TImage* image ) { typedef itk::Image< bool, _TImage::ImageDimension > _TDummy; auto o = this->GetInputData( "Mask" ); cpPlugins_Demangle_Image_ScalarPixels_2( o, _GD1, _TImage::ImageDimension, image ) this->_GD1< _TDummy, _TImage >( NULL, image ); } // ------------------------------------------------------------------------- template< class _TMask, class _TImage > void cpPluginsImageGradientFilters::GulsunTekImageFilter:: _GD1( _TMask* mask, _TImage* image ) { typedef typename _TImage::PixelType _TGradient; typedef cpExtensions::Algorithms::GulsunTekMedialness< _TImage, _TMask > _TFunction; typedef typename _TFunction::TOutput _TScalar; typedef itk::Image< _TScalar, _TImage::ImageDimension > _TOutputImage; typedef cpExtensions::Algorithms::ImageFunctionFilter< _TImage, _TOutputImage, _TFunction > _TFilter; auto filter = this->_CreateITK< _TFilter >( ); auto function = filter->GetFunction( ); if( function == NULL ) { filter->SetFunction( _TFunction::New( ) ); function = filter->GetFunction( ); } // fi function->SetMinRadius( this->m_Parameters.GetReal( "MinRadius" ) ); function->SetMaxRadius( this->m_Parameters.GetReal( "MaxRadius" ) ); function->SetProfileSampling( this->m_Parameters.GetUint( "ProfileSampling" ) ); function->SetRadialSampling( this->m_Parameters.GetUint( "RadialSampling" ) ); filter->SetInput( image ); if( mask != NULL ) function->SetMask( mask ); filter->Update( ); this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) ); } // eof - $RCSfile$