From: Leonardo Florez-Valencia Date: Mon, 18 Jan 2016 23:05:24 +0000 (-0500) Subject: Plugins updated X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=4927655a67428c05d0072a906e05f2785b3fe0ad;p=FrontAlgorithms.git Plugins updated --- diff --git a/appli/CMakeLists.txt b/appli/CMakeLists.txt index 61d2cd0..6d67748 100644 --- a/appli/CMakeLists.txt +++ b/appli/CMakeLists.txt @@ -1,6 +1,7 @@ IF(BUILD_EXAMPLES) SUBDIRS( examples + ## fpaLab ) ENDIF(BUILD_EXAMPLES) diff --git a/lib/fpa/Image/Functors/RegionGrowThresholdFunction.h b/lib/fpa/Image/Functors/RegionGrowThresholdFunction.h index 1ac7c8f..f43ad2c 100644 --- a/lib/fpa/Image/Functors/RegionGrowThresholdFunction.h +++ b/lib/fpa/Image/Functors/RegionGrowThresholdFunction.h @@ -58,10 +58,11 @@ namespace fpa protected: RegionGrowThresholdFunction( ) - : Superclass( ), - m_LowerThreshold( itk::NumericTraits< TPixel >::min( ) ), - m_UpperThreshold( itk::NumericTraits< TPixel >::max( ) ) - { } + : Superclass( ) + { + itk::NumericTraits< TPixel >::min( this->m_LowerThreshold ); + itk::NumericTraits< TPixel >::max( this->m_UpperThreshold ); + } virtual ~RegionGrowThresholdFunction( ) { } diff --git a/lib/fpaPlugins/AllPixelsImageGrowFunctionSource.cxx b/lib/fpaPlugins/AllPixelsImageGrowFunctionSource.cxx new file mode 100644 index 0000000..f70ee79 --- /dev/null +++ b/lib/fpaPlugins/AllPixelsImageGrowFunctionSource.cxx @@ -0,0 +1,60 @@ +#include "AllPixelsImageGrowFunctionSource.h" + +#include +#include +#include +#include + +// ------------------------------------------------------------------------- +fpaPlugins::AllPixelsImageGrowFunctionSource:: +AllPixelsImageGrowFunctionSource( ) + : Superclass( ) +{ + this->_AddInput( "ReferenceImage" ); + this->_MakeOutput< GrowFunction >( "Output" ); +} + +// ------------------------------------------------------------------------- +fpaPlugins::AllPixelsImageGrowFunctionSource:: +~AllPixelsImageGrowFunctionSource( ) +{ +} + +// ------------------------------------------------------------------------- +std::string fpaPlugins::AllPixelsImageGrowFunctionSource:: +_GenerateData( ) +{ + cpPlugins::Interface::Image* image = + this->GetInput< cpPlugins::Interface::Image >( "ReferenceImage" ); + if( image == NULL ) + return( "fpaPlugins::AllPixelsImageGrowFunctionSource: No input reference image." ); + + itk::DataObject* itk_image = NULL; + std::string r = ""; + cpPlugins_Image_Demangle_AllScalarTypes( 2, image, itk_image, r, _GD0 ); + else cpPlugins_Image_Demangle_AllScalarTypes( 3, image, itk_image, r, _GD0 ); + else r = "fpaPlugins::AllPixelsImageGrowFunctionSource: no valid reference image."; + + return( r ); +} + +// ------------------------------------------------------------------------- +template< class I > +std::string fpaPlugins::AllPixelsImageGrowFunctionSource:: +_GD0( itk::DataObject* data ) +{ + typedef fpa::Image::Functors::RegionGrowAllBelongsFunction< I > _F; + typename _F::Pointer functor = _F::New( ); + + // Connect output + GrowFunction* out = this->GetOutput< GrowFunction >( "Output" ); + if( out != NULL ) + { + out->SetITK< _F >( functor ); + return( "" ); + } + else + return( "fpaPlugins::AllPixelsImageGrowFunctionSource: output not correctly created." ); +} + +// eof - $RCSfile$ diff --git a/lib/fpaPlugins/AllPixelsImageGrowFunctionSource.h b/lib/fpaPlugins/AllPixelsImageGrowFunctionSource.h new file mode 100644 index 0000000..51761a2 --- /dev/null +++ b/lib/fpaPlugins/AllPixelsImageGrowFunctionSource.h @@ -0,0 +1,51 @@ +#ifndef __FPAPLUGINS__ALLPIXELSIMAGEGROWFUNCTIONSOURCE__H__ +#define __FPAPLUGINS__ALLPIXELSIMAGEGROWFUNCTIONSOURCE__H__ + +#include +#include + +namespace fpaPlugins +{ + /** + */ + class fpaPlugins_EXPORT AllPixelsImageGrowFunctionSource + : public cpPlugins::Interface::ProcessObject + { + public: + typedef AllPixelsImageGrowFunctionSource Self; + typedef cpPlugins::Interface::ProcessObject Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; + + public: + itkNewMacro( Self ); + itkTypeMacro( + AllPixelsImageGrowFunctionSource, cpPlugins::Interface::ProcessObject + ); + cpPlugins_Id_Macro( + AllPixelsImageGrowFunctionSource, FrontPropagationFunctors + ); + + protected: + AllPixelsImageGrowFunctionSource( ); + virtual ~AllPixelsImageGrowFunctionSource( ); + + virtual std::string _GenerateData( ); + + template< class I > + std::string _GD0( itk::DataObject* data ); + + private: + // Purposely not implemented. + AllPixelsImageGrowFunctionSource( const Self& other ); + Self& operator=( const Self& other ); + }; + + // --------------------------------------------------------------------- + CPPLUGINS_INHERIT_PROVIDER( AllPixelsImageGrowFunctionSource ); + +} // ecapseman + +#endif // __FPAPLUGINS__ALLPIXELSIMAGEGROWFUNCTIONSOURCE__H__ + +// eof - $RCSfile$ diff --git a/lib/fpaPlugins/CMakeLists.txt b/lib/fpaPlugins/CMakeLists.txt index ec3c96d..4b9bf2e 100644 --- a/lib/fpaPlugins/CMakeLists.txt +++ b/lib/fpaPlugins/CMakeLists.txt @@ -4,12 +4,31 @@ SET(LIBRARY_NAME fpaPlugins) ## = Source code = ## =============== -FILE(GLOB LIB_HEADERS_H "*.h") -FILE(GLOB LIB_HEADERS_HPP "*.hpp") -FILE(GLOB LIB_HEADERS_HXX "*.hxx") -FILE(GLOB LIB_SOURCES_C "*.c") -FILE(GLOB LIB_SOURCES_CPP "*.cpp") -FILE(GLOB LIB_SOURCES_CXX "*.cxx") +SET( + data_LIB_HEADERS + GrowFunction.h + GrowFunction.hxx + ) +SET( + filters_LIB_HEADERS + AllPixelsImageGrowFunctionSource.h + ThresholdImageGrowFunctionSource.h + ImageRegionGrow.h + ) +SET( + data_LIB_SOURCES + GrowFunction.cxx + ) +SET( + filters_LIB_SOURCES + AllPixelsImageGrowFunctionSource.cxx + ThresholdImageGrowFunctionSource.cxx + ImageRegionGrow.cxx + ) +INCLUDE_DIRECTORIES( + ${PROJECT_SOURCE_DIR}/lib/fpaPlugins + ${PROJECT_BINARY_DIR}/lib/fpaPlugins + ) ## ===================== ## = Compilation rules = @@ -17,17 +36,16 @@ FILE(GLOB LIB_SOURCES_CXX "*.cxx") ADD_CUSTOM_COMMAND( OUTPUT ${LIBRARY_NAME}_Host.cxx - DEPENDS ${cpPlugins_createHost_APP} ${LIB_HEADERS_H} - COMMAND ${cpPlugins_createHost_APP} ${LIBRARY_NAME}_Host.cxx fpaPlugins ${LIB_HEADERS_H} + DEPENDS ${cpPlugins_createHost_APP} ${filters_LIB_HEADERS} + COMMAND ${cpPlugins_createHost_APP} ${LIBRARY_NAME}_Host.cxx fpaPlugins ${filters_LIB_HEADERS} ) ADD_LIBRARY( ${LIBRARY_NAME} SHARED ${LIBRARY_NAME}_Host.cxx - ${LIB_SOURCES_C} - ${LIB_SOURCES_CPP} - ${LIB_SOURCES_CXX} + ${data_LIB_SOURCES} + ${filters_LIB_SOURCES} ) GENERATE_EXPORT_HEADER( ${LIBRARY_NAME} diff --git a/lib/fpaPlugins/GrowFunction.cxx b/lib/fpaPlugins/GrowFunction.cxx new file mode 100644 index 0000000..9b6d0d9 --- /dev/null +++ b/lib/fpaPlugins/GrowFunction.cxx @@ -0,0 +1,16 @@ +#include + +// ------------------------------------------------------------------------- +fpaPlugins::GrowFunction:: +GrowFunction( ) + : Superclass( ) +{ +} + +// ------------------------------------------------------------------------- +fpaPlugins::GrowFunction:: +~GrowFunction( ) +{ +} + +// eof - $RCSfile$ diff --git a/lib/fpaPlugins/GrowFunction.h b/lib/fpaPlugins/GrowFunction.h new file mode 100644 index 0000000..696e5b6 --- /dev/null +++ b/lib/fpaPlugins/GrowFunction.h @@ -0,0 +1,47 @@ +#ifndef __FPAPLUGINS__GROWFUNCTION__H__ +#define __FPAPLUGINS__GROWFUNCTION__H__ + +#include + +#include + +// ------------------------------------------------------------------------- +namespace fpaPlugins +{ + /** + */ + class cpPlugins_Interface_EXPORT GrowFunction + : public cpPlugins::Interface::DataObject + { + public: + typedef GrowFunction Self; + typedef cpPlugins::Interface::DataObject Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; + + public: + itkNewMacro( Self ); + itkTypeMacro( GrowFunction, cpPlugins::Interface::DataObject ); + cpPlugins_Id_Macro( GrowFunction, GrowFunction ); + + public: + template< class F > + inline void SetITK( itk::Object* object ); + + protected: + GrowFunction( ); + virtual ~GrowFunction( ); + + private: + // Purposely not implemented + GrowFunction( const Self& ); + Self& operator=( const Self& ); + }; + +} // ecapseman + +#include + +#endif // __FPAPLUGINS__GROWFUNCTION__H__ + +// eof - $RCSfile$ diff --git a/lib/fpaPlugins/GrowFunction.hxx b/lib/fpaPlugins/GrowFunction.hxx new file mode 100644 index 0000000..00c2cba --- /dev/null +++ b/lib/fpaPlugins/GrowFunction.hxx @@ -0,0 +1,27 @@ +#ifndef __FPAPLUGINS__GROWFUNCTION__HXX__ +#define __FPAPLUGINS__GROWFUNCTION__HXX__ + +#include + +// ------------------------------------------------------------------------- +template< class F > +void fpaPlugins::GrowFunction:: +SetITK( itk::Object* object ) +{ + typedef typename F::TSpace _TSpace; + typedef typename F::TVertex _TVertex; + typedef itk::FunctionBase< _TVertex, bool > _TBaseFunction; + + _TBaseFunction* function = dynamic_cast< _TBaseFunction* >( object ); + if( function != NULL ) + { + this->m_ITKObject = function; + this->m_VTKObject = NULL; + this->Modified( ); + + } // fi +} + +#endif // __FPAPLUGINS__GROWFUNCTION__HXX__ + +// eof - $RCSfile$ diff --git a/lib/fpaPlugins/ImageRegionGrow.cxx b/lib/fpaPlugins/ImageRegionGrow.cxx index 6429765..86c67e7 100644 --- a/lib/fpaPlugins/ImageRegionGrow.cxx +++ b/lib/fpaPlugins/ImageRegionGrow.cxx @@ -13,12 +13,17 @@ ImageRegionGrow( ) this->_AddInput( "GrowFunction" ); this->_MakeOutput< cpPlugins::Interface::Image >( "Output" ); - this->m_Parameters->ConfigureAsBool( "VisualDebug", false ); - this->m_Parameters->ConfigureAsBool( "StopAtOneFront", false ); - this->m_Parameters->ConfigureAsReal( "InsideValue", 1 ); - this->m_Parameters->ConfigureAsReal( "OutsideValue", 0 ); + this->m_Parameters->ConfigureAsBool( "VisualDebug" ); + this->m_Parameters->ConfigureAsBool( "StopAtOneFront" ); + this->m_Parameters->ConfigureAsReal( "InsideValue" ); + this->m_Parameters->ConfigureAsReal( "OutsideValue" ); this->m_Parameters->ConfigureAsPointList( "Seeds" ); + this->m_Parameters->SetBool( "VisualDebug", false ); + this->m_Parameters->SetBool( "StopAtOneFront", false ); + this->m_Parameters->SetReal( "InsideValue", 1 ); + this->m_Parameters->SetReal( "OutsideValue", 0 ); + std::vector< std::string > orders; orders.push_back( "1" ); orders.push_back( "2" ); @@ -57,6 +62,7 @@ _GD0( itk::DataObject* data ) typedef itk::Image< _TOutPixel, I::ImageDimension > _TOut; typedef fpa::Image::RegionGrow< I, _TOut > _TFilter; typedef typename _TFilter::TGrowingFunction _TFunctor; + typedef typename I::PointType _TPoint; I* image = dynamic_cast< I* >( data ); @@ -83,8 +89,8 @@ _GD0( itk::DataObject* data ) filter->SetOutsideValue( _TOutPixel( params->GetReal( "OutsideValue" ) ) ); // Assign seeds - std::vector< typename I::PointType > seeds; - params->GetPointList( seeds, "Seeds", I::ImageDimension ); + std::vector< _TPoint > seeds = + params->GetPointList< _TPoint >( "Seeds", I::ImageDimension ); for( auto sIt = seeds.begin( ); sIt != seeds.end( ); ++sIt ) { typename I::IndexType idx; diff --git a/lib/fpaPlugins/ImageRegionGrow.h b/lib/fpaPlugins/ImageRegionGrow.h index e653755..f6ce3ff 100644 --- a/lib/fpaPlugins/ImageRegionGrow.h +++ b/lib/fpaPlugins/ImageRegionGrow.h @@ -23,7 +23,7 @@ namespace fpaPlugins ImageRegionGrow, cpPlugins::Interface::ImageToImageFilter ); cpPlugins_Id_Macro( - fpaPlugins::ImageRegionGrow, "FrontPropagationImageAlgorithms" + ImageRegionGrow, FrontPropagationImageAlgorithm ); protected: diff --git a/lib/fpaPlugins/ThresholdImageGrowFunctionSource.cxx b/lib/fpaPlugins/ThresholdImageGrowFunctionSource.cxx new file mode 100644 index 0000000..8ea176e --- /dev/null +++ b/lib/fpaPlugins/ThresholdImageGrowFunctionSource.cxx @@ -0,0 +1,66 @@ +#include "ThresholdImageGrowFunctionSource.h" + +#include +#include +#include +#include + +// ------------------------------------------------------------------------- +fpaPlugins::ThresholdImageGrowFunctionSource:: +ThresholdImageGrowFunctionSource( ) + : Superclass( ) +{ + this->_AddInput( "ReferenceImage" ); + this->_MakeOutput< GrowFunction >( "Output" ); + + this->m_Parameters->ConfigureAsReal( "LowerThreshold" ); + this->m_Parameters->ConfigureAsReal( "UpperThreshold" ); + + this->m_Parameters->SetReal( "LowerThreshold", 0 ); + this->m_Parameters->SetReal( "UpperThreshold", 0 ); +} + +// ------------------------------------------------------------------------- +fpaPlugins::ThresholdImageGrowFunctionSource:: +~ThresholdImageGrowFunctionSource( ) +{ +} + +// ------------------------------------------------------------------------- +std::string fpaPlugins::ThresholdImageGrowFunctionSource:: +_GenerateData( ) +{ + cpPlugins::Interface::Image* image = + this->GetInput< cpPlugins::Interface::Image >( "ReferenceImage" ); + if( image == NULL ) + return( "fpaPlugins::ThresholdImageGrowFunctionSource: No input reference image." ); + + itk::DataObject* itk_image = NULL; + std::string r = ""; + cpPlugins_Image_Demangle_AllScalarTypes( 2, image, itk_image, r, _GD0 ); + else cpPlugins_Image_Demangle_AllScalarTypes( 3, image, itk_image, r, _GD0 ); + else r = "fpaPlugins::ThresholdImageGrowFunctionSource: no valid reference image."; + + return( r ); +} + +// ------------------------------------------------------------------------- +template< class I > +std::string fpaPlugins::ThresholdImageGrowFunctionSource:: +_GD0( itk::DataObject* data ) +{ + typedef fpa::Image::Functors::RegionGrowThresholdFunction< I > _F; + typename _F::Pointer functor = _F::New( ); + + // Connect output + GrowFunction* out = this->GetOutput< GrowFunction >( "Output" ); + if( out != NULL ) + { + out->SetITK< _F >( functor ); + return( "" ); + } + else + return( "fpaPlugins::ThresholdImageGrowFunctionSource: output not correctly created." ); +} + +// eof - $RCSfile$ diff --git a/lib/fpaPlugins/ThresholdImageGrowFunctionSource.h b/lib/fpaPlugins/ThresholdImageGrowFunctionSource.h new file mode 100644 index 0000000..acd978b --- /dev/null +++ b/lib/fpaPlugins/ThresholdImageGrowFunctionSource.h @@ -0,0 +1,51 @@ +#ifndef __FPAPLUGINS__THRESHOLDIMAGEGROWFUNCTIONSOURCE__H__ +#define __FPAPLUGINS__THRESHOLDIMAGEGROWFUNCTIONSOURCE__H__ + +#include +#include + +namespace fpaPlugins +{ + /** + */ + class fpaPlugins_EXPORT ThresholdImageGrowFunctionSource + : public cpPlugins::Interface::ProcessObject + { + public: + typedef ThresholdImageGrowFunctionSource Self; + typedef cpPlugins::Interface::ProcessObject Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; + + public: + itkNewMacro( Self ); + itkTypeMacro( + ThresholdImageGrowFunctionSource, cpPlugins::Interface::ProcessObject + ); + cpPlugins_Id_Macro( + ThresholdImageGrowFunctionSource, FrontPropagationFunctors + ); + + protected: + ThresholdImageGrowFunctionSource( ); + virtual ~ThresholdImageGrowFunctionSource( ); + + virtual std::string _GenerateData( ); + + template< class I > + std::string _GD0( itk::DataObject* data ); + + private: + // Purposely not implemented. + ThresholdImageGrowFunctionSource( const Self& other ); + Self& operator=( const Self& other ); + }; + + // --------------------------------------------------------------------- + CPPLUGINS_INHERIT_PROVIDER( ThresholdImageGrowFunctionSource ); + +} // ecapseman + +#endif // __FPAPLUGINS__THRESHOLDIMAGEGROWFUNCTIONSOURCE__H__ + +// eof - $RCSfile$