X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=plugins%2FImageAlgorithms%2FMoriRegionGrow.cxx;fp=plugins%2FImageAlgorithms%2FMoriRegionGrow.cxx;h=c12e855fbf6d164a77f1ae7fd64b349eb9424ba4;hb=6585142e69f2ff5e4fceb21320ab3795c3e82218;hp=0000000000000000000000000000000000000000;hpb=91510d06bf1895f684f9f2f6508ab7d97154576d;p=FrontAlgorithms.git diff --git a/plugins/ImageAlgorithms/MoriRegionGrow.cxx b/plugins/ImageAlgorithms/MoriRegionGrow.cxx new file mode 100644 index 0000000..c12e855 --- /dev/null +++ b/plugins/ImageAlgorithms/MoriRegionGrow.cxx @@ -0,0 +1,74 @@ +#include +#include + +#include + +// ------------------------------------------------------------------------- +fpaPluginsImageAlgorithms::MoriRegionGrow:: +MoriRegionGrow( ) + : Superclass( ) +{ + typedef cpPlugins::Pipeline::DataObject _TData; + + this->_ConfigureInput< _TData >( "GrowFunction", true, false ); + this->m_Parameters.ConfigureAsInt( "InsideValue", 1 ); + this->m_Parameters.ConfigureAsInt( "OutsideValue", 0 ); + this->m_Parameters.ConfigureAsInt( "Step", 1 ); + this->m_Parameters.ConfigureAsReal( "LowerThreshold", 1 ); + this->m_Parameters.ConfigureAsReal( "UpperThreshold", 1 ); + this->m_Parameters.ConfigureAsIntTypesChoices( "ResultType" ); +} + +// ------------------------------------------------------------------------- +fpaPluginsImageAlgorithms::MoriRegionGrow:: +~MoriRegionGrow( ) +{ +} + +// ------------------------------------------------------------------------- +void fpaPluginsImageAlgorithms::MoriRegionGrow:: +_GenerateData( ) +{ + auto o = this->GetInputData( "Input" ); + cpPlugins_Demangle_Image_ScalarPixels_AllDims_1( o, _GD0 ) + this->_Error( "Invalid input image." ); +} + +// ------------------------------------------------------------------------- +template< class _TImage > +void fpaPluginsImageAlgorithms::MoriRegionGrow:: +_GD0( _TImage* image ) +{ + auto rtype = this->m_Parameters.GetSelectedChoice( "ResultType" ); + if( rtype == "char" ) this->_GD1< _TImage, char >( image ); + else if( rtype == "uchar" ) this->_GD1< _TImage, unsigned char >( image ); + else if( rtype == "short" ) this->_GD1< _TImage, short >( image ); + else if( rtype == "ushort" ) this->_GD1< _TImage, unsigned short >( image ); + else if( rtype == "int" ) this->_GD1< _TImage, int >( image ); + else if( rtype == "uint" ) this->_GD1< _TImage, unsigned int >( image ); + else if( rtype == "long" ) this->_GD1< _TImage, long >( image ); + else if( rtype == "ulong" ) this->_GD1< _TImage, unsigned long >( image ); + else this->_GD1< _TImage, char >( image ); +} + +// ------------------------------------------------------------------------- +template< class _TInputImage, class _TOutputPixel > +void fpaPluginsImageAlgorithms::MoriRegionGrow:: +_GD1( _TInputImage* image ) +{ + typedef + itk::Image< _TOutputPixel, _TInputImage::ImageDimension > + _TOutputImage; + typedef fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage > _TFilter; + typedef typename _TFilter::TGrowFunction _TGrow; + + auto filter = this->_CreateITK< _TFilter >( ); + this->_ConfigureFilter( filter, image ); + filter->SetGrowFunction( this->GetInputData< _TGrow >( "GrowFunction" ) ); + filter->SetInsideValue( this->m_Parameters.GetInt( "InsideValue" ) ); + filter->SetOutsideValue( this->m_Parameters.GetInt( "OutsideValue" ) ); + filter->Update( ); + this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) ); +} + +// eof - $RCSfile$