From cd110994af8ac9a46a74c3a5ba3e13ab897731ec Mon Sep 17 00:00:00 2001 From: =?utf8?q?Leonardo=20Fl=C3=B3rez-Valencia?= Date: Tue, 29 Nov 2016 11:05:34 -0500 Subject: [PATCH] ... --- CMakeLists.txt | 12 +- cmake/FrontAlgorithmsConfig.cmake.in | 60 ---------- cmake/Options.cmake | 6 - lib/CMakeLists.txt | 5 - lib/fpa/Config.cxx | 1 - lib/fpa/{Config.h.in => Config.h} | 13 --- lib/fpaInstances/CMakeLists.txt | 31 ++---- lib/fpaInstances/DataObjects.i | 12 +- lib/fpaInstances/Filters.i | 8 +- plugins/CMakeLists.txt | 26 ++++- plugins/DijkstraFunctors/DijkstraFunctors.i | 12 ++ .../ExtractPathFromMinimumSpanningTree.cxx | 10 +- .../ExtractPathFromMinimumSpanningTree.h | 29 +++++ .../GaussianModelCost.cxx | 10 +- .../GaussianModelCost.h | 8 +- .../InvertCost.cxx | 10 +- .../InvertCost.h | 8 +- .../SimpleImageDijkstraCost.cxx | 13 +-- .../SimpleImageDijkstraCost.h | 8 +- .../BaseFilter.cxx} | 11 +- plugins/ImageAlgorithms/BaseFilter.h | 103 ++++++++++++++++++ .../Dijkstra.cxx} | 58 ++-------- plugins/ImageAlgorithms/Dijkstra.h | 27 +++++ plugins/ImageAlgorithms/ImageAlgorithms.i | 46 ++++++++ .../RegionGrow.cxx} | 69 ++---------- plugins/ImageAlgorithms/RegionGrow.h | 27 +++++ .../SkeletonFilter.cxx | 11 +- .../SkeletonFilter.h | 14 +-- plugins/Plugins/BaseImageFilter.h | 52 --------- .../ExtractPathFromMinimumSpanningTree.h | 29 ----- plugins/Plugins/ImageDijkstra.h | 27 ----- plugins/Plugins/ImageRegionGrow.h | 27 ----- plugins/Plugins/RegionGrowBinaryThreshold.cxx | 59 ---------- plugins/Plugins/RegionGrowBinaryThreshold.h | 29 ----- .../RegionGrowBinaryThresholdWithSeeds.h | 29 ----- plugins/Plugins/SimpleImageNeighborhood.cxx | 55 ---------- plugins/Plugins/SimpleImageNeighborhood.h | 29 ----- plugins/Plugins/fpaPlugins.i | 32 ------ .../BinaryThreshold.cxx} | 77 +++++++------ plugins/RegionGrowFunctors/BinaryThreshold.h | 29 +++++ .../RegionGrowFunctors/RegionGrowFunctors.i | 7 ++ 41 files changed, 446 insertions(+), 683 deletions(-) delete mode 100644 cmake/FrontAlgorithmsConfig.cmake.in delete mode 100644 cmake/Options.cmake delete mode 100644 lib/fpa/Config.cxx rename lib/fpa/{Config.h.in => Config.h} (59%) create mode 100644 plugins/DijkstraFunctors/DijkstraFunctors.i rename plugins/{Plugins => DijkstraFunctors}/ExtractPathFromMinimumSpanningTree.cxx (87%) create mode 100644 plugins/DijkstraFunctors/ExtractPathFromMinimumSpanningTree.h rename plugins/{Plugins => DijkstraFunctors}/GaussianModelCost.cxx (84%) rename plugins/{Plugins => DijkstraFunctors}/GaussianModelCost.h (73%) rename plugins/{Plugins => DijkstraFunctors}/InvertCost.cxx (87%) rename plugins/{Plugins => DijkstraFunctors}/InvertCost.h (73%) rename plugins/{Plugins => DijkstraFunctors}/SimpleImageDijkstraCost.cxx (85%) rename plugins/{Plugins => DijkstraFunctors}/SimpleImageDijkstraCost.h (77%) rename plugins/{Plugins/BaseImageFilter.cxx => ImageAlgorithms/BaseFilter.cxx} (76%) create mode 100644 plugins/ImageAlgorithms/BaseFilter.h rename plugins/{Plugins/ImageDijkstra.cxx => ImageAlgorithms/Dijkstra.cxx} (62%) create mode 100644 plugins/ImageAlgorithms/Dijkstra.h create mode 100644 plugins/ImageAlgorithms/ImageAlgorithms.i rename plugins/{Plugins/ImageRegionGrow.cxx => ImageAlgorithms/RegionGrow.cxx} (53%) create mode 100644 plugins/ImageAlgorithms/RegionGrow.h rename plugins/{Plugins => ImageAlgorithms}/SkeletonFilter.cxx (89%) rename plugins/{Plugins => ImageAlgorithms}/SkeletonFilter.h (50%) delete mode 100644 plugins/Plugins/BaseImageFilter.h delete mode 100644 plugins/Plugins/ExtractPathFromMinimumSpanningTree.h delete mode 100644 plugins/Plugins/ImageDijkstra.h delete mode 100644 plugins/Plugins/ImageRegionGrow.h delete mode 100644 plugins/Plugins/RegionGrowBinaryThreshold.cxx delete mode 100644 plugins/Plugins/RegionGrowBinaryThreshold.h delete mode 100644 plugins/Plugins/RegionGrowBinaryThresholdWithSeeds.h delete mode 100644 plugins/Plugins/SimpleImageNeighborhood.cxx delete mode 100644 plugins/Plugins/SimpleImageNeighborhood.h delete mode 100644 plugins/Plugins/fpaPlugins.i rename plugins/{Plugins/RegionGrowBinaryThresholdWithSeeds.cxx => RegionGrowFunctors/BinaryThreshold.cxx} (55%) create mode 100644 plugins/RegionGrowFunctors/BinaryThreshold.h create mode 100644 plugins/RegionGrowFunctors/RegionGrowFunctors.i diff --git a/CMakeLists.txt b/CMakeLists.txt index 3cdfd45..a5fba66 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,9 +35,16 @@ SET(prj_SHORT_VERSION "${prj_MAJOR_VERSION}") ## == Functions, packages and options == ## ===================================== -OPTION(USE_cpPlugins "Build cpPlugins-based code" OFF) +FIND_PACKAGE(cpPlugins QUIET) +IF(cpPlugins_DIR) + OPTION(USE_cpPlugins "Build cpPlugins-based code" ON) +ELSE(cpPlugins_DIR) + OPTION(USE_cpPlugins "Build cpPlugins-based code" OFF) + MARK_AS_ADVANCED(FORCE cpPlugins_DIR) +ENDIF(cpPlugins_DIR) IF(USE_cpPlugins) - FIND_PACKAGE(cpPlugins REQUIRED) + FIND_PACKAGE(cpPlugins) + MARK_AS_ADVANCED(CLEAR cpPlugins_DIR) ENDIF(USE_cpPlugins) INCLUDE(cmake/Restrictions.cmake) INCLUDE(cmake/KitwareTools.cmake) @@ -48,7 +55,6 @@ INCLUDE(cmake/Functions.cmake) ## == Build different parts == ## =========================== -## SUBDIRS(appli cmake lib plugins) SUBDIRS(lib plugins) ## eof - $RCSfile$ diff --git a/cmake/FrontAlgorithmsConfig.cmake.in b/cmake/FrontAlgorithmsConfig.cmake.in deleted file mode 100644 index 097bce7..0000000 --- a/cmake/FrontAlgorithmsConfig.cmake.in +++ /dev/null @@ -1,60 +0,0 @@ -## ================================ -## == Find cpPlugins-cmake tools == -## ================================ - -## ==================== -## == Find libraries == -## ==================== - -SET( - _all_libs - "@fpa_LIB@" - "@fpa_Instances@" - ) -SET(fpa_Instances "@fpa_Instances@") - -SET(_l_locations) -FOREACH(_l ${_all_libs}) - IF(MSVC) - FIND_LIBRARY( - ${_l}_LIB NAMES ${_l} - HINTS - @PROJECT_BINARY_DIR@/$(ConfigurationName) - @CMAKE_INSTALL_PREFIX@/bin - @CMAKE_INSTALL_PREFIX@/lib - ) - ELSE(MSVC) - FIND_LIBRARY( - ${_l}_LIB NAMES ${_l} - HINTS - @PROJECT_BINARY_DIR@ - @CMAKE_INSTALL_PREFIX@/bin - @CMAKE_INSTALL_PREFIX@/lib - ) - ENDIF(MSVC) - IF(${_l}_LIB) - MARK_AS_ADVANCED(FORCE ${_l}_LIB) - GET_FILENAME_COMPONENT(_dir ${${_l}_LIB} DIRECTORY) - LIST(APPEND _l_locations ${_dir}) - ENDIF(${_l}_LIB) -ENDFOREACH(_l) -IF(_l_locations) - LIST(REMOVE_DUPLICATES _l_locations) - LINK_DIRECTORIES(${_l_locations}) -ENDIF(_l_locations) - -## ========================= -## == Include directories == -## ========================= - -## TODO: this is not completely correct!!! -INCLUDE_DIRECTORIES( - @CMAKE_INSTALL_PREFIX@/include - @CMAKE_INSTALL_PREFIX@/include/fpa/Instances - @PROJECT_SOURCE_DIR@/lib - @PROJECT_BINARY_DIR@/lib - @PROJECT_SOURCE_DIR@/lib/Instances - @PROJECT_BINARY_DIR@/lib/Instances - ) - -## eof - $RCSfile$ diff --git a/cmake/Options.cmake b/cmake/Options.cmake deleted file mode 100644 index 0d477c0..0000000 --- a/cmake/Options.cmake +++ /dev/null @@ -1,6 +0,0 @@ -## =============================== -## == Some configurable options == -## =============================== - - -## eof - $RCSfile$ diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 20f87ed..8f3b1ff 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -1,8 +1,3 @@ -## ====================================== -## == Build a library from a directory == -## ====================================== - -CompileLibFromDir(fpa SHARED fpa) ## =================================== ## == Build instances for cpPlugins == diff --git a/lib/fpa/Config.cxx b/lib/fpa/Config.cxx deleted file mode 100644 index d881ac9..0000000 --- a/lib/fpa/Config.cxx +++ /dev/null @@ -1 +0,0 @@ -// eof - $RCSfile$ diff --git a/lib/fpa/Config.h.in b/lib/fpa/Config.h similarity index 59% rename from lib/fpa/Config.h.in rename to lib/fpa/Config.h index 1050a24..c59b1be 100644 --- a/lib/fpa/Config.h.in +++ b/lib/fpa/Config.h @@ -1,19 +1,6 @@ #ifndef __fpa__Config__h__ #define __fpa__Config__h__ -#include - -/* - * ========================================================================= - * Version numbers and strings - * ========================================================================= - */ -#define fpa_MAJOR_VERSION @prj_MAJ_VER@ -#define fpa_MINOR_VERSION @prj_MIN_VER@ -#define fpa_RELEASE_VERSION @prj_REL_VER@ -#define fpa_VERSION "@prj_VERSION@" -#define fpa_SHORT_VERSION "@prj_SHORT_VERSION@" - /* * ========================================================================= * Language related macros diff --git a/lib/fpaInstances/CMakeLists.txt b/lib/fpaInstances/CMakeLists.txt index 106b22e..e20f919 100644 --- a/lib/fpaInstances/CMakeLists.txt +++ b/lib/fpaInstances/CMakeLists.txt @@ -2,31 +2,22 @@ ## == Compile each instance == ## =========================== -SET( - _definitions - DataObjects - Filters +INCLUDE_DIRECTORIES( + ${PROJECT_SOURCE_DIR}/lib + ${PROJECT_BINARY_DIR}/lib ) +SET(_pfx fpaInstaces) -SET(_all_libs) -FOREACH(_d ${_definitions}) - FILE(GLOB _files ${CMAKE_CURRENT_SOURCE_DIR}/${_d}.*) - CreateLib(fpaInstances${_d} SHARED ${_files}) - TARGET_LINK_LIBRARIES( - fpaInstances${_d} - ${ITK_LIBRARIES} ${VTK_LIBRARIES} - ${cpPlugins_AllInstances} - ) - LIST(APPEND _all_libs fpaInstances${_d}) -ENDFOREACH(_d) +CreateLib(${_pfx}DataObjects SHARED ${CMAKE_CURRENT_SOURCE_DIR}/DataObjects.i) +CreateLib(${_pfx}Filters SHARED ${CMAKE_CURRENT_SOURCE_DIR}/Filters.i) -TARGET_LINK_LIBRARIES( - fpaInstancesFilters - fpaInstancesDataObjects - ) +TARGET_LINK_LIBRARIES(${_pfx}DataObjects ${cpPlugins_AllInstances}) +TARGET_LINK_LIBRARIES(${_pfx}Filters ${_pfx}DataObjects) SET( - fpa_AllInstances ${_all_libs} + fpa_AllInstances + ${_pfx}DataObjects + ${_pfx}Filters CACHE INTERNAL "All valid instances." FORCE ) diff --git a/lib/fpaInstances/DataObjects.i b/lib/fpaInstances/DataObjects.i index 79f449d..cf7f883 100644 --- a/lib/fpaInstances/DataObjects.i +++ b/lib/fpaInstances/DataObjects.i @@ -5,9 +5,13 @@ tinclude fpa/Image/Functors/SimpleDijkstraCost:h|hxx tinclude fpa/Image/MinimumSpanningTree:h|hxx tinclude fpa/Base/MinimumSpanningTree:h|hxx -instances fpa::Image::Functors::SimpleNeighborhood< itk::ImageBase< #process_dims# > > -instances fpa::Image::Functors::SimpleDijkstraCost< itk::Image< #scalar_pixels#, #process_dims# >, #reals# > -instances fpa::Base::MinimumSpanningTree< itk::Index< #process_dims# >, cpExtensions::DataStructures::PolyLineParametricPath< #process_dims# >, itk::Image< itk::Offset< #process_dims# >, #process_dims# > > -instances fpa::Image::MinimumSpanningTree< #process_dims# > +cinclude set +tinclude itkSimpleDataObjectDecorator:h|hxx +instances itk::SimpleDataObjectDecorator< std::set< itk::Index< #pdims# >, itk::Functor::IndexLexicographicCompare< #pdims# > > > + +instances fpa::Image::Functors::SimpleNeighborhood< itk::ImageBase< #pdims# > > +instances fpa::Image::Functors::SimpleDijkstraCost< itk::Image< #scalar_types#, #pdims# >, #real_types# > +instances fpa::Base::MinimumSpanningTree< itk::Index< #pdims# >, cpExtensions::DataStructures::PolyLineParametricPath< #pdims# >, itk::Image< itk::Offset< #pdims# >, #pdims# > > +instances fpa::Image::MinimumSpanningTree< #pdims# > ** eof - $RCSfile$ diff --git a/lib/fpaInstances/Filters.i b/lib/fpaInstances/Filters.i index e019334..60502a2 100644 --- a/lib/fpaInstances/Filters.i +++ b/lib/fpaInstances/Filters.i @@ -1,12 +1,12 @@ header #define ITK_MANUAL_INSTANTIATION -define i_pixels=#scalar_pixels# -define o_pixels=#scalar_pixels# +define i_scalars=#scalar_types# +define o_scalars=#scalar_types# tinclude fpa/Base/Algorithm:h|hxx tinclude fpa/Image/Algorithm:h|hxx -instances fpa::Base::Algorithm< itk::ImageToImageFilter< itk::Image< #i_pixels#, #process_dims# >, itk::Image< #o_pixels#, #process_dims# > >, itk::Index< #process_dims# >, #o_pixels# > -instances fpa::Image::Algorithm< itk::Image< #i_pixels#, #process_dims# >, itk::Image< #o_pixels#, #process_dims# > > +instances fpa::Base::Algorithm< itk::ImageToImageFilter< itk::Image< #i_scalars#, #pdims# >, itk::Image< #o_scalars#, #pdims# > >, itk::Index< #pdims# >, #o_scalars# > +instances fpa::Image::Algorithm< itk::Image< #i_scalars#, #pdims# >, itk::Image< #o_scalars#, #pdims# > > ** eof - $RCSfile$ diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index 7fcc8fc..8a67217 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -6,14 +6,28 @@ IF(USE_cpPlugins) INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR}/lib ${PROJECT_BINARY_DIR}/lib + ${PROJECT_SOURCE_DIR}/plugins + ${PROJECT_BINARY_DIR}/plugins ) - CreatePlugin(fpaPlugins Plugins) - TARGET_LINK_LIBRARIES( - fpaPlugins - cpPlugins - ${cpPlugins_AllInstances} - ${fpa_AllInstances} + + SET( + _dirs + ImageAlgorithms + RegionGrowFunctors + DijkstraFunctors ) + FOREACH(_d ${_dirs}) + CreatePlugin( + fpaPlugins${_d} ${CMAKE_CURRENT_SOURCE_DIR}/${_d} + ) + TARGET_LINK_LIBRARIES( + fpaPlugins${_d} + cpPlugins cpPluginsDataObjects + ${fpa_AllInstances} + ) + ENDFOREACH(_d) + TARGET_LINK_LIBRARIES(fpaPluginsImageAlgorithms fpaPluginsDijkstraFunctors) + ENDIF(USE_cpPlugins) ## eof - $RCSfile$ \ No newline at end of file diff --git a/plugins/DijkstraFunctors/DijkstraFunctors.i b/plugins/DijkstraFunctors/DijkstraFunctors.i new file mode 100644 index 0000000..b251418 --- /dev/null +++ b/plugins/DijkstraFunctors/DijkstraFunctors.i @@ -0,0 +1,12 @@ +header #define ITK_MANUAL_INSTANTIATION + +define i_reals=#real_types# +define o_reals=#real_types# +tinclude fpa/Base/Functors/Inverse:h|hxx +tinclude fpa/Base/Functors/GaussianModel:h|hxx + +instances fpa::Base::Functors::Inverse< #i_reals#, #o_reals# > +instances fpa::Base::Functors::GaussianModel< #i_reals#, #o_reals# > + + +** eof - $RCSfile$ diff --git a/plugins/Plugins/ExtractPathFromMinimumSpanningTree.cxx b/plugins/DijkstraFunctors/ExtractPathFromMinimumSpanningTree.cxx similarity index 87% rename from plugins/Plugins/ExtractPathFromMinimumSpanningTree.cxx rename to plugins/DijkstraFunctors/ExtractPathFromMinimumSpanningTree.cxx index 80d4111..e41c264 100644 --- a/plugins/Plugins/ExtractPathFromMinimumSpanningTree.cxx +++ b/plugins/DijkstraFunctors/ExtractPathFromMinimumSpanningTree.cxx @@ -1,11 +1,11 @@ -#include +#include #include #include #include #include // ------------------------------------------------------------------------- -fpaPlugins::ExtractPathFromMinimumSpanningTree:: +fpaPluginsDijkstraFunctors::ExtractPathFromMinimumSpanningTree:: ExtractPathFromMinimumSpanningTree( ) : Superclass( ) { @@ -19,13 +19,13 @@ ExtractPathFromMinimumSpanningTree( ) } // ------------------------------------------------------------------------- -fpaPlugins::ExtractPathFromMinimumSpanningTree:: +fpaPluginsDijkstraFunctors::ExtractPathFromMinimumSpanningTree:: ~ExtractPathFromMinimumSpanningTree( ) { } // ------------------------------------------------------------------------- -void fpaPlugins::ExtractPathFromMinimumSpanningTree:: +void fpaPluginsDijkstraFunctors::ExtractPathFromMinimumSpanningTree:: _GenerateData( ) { typedef fpa::Image::MinimumSpanningTree< 2 > _TMST2; @@ -40,7 +40,7 @@ _GenerateData( ) // ------------------------------------------------------------------------- template< class _TMST > -void fpaPlugins::ExtractPathFromMinimumSpanningTree:: +void fpaPluginsDijkstraFunctors::ExtractPathFromMinimumSpanningTree:: _GD0( _TMST* mst ) { typedef typename _TMST::IndexType _TIndex; diff --git a/plugins/DijkstraFunctors/ExtractPathFromMinimumSpanningTree.h b/plugins/DijkstraFunctors/ExtractPathFromMinimumSpanningTree.h new file mode 100644 index 0000000..4e4b386 --- /dev/null +++ b/plugins/DijkstraFunctors/ExtractPathFromMinimumSpanningTree.h @@ -0,0 +1,29 @@ +#ifndef __fpaPluginsDijkstraFunctors__ExtractPathFromMinimumSpanningTree__h__ +#define __fpaPluginsDijkstraFunctors__ExtractPathFromMinimumSpanningTree__h__ + +#include +#include + +namespace fpaPluginsDijkstraFunctors +{ + /** + */ + class fpaPluginsDijkstraFunctors_EXPORT ExtractPathFromMinimumSpanningTree + : public cpPlugins::BaseObjects::ProcessObject + { + cpPluginsObject( + ExtractPathFromMinimumSpanningTree, + cpPlugins::BaseObjects::ProcessObject, + fpaDijkstraFunctors + ); + + protected: + template< class _TMST > + inline void _GD0( _TMST* mst ); + }; + +} // ecapseman + +#endif // __fpaPluginsDijkstraFunctors__ExtractPathFromMinimumSpanningTree__h__ + +// eof - $RCSfile$ diff --git a/plugins/Plugins/GaussianModelCost.cxx b/plugins/DijkstraFunctors/GaussianModelCost.cxx similarity index 84% rename from plugins/Plugins/GaussianModelCost.cxx rename to plugins/DijkstraFunctors/GaussianModelCost.cxx index c84f5e7..8d796ee 100644 --- a/plugins/Plugins/GaussianModelCost.cxx +++ b/plugins/DijkstraFunctors/GaussianModelCost.cxx @@ -1,10 +1,10 @@ -#include +#include #include #include // ------------------------------------------------------------------------- -fpaPlugins::GaussianModelCost:: +fpaPluginsDijkstraFunctors::GaussianModelCost:: GaussianModelCost( ) : Superclass( ) { @@ -19,13 +19,13 @@ GaussianModelCost( ) } // ------------------------------------------------------------------------- -fpaPlugins::GaussianModelCost:: +fpaPluginsDijkstraFunctors::GaussianModelCost:: ~GaussianModelCost( ) { } // ------------------------------------------------------------------------- -void fpaPlugins::GaussianModelCost:: +void fpaPluginsDijkstraFunctors::GaussianModelCost:: _GenerateData( ) { auto rtype = this->m_Parameters.GetSelectedChoice( "ResultType" ); @@ -35,7 +35,7 @@ _GenerateData( ) // ------------------------------------------------------------------------- template< class _TOutput > -void fpaPlugins::GaussianModelCost:: +void fpaPluginsDijkstraFunctors::GaussianModelCost:: _GD0( ) { typedef fpa::Base::Functors::GaussianModel< _TOutput, _TOutput > _TFunctor; diff --git a/plugins/Plugins/GaussianModelCost.h b/plugins/DijkstraFunctors/GaussianModelCost.h similarity index 73% rename from plugins/Plugins/GaussianModelCost.h rename to plugins/DijkstraFunctors/GaussianModelCost.h index b4d2763..cab177d 100644 --- a/plugins/Plugins/GaussianModelCost.h +++ b/plugins/DijkstraFunctors/GaussianModelCost.h @@ -1,20 +1,20 @@ #ifndef __fpa__Plugins__GaussianModelCost__h__ #define __fpa__Plugins__GaussianModelCost__h__ -#include +#include #include -namespace fpaPlugins +namespace fpaPluginsDijkstraFunctors { /** */ - class fpaPlugins_EXPORT GaussianModelCost + class fpaPluginsDijkstraFunctors_EXPORT GaussianModelCost : public cpPlugins::BaseObjects::ProcessObject { cpPluginsObject( GaussianModelCost, cpPlugins::BaseObjects::ProcessObject, - fpaFunctors + fpaDijkstraFunctors ); protected: diff --git a/plugins/Plugins/InvertCost.cxx b/plugins/DijkstraFunctors/InvertCost.cxx similarity index 87% rename from plugins/Plugins/InvertCost.cxx rename to plugins/DijkstraFunctors/InvertCost.cxx index 4abfe33..be8e8f9 100644 --- a/plugins/Plugins/InvertCost.cxx +++ b/plugins/DijkstraFunctors/InvertCost.cxx @@ -1,10 +1,10 @@ -#include +#include #include #include // ------------------------------------------------------------------------- -fpaPlugins::InvertCost:: +fpaPluginsDijkstraFunctors::InvertCost:: InvertCost( ) : Superclass( ) { @@ -20,13 +20,13 @@ InvertCost( ) } // ------------------------------------------------------------------------- -fpaPlugins::InvertCost:: +fpaPluginsDijkstraFunctors::InvertCost:: ~InvertCost( ) { } // ------------------------------------------------------------------------- -void fpaPlugins::InvertCost:: +void fpaPluginsDijkstraFunctors::InvertCost:: _GenerateData( ) { auto rtype = this->m_Parameters.GetSelectedChoice( "ResultType" ); @@ -36,7 +36,7 @@ _GenerateData( ) // ------------------------------------------------------------------------- template< class _TOutput > -void fpaPlugins::InvertCost:: +void fpaPluginsDijkstraFunctors::InvertCost:: _GD0( ) { typedef fpa::Base::Functors::Inverse< _TOutput, _TOutput > _TFunctor; diff --git a/plugins/Plugins/InvertCost.h b/plugins/DijkstraFunctors/InvertCost.h similarity index 73% rename from plugins/Plugins/InvertCost.h rename to plugins/DijkstraFunctors/InvertCost.h index 2a3a738..7788d78 100644 --- a/plugins/Plugins/InvertCost.h +++ b/plugins/DijkstraFunctors/InvertCost.h @@ -1,20 +1,20 @@ #ifndef __fpa__Plugins__InvertCost__h__ #define __fpa__Plugins__InvertCost__h__ -#include +#include #include -namespace fpaPlugins +namespace fpaPluginsDijkstraFunctors { /** */ - class fpaPlugins_EXPORT InvertCost + class fpaPluginsDijkstraFunctors_EXPORT InvertCost : public cpPlugins::BaseObjects::ProcessObject { cpPluginsObject( InvertCost, cpPlugins::BaseObjects::ProcessObject, - fpaFunctors + fpaDijkstraFunctors ); protected: diff --git a/plugins/Plugins/SimpleImageDijkstraCost.cxx b/plugins/DijkstraFunctors/SimpleImageDijkstraCost.cxx similarity index 85% rename from plugins/Plugins/SimpleImageDijkstraCost.cxx rename to plugins/DijkstraFunctors/SimpleImageDijkstraCost.cxx index dbd3f7e..e825a16 100644 --- a/plugins/Plugins/SimpleImageDijkstraCost.cxx +++ b/plugins/DijkstraFunctors/SimpleImageDijkstraCost.cxx @@ -1,12 +1,11 @@ -#include +#include #include -#include #include #include // ------------------------------------------------------------------------- -fpaPlugins::SimpleImageDijkstraCost:: +fpaPluginsDijkstraFunctors::SimpleImageDijkstraCost:: SimpleImageDijkstraCost( ) : Superclass( ) { @@ -25,13 +24,13 @@ SimpleImageDijkstraCost( ) } // ------------------------------------------------------------------------- -fpaPlugins::SimpleImageDijkstraCost:: +fpaPluginsDijkstraFunctors::SimpleImageDijkstraCost:: ~SimpleImageDijkstraCost( ) { } // ------------------------------------------------------------------------- -void fpaPlugins::SimpleImageDijkstraCost:: +void fpaPluginsDijkstraFunctors::SimpleImageDijkstraCost:: _GenerateData( ) { auto o = this->GetInputData( "Input" ); @@ -41,7 +40,7 @@ _GenerateData( ) // ------------------------------------------------------------------------- template< class _TImage > -void fpaPlugins::SimpleImageDijkstraCost:: +void fpaPluginsDijkstraFunctors::SimpleImageDijkstraCost:: _GD0( _TImage* image ) { auto rtype = this->m_Parameters.GetSelectedChoice( "ResultType" ); @@ -51,7 +50,7 @@ _GD0( _TImage* image ) // ------------------------------------------------------------------------- template< class _TImage, class _TOutput > -void fpaPlugins::SimpleImageDijkstraCost:: +void fpaPluginsDijkstraFunctors::SimpleImageDijkstraCost:: _GD1( _TImage* image ) { typedef diff --git a/plugins/Plugins/SimpleImageDijkstraCost.h b/plugins/DijkstraFunctors/SimpleImageDijkstraCost.h similarity index 77% rename from plugins/Plugins/SimpleImageDijkstraCost.h rename to plugins/DijkstraFunctors/SimpleImageDijkstraCost.h index f5d5968..64fa18c 100644 --- a/plugins/Plugins/SimpleImageDijkstraCost.h +++ b/plugins/DijkstraFunctors/SimpleImageDijkstraCost.h @@ -1,20 +1,20 @@ #ifndef __fpa__Plugins__SimpleImageDijkstraCost__h__ #define __fpa__Plugins__SimpleImageDijkstraCost__h__ -#include +#include #include -namespace fpaPlugins +namespace fpaPluginsDijkstraFunctors { /** */ - class fpaPlugins_EXPORT SimpleImageDijkstraCost + class fpaPluginsDijkstraFunctors_EXPORT SimpleImageDijkstraCost : public cpPlugins::BaseObjects::ProcessObject { cpPluginsObject( SimpleImageDijkstraCost, cpPlugins::BaseObjects::ProcessObject, - fpaFunctors + fpaDijkstraFunctors ); protected: diff --git a/plugins/Plugins/BaseImageFilter.cxx b/plugins/ImageAlgorithms/BaseFilter.cxx similarity index 76% rename from plugins/Plugins/BaseImageFilter.cxx rename to plugins/ImageAlgorithms/BaseFilter.cxx index 0059246..da278a7 100644 --- a/plugins/Plugins/BaseImageFilter.cxx +++ b/plugins/ImageAlgorithms/BaseFilter.cxx @@ -1,9 +1,9 @@ -#include +#include #include // ------------------------------------------------------------------------- -fpaPlugins::BaseImageFilter:: -BaseImageFilter( ) +fpaPluginsImageAlgorithms::BaseFilter:: +BaseFilter( ) : Superclass( ) { typedef cpPlugins::BaseObjects::DataObject _TData; @@ -14,13 +14,14 @@ BaseImageFilter( ) this->_ConfigureInput< _TData >( "Neighborhood", false, false ); this->_ConfigureOutput< _TImage >( "Output" ); + this->m_Parameters.ConfigureAsUint( "NeighborhoodOrder", 1 ); this->m_Parameters.ConfigureAsBool( "VisualDebug", false ); this->m_Parameters.ConfigureAsBool( "StopAtOneFront", false ); } // ------------------------------------------------------------------------- -fpaPlugins::BaseImageFilter:: -~BaseImageFilter( ) +fpaPluginsImageAlgorithms::BaseFilter:: +~BaseFilter( ) { } diff --git a/plugins/ImageAlgorithms/BaseFilter.h b/plugins/ImageAlgorithms/BaseFilter.h new file mode 100644 index 0000000..11c97ca --- /dev/null +++ b/plugins/ImageAlgorithms/BaseFilter.h @@ -0,0 +1,103 @@ +#ifndef __fpaPluginsImageAlgorithms__BaseFilter__h__ +#define __fpaPluginsImageAlgorithms__BaseFilter__h__ + +#include +#include +#include +#include + +namespace fpaPluginsImageAlgorithms +{ + /** + */ + class fpaPluginsImageAlgorithms_EXPORT BaseFilter + : public cpPlugins::BaseObjects::ProcessObject + { + public: + typedef BaseFilter Self; + typedef cpPlugins::BaseObjects::ProcessObject Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; + + public: + itkTypeMacro( BaseFilter, cpPlugins::BaseObjects::ProcessObject ); + cpPlugins_Id_Macro( BaseFilter, fpaImageAlgorithm ); + + protected: + BaseFilter( ); + virtual ~BaseFilter( ); + + template< class _TFilter, class _TImage > + inline void _ConfigureFilter( _TFilter* filter, _TImage* image ); + + /* TODO + + template< class _TFilter > + inline void _ExecuteFilter( _TFilter* filter ); + + template< class _TFilter > + inline void _ConfigureDebugger( _TFilter* filter ); + + template< class _TFilter > + inline void _DeconfigureDebugger( _TFilter* filter ); + */ + + private: + // Purposely not implemented. + BaseFilter( const Self& other ); + Self& operator=( const Self& other ); + }; + +} // ecapseman + +// ------------------------------------------------------------------------- + template< class _TFilter, class _TImage > +void fpaPluginsImageAlgorithms::BaseFilter:: +_ConfigureFilter( _TFilter* filter, _TImage* image ) +{ + typedef typename _TFilter::TNeighborhoodFunction _TNeighborhood; + typedef fpa::Image::Functors::SimpleNeighborhood< _TImage > _TSimpleNeigh; + + // Simple configuration + filter->SetInput( image ); + filter->SetStopAtOneFront( this->m_Parameters.GetBool( "StopAtOneFront" ) ); + + // Neighborhood function + auto neig = this->GetInputData< _TNeighborhood >( "Neighborhood" ); + if( neig == NULL ) + { + typename _TSimpleNeigh::Pointer sfunc = _TSimpleNeigh::New( ); + sfunc->SetOrder( this->m_Parameters.GetUint( "NeighborhoodOrder" ) ); + filter->SetNeighborhoodFunction( sfunc ); + } + else + filter->SetNeighborhoodFunction( neig ); + + // Assign seeds + auto seeds = this->GetInputData< vtkPolyData >( "Seeds" ); + if( seeds != NULL ) + { + typename _TImage::PointType pnt; + typename _TImage::IndexType idx; + unsigned int dim = + ( _TImage::ImageDimension < 3 )? _TImage::ImageDimension: 3; + + for( int i = 0; i < seeds->GetNumberOfPoints( ); ++i ) + { + double buf[ 3 ]; + seeds->GetPoint( i, buf ); + pnt.Fill( 0 ); + for( unsigned int d = 0; d < dim; ++d ) + pnt[ d ] = buf[ d ]; + + if( image->TransformPhysicalPointToIndex( pnt, idx ) ) + filter->AddSeed( idx, 0 ); + + } // rof + + } // fi +} + +#endif // __fpaPluginsImageAlgorithms__BaseFilter__h__ + +// eof - $RCSfile$ diff --git a/plugins/Plugins/ImageDijkstra.cxx b/plugins/ImageAlgorithms/Dijkstra.cxx similarity index 62% rename from plugins/Plugins/ImageDijkstra.cxx rename to plugins/ImageAlgorithms/Dijkstra.cxx index 7c8212e..56be8f1 100644 --- a/plugins/Plugins/ImageDijkstra.cxx +++ b/plugins/ImageAlgorithms/Dijkstra.cxx @@ -1,17 +1,15 @@ -#include +#include #include -#include #include -#include // ------------------------------------------------------------------------- -fpaPlugins::ImageDijkstra:: -ImageDijkstra( ) +fpaPluginsImageAlgorithms::Dijkstra:: +Dijkstra( ) : Superclass( ) { typedef cpPlugins::BaseObjects::DataObject _TData; - typedef cpInstances::Image _TMST; + typedef cpInstances::Image _TMST; this->_ConfigureInput< _TData >( "Cost", false, false ); this->_ConfigureInput< _TData >( "CostConversion", false, false ); @@ -25,13 +23,13 @@ ImageDijkstra( ) } // ------------------------------------------------------------------------- -fpaPlugins::ImageDijkstra:: -~ImageDijkstra( ) +fpaPluginsImageAlgorithms::Dijkstra:: +~Dijkstra( ) { } // ------------------------------------------------------------------------- -void fpaPlugins::ImageDijkstra:: +void fpaPluginsImageAlgorithms::Dijkstra:: _GenerateData( ) { auto o = this->GetInputData( "Input" ); @@ -41,7 +39,7 @@ _GenerateData( ) // ------------------------------------------------------------------------- template< class _TImage > -void fpaPlugins::ImageDijkstra:: +void fpaPluginsImageAlgorithms::Dijkstra:: _GD0( _TImage* image ) { typedef itk::Image< float, _TImage::ImageDimension > _TFloat; @@ -54,55 +52,21 @@ _GD0( _TImage* image ) // ------------------------------------------------------------------------- template< class _TInputImage, class _TOutputImage > -void fpaPlugins::ImageDijkstra:: +void fpaPluginsImageAlgorithms::Dijkstra:: _GD1( _TInputImage* image ) { typedef fpa::Image::Dijkstra< _TInputImage, _TOutputImage > _TFilter; typedef typename _TFilter::TCostConversionFunction _TCostConversion; typedef typename _TFilter::TCostFunction _TCost; - typedef typename _TFilter::TNeighborhoodFunction _TNeighborhood; - // Get functors - auto neig = this->GetInputData< _TNeighborhood >( "Neighborhood" ); + auto filter = this->_CreateITK< _TFilter >( ); + this->_ConfigureFilter( filter, image ); auto cost = this->GetInputData< _TCost >( "Cost" ); auto conv = this->GetInputData< _TCostConversion >( "CostConversion" ); - - // Configure filter - auto filter = this->_CreateITK< _TFilter >( ); - filter->SetInput( image ); - if( neig != NULL ) - filter->SetNeighborhoodFunction( neig ); if( cost != NULL ) filter->SetCostFunction( cost ); if( conv != NULL ) filter->SetCostConversionFunction( conv ); - filter->SetStopAtOneFront( this->m_Parameters.GetBool( "StopAtOneFront" ) ); - - // Assign seeds - auto seeds = this->GetInputData< vtkPolyData >( "Seeds" ); - if( seeds != NULL ) - { - typename _TInputImage::PointType pnt; - typename _TInputImage::IndexType idx; - unsigned int dim = - ( _TInputImage::ImageDimension < 3 )? _TInputImage::ImageDimension: 3; - - for( int i = 0; i < seeds->GetNumberOfPoints( ); ++i ) - { - double buf[ 3 ]; - seeds->GetPoint( i, buf ); - pnt.Fill( 0 ); - for( unsigned int d = 0; d < dim; ++d ) - pnt[ d ] = buf[ d ]; - - if( image->TransformPhysicalPointToIndex( pnt, idx ) ) - filter->AddSeed( idx, 0 ); - - } // rof - - } // fi - - // Assign outputs filter->Update( ); this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) ); this->GetOutput( "MST" )->SetITK( filter->GetMinimumSpanningTree( ) ); diff --git a/plugins/ImageAlgorithms/Dijkstra.h b/plugins/ImageAlgorithms/Dijkstra.h new file mode 100644 index 0000000..5ac2233 --- /dev/null +++ b/plugins/ImageAlgorithms/Dijkstra.h @@ -0,0 +1,27 @@ +#ifndef __fpaPluginsImageAlgorithms__Dijkstra__h__ +#define __fpaPluginsImageAlgorithms__Dijkstra__h__ + +#include + +namespace fpaPluginsImageAlgorithms +{ + /** + */ + class fpaPluginsImageAlgorithms_EXPORT Dijkstra + : public BaseFilter + { + cpPluginsObject( Dijkstra, BaseFilter, fpaImageAlgorithms ); + + protected: + template< class _TImage > + inline void _GD0( _TImage* image ); + + template< class _TInputImage, class _TOutputPixel > + inline void _GD1( _TInputImage* image ); + }; + +} // ecapseman + +#endif // __fpaPluginsImageAlgorithms__Dijkstra__h__ + +// eof - $RCSfile$ diff --git a/plugins/ImageAlgorithms/ImageAlgorithms.i b/plugins/ImageAlgorithms/ImageAlgorithms.i new file mode 100644 index 0000000..9655ca3 --- /dev/null +++ b/plugins/ImageAlgorithms/ImageAlgorithms.i @@ -0,0 +1,46 @@ +header #define ITK_MANUAL_INSTANTIATION + +tinclude fpa/Image/Functors/SimpleNeighborhood:h|hxx +instances fpa::Image::Functors::SimpleNeighborhood< itk::Image< #scalar_types#, #pdims# > > + +cinclude fpa/Base/RegionGrow.hxx +define all_int_types=#int_types#;#uint_types# +tinclude fpa/Image/RegionGrow:h|hxx +instances fpa::Image::RegionGrow< itk::Image< #scalar_types#, #pdims# >, itk::Image< #all_int_types#, #pdims# > > + +cinclude fpa/Base/Dijkstra.hxx +tinclude fpa/Image/Dijkstra:h|hxx +instances fpa::Image::Dijkstra< itk::Image< #scalar_types#, #pdims# >, itk::Image< #real_types#, #pdims# > > + +tinclude fpa/Image/SkeletonFilter:h|hxx +instances fpa::Image::SkeletonFilter< itk::Image< #real_types#, #pdims# > > + + + +*define i_real=#real_types# +*define o_real=#real_types# + +*tinclude fpa/Image/Functors/SimpleDijkstraCost:h|hxx +*tinclude fpa/Base/Functors/Inverse:h|hxx +*tinclude fpa/Base/Functors/GaussianModel:h|hxx +*tinclude fpa/Image/Dijkstra:h|hxx +*tinclude fpa/Image/SkeletonFilter:h|hxx +*tinclude fpa/Image/Functors/RegionGrowBinaryThreshold:h|hxx + +*cinclude itkImage.h +*cinclude itkSimpleDataObjectDecorator.hxx +*cinclude fpa/Base/Dijkstra.hxx + +*instances fpa::Image::Functors::SimpleNeighborhood< itk::Image< #scalar_pixels#, #process_dims# > > +*instances fpa::Image::Functors::SimpleDijkstraCost< itk::Image< #scalar_pixels#, #process_dims# >, #real_types# > +*instances fpa::Image::Functors::RegionGrowBinaryThreshold< itk::Image< #scalar_pixels#, #process_dims# > > + +*instances fpa::Base::Functors::Inverse< #i_real#, #o_real# > +*instances fpa::Base::Functors::GaussianModel< #i_real#, #o_real# > + +*instances fpa::Image::Dijkstra< itk::Image< #scalar_pixels#, #process_dims# >, itk::Image< #real_types#, #process_dims# > > +*instances fpa::Image::RegionGrow< itk::Image< #scalar_pixels#, #process_dims# >, itk::Image< #int_types#, #process_dims# > > +*instances fpa::Image::RegionGrow< itk::Image< #scalar_pixels#, #process_dims# >, itk::Image< #uint_types#, #process_dims# > > +*instances fpa::Image::SkeletonFilter< itk::Image< #real_types#, #process_dims# > > + +** eof - $RCSfile$ diff --git a/plugins/Plugins/ImageRegionGrow.cxx b/plugins/ImageAlgorithms/RegionGrow.cxx similarity index 53% rename from plugins/Plugins/ImageRegionGrow.cxx rename to plugins/ImageAlgorithms/RegionGrow.cxx index 5056212..f620b71 100644 --- a/plugins/Plugins/ImageRegionGrow.cxx +++ b/plugins/ImageAlgorithms/RegionGrow.cxx @@ -1,33 +1,29 @@ -#include +#include #include -#include #include -#include // ------------------------------------------------------------------------- -fpaPlugins::ImageRegionGrow:: -ImageRegionGrow( ) +fpaPluginsImageAlgorithms::RegionGrow:: +RegionGrow( ) : Superclass( ) { typedef cpPlugins::BaseObjects::DataObject _TData; - typedef cpInstances::Image _TMST; this->_ConfigureInput< _TData >( "GrowFunction", true, false ); - this->m_Parameters.ConfigureAsInt( "InsideValue", 1 ); this->m_Parameters.ConfigureAsInt( "OutsideValue", 0 ); this->m_Parameters.ConfigureAsIntTypesChoices( "ResultType" ); } // ------------------------------------------------------------------------- -fpaPlugins::ImageRegionGrow:: -~ImageRegionGrow( ) +fpaPluginsImageAlgorithms::RegionGrow:: +~RegionGrow( ) { } // ------------------------------------------------------------------------- -void fpaPlugins::ImageRegionGrow:: +void fpaPluginsImageAlgorithms::RegionGrow:: _GenerateData( ) { auto o = this->GetInputData( "Input" ); @@ -37,79 +33,36 @@ _GenerateData( ) // ------------------------------------------------------------------------- template< class _TImage > -void fpaPlugins::ImageRegionGrow:: +void fpaPluginsImageAlgorithms::RegionGrow:: _GD0( _TImage* image ) { auto rtype = this->m_Parameters.GetSelectedChoice( "ResultType" ); -#ifdef cpPlugins_CONFIG_INTEGER_TYPES_char if( rtype == "char" ) this->_GD1< _TImage, char >( image ); if( rtype == "uchar" ) this->_GD1< _TImage, unsigned char >( image ); -#endif // cpPlugins_CONFIG_INTEGER_TYPES_char -#ifdef cpPlugins_CONFIG_INTEGER_TYPES_short if( rtype == "short" ) this->_GD1< _TImage, short >( image ); if( rtype == "ushort" ) this->_GD1< _TImage, unsigned short >( image ); -#endif // cpPlugins_CONFIG_INTEGER_TYPES_short -#ifdef cpPlugins_CONFIG_INTEGER_TYPES_int if( rtype == "int" ) this->_GD1< _TImage, int >( image ); if( rtype == "uint" ) this->_GD1< _TImage, unsigned int >( image ); -#endif // cpPlugins_CONFIG_INTEGER_TYPES_int -#ifdef cpPlugins_CONFIG_INTEGER_TYPES_long if( rtype == "long" ) this->_GD1< _TImage, long >( image ); if( rtype == "ulong" ) this->_GD1< _TImage, unsigned long >( image ); -#endif // cpPlugins_CONFIG_INTEGER_TYPES_long } // ------------------------------------------------------------------------- template< class _TInputImage, class _TOutputPixel > -void fpaPlugins::ImageRegionGrow:: +void fpaPluginsImageAlgorithms::RegionGrow:: _GD1( _TInputImage* image ) { - std::cout << "--------------> again <-----------------" << std::endl; - typedef itk::Image< _TOutputPixel, _TInputImage::ImageDimension > _TOutputImage; typedef fpa::Image::RegionGrow< _TInputImage, _TOutputImage > _TFilter; - typedef typename _TFilter::TGrowFunction _TGrow; - typedef typename _TFilter::TNeighborhoodFunction _TNeighborhood; - - // Get functors - auto neig = this->GetInputData< _TNeighborhood >( "Neighborhood" ); - auto grow = this->GetInputData< _TGrow >( "GrowFunction" ); + typedef typename _TFilter::TGrowFunction _TGrow; - // Configure filter auto filter = this->_CreateITK< _TFilter >( ); - filter->SetInput( image ); - filter->SetGrowFunction( grow ); + 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->SetStopAtOneFront( this->m_Parameters.GetBool( "StopAtOneFront" ) ); - - // Assign seeds - auto seeds = this->GetInputData< vtkPolyData >( "Seeds" ); - if( seeds != NULL ) - { - typename _TInputImage::PointType pnt; - typename _TInputImage::IndexType idx; - unsigned int dim = - ( _TInputImage::ImageDimension < 3 )? _TInputImage::ImageDimension: 3; - - for( int i = 0; i < seeds->GetNumberOfPoints( ); ++i ) - { - double buf[ 3 ]; - seeds->GetPoint( i, buf ); - pnt.Fill( 0 ); - for( unsigned int d = 0; d < dim; ++d ) - pnt[ d ] = buf[ d ]; - - if( image->TransformPhysicalPointToIndex( pnt, idx ) ) - filter->AddSeed( idx, 0 ); - - } // rof - - } // fi - - // Assign outputs filter->Update( ); this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) ); } diff --git a/plugins/ImageAlgorithms/RegionGrow.h b/plugins/ImageAlgorithms/RegionGrow.h new file mode 100644 index 0000000..f5b49af --- /dev/null +++ b/plugins/ImageAlgorithms/RegionGrow.h @@ -0,0 +1,27 @@ +#ifndef __fpaPluginsImageAlgorithms__RegionGrow__h__ +#define __fpaPluginsImageAlgorithms__RegionGrow__h__ + +#include + +namespace fpaPluginsImageAlgorithms +{ + /** + */ + class fpaPluginsImageAlgorithms_EXPORT RegionGrow + : public BaseFilter + { + cpPluginsObject( RegionGrow, BaseFilter, fpaImageAlgorithms ); + + protected: + template< class _TImage > + inline void _GD0( _TImage* image ); + + template< class _TInputImage, class _TOutputPixel > + inline void _GD1( _TInputImage* image ); + }; + +} // ecapseman + +#endif // __fpaPluginsImageAlgorithms__RegionGrow__h__ + +// eof - $RCSfile$ diff --git a/plugins/Plugins/SkeletonFilter.cxx b/plugins/ImageAlgorithms/SkeletonFilter.cxx similarity index 89% rename from plugins/Plugins/SkeletonFilter.cxx rename to plugins/ImageAlgorithms/SkeletonFilter.cxx index 6e9102a..d4d46c1 100644 --- a/plugins/Plugins/SkeletonFilter.cxx +++ b/plugins/ImageAlgorithms/SkeletonFilter.cxx @@ -1,6 +1,5 @@ -#include +#include #include -#include #include #include @@ -8,7 +7,7 @@ #include // ------------------------------------------------------------------------- -fpaPlugins::SkeletonFilter:: +fpaPluginsImageAlgorithms::SkeletonFilter:: SkeletonFilter( ) : Superclass( ) { @@ -23,13 +22,13 @@ SkeletonFilter( ) } // ------------------------------------------------------------------------- -fpaPlugins::SkeletonFilter:: +fpaPluginsImageAlgorithms::SkeletonFilter:: ~SkeletonFilter( ) { } // ------------------------------------------------------------------------- -void fpaPlugins::SkeletonFilter:: +void fpaPluginsImageAlgorithms::SkeletonFilter:: _GenerateData( ) { auto o = this->GetInputData( "Input" ); @@ -39,7 +38,7 @@ _GenerateData( ) // ------------------------------------------------------------------------- template< class _TImage > -void fpaPlugins::SkeletonFilter:: +void fpaPluginsImageAlgorithms::SkeletonFilter:: _GD0( _TImage* image ) { typedef fpa::Image::SkeletonFilter< _TImage > _TFilter; diff --git a/plugins/Plugins/SkeletonFilter.h b/plugins/ImageAlgorithms/SkeletonFilter.h similarity index 50% rename from plugins/Plugins/SkeletonFilter.h rename to plugins/ImageAlgorithms/SkeletonFilter.h index ee940c7..356b61c 100644 --- a/plugins/Plugins/SkeletonFilter.h +++ b/plugins/ImageAlgorithms/SkeletonFilter.h @@ -1,20 +1,20 @@ -#ifndef __fpa__Plugins__SkeletonFilter__h__ -#define __fpa__Plugins__SkeletonFilter__h__ +#ifndef __fpaPluginsImageAlgorithms__SkeletonFilter__h__ +#define __fpaPluginsImageAlgorithms__SkeletonFilter__h__ -#include +#include #include -namespace fpaPlugins +namespace fpaPluginsImageAlgorithms { /** */ - class fpaPlugins_EXPORT SkeletonFilter + class fpaPluginsImageAlgorithms_EXPORT SkeletonFilter : public cpPlugins::BaseObjects::ProcessObject { cpPluginsObject( SkeletonFilter, cpPlugins::BaseObjects::ProcessObject, - fpa + fpaImageAlgorithms ); protected: @@ -24,6 +24,6 @@ namespace fpaPlugins } // ecapseman -#endif // __fpa__Plugins__SkeletonFilter__h__ +#endif // __fpaPluginsImageAlgorithms__SkeletonFilter__h__ // eof - $RCSfile$ diff --git a/plugins/Plugins/BaseImageFilter.h b/plugins/Plugins/BaseImageFilter.h deleted file mode 100644 index 8afadd6..0000000 --- a/plugins/Plugins/BaseImageFilter.h +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef __fpa__Plugins__BaseImageFilter__h__ -#define __fpa__Plugins__BaseImageFilter__h__ - -#include -#include - -namespace fpaPlugins -{ - /** - */ - class fpaPlugins_EXPORT BaseImageFilter - : public cpPlugins::BaseObjects::ProcessObject - { - public: - typedef BaseImageFilter Self; - typedef cpPlugins::BaseObjects::ProcessObject Superclass; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; - - public: - itkTypeMacro( BaseImageFilter, cpPlugins::BaseObjects::ProcessObject ); - cpPlugins_Id_Macro( BaseImageFilter, fpaImageAlgorithm ); - - protected: - BaseImageFilter( ); - virtual ~BaseImageFilter( ); - - /* TODO - template< class _TFilter > - inline _TFilter* _ConfigureFilter( ); - - template< class _TFilter > - inline void _ExecuteFilter( _TFilter* filter ); - - template< class _TFilter > - inline void _ConfigureDebugger( _TFilter* filter ); - - template< class _TFilter > - inline void _DeconfigureDebugger( _TFilter* filter ); - */ - - private: - // Purposely not implemented. - BaseImageFilter( const Self& other ); - Self& operator=( const Self& other ); - }; - -} // ecapseman - -#endif // __fpa__Plugins__BaseImageFilter__h__ - -// eof - $RCSfile$ diff --git a/plugins/Plugins/ExtractPathFromMinimumSpanningTree.h b/plugins/Plugins/ExtractPathFromMinimumSpanningTree.h deleted file mode 100644 index 6a46fa9..0000000 --- a/plugins/Plugins/ExtractPathFromMinimumSpanningTree.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef __fpa__Plugins__ExtractPathFromMinimumSpanningTree__h__ -#define __fpa__Plugins__ExtractPathFromMinimumSpanningTree__h__ - -#include -#include - -namespace fpaPlugins -{ - /** - */ - class fpaPlugins_EXPORT ExtractPathFromMinimumSpanningTree - : public cpPlugins::BaseObjects::ProcessObject - { - cpPluginsObject( - ExtractPathFromMinimumSpanningTree, - cpPlugins::BaseObjects::ProcessObject, - fpa - ); - - protected: - template< class _TMST > - inline void _GD0( _TMST* mst ); - }; - -} // ecapseman - -#endif // __fpa__Plugins__ExtractPathFromMinimumSpanningTree__h__ - -// eof - $RCSfile$ diff --git a/plugins/Plugins/ImageDijkstra.h b/plugins/Plugins/ImageDijkstra.h deleted file mode 100644 index a76df17..0000000 --- a/plugins/Plugins/ImageDijkstra.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef __fpa__Plugins__ImageDijkstra__h__ -#define __fpa__Plugins__ImageDijkstra__h__ - -#include - -namespace fpaPlugins -{ - /** - */ - class fpaPlugins_EXPORT ImageDijkstra - : public BaseImageFilter - { - cpPluginsObject( ImageDijkstra, BaseImageFilter, fpa ); - - protected: - template< class _TImage > - inline void _GD0( _TImage* image ); - - template< class _TInputImage, class _TOutputImage > - inline void _GD1( _TInputImage* image ); - }; - -} // ecapseman - -#endif // __fpa__Plugins__ImageDijkstra__h__ - -// eof - $RCSfile$ diff --git a/plugins/Plugins/ImageRegionGrow.h b/plugins/Plugins/ImageRegionGrow.h deleted file mode 100644 index d2a9661..0000000 --- a/plugins/Plugins/ImageRegionGrow.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef __fpa__Plugins__ImageRegionGrow__h__ -#define __fpa__Plugins__ImageRegionGrow__h__ - -#include - -namespace fpaPlugins -{ - /** - */ - class fpaPlugins_EXPORT ImageRegionGrow - : public BaseImageFilter - { - cpPluginsObject( ImageRegionGrow, BaseImageFilter, fpa ); - - protected: - template< class _TImage > - inline void _GD0( _TImage* image ); - - template< class _TInputImage, class _TOutputPixel > - inline void _GD1( _TInputImage* image ); - }; - -} // ecapseman - -#endif // __fpa__Plugins__ImageRegionGrow__h__ - -// eof - $RCSfile$ diff --git a/plugins/Plugins/RegionGrowBinaryThreshold.cxx b/plugins/Plugins/RegionGrowBinaryThreshold.cxx deleted file mode 100644 index 20d5e78..0000000 --- a/plugins/Plugins/RegionGrowBinaryThreshold.cxx +++ /dev/null @@ -1,59 +0,0 @@ -#include -#include -#include - -#include -#include - -// ------------------------------------------------------------------------- -fpaPlugins::RegionGrowBinaryThreshold:: -RegionGrowBinaryThreshold( ) - : Superclass( ) -{ - typedef cpPlugins::BaseObjects::DataObject _TData; - typedef cpInstances::Image _TImage; - - this->_ConfigureInput< _TImage >( "Input", true, false ); - this->_ConfigureOutput< _TData >( "Output" ); - - this->m_Parameters.ConfigureAsReal( "LowerThreshold", 0 ); - this->m_Parameters.ConfigureAsReal( "UpperThreshold", 0 ); -} - -// ------------------------------------------------------------------------- -fpaPlugins::RegionGrowBinaryThreshold:: -~RegionGrowBinaryThreshold( ) -{ -} - -// ------------------------------------------------------------------------- -void fpaPlugins::RegionGrowBinaryThreshold:: -_GenerateData( ) -{ - auto o = this->GetInputData( "Input" ); - cpPlugins_Demangle_Image_ScalarPixels_AllDims_1( o, _GD0 ) - this->_Error( "Invalid input image." ); -} - -// ------------------------------------------------------------------------- -template< class _TImage > -void fpaPlugins::RegionGrowBinaryThreshold:: -_GD0( _TImage* image ) -{ - typedef - fpa::Image::Functors::RegionGrowBinaryThreshold< _TImage > - _TFunctor; - auto out = this->GetOutput( "Output" ); - auto f = out->GetITK< _TFunctor >( ); - if( f == NULL ) - { - typename _TFunctor::Pointer ptr_f = _TFunctor::New( ); - f = ptr_f.GetPointer( ); - out->SetITK( f ); - - } // fi - f->SetLowerThreshold( this->m_Parameters.GetReal( "LowerThreshold" ) ); - f->SetUpperThreshold( this->m_Parameters.GetReal( "UpperThreshold" ) ); -} - -// eof - $RCSfile$ diff --git a/plugins/Plugins/RegionGrowBinaryThreshold.h b/plugins/Plugins/RegionGrowBinaryThreshold.h deleted file mode 100644 index 17c19e0..0000000 --- a/plugins/Plugins/RegionGrowBinaryThreshold.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef __fpa__Plugins__RegionGrowBinaryThreshold__h__ -#define __fpa__Plugins__RegionGrowBinaryThreshold__h__ - -#include -#include - -namespace fpaPlugins -{ - /** - */ - class fpaPlugins_EXPORT RegionGrowBinaryThreshold - : public cpPlugins::BaseObjects::ProcessObject - { - cpPluginsObject( - RegionGrowBinaryThreshold, - cpPlugins::BaseObjects::ProcessObject, - fpaFunctors - ); - - protected: - template< class _TImage > - inline void _GD0( _TImage* image ); - }; - -} // ecapseman - -#endif // __fpa__Plugins__RegionGrowBinaryThreshold__h__ - -// eof - $RCSfile$ diff --git a/plugins/Plugins/RegionGrowBinaryThresholdWithSeeds.h b/plugins/Plugins/RegionGrowBinaryThresholdWithSeeds.h deleted file mode 100644 index cb8ebe9..0000000 --- a/plugins/Plugins/RegionGrowBinaryThresholdWithSeeds.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef __fpa__Plugins__RegionGrowBinaryThresholdWithSeeds__h__ -#define __fpa__Plugins__RegionGrowBinaryThresholdWithSeeds__h__ - -#include -#include - -namespace fpaPlugins -{ - /** - */ - class fpaPlugins_EXPORT RegionGrowBinaryThresholdWithSeeds - : public cpPlugins::BaseObjects::ProcessObject - { - cpPluginsObject( - RegionGrowBinaryThresholdWithSeeds, - cpPlugins::BaseObjects::ProcessObject, - fpaFunctors - ); - - protected: - template< class _TImage > - inline void _GD0( _TImage* image ); - }; - -} // ecapseman - -#endif // __fpa__Plugins__RegionGrowBinaryThresholdWithSeeds__h__ - -// eof - $RCSfile$ diff --git a/plugins/Plugins/SimpleImageNeighborhood.cxx b/plugins/Plugins/SimpleImageNeighborhood.cxx deleted file mode 100644 index 3d3e943..0000000 --- a/plugins/Plugins/SimpleImageNeighborhood.cxx +++ /dev/null @@ -1,55 +0,0 @@ -#include -#include -#include - -#include -#include - -// ------------------------------------------------------------------------- -fpaPlugins::SimpleImageNeighborhood:: -SimpleImageNeighborhood( ) - : Superclass( ) -{ - typedef cpPlugins::BaseObjects::DataObject _TData; - typedef cpInstances::Image _TImage; - - this->_ConfigureInput< _TImage >( "Input", true, false ); - this->_ConfigureOutput< _TData >( "Output" ); - - this->m_Parameters.ConfigureAsUint( "Order", 1 ); -} - -// ------------------------------------------------------------------------- -fpaPlugins::SimpleImageNeighborhood:: -~SimpleImageNeighborhood( ) -{ -} - -// ------------------------------------------------------------------------- -void fpaPlugins::SimpleImageNeighborhood:: -_GenerateData( ) -{ - auto o = this->GetInputData( "Input" ); - cpPlugins_Demangle_Image_ScalarPixels_AllDims_1( o, _GD0 ) - this->_Error( "Invalid input image." ); -} - -// ------------------------------------------------------------------------- -template< class _TImage > -void fpaPlugins::SimpleImageNeighborhood:: -_GD0( _TImage* image ) -{ - typedef fpa::Image::Functors::SimpleNeighborhood< _TImage > _TFunctor; - auto out = this->GetOutput( "Output" ); - auto f = out->GetITK< _TFunctor >( ); - if( f == NULL ) - { - typename _TFunctor::Pointer ptr_f = _TFunctor::New( ); - f = ptr_f.GetPointer( ); - out->SetITK( f ); - - } // fi - f->SetOrder( this->m_Parameters.GetUint( "Order" ) ); -} - -// eof - $RCSfile$ diff --git a/plugins/Plugins/SimpleImageNeighborhood.h b/plugins/Plugins/SimpleImageNeighborhood.h deleted file mode 100644 index 6c0ac92..0000000 --- a/plugins/Plugins/SimpleImageNeighborhood.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef __fpa__Plugins__SimpleImageNeighborhood__h__ -#define __fpa__Plugins__SimpleImageNeighborhood__h__ - -#include -#include - -namespace fpaPlugins -{ - /** - */ - class fpaPlugins_EXPORT SimpleImageNeighborhood - : public cpPlugins::BaseObjects::ProcessObject - { - cpPluginsObject( - SimpleImageNeighborhood, - cpPlugins::BaseObjects::ProcessObject, - fpaFunctors - ); - - protected: - template< class _TImage > - inline void _GD0( _TImage* image ); - }; - -} // ecapseman - -#endif // __fpa__Plugins__SimpleImageNeighborhood__h__ - -// eof - $RCSfile$ diff --git a/plugins/Plugins/fpaPlugins.i b/plugins/Plugins/fpaPlugins.i deleted file mode 100644 index 34a013a..0000000 --- a/plugins/Plugins/fpaPlugins.i +++ /dev/null @@ -1,32 +0,0 @@ -header #define ITK_MANUAL_INSTANTIATION - -define i_real=#real_types# -define o_real=#real_types# - -tinclude fpa/Image/Functors/SimpleNeighborhood:h|hxx -tinclude fpa/Image/Functors/SimpleDijkstraCost:h|hxx -tinclude fpa/Base/Functors/Inverse:h|hxx -tinclude fpa/Base/Functors/GaussianModel:h|hxx -tinclude fpa/Image/RegionGrow:h|hxx -tinclude fpa/Image/Dijkstra:h|hxx -tinclude fpa/Image/SkeletonFilter:h|hxx -tinclude fpa/Image/Functors/RegionGrowBinaryThreshold:h|hxx - -cinclude itkImage.h -cinclude itkSimpleDataObjectDecorator.hxx -cinclude fpa/Base/RegionGrow.hxx -cinclude fpa/Base/Dijkstra.hxx - -instances fpa::Image::Functors::SimpleNeighborhood< itk::Image< #scalar_pixels#, #process_dims# > > -instances fpa::Image::Functors::SimpleDijkstraCost< itk::Image< #scalar_pixels#, #process_dims# >, #real_types# > -instances fpa::Image::Functors::RegionGrowBinaryThreshold< itk::Image< #scalar_pixels#, #process_dims# > > - -instances fpa::Base::Functors::Inverse< #i_real#, #o_real# > -instances fpa::Base::Functors::GaussianModel< #i_real#, #o_real# > - -instances fpa::Image::Dijkstra< itk::Image< #scalar_pixels#, #process_dims# >, itk::Image< #real_types#, #process_dims# > > -instances fpa::Image::RegionGrow< itk::Image< #scalar_pixels#, #process_dims# >, itk::Image< #int_types#, #process_dims# > > -instances fpa::Image::RegionGrow< itk::Image< #scalar_pixels#, #process_dims# >, itk::Image< #uint_types#, #process_dims# > > -instances fpa::Image::SkeletonFilter< itk::Image< #real_types#, #process_dims# > > - -** eof - $RCSfile$ diff --git a/plugins/Plugins/RegionGrowBinaryThresholdWithSeeds.cxx b/plugins/RegionGrowFunctors/BinaryThreshold.cxx similarity index 55% rename from plugins/Plugins/RegionGrowBinaryThresholdWithSeeds.cxx rename to plugins/RegionGrowFunctors/BinaryThreshold.cxx index e799ae2..05010ab 100644 --- a/plugins/Plugins/RegionGrowBinaryThresholdWithSeeds.cxx +++ b/plugins/RegionGrowFunctors/BinaryThreshold.cxx @@ -1,34 +1,35 @@ -#include +#include #include -#include #include #include #include // ------------------------------------------------------------------------- -fpaPlugins::RegionGrowBinaryThresholdWithSeeds:: -RegionGrowBinaryThresholdWithSeeds( ) +fpaPluginsRegionGrowFunctors::BinaryThreshold:: +BinaryThreshold( ) : Superclass( ) { typedef cpPlugins::BaseObjects::DataObject _TData; typedef cpInstances::Image _TImage; this->_ConfigureInput< _TImage >( "Input", true, false ); - this->_ConfigureInput< _TData >( "Seeds", true, false ); + this->_ConfigureInput< _TData >( "Seeds", false, false ); this->_ConfigureOutput< _TData >( "Output" ); this->m_Parameters.ConfigureAsUint( "Radius", 1 ); + this->m_Parameters.ConfigureAsReal( "LowerThreshold", 0 ); + this->m_Parameters.ConfigureAsReal( "UpperThreshold", 0 ); } // ------------------------------------------------------------------------- -fpaPlugins::RegionGrowBinaryThresholdWithSeeds:: -~RegionGrowBinaryThresholdWithSeeds( ) +fpaPluginsRegionGrowFunctors::BinaryThreshold:: +~BinaryThreshold( ) { } // ------------------------------------------------------------------------- -void fpaPlugins::RegionGrowBinaryThresholdWithSeeds:: +void fpaPluginsRegionGrowFunctors::BinaryThreshold:: _GenerateData( ) { auto o = this->GetInputData( "Input" ); @@ -38,7 +39,7 @@ _GenerateData( ) // ------------------------------------------------------------------------- template< class _TImage > -void fpaPlugins::RegionGrowBinaryThresholdWithSeeds:: +void fpaPluginsRegionGrowFunctors::BinaryThreshold:: _GD0( _TImage* image ) { typedef itk::ConstNeighborhoodIterator< _TImage > _TInIt; @@ -57,9 +58,9 @@ _GD0( _TImage* image ) // Compute thresholds from seeds auto seeds = this->GetInputData< vtkPolyData >( "Seeds" ); - std::vector< typename _TImage::IndexType > indices; if( seeds != NULL ) { + std::vector< typename _TImage::IndexType > indices; typename _TImage::PointType pnt; typename _TImage::IndexType idx; unsigned int dim = @@ -77,36 +78,40 @@ _GD0( _TImage* image ) } // rof - } // fi - - typename _TImage::SizeType r; - r.Fill( this->m_Parameters.GetUint( "Radius" ) ); - _TInIt iIt( r, image, image->GetRequestedRegion( ) ); - double v_s1 = double( 0 ); - double v_s2 = double( 0 ); - double v_n = double( 0 ); - double v_min = std::numeric_limits< double >::max( ); - double v_max = -v_min; - for( auto idxIt = indices.begin( ); idxIt != indices.end( ); ++idxIt ) - { - iIt.SetLocation( *idxIt ); - for( unsigned int i = 0; i < iIt.Size( ); ++i ) + typename _TImage::SizeType r; + r.Fill( this->m_Parameters.GetUint( "Radius" ) ); + _TInIt iIt( r, image, image->GetRequestedRegion( ) ); + double v_s1 = double( 0 ); + double v_s2 = double( 0 ); + double v_n = double( 0 ); + double v_min = std::numeric_limits< double >::max( ); + double v_max = -v_min; + for( auto idxIt = indices.begin( ); idxIt != indices.end( ); ++idxIt ) { - double v = double( iIt.GetPixel( i ) ); - v_s1 += v; - v_s2 += v * v; - v_n += double( 1 ); - v_min = ( v < v_min )? v: v_min; - v_max = ( v_max < v )? v: v_max; + iIt.SetLocation( *idxIt ); + for( unsigned int i = 0; i < iIt.Size( ); ++i ) + { + double v = double( iIt.GetPixel( i ) ); + v_s1 += v; + v_s2 += v * v; + v_n += double( 1 ); + v_min = ( v < v_min )? v: v_min; + v_max = ( v_max < v )? v: v_max; + + } // rof } // rof + double s = ( v_s2 - ( ( v_s1 * v_s1 ) / v_n ) ) / ( v_n - double( 1 ) ); + s = std::sqrt( s ) / double( 2 ); + f->SetLowerThreshold( v_min ); + f->SetUpperThreshold( v_max ); + } + else + { + f->SetLowerThreshold( this->m_Parameters.GetReal( "LowerThreshold" ) ); + f->SetUpperThreshold( this->m_Parameters.GetReal( "UpperThreshold" ) ); - } // rof - double s = ( v_s2 - ( ( v_s1 * v_s1 ) / v_n ) ) / ( v_n - double( 1 ) ); - s = std::sqrt( s ) / double( 2 ); - - f->SetLowerThreshold( v_min ); - f->SetUpperThreshold( v_max ); + } // fi } // eof - $RCSfile$ diff --git a/plugins/RegionGrowFunctors/BinaryThreshold.h b/plugins/RegionGrowFunctors/BinaryThreshold.h new file mode 100644 index 0000000..30f9a0e --- /dev/null +++ b/plugins/RegionGrowFunctors/BinaryThreshold.h @@ -0,0 +1,29 @@ +#ifndef __fpaPluginsRegionGrowFunctors__BinaryThreshold__h__ +#define __fpaPluginsRegionGrowFunctors__BinaryThreshold__h__ + +#include +#include + +namespace fpaPluginsRegionGrowFunctors +{ + /** + */ + class fpaPluginsRegionGrowFunctors_EXPORT BinaryThreshold + : public cpPlugins::BaseObjects::ProcessObject + { + cpPluginsObject( + BinaryThreshold, + cpPlugins::BaseObjects::ProcessObject, + fpaRegionGrowFunctors + ); + + protected: + template< class _TImage > + inline void _GD0( _TImage* image ); + }; + +} // ecapseman + +#endif // __fpaPluginsRegionGrowFunctors__BinaryThreshold__h__ + +// eof - $RCSfile$ diff --git a/plugins/RegionGrowFunctors/RegionGrowFunctors.i b/plugins/RegionGrowFunctors/RegionGrowFunctors.i new file mode 100644 index 0000000..c310a00 --- /dev/null +++ b/plugins/RegionGrowFunctors/RegionGrowFunctors.i @@ -0,0 +1,7 @@ +header #define ITK_MANUAL_INSTANTIATION + +cinclude itkImage.h +tinclude fpa/Image/Functors/RegionGrowBinaryThreshold:h|hxx +instances fpa::Image::Functors::RegionGrowBinaryThreshold< itk::Image< #scalar_types#, #pdims# > > + +** eof - $RCSfile$ -- 2.47.1