#include #include #include /* TODO #include #include #include #include #include #include */ // ------------------------------------------------------------------------- cpPluginsImageGradientFilters::GulsunTekImageFilter:: GulsunTekImageFilter( ) : Superclass( ) { this->_ConfigureInput< cpPlugins::DataObjects::Image >( "Input", true, false ); this->_ConfigureInput< cpPlugins::DataObjects::Image >( "Mask", false, false ); this->_ConfigureOutput< cpPlugins::DataObjects::Image >( "Output" ); this->m_Parameters.ConfigureAsReal( "MinRadius" ); this->m_Parameters.ConfigureAsReal( "MaxRadius" ); this->m_Parameters.ConfigureAsUint( "ProfileSampling" ); this->m_Parameters.ConfigureAsUint( "RadialSampling" ); this->m_Parameters.SetReal( "MinRadius", 0 ); this->m_Parameters.SetReal( "MaxRadius", 1 ); this->m_Parameters.SetUint( "ProfileSampling", 4 ); this->m_Parameters.SetUint( "RadialSampling", 10 ); } // ------------------------------------------------------------------------- cpPluginsImageGradientFilters::GulsunTekImageFilter:: ~GulsunTekImageFilter( ) { } // ------------------------------------------------------------------------- void cpPluginsImageGradientFilters::GulsunTekImageFilter:: _GenerateData( ) { auto o = this->GetInputData( "Input" ); cpPlugins_Demangle_ImageCovariantVectors_Dims( o, _GD0 ); else this->_Error( "Invalid input image." ); } // ------------------------------------------------------------------------- template< class _TImage > void cpPluginsImageGradientFilters::GulsunTekImageFilter:: _GD0( _TImage* image ) { typedef itk::Image< char, _TImage::ImageDimension > _TChar; typedef itk::Image< short, _TImage::ImageDimension > _TShort; typedef itk::Image< int, _TImage::ImageDimension > _TInt; typedef itk::Image< long, _TImage::ImageDimension > _TLong; typedef itk::Image< float, _TImage::ImageDimension > _TFloat; typedef itk::Image< double, _TImage::ImageDimension > _TDouble; typedef itk::Image< unsigned char, _TImage::ImageDimension > _TUChar; typedef itk::Image< unsigned short, _TImage::ImageDimension > _TUShort; typedef itk::Image< unsigned int, _TImage::ImageDimension > _TUInt; typedef itk::Image< unsigned long, _TImage::ImageDimension > _TULong; auto m = this->GetInput( "Mask" ); auto ci = m->GetITK< _TChar >( ); auto si = m->GetITK< _TShort >( ); auto ii = m->GetITK< _TInt >( ); auto li = m->GetITK< _TLong >( ); auto fi = m->GetITK< _TFloat >( ); auto di = m->GetITK< _TDouble >( ); auto uci = m->GetITK< _TUChar >( ); auto usi = m->GetITK< _TUShort >( ); auto uii = m->GetITK< _TUInt >( ); auto uli = m->GetITK< _TULong >( ); if ( ci != NULL ) this->_GD1( image, ci ); else if( si != NULL ) this->_GD1( image, si ); else if( ii != NULL ) this->_GD1( image, ii ); else if( li != NULL ) this->_GD1( image, li ); else if( fi != NULL ) this->_GD1( image, fi ); else if( di != NULL ) this->_GD1( image, di ); else if( uci != NULL ) this->_GD1( image, uci ); else if( usi != NULL ) this->_GD1( image, usi ); else if( uii != NULL ) this->_GD1( image, uii ); else if( uli != NULL ) this->_GD1( image, uli ); else this->_GD1( image, ci ); } // ------------------------------------------------------------------------- template< class _TImage, class _TMask > void cpPluginsImageGradientFilters::GulsunTekImageFilter:: _GD1( _TImage* image, _TMask* mask ) { 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$