From 9c4035dc18f4e44a92cda3e3c1c6e583c94ef06b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Leonardo=20Fl=C3=B3rez-Valencia?= Date: Mon, 12 Sep 2016 10:15:51 -0500 Subject: [PATCH] ... --- CMakeLists.txt | 54 - COMPILATION | 31 - README | 21 - appli/CMakeLists.txt | 8 - appli/TempAirwaysAppli/CMakeLists.txt | 20 - appli/TempAirwaysAppli/TempAirwaysAppli.cxx | 1065 -------- appli/examples/CMakeLists.txt | 35 - appli/examples/example_BinaryDistanceMap.cxx | 80 - appli/examples/example_CircleOfWillis.cxx | 141 -- appli/examples/example_HausdorffDistance.cxx | 59 - .../example_ImageAlgorithmDijkstra_00.cxx | 44 - .../example_ImageAlgorithmDijkstra_01.cxx | 202 -- .../example_ImageAlgorithmDijkstra_02.cxx | 205 -- .../example_ImageAlgorithmDijkstra_03.cxx | 304 --- .../example_ImageAlgorithmFastMarching_00.cxx | 44 - .../example_ImageAlgorithmFastMarching_01.cxx | 152 -- .../example_ImageAlgorithmRegionGrow_00.cxx | 51 - .../example_ImageAlgorithmRegionGrow_01.cxx | 157 -- ...AlgorithmRegionGrow_MultipleThresholds.cxx | 168 -- ...example_ImageAlgorithm_Skeletonization.cxx | 257 -- ..._Image_Dijkstra_AbsoluteDifferenceCost.cxx | 164 -- .../example_Image_Dijkstra_CostFromInput.cxx | 177 -- ...xample_Image_Dijkstra_CostFromRGBInput.cxx | 178 -- .../example_Image_Dijkstra_DanielssonCost.cxx | 204 -- ...e_Dijkstra_DanielssonCost_TwoSeedsPath.cxx | 253 -- ...ample_Image_Dijkstra_EndPointDetection.cxx | 331 --- ..._Dijkstra_EndPointDetection_WithoutVTK.cxx | 249 -- .../example_Image_Dijkstra_LabelSkeleton.cxx | 421 --- ...Image_IncrementalRegionGrow_Thresholds.cxx | 235 -- .../example_Image_RegionGrow_AllPixels.cxx | 101 - .../example_Image_RegionGrow_AllRGBPixels.cxx | 103 - ...ample_Image_RegionGrow_ConnectedPixels.cxx | 98 - ...le_Image_RegionGrow_ConnectedRGBPixels.cxx | 100 - ...age_RegionGrow_GaussianModelEstimation.cxx | 173 -- ...ample_IncrementalRegionGrow_Thresholds.cxx | 164 -- appli/examples/example_ShowSkeleton.cxx | 254 -- appli/examples/example_Thinning.cxx | 40 - appli/examples/fpa_Utility.h | 157 -- cmake/CMakeLists.txt | 17 - cmake/FrontAlgorithmsConfig.cmake.in | 37 - cmake/fpa_Policies.cmake | 13 - data/binary_test_2D_00.png | Bin 5192 -> 0 bytes data/ones_image.png | Bin 1697 -> 0 bytes data/workspaces/workspace_airwaysappli.wxml | 73 - doc/UML/fpa.dia | Bin 4287 -> 0 bytes lib/Airways/AirwaysLib/CMakeLists.txt | 43 - lib/Airways/AirwaysLib/airwaysEdge.cxx | 739 ------ lib/Airways/AirwaysLib/airwaysEdge.h | 323 --- lib/Airways/AirwaysLib/airwaysNode.cxx | 1655 ------------ lib/Airways/AirwaysLib/airwaysNode.h | 597 ----- lib/Airways/AirwaysLib/airwaysTree.cxx | 2251 ----------------- lib/Airways/AirwaysLib/airwaysTree.h | 372 --- .../AirwaysLib/airwaysTreeTypeDefinition.h | 132 - lib/Airways/CMakeLists.txt | 6 - lib/Airways/MathLib/CMakeLists.txt | 37 - lib/Airways/MathLib/Quaternion.cpp | 168 -- lib/Airways/MathLib/Quaternion.h | 174 -- lib/Airways/MathLib/vec3.cxx | 233 -- lib/Airways/MathLib/vec3.h | 221 -- lib/Airways/fpa2Airways/Converter.h | 56 - lib/Airways/fpa2Airways/Converter.hxx | 84 - lib/CMakeLists.txt | 12 - lib/fpa/Base/Algorithm.h | 183 -- lib/fpa/Base/Algorithm.hxx | 366 --- lib/fpa/Base/Dijkstra.h | 130 - lib/fpa/Base/Dijkstra.hxx | 145 -- lib/fpa/Base/Events.h | 103 - ...tsAndBifurcationsFromMinimumSpanningTree.h | 93 - ...AndBifurcationsFromMinimumSpanningTree.hxx | 222 -- .../Base/ExtractPathFromMinimumSpanningTree.h | 74 - .../ExtractPathFromMinimumSpanningTree.hxx | 70 - lib/fpa/Base/FastMarching.h | 78 - lib/fpa/Base/FastMarching.hxx | 121 - lib/fpa/Base/Functors/InvertCostFunction.h | 73 - lib/fpa/Base/Functors/TautologyFunction.h | 62 - lib/fpa/Base/ImageSkeleton.h | 70 - lib/fpa/Base/ImageSkeleton.hxx | 84 - lib/fpa/Base/IncrementalRegionGrow.h | 87 - lib/fpa/Base/IncrementalRegionGrow.hxx | 154 -- lib/fpa/Base/MinimumSpanningTree.h | 102 - lib/fpa/Base/MinimumSpanningTree.hxx | 236 -- lib/fpa/Base/RegionGrow.h | 105 - lib/fpa/Base/RegionGrow.hxx | 89 - lib/fpa/Base/RegionGrowWithMultipleCriteria.h | 83 - .../Base/RegionGrowWithMultipleCriteria.hxx | 108 - lib/fpa/Common.cxx.in | 9 - lib/fpa/Common.h | 15 - lib/fpa/IO/MinimumSpanningTreeReader.h | 61 - lib/fpa/IO/MinimumSpanningTreeReader.hxx | 187 -- lib/fpa/IO/MinimumSpanningTreeWriter.h | 63 - lib/fpa/IO/MinimumSpanningTreeWriter.hxx | 183 -- lib/fpa/Image/Algorithm.h | 94 - lib/fpa/Image/Algorithm.hxx | 145 -- lib/fpa/Image/Dijkstra.h | 105 - lib/fpa/Image/Dijkstra.hxx | 68 - lib/fpa/Image/DijkstraWithEndPointDetection.h | 160 -- .../Image/DijkstraWithEndPointDetection.hxx | 561 ---- ...tsAndBifurcationsFromMinimumSpanningTree.h | 93 - ...AndBifurcationsFromMinimumSpanningTree.hxx | 235 -- lib/fpa/Image/FastMarching.h | 58 - lib/fpa/Image/Functors/FluxMedialness.h | 78 - lib/fpa/Image/Functors/FluxMedialness.hxx | 108 - .../Functors/GaussianModelEstimatorFunction.h | 74 - .../GaussianModelEstimatorFunction.hxx | 76 - .../Functors/GradientImageFunctionBase.h | 73 - .../Functors/GradientImageFunctionBase.hxx | 59 - lib/fpa/Image/Functors/GulsunTekMedialness.h | 80 - .../Image/Functors/GulsunTekMedialness.hxx | 114 - .../ImageAbsoluteDifferenceCostFunction.h | 87 - lib/fpa/Image/Functors/ImageCostFunction.h | 90 - lib/fpa/Image/Functors/MFluxMedialness.h | 78 - lib/fpa/Image/Functors/MFluxMedialness.hxx | 159 -- .../Functors/RegionGrowAllBelongsFunction.h | 60 - .../Functors/RegionGrowThresholdFunction.h | 88 - lib/fpa/Image/IncrementalRegionGrow.h | 71 - lib/fpa/Image/IncrementalRegionGrow.hxx | 30 - lib/fpa/Image/MinimumSpanningTree.h | 85 - lib/fpa/Image/MinimumSpanningTree.hxx | 152 -- lib/fpa/Image/RegionGrow.h | 72 - lib/fpa/Image/RegionGrow.hxx | 32 - .../Image/RegionGrowWithMultipleCriteria.h | 65 - .../Image/RegionGrowWithMultipleThresholds.h | 96 - .../RegionGrowWithMultipleThresholds.hxx | 256 -- lib/fpa/VTK/Image/ImageSkeletonToPolyData.h | 67 - lib/fpa/VTK/Image/ImageSkeletonToPolyData.hxx | 176 -- lib/fpa/VTK/Image/Observer2D.h | 88 - lib/fpa/VTK/Image/Observer2D.hxx | 226 -- lib/fpa/VTK/Image/Observer3D.h | 86 - lib/fpa/VTK/Image/Observer3D.hxx | 211 -- lib/fpa_Instances/Backtracking.i | 21 - lib/fpa_Instances/CMakeLists.txt | 24 - lib/fpa_Instances/Filters.i | 43 - lib/fpa_Instances/Functors.i | 31 - lib/fpa_Instances/Instances.i | 51 - lib/fpa_Instances/Observers.i | 24 - plugins/CMakeLists.txt | 7 - plugins/fpa/BaseImageFilter.cxx | 49 - plugins/fpa/BaseImageFilter.h | 68 - plugins/fpa/BaseImageFilter.hxx | 150 -- plugins/fpa/CMakeLists.txt | 59 - ...AndBifurcationsFromMinimumSpanningTree.cxx | 73 - ...tsAndBifurcationsFromMinimumSpanningTree.h | 50 - .../ExtractPathFromMinimumSpanningTree.cxx | 81 - .../fpa/ExtractPathFromMinimumSpanningTree.h | 48 - .../fpa/GradientBaseImageFunctionSource.cxx | 93 - plugins/fpa/GradientBaseImageFunctionSource.h | 51 - plugins/fpa/ImageDijkstra.cxx | 69 - plugins/fpa/ImageDijkstra.h | 43 - plugins/fpa/ImageRegionGrow.cxx | 65 - plugins/fpa/ImageRegionGrow.h | 43 - plugins/fpa/ImageSkeleton.cxx | 75 - plugins/fpa/ImageSkeleton.h | 52 - plugins/fpa/InvertCostFunction.cxx | 61 - plugins/fpa/InvertCostFunction.h | 44 - plugins/fpa/MinimumSpanningTree.cxx | 57 - plugins/fpa/MinimumSpanningTree.h | 47 - plugins/fpa/MinimumSpanningTreeReader.cxx | 70 - plugins/fpa/MinimumSpanningTreeReader.h | 44 - plugins/fpa/MinimumSpanningTreeWriter.cxx | 62 - plugins/fpa/MinimumSpanningTreeWriter.h | 44 - plugins/fpa/RegionGrowThresholdFunction.cxx | 59 - plugins/fpa/RegionGrowThresholdFunction.h | 46 - 162 files changed, 23359 deletions(-) delete mode 100644 CMakeLists.txt delete mode 100644 COMPILATION delete mode 100644 README delete mode 100644 appli/CMakeLists.txt delete mode 100644 appli/TempAirwaysAppli/CMakeLists.txt delete mode 100644 appli/TempAirwaysAppli/TempAirwaysAppli.cxx delete mode 100644 appli/examples/CMakeLists.txt delete mode 100644 appli/examples/example_BinaryDistanceMap.cxx delete mode 100644 appli/examples/example_CircleOfWillis.cxx delete mode 100644 appli/examples/example_HausdorffDistance.cxx delete mode 100644 appli/examples/example_ImageAlgorithmDijkstra_00.cxx delete mode 100644 appli/examples/example_ImageAlgorithmDijkstra_01.cxx delete mode 100644 appli/examples/example_ImageAlgorithmDijkstra_02.cxx delete mode 100644 appli/examples/example_ImageAlgorithmDijkstra_03.cxx delete mode 100644 appli/examples/example_ImageAlgorithmFastMarching_00.cxx delete mode 100644 appli/examples/example_ImageAlgorithmFastMarching_01.cxx delete mode 100644 appli/examples/example_ImageAlgorithmRegionGrow_00.cxx delete mode 100644 appli/examples/example_ImageAlgorithmRegionGrow_01.cxx delete mode 100644 appli/examples/example_ImageAlgorithmRegionGrow_MultipleThresholds.cxx delete mode 100644 appli/examples/example_ImageAlgorithm_Skeletonization.cxx delete mode 100644 appli/examples/example_Image_Dijkstra_AbsoluteDifferenceCost.cxx delete mode 100644 appli/examples/example_Image_Dijkstra_CostFromInput.cxx delete mode 100644 appli/examples/example_Image_Dijkstra_CostFromRGBInput.cxx delete mode 100644 appli/examples/example_Image_Dijkstra_DanielssonCost.cxx delete mode 100644 appli/examples/example_Image_Dijkstra_DanielssonCost_TwoSeedsPath.cxx delete mode 100644 appli/examples/example_Image_Dijkstra_EndPointDetection.cxx delete mode 100644 appli/examples/example_Image_Dijkstra_EndPointDetection_WithoutVTK.cxx delete mode 100644 appli/examples/example_Image_Dijkstra_LabelSkeleton.cxx delete mode 100644 appli/examples/example_Image_IncrementalRegionGrow_Thresholds.cxx delete mode 100644 appli/examples/example_Image_RegionGrow_AllPixels.cxx delete mode 100644 appli/examples/example_Image_RegionGrow_AllRGBPixels.cxx delete mode 100644 appli/examples/example_Image_RegionGrow_ConnectedPixels.cxx delete mode 100644 appli/examples/example_Image_RegionGrow_ConnectedRGBPixels.cxx delete mode 100644 appli/examples/example_Image_RegionGrow_GaussianModelEstimation.cxx delete mode 100644 appli/examples/example_IncrementalRegionGrow_Thresholds.cxx delete mode 100644 appli/examples/example_ShowSkeleton.cxx delete mode 100644 appli/examples/example_Thinning.cxx delete mode 100644 appli/examples/fpa_Utility.h delete mode 100644 cmake/CMakeLists.txt delete mode 100644 cmake/FrontAlgorithmsConfig.cmake.in delete mode 100644 cmake/fpa_Policies.cmake delete mode 100644 data/binary_test_2D_00.png delete mode 100644 data/ones_image.png delete mode 100644 data/workspaces/workspace_airwaysappli.wxml delete mode 100644 doc/UML/fpa.dia delete mode 100644 lib/Airways/AirwaysLib/CMakeLists.txt delete mode 100644 lib/Airways/AirwaysLib/airwaysEdge.cxx delete mode 100644 lib/Airways/AirwaysLib/airwaysEdge.h delete mode 100644 lib/Airways/AirwaysLib/airwaysNode.cxx delete mode 100644 lib/Airways/AirwaysLib/airwaysNode.h delete mode 100644 lib/Airways/AirwaysLib/airwaysTree.cxx delete mode 100644 lib/Airways/AirwaysLib/airwaysTree.h delete mode 100644 lib/Airways/AirwaysLib/airwaysTreeTypeDefinition.h delete mode 100644 lib/Airways/CMakeLists.txt delete mode 100644 lib/Airways/MathLib/CMakeLists.txt delete mode 100644 lib/Airways/MathLib/Quaternion.cpp delete mode 100644 lib/Airways/MathLib/Quaternion.h delete mode 100644 lib/Airways/MathLib/vec3.cxx delete mode 100644 lib/Airways/MathLib/vec3.h delete mode 100644 lib/Airways/fpa2Airways/Converter.h delete mode 100644 lib/Airways/fpa2Airways/Converter.hxx delete mode 100644 lib/CMakeLists.txt delete mode 100644 lib/fpa/Base/Algorithm.h delete mode 100644 lib/fpa/Base/Algorithm.hxx delete mode 100644 lib/fpa/Base/Dijkstra.h delete mode 100644 lib/fpa/Base/Dijkstra.hxx delete mode 100644 lib/fpa/Base/Events.h delete mode 100644 lib/fpa/Base/ExtractEndPointsAndBifurcationsFromMinimumSpanningTree.h delete mode 100644 lib/fpa/Base/ExtractEndPointsAndBifurcationsFromMinimumSpanningTree.hxx delete mode 100644 lib/fpa/Base/ExtractPathFromMinimumSpanningTree.h delete mode 100644 lib/fpa/Base/ExtractPathFromMinimumSpanningTree.hxx delete mode 100644 lib/fpa/Base/FastMarching.h delete mode 100644 lib/fpa/Base/FastMarching.hxx delete mode 100644 lib/fpa/Base/Functors/InvertCostFunction.h delete mode 100644 lib/fpa/Base/Functors/TautologyFunction.h delete mode 100644 lib/fpa/Base/ImageSkeleton.h delete mode 100644 lib/fpa/Base/ImageSkeleton.hxx delete mode 100644 lib/fpa/Base/IncrementalRegionGrow.h delete mode 100644 lib/fpa/Base/IncrementalRegionGrow.hxx delete mode 100644 lib/fpa/Base/MinimumSpanningTree.h delete mode 100644 lib/fpa/Base/MinimumSpanningTree.hxx delete mode 100644 lib/fpa/Base/RegionGrow.h delete mode 100644 lib/fpa/Base/RegionGrow.hxx delete mode 100644 lib/fpa/Base/RegionGrowWithMultipleCriteria.h delete mode 100644 lib/fpa/Base/RegionGrowWithMultipleCriteria.hxx delete mode 100644 lib/fpa/Common.cxx.in delete mode 100644 lib/fpa/Common.h delete mode 100644 lib/fpa/IO/MinimumSpanningTreeReader.h delete mode 100644 lib/fpa/IO/MinimumSpanningTreeReader.hxx delete mode 100644 lib/fpa/IO/MinimumSpanningTreeWriter.h delete mode 100644 lib/fpa/IO/MinimumSpanningTreeWriter.hxx delete mode 100644 lib/fpa/Image/Algorithm.h delete mode 100644 lib/fpa/Image/Algorithm.hxx delete mode 100644 lib/fpa/Image/Dijkstra.h delete mode 100644 lib/fpa/Image/Dijkstra.hxx delete mode 100644 lib/fpa/Image/DijkstraWithEndPointDetection.h delete mode 100644 lib/fpa/Image/DijkstraWithEndPointDetection.hxx delete mode 100644 lib/fpa/Image/ExtractEndPointsAndBifurcationsFromMinimumSpanningTree.h delete mode 100644 lib/fpa/Image/ExtractEndPointsAndBifurcationsFromMinimumSpanningTree.hxx delete mode 100644 lib/fpa/Image/FastMarching.h delete mode 100644 lib/fpa/Image/Functors/FluxMedialness.h delete mode 100644 lib/fpa/Image/Functors/FluxMedialness.hxx delete mode 100644 lib/fpa/Image/Functors/GaussianModelEstimatorFunction.h delete mode 100644 lib/fpa/Image/Functors/GaussianModelEstimatorFunction.hxx delete mode 100644 lib/fpa/Image/Functors/GradientImageFunctionBase.h delete mode 100644 lib/fpa/Image/Functors/GradientImageFunctionBase.hxx delete mode 100644 lib/fpa/Image/Functors/GulsunTekMedialness.h delete mode 100644 lib/fpa/Image/Functors/GulsunTekMedialness.hxx delete mode 100644 lib/fpa/Image/Functors/ImageAbsoluteDifferenceCostFunction.h delete mode 100644 lib/fpa/Image/Functors/ImageCostFunction.h delete mode 100644 lib/fpa/Image/Functors/MFluxMedialness.h delete mode 100644 lib/fpa/Image/Functors/MFluxMedialness.hxx delete mode 100644 lib/fpa/Image/Functors/RegionGrowAllBelongsFunction.h delete mode 100644 lib/fpa/Image/Functors/RegionGrowThresholdFunction.h delete mode 100644 lib/fpa/Image/IncrementalRegionGrow.h delete mode 100644 lib/fpa/Image/IncrementalRegionGrow.hxx delete mode 100644 lib/fpa/Image/MinimumSpanningTree.h delete mode 100644 lib/fpa/Image/MinimumSpanningTree.hxx delete mode 100644 lib/fpa/Image/RegionGrow.h delete mode 100644 lib/fpa/Image/RegionGrow.hxx delete mode 100644 lib/fpa/Image/RegionGrowWithMultipleCriteria.h delete mode 100644 lib/fpa/Image/RegionGrowWithMultipleThresholds.h delete mode 100644 lib/fpa/Image/RegionGrowWithMultipleThresholds.hxx delete mode 100644 lib/fpa/VTK/Image/ImageSkeletonToPolyData.h delete mode 100644 lib/fpa/VTK/Image/ImageSkeletonToPolyData.hxx delete mode 100644 lib/fpa/VTK/Image/Observer2D.h delete mode 100644 lib/fpa/VTK/Image/Observer2D.hxx delete mode 100644 lib/fpa/VTK/Image/Observer3D.h delete mode 100644 lib/fpa/VTK/Image/Observer3D.hxx delete mode 100644 lib/fpa_Instances/Backtracking.i delete mode 100644 lib/fpa_Instances/CMakeLists.txt delete mode 100644 lib/fpa_Instances/Filters.i delete mode 100644 lib/fpa_Instances/Functors.i delete mode 100644 lib/fpa_Instances/Instances.i delete mode 100644 lib/fpa_Instances/Observers.i delete mode 100644 plugins/CMakeLists.txt delete mode 100644 plugins/fpa/BaseImageFilter.cxx delete mode 100644 plugins/fpa/BaseImageFilter.h delete mode 100644 plugins/fpa/BaseImageFilter.hxx delete mode 100644 plugins/fpa/CMakeLists.txt delete mode 100644 plugins/fpa/ExtractEndPointsAndBifurcationsFromMinimumSpanningTree.cxx delete mode 100644 plugins/fpa/ExtractEndPointsAndBifurcationsFromMinimumSpanningTree.h delete mode 100644 plugins/fpa/ExtractPathFromMinimumSpanningTree.cxx delete mode 100644 plugins/fpa/ExtractPathFromMinimumSpanningTree.h delete mode 100644 plugins/fpa/GradientBaseImageFunctionSource.cxx delete mode 100644 plugins/fpa/GradientBaseImageFunctionSource.h delete mode 100644 plugins/fpa/ImageDijkstra.cxx delete mode 100644 plugins/fpa/ImageDijkstra.h delete mode 100644 plugins/fpa/ImageRegionGrow.cxx delete mode 100644 plugins/fpa/ImageRegionGrow.h delete mode 100644 plugins/fpa/ImageSkeleton.cxx delete mode 100644 plugins/fpa/ImageSkeleton.h delete mode 100644 plugins/fpa/InvertCostFunction.cxx delete mode 100644 plugins/fpa/InvertCostFunction.h delete mode 100644 plugins/fpa/MinimumSpanningTree.cxx delete mode 100644 plugins/fpa/MinimumSpanningTree.h delete mode 100644 plugins/fpa/MinimumSpanningTreeReader.cxx delete mode 100644 plugins/fpa/MinimumSpanningTreeReader.h delete mode 100644 plugins/fpa/MinimumSpanningTreeWriter.cxx delete mode 100644 plugins/fpa/MinimumSpanningTreeWriter.h delete mode 100644 plugins/fpa/RegionGrowThresholdFunction.cxx delete mode 100644 plugins/fpa/RegionGrowThresholdFunction.h diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index 30f36c0..0000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,54 +0,0 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.8) -INCLUDE(cmake/fpa_Policies.cmake) - -## ================== -## == Project name == -## ================== - -PROJECT(FrontAlgorithms) -SET(prj_MAJ_VER "0") -SET(prj_MIN_VER "1") -SET(prj_REL_VER "0") -SET(prj_VER "${prj_MAJ_VER}.${prj_MIN_VER}.${prj_REL_VER}") -SET(prj_sVER "${prj_MAJ_VER}") - -## ===================== -## == Main dependency == -## ===================== - -FIND_PACKAGE(cpPlugins REQUIRED) - -## ============= -## == Options == -## ============= - -OPTION(BUILD_PLUGINS "Build plugins" ON) -OPTION(BUILD_TempAirwaysAppli "Build temporary appli" OFF) - -## ========================= -## == Include directories == -## ========================= - -INCLUDE_DIRECTORIES( - ${PROJECT_SOURCE_DIR} - ${PROJECT_BINARY_DIR} - ${PROJECT_SOURCE_DIR}/lib - ${PROJECT_BINARY_DIR}/lib - ${PROJECT_SOURCE_DIR}/lib/fpa_Instances - ${PROJECT_BINARY_DIR}/lib/fpa_Instances - ${PROJECT_SOURCE_DIR}/plugins - ${PROJECT_BINARY_DIR}/plugins - ) - -## ============================= -## == Subdirs containing code == -## ============================= - -SUBDIRS( - cmake - lib - plugins - appli - ) - -## eof - $RCSfile$ diff --git a/COMPILATION b/COMPILATION deleted file mode 100644 index d4f2408..0000000 --- a/COMPILATION +++ /dev/null @@ -1,31 +0,0 @@ -@description - The project uses CMake as compilation helper. It should compile on the three - major box flavors (linux, windows, mac). However, as of december 2014, it - has only been tested on linux Fedora 20 and Ubuntu 14.04. - -@prerequisites - 1. CMake (>=2.8.12.2) - - 3. Insight Toolkit -ITK- (>=4.6.0) - 3.1 Required cmake flags: - BUILD_SHARED_LIBS:BOOL=ON - 3.2 [OPTIONAL] If USE_VTK=ON - Module_ITKVtkGlue:BOOL=ON - - 4. [OPTIONAL] Visualization Toolkit -VTK- (>=6.1.0) - 4.1 Required cmake flags: - BUILD_SHARED_LIBS:BOOL=ON - - 5. [OPTIONAL] cpPlugins (>=0.0.1) - 5.1 Required cmake flags: - BUILD_SHARED_LIBS:BOOL=ON - -@cmake_flags - BUILD_EXAMPLES:BOOL - Build example applications? (most of them are command line) - CMAKE_BUILD_TYPE:STRING - Debug/Release? - CMAKE_INSTALL_PREFIX:STRING - Where to put installation products? (in windows this option has no use) - -## eof - $RCSfile$ diff --git a/README b/README deleted file mode 100644 index 4ebdcfb..0000000 --- a/README +++ /dev/null @@ -1,21 +0,0 @@ - -@project - FrontAlgorithms: Generic implementation of front propagation algorithms - with some extra features - -@version - 0.0.1 (2014-12-31) - -@authors - Maciej ORKISZ (maciej.orkisz@creatis.insa-lyon.fr) - Leonardo FLOREZ-VALENCIA (florez-l@javeriana.edu.co) - - -@description - - -@license - - - -## eof - $RCSfile$ diff --git a/appli/CMakeLists.txt b/appli/CMakeLists.txt deleted file mode 100644 index 0e315a1..0000000 --- a/appli/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ - -IF(BUILD_TempAirwaysAppli) - SUBDIRS( - TempAirwaysAppli - ) -ENDIF(BUILD_TempAirwaysAppli) - -## eof - $RCSfile$ diff --git a/appli/TempAirwaysAppli/CMakeLists.txt b/appli/TempAirwaysAppli/CMakeLists.txt deleted file mode 100644 index b038389..0000000 --- a/appli/TempAirwaysAppli/CMakeLists.txt +++ /dev/null @@ -1,20 +0,0 @@ - -## Find Boost -FIND_PACKAGE(Boost REQUIRED system filesystem program_options) -INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS}) - -INCLUDE_DIRECTORIES( - ${PROJECT_SOURCE_DIR}/lib/Airways/MathLib - ${PROJECT_SOURCE_DIR}/lib/Airways/AirwaysLib - ${PROJECT_BINARY_DIR}/lib/Airways/MathLib - ${PROJECT_BINARY_DIR}/lib/Airways/AirwaysLib - ) -ADD_EXECUTABLE(TempAirwaysAppli TempAirwaysAppli.cxx) -TARGET_LINK_LIBRARIES( - TempAirwaysAppli - ${Boost_LIBRARIES} TempAirwaysAppli_AirwaysLib - cpPlugins - ${fpa_LIBRARIES} - ) - -## eof - $RCSfile$ diff --git a/appli/TempAirwaysAppli/TempAirwaysAppli.cxx b/appli/TempAirwaysAppli/TempAirwaysAppli.cxx deleted file mode 100644 index 2664f78..0000000 --- a/appli/TempAirwaysAppli/TempAirwaysAppli.cxx +++ /dev/null @@ -1,1065 +0,0 @@ -#include -#include -#include - -#include -#include - -#include "vec3.h" -#include "airwaysTree.h" - -#include -#include - -using namespace airways; -namespace po = boost::program_options; - -namespace -{ - const size_t ERROR_IN_COMMAND_LINE = 1; - const size_t SUCCESS = 0; - const size_t ERROR_UNHANDLED_EXCEPTION = 2; -} // namespace - -typedef std::vector< AirwaysTree > AirwaysVector; - -// Auxiliar struct to save info for execution. -typedef void* TImagePointer; -struct TreeInfo{ - - TreeInfo( ) - { - this->myWorkspace = new cpPlugins::Workspace( ); - } - ~TreeInfo( ) - { - /* - if( this->IsMyWorkspace ) - delete this->myWorkspace; - */ - } - - void CastImage( ) - { - try - { - this->myWorkspace->Execute( "cast" ); - } - catch( itk::ExceptionObject& err ) - { - std::cerr << "Error: " << err << std::endl; - std::exit( 1 ); - - } // yrt - this->Image = - this->myWorkspace->GetFilter( "cast" )->GetOutputData( "Output" )-> - GetITK< TInputImage >( ); - } - - TInputImage::Pointer Image; - cpPlugins::Workspace* myWorkspace; - bool IsMyWorkspace; - Vec3 seed; - std::string folderpath_pigResults; - std::string pig_name; - std::string image_name; - -}; -// Constants -unsigned char red[3] = { 255, 0, 0 }; -unsigned char green[3] = { 0, 255, 0 }; -unsigned char blue[3] = { 0, 0, 255 }; -unsigned char yellow[3]= { 255, 255, 0 }; -unsigned char purple[3]= { 255, 0, 255 }; -unsigned char cyan[3]= { 0, 255, 255 }; - -cpPlugins::Interface myPlugins; - -// ------------------------------------------------------------------------- -void Load_cpPlugins( const std::string& plugins ); -void CreateResultDirectory(AirwaysTree tree); -void DrawVTKLinesFromTree(AirwaysTree& tree, const std::string filename, bool common); -AirwaysTree& CreateAirwaysTreeFromSegmentation(Vec3 seed, TInputImage* input_image, cpPlugins::Workspace& ws ); -vector ReadInputFile(const char* filename); -void printCommonTreeBetweenTwoTrees(AirwaysTree tree_A, AirwaysTree tree_B, std::vector< std::pair< std::pair, std::pair > > vector_pair_edges_A_to_B, unsigned int Q, unsigned int F); -void printMatchingResultToFile(AirwaysTree tree_A, AirwaysTree tree_B, std::map< unsigned int, std::vector > map_A_to_B, std::map< unsigned int, std::vector > map_B_to_A, unsigned int Q, unsigned int F); -void createLinesAndPointsForVTK(const Node* node, vtkSmartPointer& pts,vtkSmartPointer& lines, vtkSmartPointer& colors, bool common, bool isRoot); - -// ------------------------------------------------------------------------- -int main( int argc, char* argv[] ) -{ - Load_cpPlugins( "./plugins.cfg" ); - - try - { - // Define and parse the program options - po::options_description desc("Options"); - desc.add_options()("use_file", po::value(), "Adds the filepath containing the file to be used in creaAirwaysTree -- Mandatory") - ("build_trees","Creates trees from a given filepath (arg) and stores it in a .vtk file") - ("subtree_levels", po::value(),"Get a subtree(s) by levels - result: a vtk and reconstructed img .mhd") - ("subtree_length", po::value(),"Get a subtree(s) by length - result: a vtk and reconstructed img .mhd") - ("subtree_diameter", po::value(),"Get a subtree(s) by diameter - result: a vtk and reconstructed img .mhd") - ("compare_trees", "Compare the trees given in the input file or the subtrees using an option - result: a vtk and reconstructed img .mhd"); - //TODO: Fix image segmentation. ("segment_images", "Creates a binary image corresponding to the segmentation of of a given original image (arg) and seed (arg), saves it to a .mhd file and uses it for subsequent operations") - po::variables_map vm; - try - { - std::string fileName; - vector treeInfoVector; - AirwaysVector aVector; - TImagePointer segmentationImage; - Vec3 seed; - po::store(po::parse_command_line(argc, argv, desc), vm); // can throw - if (vm.count("use_file")) - { - fileName = vm["use_file"].as(); - treeInfoVector = ReadInputFile(fileName.c_str()); - } - - if(vm.count("segment_images")) - { - } - - // Build trees option - if (vm.count("build_trees")) - { - for(unsigned int i = 0; i < treeInfoVector.size(); ++ i){ - TreeInfo info = treeInfoVector[i]; - try - { - info.myWorkspace->PrintExecutionOn( ); - info.myWorkspace->Execute( "eb" ); - } - catch( itk::ExceptionObject& err ) - { - std::cerr << "Error: " << err << std::endl; - std::exit( 1 ); - - } // fi - info.CastImage( ); - AirwaysTree tree = CreateAirwaysTreeFromSegmentation( info.seed, info.Image, *(info.myWorkspace )); - tree.SetResultPath(info.folderpath_pigResults); - tree.SetImageName(info.image_name); - aVector.push_back(tree); - } - for (unsigned int i = 0; i < aVector.size(); ++i) - { - CreateResultDirectory(aVector[i]); - std::string fullPath = aVector[i].GetResultPath() + "/" + aVector[i].GetImageName() + ".vtk"; - DrawVTKLinesFromTree(aVector[i], fullPath, false); - - } //for - } //if - - // Subtree levels option - if (vm.count("subtree_levels")) - { - } //if - else if (vm.count("subtree_length")) - { - } //if - else if (vm.count("subtree_diameter")) - { - } //if - - if (vm.count("compare_trees")) - { - std::cout << "Option: Compare trees" << std::endl; - /** - * this piece of code only test in the case of two trees, so it can be replaced - * to a code which does a cascade - */ - - //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - //CODIGO DE COMPARACIÓN DE ARBOLES - //std::cout << "Comparing trees ..." << std::endl; - //aVector[0].CompareTrees(aVector[1]); - //std::cout << "Comparing trees ... OK" << std::endl; - - std::cout << "Tree A ... " << std::endl; - //aVector[0].printNodeAndChildrenIds(); - std::cout << "Tree A ... OK" << std::endl; - - std::cout << "Tree B ... " << std::endl; - //aVector[1].printNodeAndChildrenIds(); - std::cout << "Tree B ... OK" << std::endl; - - std::cout << "Comparing trees Orkisz-Morales..." << std::endl; - // Vectors to save the common and uncommon nodes - vec_nodes commonA; - vec_nodes commonB; - vec_nodes nonCommonA; - vec_nodes nonCommonB; - std::map< unsigned int, std::vector > map_A_to_B; - std::map< unsigned int, std::vector > map_B_to_A; - std::vector< std::pair< std::pair, std::pair > > vector_pair_edges_A_to_B; - - // Input parameter for comparison - unsigned int Q = 1; // Corresponds to the depth to select "fathers" nodes - unsigned int F = 1; // Correspond to the depth to select "family" nodes - std::cout << "Q = " << Q << std::endl; - std::cout << "F = " << F << std::endl; - - clock_t before_compare = clock(); - aVector[0].CompareTreesOrkiszMorales(aVector[1], Q, F, commonA, commonB, nonCommonA, nonCommonB, map_A_to_B, map_B_to_A, vector_pair_edges_A_to_B); - clock_t after_compare = clock(); - double compare_time = double(after_compare - before_compare) / CLOCKS_PER_SEC; - std::cout << "Matching time: " << compare_time << std::endl; - - // Print the common tree with common edges - printCommonTreeBetweenTwoTrees(aVector[0], aVector[1], vector_pair_edges_A_to_B, Q, F); - printMatchingResultToFile(aVector[0], aVector[1], map_A_to_B, map_B_to_A, Q, F); - //printSeparatedCommonTrees(aVector[0], aVector[1], vector_pair_edges_A_to_B, Q, F); - //reconstructAndSaveCommonTrees(aVector[0], aVector[1], vector_pair_edges_A_to_B, Q, F); - - // Print all the maps that have more that two connections - std::cout << "Printing multiple relation A to B. Total relations: " << map_A_to_B.size() << std::endl; - for(std::map< unsigned int, std::vector >::iterator it_map_A_to_B = map_A_to_B.begin(); it_map_A_to_B != map_A_to_B.end(); ++it_map_A_to_B) - { - if((*it_map_A_to_B).second.size() > 1) - { - std::cout << "Multiple relation A to B with size:" << (*it_map_A_to_B).second.size() << ", from Id:" << (*it_map_A_to_B).first << std::endl; - for(std::vector::iterator it_node = (*it_map_A_to_B).second.begin(); it_node != (*it_map_A_to_B).second.end(); ++it_node) - { - std::cout << "Id: " << (*it_node)->GetId() << std::endl; - } - } - } - std::cout << "Printing multiple relation A to B ... OK" << std::endl; - - std::cout << "Printing multiple relation B to A. Total relations: " << map_B_to_A.size() << std::endl; - for(std::map< unsigned int, std::vector >::iterator it_map_B_to_A = map_B_to_A.begin(); it_map_B_to_A != map_B_to_A.end(); ++it_map_B_to_A) - { - if((*it_map_B_to_A).second.size() > 1) - { - std::cout << "Multiple relation B to A with size:" << (*it_map_B_to_A).second.size() << ", from Id:" << (*it_map_B_to_A).first << std::endl; - for(std::vector::iterator it_node = (*it_map_B_to_A).second.begin(); it_node != (*it_map_B_to_A).second.end(); ++it_node) - { - std::cout << "Id: " << (*it_node)->GetId() << std::endl; - } - } - } - std::cout << "Printing multiple relation B to A ... OK" << std::endl; - - // Mark only the common nodes - aVector[0].UnMarkAll(); - aVector[1].UnMarkAll(); - - // -------------------------------------- - // ------ Get common paths marked ------- - // -------------------------------------- - - /* - std::string path_folder = "/run/media/alfredo/Data/Pulmones/results/airwaysGraphs/comparisonResutls/probes/"; - std::string suffix_vtk = ".vtk"; - std::string name_tree = "TreeA_dP2P"; - int iteration = 1; - for(vec_nodes::iterator it_A = commonA.begin(); it_A != commonA.end(); ++it_A) - { - aVector[0].MarkPathFromNodeToNode(aVector[0].GetRoot(), (*it_A)); - - std::stringstream filepath_actualIteration; - filepath_actualIteration << path_folder << name_tree << "__" << iteration << "_idA_" << (*it_A)->GetId() << suffix_vtk; - - DrawVTKLinesFromTree(aVector[0], filepath_actualIteration.str(), true); - ++iteration; - } - - iteration = 1; - name_tree = "TreeB_dP2P"; - for(vec_nodes::iterator it_B = commonB.begin(); it_B != commonB.end(); ++it_B) - { - aVector[1].MarkPathFromNodeToNode(aVector[1].GetRoot(), (*it_B)); - - std::stringstream filepath_actualIteration; - filepath_actualIteration << path_folder << name_tree << "__" << iteration << "_idB_" << (*it_B)->GetId() << suffix_vtk; - - DrawVTKLinesFromTree(aVector[1], filepath_actualIteration.str(), true); - ++iteration; - } - */ - - // -------------------------------------- - // -------------------------------------- - - /* - //XXXXXXXXXXXXXXXXXXXXXXXXXXXX - //1. PRINT EACH NODE OF EACH TREE AND SAVE IT USING AS NAME ITS ID - - // Tree A - for(int i = 2; i < aVector[0].GetWeight(); ++i) - { - //std::cout << "Writing idA: " << i << std::endl; - AirwaysTree* tree_id = aVector[0].GetSingleDetachedTreeNodeById(i); - //std::cout << "Got id: " << i << ", numberOfNodes: " << tree_id->GetWeight() << std::endl; - if(tree_id) - { - std::stringstream filepath_actualIteration; - filepath_actualIteration << aVector[0].GetResultPath() << "/" << aVector[0].GetImageName() << "_id_" << i << suffix_vtk; - DrawVTKLinesFromTree(*tree_id, filepath_actualIteration.str(), false); - delete(tree_id); - } - else - std::cout << "Tree NULL" << std::endl; - } - - // Tree B - for(int i = 2; i < aVector[1].GetWeight(); ++i) - { - //std::cout << "Writing idA: " << i << std::endl; - AirwaysTree* tree_id = aVector[1].GetSingleDetachedTreeNodeById(i); - //std::cout << "Got id: " << i << ", numberOfNodes: " << tree_id->GetWeight() << std::endl; - if(tree_id) - { - std::stringstream filepath_actualIteration; - filepath_actualIteration << aVector[1].GetResultPath() << "/" << aVector[1].GetImageName() << "_id_" << i << suffix_vtk; - DrawVTKLinesFromTree(*tree_id, filepath_actualIteration.str(), false); - delete(tree_id); - } - else - std::cout << "Tree NULL" << std::endl; - } - - std::cout << "Comparing trees Orkisz-Morales... OK" << std::endl; - - */ - - //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - /*// AMP - aVector[0].SubIsomorphism(aVector[1]); - - std::cout << "Flag after SubIsomorphism" << std::endl; - std::string fullPathA = aVector[0].GetResultPath() + "/" + aVector[0].GetImageName() + "_CMP.vtk"; - std::string fullPathB = aVector[1].GetResultPath() + "/" + aVector[1].GetImageName() + "_CMP.vtk"; - DrawVTKLinesFromTree(aVector[0], fullPathA, true); - DrawVTKLinesFromTree(aVector[1], fullPathB, true); - - std::cout << "Flag after write vtk" << std::endl; - TInputImage::Pointer imgA, imgB; - aVector[0].ImageReconstruction(imgA); - std::cout << "Flag after Reconstruction A" << std::endl; - - aVector[1].ImageReconstruction(imgB); - std::cout << "Flag after Reconstruction B" << std::endl; - - std::string fullPathA_mhd = aVector[0].GetResultPath() + "/" + aVector[0].GetImageName() + "_CMP.vtk"; - std::string fullPathB_mhd = aVector[1].GetResultPath() + "/" + aVector[1].GetImageName() + "_CMP.vtk"; - WriteImage(imgA, fullPathA_mhd); - WriteImage(imgB, fullPathB_mhd); - - //AMP*/ - } - po::notify(vm); // throws on error, so do after help in case - } - catch (std::exception& e) - { - std::cerr << "Unhandled Exception reached the top of main: " << e.what() << ", application will now exit" << std::endl; - return ERROR_UNHANDLED_EXCEPTION; - } // yrt - } - catch (std::exception& e) - { - std::cerr << "Unhandled Exception reached the top of main: " << e.what() << ", application will now exit" << std::endl; - return ERROR_UNHANDLED_EXCEPTION; - } // yrt - return( 0 ); -} - -// ------------------------------------------------------------------------- -void Load_cpPlugins( const std::string& plugins ) -{ - myPlugins.LoadConfiguration( plugins ); -} - -// ------------------------------------------------------------------------- -void CreateResultDirectory(AirwaysTree tree) -{ - boost::filesystem::path dir(tree.GetResultPath()); - if (boost::filesystem::create_directories(dir)) - { - std::cout << "FolderName = " << tree.GetResultPath() << " has been created" << std::endl; - } //if - else - std::cout << "FolderName = " << tree.GetResultPath() << " already exists" << std::endl; -} - -// ------------------------------------------------------------------------- -void DrawVTKLinesFromTree(AirwaysTree& tree, const std::string filepath, bool common) -{ - // Create the array of points, lines, and colors - vtkSmartPointer pts = vtkSmartPointer::New(); - vtkSmartPointer lines = vtkSmartPointer::New(); - vtkSmartPointer colors = vtkSmartPointer::New(); - colors->SetNumberOfComponents(3); - colors->SetName("Colors"); - - //vtk sphere for sources - //vtkSmartPointer sphereSource = vtkSmartPointer::New(); - //Vec3 root = tree.GetRoot()->GetCoords(); - //sphereSource->SetCenter(root[0], root[1], root[2]); - //sphereSource->SetRadius(1); - //UndirectedGraph - - srand(time(NULL)); - unsigned int id = 1; - - // Create and fill the points, lines, and color vectors - //CalculateVTKLinesFromEdges(tree.GetRoot(), 0, id, pts, lines, colors, common); - pts->SetNumberOfPoints(tree.GetWeight()+1); - createLinesAndPointsForVTK(tree.GetRoot(), pts, lines, colors, common, true); - - // Create the polydata - vtkSmartPointer linesPolyData = vtkSmartPointer::New(); - - // Set the points, lines, and colors - linesPolyData->SetPoints(pts); - linesPolyData->SetLines(lines); - linesPolyData->GetCellData()->SetScalars(colors); - - // Write the file - vtkSmartPointer writer = vtkSmartPointer::New(); - writer->SetFileName(filepath.c_str()); - -#if VTK_MAJOR_VERSION <= 5 - writer->SetInput(linesPolyData); -#else - writer->SetInputData(linesPolyData); -#endif - writer->Write(); - - //The following code is to test the vtk polydata and visualize it - /* // Visualize - vtkSmartPointer mapper = - vtkSmartPointer::New(); - #if VTK_MAJOR_VERSION <= 5 - mapper->SetInput(linesPolyData); - #else - mapper->SetInputData(linesPolyData); - #endif - vtkSmartPointer actor = vtkSmartPointer::New(); - actor->SetMapper(mapper); - - //sphere - vtkSmartPointer mapperSphere = vtkSmartPointer< - vtkPolyDataMapper>::New(); - mapperSphere->SetInputConnection(sphereSource->GetOutputPort()); - - vtkSmartPointer actorSphere = vtkSmartPointer::New(); - actorSphere->SetMapper(mapperSphere); - //end sphere - - vtkSmartPointer renderer = vtkSmartPointer::New(); - vtkSmartPointer renderWindow = vtkSmartPointer< - vtkRenderWindow>::New(); - renderWindow->AddRenderer(renderer); - vtkSmartPointer renderWindowInteractor = - vtkSmartPointer::New(); - renderWindowInteractor->SetRenderWindow(renderWindow); - renderer->AddActor(actorSphere); - renderer->AddActor(actor); - - renderWindow->Render(); - renderWindowInteractor->Start();*/ -} - -// ------------------------------------------------------------------------- -#include -#include -#include -#include -#include - -template< class TImage, class TVertex > -Node* FAVertexToNode( TVertex vertex, TImage* image ) -{ - //The FrontAlgorithms Vertex is an TImageType::IndexType - typename TImage::PointType point; - image->TransformIndexToPhysicalPoint( vertex, point ); - Vec3 alfPoint(point[0],point[1],point[2]); - return new Node(alfPoint); -} - -AirwaysTree& ConvertFilterToAirwaysTree( TInputImage* input_image, cpPlugins::Workspace& ws ) -{ - typedef - fpa::Base::ImageSkeleton< fpa::Image::MinimumSpanningTree< 3 > > - TFASkeleton; - typedef TFASkeleton::TVertex TVertexFA; - typedef TFASkeleton::TVertexCmp TVertexCompareFA; - typedef cpExtensions::DataStructures::ImageIndexesContainer< 3 > TVerticesFA; - - typedef Node TVertexAirways; - typedef Edge TEdgeAirways; - typedef pair_posVox_rad TSkelePoint; - typedef vec_pair_posVox_rad TSkelePoints; - typedef std::map< TVertexFA, TVertexAirways*, TVertexCompareFA > VertexMap; - VertexMap vertexMap; - std::time_t start,end; - std::time(&start); - std::cout << "Starting conversion " << std::endl; - - auto w_filter = ws.GetFilter( "eb" ); - auto distance_map = - ws.GetFilter( "dmap" )->GetOutputData( "Output" )-> - GetITK< itk::Image< float, 3 > >( ); - auto sk = - w_filter->GetOutputData( "Skeleton" )->GetITK< TFASkeleton >( ); - const auto& branches = sk->Get( ); - auto seed0 = - ws.GetFilter( "seed" )->GetOutputData( "Output" )-> - GetITK< TVerticesFA >( )->Get( )[ 0 ]; - - std::queue< TVertexFA > q; - // TODO: std::set< TVertexFA, TVertexCompareFA > marks; - q.push( seed0 ); - while( !q.empty( ) ) - { - auto sVertex = q.front( ); - q.pop( ); - auto sIt = branches.find( sVertex ); - /* TODO - if( marks.find( sVertex ) != marks.end( ) ) - { - std::cout << "MARK!!!!! : " << sVertex << std::endl; - } - marks.insert( sVertex ); - */ - - // End node... do nothing - if( sIt == branches.end( ) ) - continue; - - // Create source node - auto srcIt = vertexMap.find( sVertex ); - if( srcIt == vertexMap.end( ) ) - srcIt = vertexMap.insert( - VertexMap::value_type( - sVertex, FAVertexToNode( sVertex, input_image ) - ) - ).first; - - // TODO: std::cout << sVertex << " " << " " << sLevel << " " << seed0 << std::endl; - // Create destination nodes - for( auto eIt = sIt->second.begin( ); eIt != sIt->second.end( ); ++eIt ) - { - auto dstIt = vertexMap.find( eIt->first ); - if( dstIt == vertexMap.end( ) ) - dstIt = vertexMap.insert( - VertexMap::value_type( - eIt->first, FAVertexToNode( eIt->first, input_image ) - ) - ).first; - - // Connect in the acyclic graph - dstIt->second->SetFather( srcIt->second ); - srcIt->second->AddChild( dstIt->second ); - - // Create detailed edge - TEdgeAirways* edge = new Edge( ); - edge->SetSource( srcIt->second ); - edge->SetTarget( dstIt->second ); - auto path = eIt->second->GetVertexList( ); - for( unsigned int pIt = 0; pIt < path->Size( ); ++pIt ) - { - itk::ImageBase< 3 >::PointType pnt; - auto cidx = path->GetElement( pIt ); - input_image->TransformContinuousIndexToPhysicalPoint( cidx, pnt ); - TVertexFA idx; - input_image->TransformPhysicalPointToIndex( pnt, idx ); - Vec3 coords = FAVertexToNode( idx, input_image )->GetCoords( ); - pair_posVox_rad skPair( coords, distance_map->GetPixel( idx ) ); - edge->AddSkeletonPairInfo( skPair ); - - } // rof - - // Finish association - dstIt->second->SetEdge( edge ); - - // Put it as next candidate - q.push( eIt->first ); - - } // rof - - } // elihw - - AirwaysTree* tree = - new AirwaysTree( input_image, NULL, vertexMap[ seed0 ], false ); - std::time(&end); - std::cout << "Finished conversion. New AlfTree has weight: "<GetWeight()<<". Takes "<<(end-start)<<" s." << std::endl; - return *tree; -} - -// ------------------------------------------------------------------------- -AirwaysTree& CreateAirwaysTreeFromSegmentation(Vec3 seed, TInputImage* input_image, cpPlugins::Workspace& ws ) -{ - return( ConvertFilterToAirwaysTree( input_image, ws ) ); -} - -// ------------------------------------------------------------------------- -vector ReadInputFile(const char* filename) -{ - // Variables - std::ifstream infile(filename); - std::string line; - std::string folderpath_allResults; - vector vectorInfo; - // Parse the file - bool firstLine = false; - - while (std::getline(infile, line)) - { - // First line contains the output folder - std::istringstream iss(line); - if (!firstLine) - { - if (!(iss >> folderpath_allResults)) - { - std::cout << "no file" << std::endl; - return vectorInfo; - } //if - firstLine = true; - } //if - // Other lines, not the first one, contain the information for the airways to be created - else - { - TreeInfo treeInfo; - float point_trachea[3]; - std::string filepath_airwayImage, name_pig, name_image; - if (!(iss >> point_trachea[0] >> point_trachea[1] >> point_trachea[2] >> filepath_airwayImage >> name_pig >> name_image)) - { - std::cout << "There is no tree information in the file." << std::endl; - break; - } //if - else - { - // Print information - std::cout << "Point trachea:[" << point_trachea[0] << "," << point_trachea[1] << "," << point_trachea[2] << "]" << std::endl; - } - - //Save info. - - //Save seed info. - Vec3 seed(point_trachea[0], point_trachea[1], point_trachea[2]); //real coords seed - treeInfo.seed = seed; - // Create the outputs - treeInfo.folderpath_pigResults = folderpath_allResults + "/" + name_pig + "/"; - treeInfo.pig_name = name_pig; - treeInfo.image_name = name_image; - // Read the image - /* - treeInfo.image = ReadImage(filepath_airwayImage); - */ - // Execute first pipeline's part - std::stringstream seed_stream; - seed_stream - << point_trachea[0] << " " - << point_trachea[1] << " " - << point_trachea[2]; - - treeInfo.myWorkspace->SetInterface( &myPlugins ); - std::string err = treeInfo.myWorkspace->LoadWorkspace( "./workspace_airwaysappli.wxml" ); - if( err != "" ) - { - std::cerr << "Error: " << err << std::endl; - std::exit( 1 ); - - } // fi - treeInfo.myWorkspace->SetParameter( "FileNames@reader", filepath_airwayImage ); - treeInfo.myWorkspace->SetParameter( "Text@seed", seed_stream.str( ) ); - vectorInfo.push_back(treeInfo); - - } //else - } //while - return vectorInfo; -} - -// ------------------------------------------------------------------------- -void printCommonTreeBetweenTwoTrees(AirwaysTree tree_A, AirwaysTree tree_B, std::vector< std::pair< std::pair, std::pair > > vector_pair_edges_A_to_B, unsigned int Q, unsigned int F) -{ - std::cout << "printCommonTreeBetweenTwoTrees, edges:" << vector_pair_edges_A_to_B.size() << std::endl; - - // Vtk points, cell array, and colors - vtkSmartPointer points_common = vtkSmartPointer::New(); - vtkSmartPointer lines_common = vtkSmartPointer::New(); - vtkSmartPointer colors_common = vtkSmartPointer::New(); - colors_common->SetNumberOfComponents(3); - colors_common->SetName("Colors"); - - // Add all the points - // 0 - 1000 points for tree A and from 1001 for tree B - points_common->SetNumberOfPoints(1000 + tree_B.GetWeight() + 100); - - // Add points for tree A - vec_nodes vector_nodesA = tree_A.GetNodes(); - for(vec_nodes::iterator it_nodesA = vector_nodesA.begin(); it_nodesA != vector_nodesA.end(); ++it_nodesA) - { - points_common->SetPoint((*it_nodesA)->GetId(),(*it_nodesA)->GetCoords().GetVec3()); - } - - // Add points for tree B - vec_nodes vector_nodesB = tree_B.GetNodes(); - for(vec_nodes::iterator it_nodesB = vector_nodesB.begin(); it_nodesB != vector_nodesB.end(); ++it_nodesB) - { - points_common->SetPoint((*it_nodesB)->GetId()+1000,(*it_nodesB)->GetCoords().GetVec3()); - } - - // Add the edges for both trees - std::vector< std::pair< std::pair, std::pair > >::iterator it_edges = vector_pair_edges_A_to_B.begin(); - int number_pairs = 0; - for(; it_edges != vector_pair_edges_A_to_B.end(); ++it_edges) - { - std::cout << "Pair:" << number_pairs << std::endl; - std::pair edge_A = (*it_edges).first; - std::pair edge_B = (*it_edges).second; - - vec_nodes path_A; - edge_A.first->GetPathToNode(edge_A.second, path_A); - - vec_nodes path_B; - edge_B.first->GetPathToNode(edge_B.second, path_B); - - // Set color to be used - int numColor = number_pairs % 6; - unsigned char color[3]; - color[0] = green[0]; - color[1] = green[1]; - color[2] = green[2]; - if(numColor == 1) - { - color[0] = red[0]; - color[1] = red[1]; - color[2] = red[2]; - } - else if(numColor == 2) - { - color[0] = blue[0]; - color[1] = blue[1]; - color[2] = blue[2]; - } - else if(numColor == 3) - { - color[0] = yellow[0]; - color[1] = yellow[1]; - color[2] = yellow[2]; - } - else if(numColor == 4) - { - color[0] = purple[0]; - color[1] = purple[1]; - color[2] = purple[2]; - } - else if(numColor == 5) - { - color[0] = cyan[0]; - color[1] = cyan[1]; - color[2] = cyan[2]; - } - - number_pairs++; - - // Trace line A - //if(path_A.size() > 0 && number_pairs < 50) - if( path_A.size() ) - { - vtkSmartPointer line = vtkSmartPointer::New(); - lines_common->InsertNextCell(path_A.size()); - int id_point = 0; - for(vec_nodes::iterator it_pathA = path_A.begin(); it_pathA != path_A.end(); ++it_pathA) - { - lines_common->InsertCellPoint((*it_pathA)->GetId()); - //line->GetPointIds()->SetId( id_point, (*it_pathA)->GetId() ); - //id_point++; - } - //lines_common->InsertNextCell(line); - colors_common->InsertNextTupleValue(color); - } - else - { - std::cout << "No path A" << std::endl; - } - - - // Trace line B - //if(path_B.size() > 0 && number_pairs < 50) - if( path_B.size() ) - { - vtkSmartPointer line = vtkSmartPointer::New(); - lines_common->InsertNextCell(path_B.size()); - int id_point = 0; - for(vec_nodes::iterator it_pathB = path_B.begin(); it_pathB != path_B.end(); ++it_pathB) - { - lines_common->InsertCellPoint((*it_pathB)->GetId()+1000); - //line->GetPointIds()->SetId( id_point, (*it_pathB)->GetId()+1000 ); - id_point++; - } - //lines_common->InsertNextCell(line); - colors_common->InsertNextTupleValue(color); - } - else - { - std::cout << "No path B" << std::endl; - } - } - - // Save the polydata - // Create the polydata - vtkSmartPointer linesPolyData = vtkSmartPointer::New(); - - // Set the points, lines, and colors - linesPolyData->SetPoints(points_common); - linesPolyData->SetLines(lines_common); - linesPolyData->GetCellData()->SetScalars(colors_common); - - // ------------------------------------------------ - // Write the vtk file - - // Create the pathfile to save - std::stringstream filepath_actualIteration; - filepath_actualIteration << tree_A.GetResultPath() << "/" << tree_A.GetImageName() << "_" << tree_B.GetImageName() << "_Q_" << Q << "_F_" << F << ".vtk"; - std::cout << "File to save:" << filepath_actualIteration.str() << std::endl; - - // Create the writer - vtkSmartPointer writer = vtkSmartPointer::New(); - writer->SetFileName(filepath_actualIteration.str().c_str()); - - // Set input and write -#if VTK_MAJOR_VERSION <= 5 - writer->SetInput(linesPolyData); -#else - writer->SetInputData(linesPolyData); -#endif - writer->Write(); - - - - // *************************************** - // Save the links in a file - // ******* - - // Create the outputfile - std::stringstream filepath_evaluation; - filepath_evaluation << tree_A.GetResultPath() << "/" << tree_A.GetImageName() << "_" << tree_B.GetImageName() << "_Q_" << Q << "_F_" << F << ".csv"; - - std::ofstream file(filepath_evaluation.str().c_str()); - if(file.is_open()) - { - // Save the header - //file << "Node_" << tree_A.GetImageName() << " " << "Node_" << tree_B.GetImageName()<< "\n"; - file << "TreeName " - "idLocalN1 idLocalN2 " - "Node1x Node1y Node1z " - "Node2x Node2y Node2z " - "idGlobalN1 " - "idMatch" << std::endl; - - - std::vector< std::pair< std::pair, std::pair > >::iterator it_edges = vector_pair_edges_A_to_B.begin(); - for(; it_edges != vector_pair_edges_A_to_B.end(); ++it_edges) - { - - std::pair edge_A = (*it_edges).first; - std::pair edge_B = (*it_edges).second; - - //file << edge_A.second->GetId() << " " << edge_B.second->GetId()+1000 << "\n"; - Vec3 coord_EndNodeA = edge_A.second->GetCoords(); - Vec3 coord_EndNodeB = edge_B.second->GetCoords(); - file << tree_A.GetImageName() << " " << - edge_A.second->GetId() << " " << edge_B.second->GetId()+1000 << " " << - coord_EndNodeA[0] << " " << coord_EndNodeA[1] << " " << coord_EndNodeA[2] << " " << - coord_EndNodeB[0] << " " << coord_EndNodeB[1] << " " << coord_EndNodeB[2] << " " << - tree_A.GetImageName() << coord_EndNodeA[0] << coord_EndNodeA[1] << coord_EndNodeA[2] << " " << - tree_B.GetImageName() << coord_EndNodeB[0] << coord_EndNodeB[1] << coord_EndNodeB[2] <<"\n"; - - file << tree_B.GetImageName() << " " << - edge_B.second->GetId()+1000 << " " << edge_A.second->GetId() << " " << - coord_EndNodeB[0] << " " << coord_EndNodeB[1] << " " << coord_EndNodeB[2] << " " << - coord_EndNodeA[0] << " " << coord_EndNodeA[1] << " " << coord_EndNodeA[2] << " " << - tree_B.GetImageName() << coord_EndNodeB[0] << coord_EndNodeB[1] << coord_EndNodeB[2] << " " << - tree_A.GetImageName() << coord_EndNodeA[0] << coord_EndNodeA[1] << coord_EndNodeA[2] << "\n"; - } - } - - file.close(); - // ******* - // *************************************** - - - - - std::cout << "printCommonTreeBetweenTwoTrees ... OK" << std::endl; -} - -// ------------------------------------------------------------------------- -void printMatchingResultToFile(AirwaysTree tree_A, AirwaysTree tree_B, std::map< unsigned int, std::vector > map_A_to_B, std::map< unsigned int, std::vector > map_B_to_A, unsigned int Q, unsigned int F) -{ - std::cout << "Printing matching result ... " << std::endl; - - // Variables and types - typedef std::map< unsigned int, vec_nodes > map_id_node; - - // Create the outputfile - std::stringstream filepath_evaluation; - filepath_evaluation << tree_A.GetResultPath() << "/" << tree_A.GetImageName() << "_" << tree_B.GetImageName() << "_Q_" << Q << "_F_" << F << "_matching.csv"; - - std::ofstream file(filepath_evaluation.str().c_str()); - if(file.is_open()) - { - // Save the header - file << "TreeName idLocalN1 idLocalN2 " - "Node1x Node1y Node1z " - "Node2x Node2y Node2z " - "idGlobalN1 " - "idMatch " - "typeMatch_match_1_nonmatch_0 " - "depth " - "leaf"<< std::endl; - - // --------------- - // From A to B - - // Save the match or non-match for each node from A to B - for(int id_a=1; id_a <= tree_A.GetWeight( ); ++id_a) - { - // Get the actual node in tree A - Node* node_a = tree_A.GetNodeById( id_a ); - Vec3 coords_a = node_a->GetCoords(); - unsigned int depth_a = tree_A.GetDepthById(id_a); - bool leaf_a = node_a->IsLeaf(); - - // Check if the node was matched - map_id_node::iterator it_a2b = map_A_to_B.find( id_a ); - if( it_a2b != map_A_to_B.end( ) ) - { - // Get the correspoding matching nodes and print them - vec_nodes nodes_B = (*it_a2b).second; - - vec_nodes::iterator it_nodes_b = nodes_B.begin( ); - for( ; it_nodes_b != nodes_B.end( ); ++it_nodes_b) - { - Vec3 coords_b = (*it_nodes_b)->GetCoords(); - - file << tree_A.GetImageName() << " " << id_a << " " << (*it_nodes_b)->GetId()+1000 << " " - << coords_a[0] << " " << coords_a[1] << " " << coords_a[2] << " " - << coords_b[0] << " " << coords_b[1] << " " << coords_b[2] << " " - << tree_A.GetImageName() << coords_a[0] << coords_a[1] << coords_a[2] << " " - << tree_A.GetImageName() << coords_a[0] << coords_a[1] << coords_a[2] << coords_b[0] << coords_b[1] << coords_b[2] << " " - << "1" << " " - << depth_a << " " - << leaf_a << "\n"; - } - } - else - { - file << tree_A.GetImageName() << " " << id_a << " " << "0" << " " - << coords_a[0] << " " << coords_a[1] << " " << coords_a[2] << " " - << "0" << " " << "0" << " " << "0" << " " - << tree_A.GetImageName() << coords_a[0] << coords_a[1] << coords_a[2] << " " - << tree_A.GetImageName() << coords_a[0] << coords_a[1] << coords_a[2] << "0" << "0" << "0" << " " - << "0" << " " - << depth_a << " " - << leaf_a << "\n"; - } - } - - // --------------- - // From B to A - - // Save the match or non-match for each node from A to B - for(int id_b=1; id_b <= tree_B.GetWeight( ); ++id_b) - { - // Get the actual node in tree B - Node* node_b = tree_B.GetNodeById( id_b ); - Vec3 coords_b = node_b->GetCoords(); - unsigned int depth_b = tree_B.GetDepthById(id_b); - bool leaf_b = node_b->IsLeaf(); - - // Check if the node was matched - map_id_node::iterator it_b2a = map_B_to_A.find( id_b ); - if( it_b2a != map_B_to_A.end( ) ) - { - // Get the correspoding matching nodes and print them - vec_nodes nodes_A = (*it_b2a).second; - - vec_nodes::iterator it_nodes_a = nodes_A.begin( ); - for( ; it_nodes_a != nodes_A.end( ); ++it_nodes_a) - { - Vec3 coords_a = (*it_nodes_a)->GetCoords(); - - file << tree_B.GetImageName() << " " << id_b+1000 << " " << (*it_nodes_a)->GetId() << " " - << coords_b[0] << " " << coords_b[1] << " " << coords_b[2] << " " - << coords_a[0] << " " << coords_a[1] << " " << coords_a[2] << " " - << tree_B.GetImageName() << coords_b[0] << coords_b[1] << coords_b[2] << " " - << tree_B.GetImageName() << coords_b[0] << coords_b[1] << coords_b[2] << coords_a[0] << coords_a[1] << coords_a[2] << " " - << "1" << " " - << depth_b << " " - << leaf_b << "\n"; - } - } - else - { - file << tree_B.GetImageName() << " " << id_b+1000 << " " << "0" << " " - << coords_b[0] << " " << coords_b[1] << " " << coords_b[2] << " " - << "0" << " " << "0" << " " << "0" << " " - << tree_B.GetImageName() << coords_b[0] << coords_b[1] << coords_b[2] << " " - << tree_B.GetImageName() << coords_b[0] << coords_b[1] << coords_b[2] << "0" << "0" << "0" << " " - << "0" << " " - << depth_b << " " - << leaf_b << "\n"; - }//esle - }//rof - }//fi - - file.close(); // Close the file - - std::cout << "Printing matching result DONE" << std::endl; -} - -// ------------------------------------------------------------------------- -void createLinesAndPointsForVTK(const Node* node, vtkSmartPointer& pts,vtkSmartPointer& lines, vtkSmartPointer& colors, bool common, bool isRoot) -{ - // Insert the actual point/node - //vtkIdType id_father = idNonRoot; - //if(isRoot) - //id_father = pts->InsertNextPoint(node->GetCoords().GetVec3()); - vtkIdType id_father = node->GetId(); - if(isRoot) - pts->SetPoint(id_father,node->GetCoords().GetVec3()); - - // Iterate over the children - const vec_nodes children = node->GetChildren(); - for (vec_nodes::const_iterator it_child = children.begin(); it_child != children.end(); ++it_child) - { - if (!(*it_child)->IsMarked() && common) - continue; - - //vtkIdType id_son = pts->InsertNextPoint((*it_child)->GetCoords().GetVec3()); - vtkIdType id_son = (*it_child)->GetId(); - pts->SetPoint(id_son,(*it_child)->GetCoords().GetVec3()); - - // Set color to be used - int numColor = (*it_child)->GetLevel() % 4; - if(numColor == 0) - colors->InsertNextTupleValue(green); - else if(numColor == 1) - colors->InsertNextTupleValue(red); - else if(numColor == 2) - colors->InsertNextTupleValue(red); - else - colors->InsertNextTupleValue(red); - - // Add the line - vtkSmartPointer line = vtkSmartPointer::New(); - line->GetPointIds()->SetId(0, id_father); - line->GetPointIds()->SetId(1, id_son); - lines->InsertNextCell(line); - - createLinesAndPointsForVTK(*it_child, pts, lines, colors, common, false); - } //for -} - -// eof - $RCSfile$ diff --git a/appli/examples/CMakeLists.txt b/appli/examples/CMakeLists.txt deleted file mode 100644 index b2d1450..0000000 --- a/appli/examples/CMakeLists.txt +++ /dev/null @@ -1,35 +0,0 @@ -SET( - SIMPLE_EXAMPLES - example_Image_Dijkstra_EndPointDetection_WithoutVTK - ) -FOREACH(EX ${SIMPLE_EXAMPLES}) - ADD_EXECUTABLE(${EX} ${EX}.cxx) - TARGET_LINK_LIBRARIES(${EX} FrontAlgorithms) -ENDFOREACH(EX) - -SET( - SIMPLE_VTK_EXAMPLES - example_Image_RegionGrow_AllPixels - example_Image_RegionGrow_AllRGBPixels - example_Image_RegionGrow_ConnectedPixels - example_Image_RegionGrow_ConnectedRGBPixels - example_Image_Dijkstra_AbsoluteDifferenceCost - example_Image_Dijkstra_EndPointDetection - # example_Image_RegionGrow_GaussianModelEstimation - # example_Image_IncrementalRegionGrow_Thresholds - # example_Image_Dijkstra_CostFromInput - # example_Image_Dijkstra_CostFromRGBInput - # example_Image_Dijkstra_DanielssonCost - # example_Image_Dijkstra_DanielssonCost_TwoSeedsPath - # example_Image_Dijkstra_LabelSkeleton - # example_ShowSkeleton - # example_CircleOfWillis - ) -FOREACH(EX ${SIMPLE_VTK_EXAMPLES}) - ADD_EXECUTABLE(${EX} ${EX}.cxx) - TARGET_LINK_LIBRARIES( - ${EX} FrontAlgorithms - ) -ENDFOREACH(EX) - -## eof - $RCSfile$ diff --git a/appli/examples/example_BinaryDistanceMap.cxx b/appli/examples/example_BinaryDistanceMap.cxx deleted file mode 100644 index 7628ebf..0000000 --- a/appli/examples/example_BinaryDistanceMap.cxx +++ /dev/null @@ -1,80 +0,0 @@ -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -// ------------------------------------------------------------------------- -const unsigned int Dim = 3; -typedef unsigned char TPixel; -typedef float TScalar; -typedef itk::Image< TPixel, Dim > TImage; -typedef itk::Image< TScalar, Dim > TScalarImage; -typedef itk::ImageFileReader< TImage > TImageReader; -typedef itk::ImageFileWriter< TScalarImage > TImageWriter; - -// ------------------------------------------------------------------------- -int main( int argc, char* argv[] ) -{ - if( argc < 3 ) - { - std::cerr - << "Usage: " << argv[ 0 ] - << " input_image output_image" - << std::endl; - return( 1 ); - - } // fi - std::string input_image_fn = argv[ 1 ]; - std::string output_image_fn = argv[ 2 ]; - - // Read image - TImageReader::Pointer input_image_reader = TImageReader::New( ); - input_image_reader->SetFileName( input_image_fn ); - try - { - input_image_reader->Update( ); - } - catch( itk::ExceptionObject& err ) - { - std::cerr << "Error caught: " << err << std::endl; - return( 1 ); - - } // yrt - - // Invert intensity - typedef itk::MinimumMaximumImageCalculator< TImage > TMinMax; - TMinMax::Pointer minmax = TMinMax::New( ); - minmax->SetImage( input_image_reader->GetOutput( ) ); - minmax->Compute( ); - - typedef itk::InvertIntensityImageFilter< TImage > TInvert; - TInvert::Pointer invert = TInvert::New( ); - invert->SetInput( input_image_reader->GetOutput( ) ); - invert->SetMaximum( minmax->GetMaximum( ) ); - - typedef itk::DanielssonDistanceMapImageFilter< TImage, TScalarImage > TDistance; - TDistance::Pointer distance = TDistance::New( ); - distance->SetInput( invert->GetOutput( ) ); - distance->InputIsBinaryOn( ); - distance->SquaredDistanceOn( ); - std::clock_t start = std::clock( ); - distance->Update( ); - std::clock_t end = std::clock( ); - double seconds = double( end - start ) / double( CLOCKS_PER_SEC ); - std::cout << "Distance map time = " << seconds << std::endl; - - TImageWriter::Pointer writer = TImageWriter::New( ); - writer->SetInput( distance->GetOutput( ) ); - writer->SetFileName( output_image_fn ); - writer->Update( ); - - return( 0 ); -} - -// eof - $RCSfile$ diff --git a/appli/examples/example_CircleOfWillis.cxx b/appli/examples/example_CircleOfWillis.cxx deleted file mode 100644 index e00ca3d..0000000 --- a/appli/examples/example_CircleOfWillis.cxx +++ /dev/null @@ -1,141 +0,0 @@ -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include - -// ------------------------------------------------------------------------- -const unsigned int Dimension = 3; -typedef short TPixel; - -typedef itk::Image< TPixel, Dimension > TImage; - -// ------------------------------------------------------------------------- -int main( int argc, char* argv[] ) -{ - if( argc < 3 ) - { - std::cerr - << "Usage: " << argv[ 0 ] - << " input_image input_seeds" - << std::endl; - return( 1 ); - - } // fi - std::string input_image_fn = argv[ 1 ]; - std::string input_seeds_fn = argv[ 2 ]; - - // Read image - itk::ImageFileReader< TImage >::Pointer input_image_reader = - itk::ImageFileReader< TImage >::New( ); - input_image_reader->SetFileName( input_image_fn ); - try - { - input_image_reader->Update( ); - } - catch( itk::ExceptionObject& err ) - { - std::cerr << "Error caugth: " << err << std::endl; - return( 1 ); - - } // yrt - TImage::ConstPointer input_image = input_image_reader->GetOutput( ); - itk::ImageToVTKImageFilter< TImage >::Pointer input_image_vtk = - itk::ImageToVTKImageFilter< TImage >::New( ); - input_image_vtk->SetInput( input_image ); - input_image_vtk->Update( ); - - // Read seeds - std::ifstream input_seeds_fs( input_seeds_fn.c_str( ) ); - if( !input_seeds_fs ) - { - std::cerr - << "Error opening file \"" << input_seeds_fn << "\"" << std::endl; - return( 1 ); - - } // fi - - // Read seed points - std::string str_val; - unsigned int number_of_points; - input_seeds_fs >> str_val >> number_of_points; - input_seeds_fs >> str_val; // X - input_seeds_fs >> str_val; // Y - input_seeds_fs >> str_val; // Z - input_seeds_fs >> str_val; // value - input_seeds_fs >> str_val; // Label - - vtkSmartPointer< vtkPoints > input_seeds_points = - vtkSmartPointer< vtkPoints >::New( ); - vtkSmartPointer< vtkCellArray > input_seeds_cells = - vtkSmartPointer< vtkCellArray >::New( ); - vtkSmartPointer< vtkFloatArray > input_seeds_ids = - vtkSmartPointer< vtkFloatArray >::New( ); - - input_seeds_ids->SetNumberOfComponents( 1 ); - input_seeds_ids->SetNumberOfTuples( number_of_points ); - - double min_value = std::numeric_limits< double >::max( ); - double max_value = double( 0 ); - for( unsigned int i = 0; i < number_of_points; ++i ) - { - unsigned int x, y, z; - double value; - input_seeds_fs >> x >> y >> z >> value >> str_val; - - min_value = ( value < min_value )? value: min_value; - max_value = ( value > max_value )? value: max_value; - - TImage::IndexType idx; - idx[ 0 ] = x; - idx[ 1 ] = y; - idx[ 2 ] = z; - TImage::PointType pnt; - input_image->TransformIndexToPhysicalPoint( idx, pnt ); - - input_seeds_points->InsertNextPoint( pnt[ 0 ], pnt[ 1 ], pnt[ 2 ] ); - input_seeds_cells->InsertNextCell( 1 ); - input_seeds_cells->InsertCellPoint( i ); - input_seeds_ids->SetTuple1( - i, double( i ) / double( number_of_points - 1 ) - ); - - - } // rof - input_seeds_fs.close( ); - - vtkSmartPointer< vtkPolyData > input_seeds = - vtkSmartPointer< vtkPolyData >::New( ); - input_seeds->SetPoints( input_seeds_points ); - input_seeds->SetVerts( input_seeds_cells ); - input_seeds->GetPointData( )->SetScalars( input_seeds_ids ); - - // Show input image and let some interaction - fpa::VTK::ImageMPR view; - view.SetBackground( 0.3, 0.2, 0.8 ); - view.SetSize( 600, 600 ); - view.SetImage( input_image_vtk->GetOutput( ) ); - view.SetWindowLevel( - max_value - min_value, - ( min_value + max_value ) / double( 2 ) - ); - view.AddPolyData( input_seeds ); - view.Render( ); - view.Start( ); - - return( 0 ); -} - -// eof - $RCSfile$ diff --git a/appli/examples/example_HausdorffDistance.cxx b/appli/examples/example_HausdorffDistance.cxx deleted file mode 100644 index ebcede0..0000000 --- a/appli/examples/example_HausdorffDistance.cxx +++ /dev/null @@ -1,59 +0,0 @@ -#include -#include -#include - -#include -#include -#include -#include - -// ------------------------------------------------------------------------- -const unsigned int Dim = 3; -typedef unsigned short TPixel; -typedef float TScalar; -typedef itk::Image< TPixel, Dim > TImage; -typedef itk::ImageFileReader< TImage > TImageReader; -typedef itk::HausdorffDistanceImageFilter< TImage, TImage > TDistance; - -// ------------------------------------------------------------------------- -int main( int argc, char* argv[] ) -{ - if( argc < 3 ) - { - std::cerr - << "Usage: " << argv[ 0 ] - << " first_image second_image" - << std::endl; - return( 1 ); - - } // fi - std::string first_image_fn = argv[ 1 ]; - std::string second_image_fn = argv[ 2 ]; - - // Read image - TImageReader::Pointer first_image_reader = TImageReader::New( ); - TImageReader::Pointer second_image_reader = TImageReader::New( ); - first_image_reader->SetFileName( first_image_fn ); - second_image_reader->SetFileName( second_image_fn ); - try - { - first_image_reader->Update( ); - second_image_reader->Update( ); - } - catch( itk::ExceptionObject& err ) - { - std::cerr << "Error caught: " << err << std::endl; - return( 1 ); - - } // yrt - - TDistance::Pointer distance = TDistance::New( ); - distance->SetInput1( first_image_reader->GetOutput( ) ); - distance->SetInput2( second_image_reader->GetOutput( ) ); - distance->Update( ); - std::cout << "Hausdorff distance = " << distance->GetHausdorffDistance( ) << std::endl; - - return( 0 ); -} - -// eof - $RCSfile$ diff --git a/appli/examples/example_ImageAlgorithmDijkstra_00.cxx b/appli/examples/example_ImageAlgorithmDijkstra_00.cxx deleted file mode 100644 index 86cff08..0000000 --- a/appli/examples/example_ImageAlgorithmDijkstra_00.cxx +++ /dev/null @@ -1,44 +0,0 @@ -#include -#include - -#include - -// ------------------------------------------------------------------------- -const unsigned int Dim = 2; -typedef unsigned char TPixel; -typedef double TCost; -typedef itk::Image< TPixel, Dim > TImage; - -typedef fpa::Image::Dijkstra< TImage, TCost > TFrontAlgorithm; - -// ------------------------------------------------------------------------- -int main( int argc, char* argv[] ) -{ - // Create a dummy image - TImage::SizeType imageSize; - imageSize.Fill( 100 ); - - TImage::SpacingType imageSpacing; - imageSpacing.Fill( 1 ); - - TImage::Pointer image = TImage::New( ); - image->SetRegions( imageSize ); - image->SetSpacing( imageSpacing ); - image->Allocate( ); - image->FillBuffer( TPixel( 1 ) ); - - // Seed - TImage::IndexType seed; - seed.Fill( 50 ); - - // Configure algorithm - TFrontAlgorithm::Pointer algorithm = TFrontAlgorithm::New( ); - algorithm->AddSeed( seed, TCost( 0 ) ); - algorithm->SetInput( image ); - algorithm->SetNeighborhoodOrder( 1 ); - algorithm->Update( ); - - return( 0 ); -} - -// eof - $RCSfile$ diff --git a/appli/examples/example_ImageAlgorithmDijkstra_01.cxx b/appli/examples/example_ImageAlgorithmDijkstra_01.cxx deleted file mode 100644 index 6bcf5b3..0000000 --- a/appli/examples/example_ImageAlgorithmDijkstra_01.cxx +++ /dev/null @@ -1,202 +0,0 @@ -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -// ------------------------------------------------------------------------- -const unsigned int Dim = 2; -typedef unsigned char TPixel; -typedef double TScalar; -typedef itk::Image< TPixel, Dim > TImage; -typedef itk::Image< TScalar, Dim > TScalarImage; -typedef itk::ImageToVTKImageFilter< TImage > TVTKImage; - -typedef itk::ImageFileReader< TImage > TImageReader; -typedef fpa::Image::Dijkstra< TScalarImage, TScalar > TFrontAlgorithm; - -typedef -fpa::VTK::Image2DObserver< TFrontAlgorithm, vtkRenderWindow > -TObserver; - -// ------------------------------------------------------------------------- -class InvertPixelFunctor -{ -public: - InvertPixelFunctor( ) - { } - virtual ~InvertPixelFunctor( ) - { } - bool operator!=( const InvertPixelFunctor& other ) const - { return( false ); } - bool operator==( const InvertPixelFunctor& other ) const - { return( !( *this != other ) ); } - inline TScalar operator()( const TScalar& A ) const - { - return( TScalar( 1 ) / std::pow( TScalar( 1 ) + A, TScalar( 4 ) ) ); - } -}; - -// ------------------------------------------------------------------------- -int main( int argc, char* argv[] ) -{ - if( argc < 3 ) - { - std::cerr - << "Usage: " << argv[ 0 ] - << " input_image neighborhood_order [stop_at_one_front]" - << std::endl; - return( 1 ); - - } // fi - std::string input_image_fn = argv[ 1 ]; - unsigned int neighborhood_order = std::atoi( argv[ 2 ] ); - bool stop_at_one_front = false; - if( 3 < argc ) - stop_at_one_front = ( std::atoi( argv[ 3 ] ) == 1 ); - - // Read image - TImageReader::Pointer input_image_reader = TImageReader::New( ); - input_image_reader->SetFileName( input_image_fn ); - try - { - input_image_reader->Update( ); - } - catch( itk::ExceptionObject& err ) - { - std::cerr << "Error caught: " << err << std::endl; - return( 1 ); - - } // yrt - TImage::ConstPointer input_image = input_image_reader->GetOutput( ); - - TVTKImage::Pointer vtk_image = TVTKImage::New( ); - vtk_image->SetInput( input_image ); - vtk_image->Update( ); - - // VTK visualization - vtkSmartPointer< vtkImageActor > actor = - vtkSmartPointer< vtkImageActor >::New( ); - actor->SetInputData( vtk_image->GetOutput( ) ); - - vtkSmartPointer< vtkRenderer > renderer = - vtkSmartPointer< vtkRenderer >::New( ); - renderer->SetBackground( 0.1, 0.2, 0.7 ); - renderer->AddActor( actor ); - vtkSmartPointer< vtkRenderWindow > window = - vtkSmartPointer< vtkRenderWindow >::New( ); - window->SetSize( 800, 800 ); - window->AddRenderer( renderer ); - - // VTK interaction - vtkSmartPointer< vtkInteractorStyleImage > imageStyle = - vtkSmartPointer< vtkInteractorStyleImage >::New( ); - vtkSmartPointer< vtkRenderWindowInteractor > interactor = - vtkSmartPointer< vtkRenderWindowInteractor >::New( ); - interactor->SetInteractorStyle( imageStyle ); - window->SetInteractor( interactor ); - window->Render( ); - - // Create the widget and its representation - vtkSmartPointer< vtkPointHandleRepresentation3D > handle = - vtkSmartPointer< vtkPointHandleRepresentation3D >::New( ); - handle->GetProperty( )->SetColor( 1, 0, 0 ); - vtkSmartPointer< vtkSeedRepresentation > rep = - vtkSmartPointer< vtkSeedRepresentation >::New( ); - rep->SetHandleRepresentation( handle ); - - vtkSmartPointer< vtkSeedWidget > widget = - vtkSmartPointer< vtkSeedWidget >::New( ); - widget->SetInteractor( interactor ); - widget->SetRepresentation( rep ); - - // Let some interaction - interactor->Initialize( ); - window->Render( ); - widget->On( ); - interactor->Start( ); - - // Compute cost map - typedef itk::MinimumMaximumImageCalculator< TImage > TMinMax; - typedef itk::InvertIntensityImageFilter< TImage > TInvert; - typedef itk::DanielssonDistanceMapImageFilter< TImage, TScalarImage > TDanielsson; - typedef itk::UnaryFunctorImageFilter< TScalarImage, TScalarImage, InvertPixelFunctor > TInvertFunctor; - - TMinMax::Pointer input_image_min_max = TMinMax::New( ); - input_image_min_max->SetImage( input_image ); - input_image_min_max->Compute( ); - - TInvert::Pointer invert = TInvert::New( ); - invert->SetInput( input_image ); - invert->SetMaximum( input_image_min_max->GetMaximum( ) ); - - TDanielsson::Pointer danielsson = TDanielsson::New( ); - danielsson->SetInput( invert->GetOutput( ) ); - danielsson->InputIsBinaryOn( ); - danielsson->SquaredDistanceOff( ); - danielsson->UseImageSpacingOn( ); - - TInvertFunctor::Pointer invert_pixels = TInvertFunctor::New( ); - invert_pixels->SetInput( danielsson->GetOutput( ) ); - invert_pixels->Update( ); - - // Configure observer - TObserver::Pointer obs = TObserver::New( ); - obs->SetImage( invert_pixels->GetOutput( ), window ); - - // Configure algorithm - TFrontAlgorithm::Pointer algorithm = TFrontAlgorithm::New( ); - for( unsigned int s = 0; s < rep->GetNumberOfSeeds( ); s++ ) - { - double pos[ 3 ]; - rep->GetSeedWorldPosition( s, pos ); - - TImage::PointType pnt; - pnt[ 0 ] = pos[ 0 ]; - pnt[ 1 ] = pos[ 1 ]; - - TImage::IndexType idx; - if( input_image->TransformPhysicalPointToIndex( pnt, idx ) ) - { - algorithm->AddSeed( idx, 0 ); - std::cout << " Seed --> " << idx << std::endl; - - } // fi - - } // rof - algorithm->AddObserver( itk::AnyEvent( ), obs ); - algorithm->ThrowEventsOn( ); - algorithm->SetInput( invert_pixels->GetOutput( ) ); - algorithm->SetNeighborhoodOrder( neighborhood_order ); - algorithm->SetStopAtOneFront( stop_at_one_front ); - algorithm->Update( ); - - // One last interaction - window->Render( ); - interactor->Start( ); - - return( 0 ); -} - -// eof - $RCSfile$ diff --git a/appli/examples/example_ImageAlgorithmDijkstra_02.cxx b/appli/examples/example_ImageAlgorithmDijkstra_02.cxx deleted file mode 100644 index 728313e..0000000 --- a/appli/examples/example_ImageAlgorithmDijkstra_02.cxx +++ /dev/null @@ -1,205 +0,0 @@ -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -// ------------------------------------------------------------------------- -const unsigned int Dim = 2; -typedef unsigned char TPixel; -typedef itk::RGBAPixel< TPixel > TRGBAPixel; -typedef double TScalar; -typedef itk::Image< TPixel, Dim > TImage; -typedef itk::Image< TScalar, Dim > TDistanceMap; -typedef itk::Image< TRGBAPixel, Dim > TRGBAImage; -typedef itk::ImageToVTKImageFilter< TImage > TVTKImage; -typedef itk::ImageToVTKImageFilter< TRGBAImage > TVTKRGBAImage; - -typedef itk::ImageFileReader< TImage > TImageReader; -typedef -itk::SignedDanielssonDistanceMapImageFilter< TImage, TDistanceMap > -TDistanceFilter; - -typedef fpa::Image::Dijkstra< TDistanceMap, TScalar > TFrontAlgorithm; -typedef fpa::Base::TreeExtractor< TFrontAlgorithm > TExtractor; -typedef fpa::Base::Functors::InvertCostFunction< TScalar > TScalarFunction; - -typedef -fpa::VTK::Image2DObserver< TExtractor, vtkRenderWindow > -TObserver; - -// ------------------------------------------------------------------------- -int main( int argc, char* argv[] ) -{ - if( argc < 2 ) - { - std::cerr - << "Usage: " << argv[ 0 ] - << " input_image [stop_at_one_front]" << std::endl; - return( 1 ); - - } // fi - std::string input_image_fn = argv[ 1 ]; - bool stop_at_one_front = false; - if( 2 < argc ) - stop_at_one_front = ( std::atoi( argv[ 2 ] ) == 1 ); - - // Read image - TImageReader::Pointer input_image_reader = TImageReader::New( ); - input_image_reader->SetFileName( input_image_fn ); - try - { - input_image_reader->Update( ); - } - catch( itk::ExceptionObject& err ) - { - std::cerr << "Error caught: " << err << std::endl; - return( 1 ); - - } // yrt - - TDistanceFilter::Pointer dist_filter = TDistanceFilter::New( ); - dist_filter->SetInput( input_image_reader->GetOutput( ) ); - dist_filter->InsideIsPositiveOn( ); - dist_filter->SquaredDistanceOff( ); - dist_filter->Update( ); - - TImage::ConstPointer input_image = input_image_reader->GetOutput( ); - - TVTKImage::Pointer vtk_image = TVTKImage::New( ); - vtk_image->SetInput( input_image ); - vtk_image->Update( ); - - // VTK visualization - vtkSmartPointer< vtkImageActor > actor = - vtkSmartPointer< vtkImageActor >::New( ); - actor->SetInputData( vtk_image->GetOutput( ) ); - - vtkSmartPointer< vtkRenderer > renderer = - vtkSmartPointer< vtkRenderer >::New( ); - renderer->SetBackground( 0.1, 0.2, 0.7 ); - renderer->AddActor( actor ); - vtkSmartPointer< vtkRenderWindow > window = - vtkSmartPointer< vtkRenderWindow >::New( ); - window->SetSize( 800, 800 ); - window->AddRenderer( renderer ); - - // VTK interaction - vtkSmartPointer< vtkInteractorStyleImage > imageStyle = - vtkSmartPointer< vtkInteractorStyleImage >::New( ); - vtkSmartPointer< vtkRenderWindowInteractor > interactor = - vtkSmartPointer< vtkRenderWindowInteractor >::New( ); - interactor->SetInteractorStyle( imageStyle ); - window->SetInteractor( interactor ); - window->Render( ); - - // Create the widget and its representation - vtkSmartPointer< vtkPointHandleRepresentation3D > handle = - vtkSmartPointer< vtkPointHandleRepresentation3D >::New( ); - handle->GetProperty( )->SetColor( 1, 0, 0 ); - vtkSmartPointer< vtkSeedRepresentation > rep = - vtkSmartPointer< vtkSeedRepresentation >::New( ); - rep->SetHandleRepresentation( handle ); - - vtkSmartPointer< vtkSeedWidget > widget = - vtkSmartPointer< vtkSeedWidget >::New( ); - widget->SetInteractor( interactor ); - widget->SetRepresentation( rep ); - - // Let some interaction - interactor->Initialize( ); - window->Render( ); - widget->On( ); - interactor->Start( ); - - // Configure observer - TObserver::Pointer obs = TObserver::New( ); - obs->SetImage( dist_filter->GetOutput( ), window ); - - // Configure membership function - TScalarFunction::Pointer cost_function = TScalarFunction::New( ); - - // Configure algorithm - TExtractor::Pointer algorithm = TExtractor::New( ); - for( unsigned int s = 0; s < rep->GetNumberOfSeeds( ); s++ ) - { - double pos[ 3 ]; - rep->GetSeedWorldPosition( s, pos ); - - TImage::PointType pnt; - pnt[ 0 ] = pos[ 0 ]; - pnt[ 1 ] = pos[ 1 ]; - - TImage::IndexType idx; - if( input_image->TransformPhysicalPointToIndex( pnt, idx ) ) - { - algorithm->AddSeed( idx, 0 ); - if( s == 0 ) - algorithm->SetRoot( idx ); - else - algorithm->AddLeaf( idx ); - - } // fi - - } // rof - algorithm->AddObserver( itk::AnyEvent( ), obs ); - algorithm->ThrowEventsOn( ); - algorithm->SetInput( dist_filter->GetOutput( ) ); - algorithm->SetNeighborhoodOrder( 1 ); - algorithm->SetStopAtOneFront( stop_at_one_front ); - algorithm->SetCostConversion( cost_function ); - algorithm->Update( ); - - // Create image with tree - TPixel transparent_color[] = { 0, 0, 0, 0 }; - TPixel solid_color[] = { 255, 255, 0, 255 }; - TRGBAImage::Pointer tree_image = TRGBAImage::New( ); - tree_image->CopyInformation( input_image ); - tree_image->SetRequestedRegionToLargestPossibleRegion( ); - tree_image->SetBufferedRegion( tree_image->GetRequestedRegion( ) ); - tree_image->Allocate( ); - tree_image->FillBuffer( TRGBAPixel( transparent_color ) ); - - const TExtractor::TTree& tree = algorithm->GetTree( ); - TExtractor::TTree::const_iterator tIt = tree.begin( ); - for( ; tIt != tree.end( ); ++tIt ) - tree_image->SetPixel( tIt->first, TRGBAPixel( solid_color ) ); - - TVTKRGBAImage::Pointer vtk_tree_image = TVTKRGBAImage::New( ); - vtk_tree_image->SetInput( tree_image ); - vtk_tree_image->Update( ); - - vtkSmartPointer< vtkImageActor > tree_actor = - vtkSmartPointer< vtkImageActor >::New( ); - tree_actor->SetInputData( vtk_tree_image->GetOutput( ) ); - - renderer->AddActor( tree_actor ); - window->Render( ); - - // One last interaction - interactor->Start( ); - - return( 0 ); -} - -// eof - $RCSfile$ diff --git a/appli/examples/example_ImageAlgorithmDijkstra_03.cxx b/appli/examples/example_ImageAlgorithmDijkstra_03.cxx deleted file mode 100644 index 9f529f1..0000000 --- a/appli/examples/example_ImageAlgorithmDijkstra_03.cxx +++ /dev/null @@ -1,304 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -// ------------------------------------------------------------------------- -const unsigned int Dim = 3; -typedef float TPixel; -typedef float TScalar; -typedef itk::Image< TPixel, Dim > TImage; -typedef itk::ImageToVTKImageFilter< TImage > TVTKImage; - -typedef itk::ImageFileReader< TImage > TImageReader; -typedef itk::ImageFileWriter< TImage > TImageWriter; -typedef fpa::Image::DijkstraWithSphereBacktracking< TImage, TScalar > TDijkstra; - -typedef fpa::VTK::ImageMPR TMPR; -typedef fpa::VTK::Image3DObserver< TDijkstra, vtkRenderWindow > TDijkstraObs; - -struct TBranch -{ - double Length; - TImage::PointType::VectorType V1; - TImage::PointType::VectorType V2; - - bool operator<( const TBranch& other ) const - { - return( other.Length < this->Length ); - } -}; -typedef std::multiset< TBranch > TBranches; - -// ------------------------------------------------------------------------- -int main( int argc, char* argv[] ) -{ - if( argc < 8 ) - { - std::cerr - << "Usage: " << argv[ 0 ] - << " input_image x y z output_image output_imagej output_vtk" - << " visual_debug" - << std::endl; - return( 1 ); - - } // fi - std::string input_image_fn = argv[ 1 ]; - TImage::PointType seed_pnt; - seed_pnt[ 0 ] = std::atof( argv[ 2 ] ); - seed_pnt[ 1 ] = std::atof( argv[ 3 ] ); - seed_pnt[ 2 ] = std::atof( argv[ 4 ] ); - std::string output_image_fn = argv[ 5 ]; - std::string output_imagej_fn = argv[ 6 ]; - std::string output_vtk_fn = argv[ 7 ]; - bool visual_debug = false; - if( argc > 8 ) - visual_debug = ( std::atoi( argv[ 8 ] ) == 1 ); - - // Read image - TImageReader::Pointer input_image_reader = TImageReader::New( ); - input_image_reader->SetFileName( input_image_fn ); - try - { - input_image_reader->Update( ); - } - catch( itk::ExceptionObject& err ) - { - std::cerr << "Error caught: " << err << std::endl; - return( 1 ); - - } // yrt - TImage::ConstPointer input_image = input_image_reader->GetOutput( ); - - // Show image - TVTKImage::Pointer vtk_image = TVTKImage::New( ); - vtk_image->SetInput( input_image ); - vtk_image->Update( ); - - TMPR view; - view.SetBackground( 0.3, 0.2, 0.8 ); - view.SetSize( 800, 800 ); - view.SetImage( vtk_image->GetOutput( ) ); - - /* TODO - vtkSmartPointer< vtkImageMarchingCubes > mc = - vtkSmartPointer< vtkImageMarchingCubes >::New( ); - mc->SetInputData( vtk_image->GetOutput( ) ); - mc->SetValue( 0, 1e-2 ); - mc->Update( ); - view.AddPolyData( mc->GetOutput( ), 1, 1, 1, 0.4 ); - */ - - // Allow some interaction - view.Render( ); - if( visual_debug ) - view.Start( ); - - TImage::IndexType seed_idx; - input_image->TransformPhysicalPointToIndex( seed_pnt, seed_idx ); - /* TODO - std::cout << seed_idx << " " << seed_pnt << std::endl; - seed_idx[ 0 ] = 256; - seed_idx[ 1 ] = 313; - seed_idx[ 2 ] = 381; - */ - - // Extract paths - TDijkstra::Pointer paths = TDijkstra::New( ); - paths->AddSeed( seed_idx, TScalar( 0 ) ); - paths->SetInput( input_image ); - paths->SetNeighborhoodOrder( 2 ); - - if( visual_debug ) - { - // Configure observer - TDijkstraObs::Pointer obs = TDijkstraObs::New( ); - obs->SetRenderWindow( view.GetWindow( ) ); - paths->AddObserver( itk::AnyEvent( ), obs ); - paths->ThrowEventsOn( ); - } - else - paths->ThrowEventsOff( ); - std::clock_t start = std::clock( ); - paths->Update( ); - std::clock_t end = std::clock( ); - double seconds = double( end - start ) / double( CLOCKS_PER_SEC ); - std::cout << "Paths extraction time = " << seconds << std::endl; - - // Create polydata - vtkSmartPointer< vtkPoints > points = - vtkSmartPointer< vtkPoints >::New( ); - vtkSmartPointer< vtkCellArray > cells = - vtkSmartPointer< vtkCellArray >::New( ); - vtkSmartPointer< vtkFloatArray > scalars = - vtkSmartPointer< vtkFloatArray >::New( ); - - TDijkstra::TMarkImage::Pointer new_marks = TDijkstra::TMarkImage::New( ); - new_marks->SetLargestPossibleRegion( input_image->GetLargestPossibleRegion( ) ); - new_marks->SetRequestedRegion( input_image->GetRequestedRegion( ) ); - new_marks->SetBufferedRegion( input_image->GetBufferedRegion( ) ); - new_marks->SetOrigin( input_image->GetOrigin( ) ); - new_marks->SetSpacing( input_image->GetSpacing( ) ); - new_marks->SetDirection( input_image->GetDirection( ) ); - new_marks->Allocate( ); - new_marks->FillBuffer( 0 ); - - const TDijkstra::TMarkImage* marks = paths->GetOutputMarkImage( ); - TDijkstra::TMark max_mark = paths->GetNumberOfBranches( ); - const TDijkstra::TVertices& endpoints = paths->GetEndPoints( ); - const TDijkstra::TVertices& bifurcations = paths->GetBifurcationPoints( ); - const TDijkstra::TTree& tree = paths->GetFullTree( ); - const TDijkstra::TTree& reduced_tree = paths->GetReducedTree( ); - TDijkstra::TVertices::const_iterator epIt = endpoints.begin( ); - - TBranches branches; - TImage::PointType ori = input_image->GetOrigin( ); - - TDijkstra::TTree::const_iterator rIt = reduced_tree.begin( ); - for( ; rIt != reduced_tree.end( ); ++rIt ) - { - TDijkstra::TTree::const_iterator tIt = tree.find( rIt->first ); - - // Prepare branch "a la ImageJ" - TBranch branch; - TImage::PointType p1, p2; - input_image->TransformIndexToPhysicalPoint( rIt->second.first, p1 ); - input_image->TransformIndexToPhysicalPoint( rIt->first, p2 ); - branch.V1 = p1 - ori; - branch.V2 = p2 - ori; - branch.Length = double( 0 ); - - double pd = - ( double( tIt->second.second ) - double( 1 ) ) / - ( double( max_mark ) - double( 1 ) ); - bool start = true; - TImage::PointType prev; - do - { - TDijkstra::TVertex idx = tIt->first; - new_marks->SetPixel( idx, 255 ); - TImage::PointType pnt; - input_image->TransformIndexToPhysicalPoint( idx, pnt ); - points->InsertNextPoint( pnt[ 0 ], pnt[ 1 ], pnt[ 2 ] ); - scalars->InsertNextTuple1( pd ); - if( !start ) - { - cells->InsertNextCell( 2 ); - cells->InsertCellPoint( points->GetNumberOfPoints( ) - 2 ); - cells->InsertCellPoint( points->GetNumberOfPoints( ) - 1 ); - branch.Length += prev.EuclideanDistanceTo( pnt ); - - } // fi - start = false; - prev = pnt; - tIt = tree.find( tIt->second.first ); - - } while( tIt->first != rIt->second.first ); - - // Last point - TDijkstra::TVertex idx = tIt->first; - new_marks->SetPixel( idx, 255 ); - TImage::PointType pnt; - input_image->TransformIndexToPhysicalPoint( idx, pnt ); - points->InsertNextPoint( pnt[ 0 ], pnt[ 1 ], pnt[ 2 ] ); - scalars->InsertNextTuple1( pd ); - if( !start ) - { - cells->InsertNextCell( 2 ); - cells->InsertCellPoint( points->GetNumberOfPoints( ) - 2 ); - cells->InsertCellPoint( points->GetNumberOfPoints( ) - 1 ); - branch.Length += prev.EuclideanDistanceTo( pnt ); - - } // fi - branches.insert( branch ); - - } // rof - - std::ofstream bout( output_imagej_fn.c_str( ) ); - if( !bout ) - { - std::cerr << "Error: could not open " << output_imagej_fn << std::endl; - return( 1 ); - - } // fi - int i = 1; - for( TBranches::const_iterator bIt = branches.begin( ); bIt != branches.end( ); ++bIt, ++i ) - { - bout - << std::setiosflags( std::ios::fixed) << std::setprecision( 3 ) - << i << "\t1.000\t" - << bIt->Length << "\t" - << bIt->V1[ 0 ] << "\t" - << bIt->V1[ 1 ] << "\t" - << bIt->V1[ 2 ] << "\t" - << bIt->V2[ 0 ] << "\t" - << bIt->V2[ 1 ] << "\t" - << bIt->V2[ 2 ] << "\t" - << ( bIt->V2 - bIt->V1 ).GetNorm( ) - << std::endl; - - } // rof - bout.close( ); - - vtkSmartPointer< vtkPolyData > vtk_tree = - vtkSmartPointer< vtkPolyData >::New( ); - vtk_tree->SetPoints( points ); - vtk_tree->SetLines( cells ); - vtk_tree->GetPointData( )->SetScalars( scalars ); - - view.AddPolyData( vtk_tree ); - view.Render( ); - if( visual_debug ) - view.Start( ); - - vtkSmartPointer< vtkPolyDataWriter > writer = - vtkSmartPointer< vtkPolyDataWriter >::New( ); - writer->SetInputData( vtk_tree ); - writer->SetFileName( output_vtk_fn.c_str( ) ); - writer->Update( ); - - itk::ImageFileWriter< TDijkstra::TMarkImage >::Pointer marks_writer = - itk::ImageFileWriter< TDijkstra::TMarkImage >::New( ); - marks_writer->SetInput( new_marks ); - marks_writer->SetFileName( output_image_fn ); - marks_writer->Update( ); - - TImageWriter::Pointer dijkstra_writer = - TImageWriter::New( ); - dijkstra_writer->SetInput( paths->GetOutput( ) ); - dijkstra_writer->SetFileName( "dijkstra.mhd" ); - dijkstra_writer->Update( ); - - return( 0 ); -} - -// eof - $RCSfile$ diff --git a/appli/examples/example_ImageAlgorithmFastMarching_00.cxx b/appli/examples/example_ImageAlgorithmFastMarching_00.cxx deleted file mode 100644 index 1573ce6..0000000 --- a/appli/examples/example_ImageAlgorithmFastMarching_00.cxx +++ /dev/null @@ -1,44 +0,0 @@ -#include -#include - -#include - -// ------------------------------------------------------------------------- -const unsigned int Dim = 2; -typedef unsigned char TPixel; -typedef double TCost; -typedef itk::Image< TPixel, Dim > TImage; - -typedef fpa::Image::FastMarching< TImage, TCost > TFrontAlgorithm; - -// ------------------------------------------------------------------------- -int main( int argc, char* argv[] ) -{ - // Create a dummy image - TImage::SizeType imageSize; - imageSize.Fill( 100 ); - - TImage::SpacingType imageSpacing; - imageSpacing.Fill( 1 ); - - TImage::Pointer image = TImage::New( ); - image->SetRegions( imageSize ); - image->SetSpacing( imageSpacing ); - image->Allocate( ); - image->FillBuffer( TPixel( 1 ) ); - - // Seed - TImage::IndexType seed; - seed.Fill( 50 ); - - // Configure algorithm - TFrontAlgorithm::Pointer algorithm = TFrontAlgorithm::New( ); - algorithm->AddSeed( seed, TCost( 0 ) ); - algorithm->SetInput( image ); - algorithm->SetNeighborhoodOrder( 1 ); - algorithm->Update( ); - - return( 0 ); -} - -// eof - $RCSfile$ diff --git a/appli/examples/example_ImageAlgorithmFastMarching_01.cxx b/appli/examples/example_ImageAlgorithmFastMarching_01.cxx deleted file mode 100644 index cfa306f..0000000 --- a/appli/examples/example_ImageAlgorithmFastMarching_01.cxx +++ /dev/null @@ -1,152 +0,0 @@ -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -// ------------------------------------------------------------------------- -const unsigned int Dim = 2; -typedef unsigned char TPixel; -typedef double TScalar; -typedef itk::Image< TPixel, Dim > TImage; -typedef itk::ImageToVTKImageFilter< TImage > TVTKImage; - -typedef itk::ImageFileReader< TImage > TImageReader; -typedef fpa::Image::FastMarching< TImage, TScalar > TFrontAlgorithm; - -typedef -fpa::VTK::Image2DObserver< TFrontAlgorithm, vtkRenderWindow > -TObserver; - -// ------------------------------------------------------------------------- -int main( int argc, char* argv[] ) -{ - if( argc < 2 ) - { - std::cerr - << "Usage: " << argv[ 0 ] - << " input_image [stop_at_one_front]" << std::endl; - return( 1 ); - - } // fi - std::string input_image_fn = argv[ 1 ]; - bool stop_at_one_front = false; - if( 2 < argc ) - stop_at_one_front = ( std::atoi( argv[ 2 ] ) == 1 ); - - // Read image - TImageReader::Pointer input_image_reader = TImageReader::New( ); - input_image_reader->SetFileName( input_image_fn ); - try - { - input_image_reader->Update( ); - } - catch( itk::ExceptionObject& err ) - { - std::cerr << "Error caught: " << err << std::endl; - return( 1 ); - - } // yrt - TImage::ConstPointer input_image = input_image_reader->GetOutput( ); - - TVTKImage::Pointer vtk_image = TVTKImage::New( ); - vtk_image->SetInput( input_image ); - vtk_image->Update( ); - - // VTK visualization - vtkSmartPointer< vtkImageActor > actor = - vtkSmartPointer< vtkImageActor >::New( ); - actor->SetInputData( vtk_image->GetOutput( ) ); - - vtkSmartPointer< vtkRenderer > renderer = - vtkSmartPointer< vtkRenderer >::New( ); - renderer->SetBackground( 0.1, 0.2, 0.7 ); - renderer->AddActor( actor ); - vtkSmartPointer< vtkRenderWindow > window = - vtkSmartPointer< vtkRenderWindow >::New( ); - window->SetSize( 800, 800 ); - window->AddRenderer( renderer ); - - // VTK interaction - vtkSmartPointer< vtkInteractorStyleImage > imageStyle = - vtkSmartPointer< vtkInteractorStyleImage >::New( ); - vtkSmartPointer< vtkRenderWindowInteractor > interactor = - vtkSmartPointer< vtkRenderWindowInteractor >::New( ); - interactor->SetInteractorStyle( imageStyle ); - window->SetInteractor( interactor ); - window->Render( ); - - // Create the widget and its representation - vtkSmartPointer< vtkPointHandleRepresentation3D > handle = - vtkSmartPointer< vtkPointHandleRepresentation3D >::New( ); - handle->GetProperty( )->SetColor( 1, 0, 0 ); - vtkSmartPointer< vtkSeedRepresentation > rep = - vtkSmartPointer< vtkSeedRepresentation >::New( ); - rep->SetHandleRepresentation( handle ); - - vtkSmartPointer< vtkSeedWidget > widget = - vtkSmartPointer< vtkSeedWidget >::New( ); - widget->SetInteractor( interactor ); - widget->SetRepresentation( rep ); - - // Let some interaction - interactor->Initialize( ); - window->Render( ); - widget->On( ); - interactor->Start( ); - - // Configure observer - TObserver::Pointer obs = TObserver::New( ); - obs->SetImage( input_image, window ); - - // Configure algorithm - TFrontAlgorithm::Pointer algorithm = TFrontAlgorithm::New( ); - for( unsigned int s = 0; s < rep->GetNumberOfSeeds( ); s++ ) - { - double pos[ 3 ]; - rep->GetSeedWorldPosition( s, pos ); - - TImage::PointType pnt; - pnt[ 0 ] = pos[ 0 ]; - pnt[ 1 ] = pos[ 1 ]; - - TImage::IndexType idx; - if( input_image->TransformPhysicalPointToIndex( pnt, idx ) ) - { - algorithm->AddSeed( idx, 0 ); - std::cout << " Seed --> " << idx << std::endl; - - } // fi - - } // rof - algorithm->AddObserver( itk::AnyEvent( ), obs ); - algorithm->ThrowEventsOn( ); - algorithm->SetInput( input_image ); - algorithm->SetNeighborhoodOrder( 1 ); - algorithm->SetStopAtOneFront( stop_at_one_front ); - algorithm->Update( ); - - // One last interaction - window->Render( ); - interactor->Start( ); - - return( 0 ); -} - -// eof - $RCSfile$ diff --git a/appli/examples/example_ImageAlgorithmRegionGrow_00.cxx b/appli/examples/example_ImageAlgorithmRegionGrow_00.cxx deleted file mode 100644 index 149977a..0000000 --- a/appli/examples/example_ImageAlgorithmRegionGrow_00.cxx +++ /dev/null @@ -1,51 +0,0 @@ -#include -#include - -#include -#include - -// ------------------------------------------------------------------------- -const unsigned int Dim = 2; -typedef unsigned char TPixel; -typedef itk::Image< TPixel, Dim > TImage; - -typedef fpa::Image::RegionGrow< TImage > TFrontAlgorithm; -typedef -fpa::Image::Functors::RegionGrowAllBelongsFunction< TImage > -TMembershipFunction; - -// ------------------------------------------------------------------------- -int main( int argc, char* argv[] ) -{ - // Create a dummy image - TImage::SizeType imageSize; - imageSize.Fill( 10 ); - - TImage::SpacingType imageSpacing; - imageSpacing.Fill( 1 ); - - TImage::Pointer image = TImage::New( ); - image->SetRegions( imageSize ); - image->SetSpacing( imageSpacing ); - image->Allocate( ); - image->FillBuffer( TPixel( 1 ) ); - - // Seed - TImage::IndexType seed; - seed.Fill( 5 ); - - // Configure membership function - TMembershipFunction::Pointer membership = TMembershipFunction::New( ); - - // Configure algorithm - TFrontAlgorithm::Pointer algorithm = TFrontAlgorithm::New( ); - algorithm->AddSeed( seed, 0 ); - algorithm->SetInput( image ); - algorithm->SetNeighborhoodOrder( 1 ); - algorithm->SetMembershipFunction( membership ); - algorithm->Update( ); - - return( 0 ); -} - -// eof - $RCSfile$ diff --git a/appli/examples/example_ImageAlgorithmRegionGrow_01.cxx b/appli/examples/example_ImageAlgorithmRegionGrow_01.cxx deleted file mode 100644 index e41b65d..0000000 --- a/appli/examples/example_ImageAlgorithmRegionGrow_01.cxx +++ /dev/null @@ -1,157 +0,0 @@ -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -// ------------------------------------------------------------------------- -const unsigned int Dim = 2; -typedef unsigned char TPixel; -typedef double TScalar; -typedef itk::Image< TPixel, Dim > TImage; -typedef itk::ImageToVTKImageFilter< TImage > TVTKImage; - -typedef itk::ImageFileReader< TImage > TImageReader; -typedef fpa::Image::RegionGrow< TImage > TFrontAlgorithm; - -typedef -fpa::Image::Functors::RegionGrowThresholdFunction< TImage > -TMembershipFunction; - -typedef -fpa::VTK::Image2DObserver< TFrontAlgorithm, vtkRenderWindow > -TObserver; - -// ------------------------------------------------------------------------- -int main( int argc, char* argv[] ) -{ - if( argc < 4 ) - { - std::cerr - << "Usage: " << argv[ 0 ] - << " input_image lower_threshold upper_threshold" << std::endl; - return( 1 ); - - } // fi - std::string input_image_fn = argv[ 1 ]; - TPixel lower_threshold = TPixel( std::atof( argv[ 2 ] ) ); - TPixel upper_threshold = TPixel( std::atof( argv[ 3 ] ) ); - - // Read image - TImageReader::Pointer input_image_reader = TImageReader::New( ); - input_image_reader->SetFileName( input_image_fn ); - try - { - input_image_reader->Update( ); - } - catch( itk::ExceptionObject& err ) - { - std::cerr << "Error caught: " << err << std::endl; - return( 1 ); - - } // yrt - TImage::ConstPointer input_image = input_image_reader->GetOutput( ); - - TVTKImage::Pointer vtk_image = TVTKImage::New( ); - vtk_image->SetInput( input_image ); - vtk_image->Update( ); - - // VTK visualization - vtkSmartPointer< vtkImageActor > actor = - vtkSmartPointer< vtkImageActor >::New( ); - actor->SetInputData( vtk_image->GetOutput( ) ); - - vtkSmartPointer< vtkRenderer > renderer = - vtkSmartPointer< vtkRenderer >::New( ); - renderer->SetBackground( 0.1, 0.2, 0.7 ); - renderer->AddActor( actor ); - vtkSmartPointer< vtkRenderWindow > window = - vtkSmartPointer< vtkRenderWindow >::New( ); - window->SetSize( 800, 800 ); - window->AddRenderer( renderer ); - - // VTK interaction - vtkSmartPointer< vtkInteractorStyleImage > imageStyle = - vtkSmartPointer< vtkInteractorStyleImage >::New( ); - vtkSmartPointer< vtkRenderWindowInteractor > interactor = - vtkSmartPointer< vtkRenderWindowInteractor >::New( ); - interactor->SetInteractorStyle( imageStyle ); - window->SetInteractor( interactor ); - window->Render( ); - - // Create the widget and its representation - vtkSmartPointer< vtkPointHandleRepresentation3D > handle = - vtkSmartPointer< vtkPointHandleRepresentation3D >::New( ); - handle->GetProperty( )->SetColor( 1, 0, 0 ); - vtkSmartPointer< vtkSeedRepresentation > rep = - vtkSmartPointer< vtkSeedRepresentation >::New( ); - rep->SetHandleRepresentation( handle ); - - vtkSmartPointer< vtkSeedWidget > widget = - vtkSmartPointer< vtkSeedWidget >::New( ); - widget->SetInteractor( interactor ); - widget->SetRepresentation( rep ); - - // Let some interaction - interactor->Initialize( ); - window->Render( ); - widget->On( ); - interactor->Start( ); - - // Configure observer - TObserver::Pointer obs = TObserver::New( ); - obs->SetImage( input_image, window ); - - // Configure membership function - TMembershipFunction::Pointer membership = TMembershipFunction::New( ); - membership->SetLowerThreshold( lower_threshold ); - membership->SetUpperThreshold( upper_threshold ); - - // Configure algorithm - TFrontAlgorithm::Pointer algorithm = TFrontAlgorithm::New( ); - for( unsigned int s = 0; s < rep->GetNumberOfSeeds( ); s++ ) - { - double pos[ 3 ]; - rep->GetSeedWorldPosition( s, pos ); - - TImage::PointType pnt; - pnt[ 0 ] = TScalar( pos[ 0 ] ); - pnt[ 1 ] = TScalar( pos[ 1 ] ); - - TImage::IndexType idx; - if( input_image->TransformPhysicalPointToIndex( pnt, idx ) ) - algorithm->AddSeed( idx, 0 ); - - } // rof - algorithm->AddObserver( itk::AnyEvent( ), obs ); - algorithm->ThrowEventsOn( ); - algorithm->SetInput( input_image ); - algorithm->SetNeighborhoodOrder( 1 ); - algorithm->SetMembershipFunction( membership ); - algorithm->Update( ); - - // One last interaction - interactor->Start( ); - - return( 0 ); -} - -// eof - $RCSfile$ diff --git a/appli/examples/example_ImageAlgorithmRegionGrow_MultipleThresholds.cxx b/appli/examples/example_ImageAlgorithmRegionGrow_MultipleThresholds.cxx deleted file mode 100644 index d2f6b2a..0000000 --- a/appli/examples/example_ImageAlgorithmRegionGrow_MultipleThresholds.cxx +++ /dev/null @@ -1,168 +0,0 @@ -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -// ------------------------------------------------------------------------- -const unsigned int Dim = 3; -typedef short TPixel; -typedef double TScalar; -typedef itk::Image< TPixel, Dim > TImage; -typedef itk::ImageToVTKImageFilter< TImage > TVTKImage; - -typedef itk::ImageFileReader< TImage > TImageReader; -typedef itk::ImageFileWriter< TImage > TImageWriter; - -typedef -fpa::Image::RegionGrowWithMultipleThresholds< TImage > -TFrontAlgorithm; -typedef -fpa::VTK::Image3DObserver< TFrontAlgorithm, vtkRenderWindow > -TObserver; - -// ------------------------------------------------------------------------- -int main( int argc, char* argv[] ) -{ - if( argc < 6 ) - { - std::cerr - << "Usage: " << argv[ 0 ] - << " input_image thr_0 thr_1 step output_image" - << " visual_debug" - << std::endl; - return( 1 ); - - } // fi - std::string input_image_fn = argv[ 1 ]; - TPixel thr_0 = TPixel( std::atof( argv[ 2 ] ) ); - TPixel thr_1 = TPixel( std::atof( argv[ 3 ] ) ); - unsigned int step = std::atoi( argv[ 4 ] ); - std::string output_image_fn = argv[ 5 ]; - bool visual_debug = false; - if( argc > 6 ) - visual_debug = ( std::atoi( argv[ 6 ] ) == 1 ); - - // Read image - TImageReader::Pointer input_image_reader = TImageReader::New( ); - input_image_reader->SetFileName( input_image_fn ); - try - { - input_image_reader->Update( ); - } - catch( itk::ExceptionObject& err ) - { - std::cerr << "Error caught: " << err << std::endl; - return( 1 ); - - } // yrt - TImage::ConstPointer input_image = input_image_reader->GetOutput( ); - TImage::SpacingType spac = input_image->GetSpacing( ); - double min_spac = spac[ 0 ]; - for( unsigned int d = 1; d < Dim; d++ ) - min_spac = ( spac[ d ] < min_spac )? spac[ d ]: min_spac; - - TVTKImage::Pointer vtk_image = TVTKImage::New( ); - vtk_image->SetInput( input_image ); - vtk_image->Update( ); - - fpa::VTK::ImageMPR view; - view.SetBackground( 0.3, 0.2, 0.8 ); - view.SetSize( 800, 800 ); - view.SetImage( vtk_image->GetOutput( ) ); - - // Wait for a seed to be given - while( view.GetNumberOfSeeds( ) == 0 ) - view.Start( ); - - // Convert seed - double seed[ 3 ]; - view.GetSeed( 0, seed ); - TImage::PointType seed_pnt; - seed_pnt[ 0 ] = seed[ 0 ]; - seed_pnt[ 1 ] = seed[ 1 ]; - seed_pnt[ 2 ] = seed[ 2 ]; - TImage::IndexType seed_idx; - input_image->TransformPhysicalPointToIndex( seed_pnt, seed_idx ); - - // Configure algorithm - TFrontAlgorithm::Pointer algorithm = TFrontAlgorithm::New( ); - algorithm->AddThresholds( thr_0, thr_1, step ); - algorithm->AddSeed( seed_idx, 0 ); - algorithm->SetInput( input_image ); - algorithm->SetNeighborhoodOrder( 1 ); - algorithm->SetDifferenceThreshold( double( 3 ) ); - algorithm->SetInsideValue( 0 ); - algorithm->SetOutsideValue( 1 ); - - if( visual_debug ) - { - // Configure observer - TObserver::Pointer obs = TObserver::New( ); - obs->SetRenderWindow( view.GetWindow( ) ); - algorithm->AddObserver( itk::AnyEvent( ), obs ); - algorithm->ThrowEventsOn( ); - } - else - algorithm->ThrowEventsOff( ); - - std::clock_t start = std::clock( ); - algorithm->Update( ); - std::clock_t end = std::clock( ); - double seconds = double( end - start ) / double( CLOCKS_PER_SEC ); - std::cout << "Execution time = " << seconds << std::endl; - - // Show result - TVTKImage::Pointer output_image_vtk = TVTKImage::New( ); - output_image_vtk->SetInput( algorithm->GetOutput( ) ); - output_image_vtk->Update( ); - - vtkSmartPointer< vtkImageMarchingCubes > mc = - vtkSmartPointer< vtkImageMarchingCubes >::New( ); - mc->SetInputData( output_image_vtk->GetOutput( ) ); - mc->SetValue( - 0, - double( algorithm->GetInsideValue( ) ) * double( 0.95 ) - ); - mc->Update( ); - - // Let some interaction and close program - view.AddPolyData( mc->GetOutput( ), 0.1, 0.6, 0.8, 0.5 ); - view.Start( ); - - // Write resulting image - TImageWriter::Pointer output_image_writer = TImageWriter::New( ); - output_image_writer->SetInput( algorithm->GetOutput( ) ); - output_image_writer->SetFileName( output_image_fn ); - try - { - output_image_writer->Update( ); - } - catch( itk::ExceptionObject& err ) - { - std::cerr << "Error caught: " << err << std::endl; - return( 1 ); - - } // yrt - return( 0 ); -} - -// eof - $RCSfile$ diff --git a/appli/examples/example_ImageAlgorithm_Skeletonization.cxx b/appli/examples/example_ImageAlgorithm_Skeletonization.cxx deleted file mode 100644 index 22b85e7..0000000 --- a/appli/examples/example_ImageAlgorithm_Skeletonization.cxx +++ /dev/null @@ -1,257 +0,0 @@ -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include - -// ------------------------------------------------------------------------- -const unsigned int Dim = 3; -typedef short TPixel; -typedef float TScalar; -typedef itk::Image< TPixel, Dim > TImage; -typedef itk::Image< TScalar, Dim > TDistanceMap; -typedef itk::ImageToVTKImageFilter< TImage > TVTKImage; -typedef itk::ImageToVTKImageFilter< TDistanceMap > TVTKDistanceMap; - -typedef itk::ImageFileReader< TImage > TImageReader; -typedef itk::ImageFileWriter< TImage > TImageWriter; -typedef itk::ImageFileWriter< TDistanceMap > TDistanceMapWriter; -typedef fpa::Image::RegionGrowWithMultipleThresholds< TImage > TSegmentor; -typedef -itk::DanielssonDistanceMapImageFilter< TImage, TDistanceMap > -TDistanceFilter; -typedef -fpa::Image::DijkstraWithSphereBacktracking< TDistanceMap, TScalar > -TDijkstra; - -typedef fpa::VTK::ImageMPR TMPR; -typedef fpa::VTK::Image3DObserver< TSegmentor, vtkRenderWindow > TSegmentorObs; -typedef fpa::VTK::Image3DObserver< TDijkstra, vtkRenderWindow > TDijkstraObs; - -// ------------------------------------------------------------------------- -int main( int argc, char* argv[] ) -{ - if( argc < 8 ) - { - std::cerr - << "Usage: " << argv[ 0 ] - << " input_image thr_0 thr_1 step" - << " output_segmentation output_distancemap output_dijkstra" - << " visual_debug" - << std::endl; - return( 1 ); - - } // fi - std::string input_image_fn = argv[ 1 ]; - TPixel thr_0 = TPixel( std::atof( argv[ 2 ] ) ); - TPixel thr_1 = TPixel( std::atof( argv[ 3 ] ) ); - unsigned int step = std::atoi( argv[ 4 ] ); - std::string output_segmentation_fn = argv[ 5 ]; - std::string output_distancemap_fn = argv[ 6 ]; - std::string output_dijkstra_fn = argv[ 7 ]; - bool visual_debug = false; - if( argc > 8 ) - visual_debug = ( std::atoi( argv[ 8 ] ) == 1 ); - - // Read image - TImageReader::Pointer input_image_reader = TImageReader::New( ); - input_image_reader->SetFileName( input_image_fn ); - try - { - input_image_reader->Update( ); - } - catch( itk::ExceptionObject& err ) - { - std::cerr << "Error caught: " << err << std::endl; - return( 1 ); - - } // yrt - TImage::ConstPointer input_image = input_image_reader->GetOutput( ); - - // Show image - TVTKImage::Pointer vtk_image = TVTKImage::New( ); - vtk_image->SetInput( input_image ); - vtk_image->Update( ); - - TMPR view; - view.SetBackground( 0.3, 0.2, 0.8 ); - view.SetSize( 800, 800 ); - view.SetImage( vtk_image->GetOutput( ) ); - - // Wait for a seed to be given - while( view.GetNumberOfSeeds( ) == 0 ) - view.Start( ); - - // Get seed from user - double seed[ 3 ]; - view.GetSeed( 0, seed ); - TImage::PointType seed_pnt; - seed_pnt[ 0 ] = seed[ 0 ]; - seed_pnt[ 1 ] = seed[ 1 ]; - seed_pnt[ 2 ] = seed[ 2 ]; - TImage::IndexType seed_idx; - input_image->TransformPhysicalPointToIndex( seed_pnt, seed_idx ); - - // Segment input image - TSegmentor::Pointer segmentor = TSegmentor::New( ); - segmentor->AddThresholds( thr_0, thr_1, step ); - segmentor->AddSeed( seed_idx, 0 ); - segmentor->SetInput( input_image ); - segmentor->SetNeighborhoodOrder( 1 ); - segmentor->SetDifferenceThreshold( double( 3 ) ); - segmentor->SetInsideValue( TPixel( 0 ) ); // WARNING: This is to optimize - segmentor->SetOutsideValue( TPixel( 1 ) ); // distance map calculation - if( visual_debug ) - { - // Configure observer - TSegmentorObs::Pointer obs = TSegmentorObs::New( ); - obs->SetRenderWindow( view.GetWindow( ) ); - segmentor->AddObserver( itk::AnyEvent( ), obs ); - segmentor->ThrowEventsOn( ); - } - else - segmentor->ThrowEventsOff( ); - std::clock_t start = std::clock( ); - segmentor->Update( ); - std::clock_t end = std::clock( ); - double seconds = double( end - start ) / double( CLOCKS_PER_SEC ); - std::cout << "Segmentation time = " << seconds << std::endl; - - // Extract distance map - TDistanceFilter::Pointer distanceMap = TDistanceFilter::New( ); - distanceMap->SetInput( segmentor->GetOutput( ) ); - distanceMap->InputIsBinaryOn( ); - distanceMap->SquaredDistanceOn( ); - distanceMap->UseImageSpacingOn( ); - start = std::clock( ); - distanceMap->Update( ); - end = std::clock( ); - seconds = double( end - start ) / double( CLOCKS_PER_SEC ); - std::cout << "Distance map time = " << seconds << std::endl; - - TVTKDistanceMap::Pointer vtk_distanceMap = TVTKDistanceMap::New( ); - vtk_distanceMap->SetInput( distanceMap->GetOutput( ) ); - vtk_distanceMap->Update( ); - - vtkSmartPointer< vtkImageMarchingCubes > mc = - vtkSmartPointer< vtkImageMarchingCubes >::New( ); - mc->SetInputData( vtk_distanceMap->GetOutput( ) ); - mc->SetValue( 0, 1e-2 ); - mc->Update( ); - view.AddPolyData( mc->GetOutput( ), 1, 1, 1, 0.4 ); - view.Render( ); - - // Extract paths - TDijkstra::Pointer paths = TDijkstra::New( ); - paths->AddSeed( segmentor->GetSeed( 0 ), TScalar( 0 ) ); - paths->SetInput( distanceMap->GetOutput( ) ); - paths->SetNeighborhoodOrder( 2 ); - - if( visual_debug ) - { - // Configure observer - TDijkstraObs::Pointer obs = TDijkstraObs::New( ); - obs->SetRenderWindow( view.GetWindow( ) ); - paths->AddObserver( itk::AnyEvent( ), obs ); - paths->ThrowEventsOn( ); - } - else - paths->ThrowEventsOff( ); - start = std::clock( ); - paths->Update( ); - end = std::clock( ); - seconds = double( end - start ) / double( CLOCKS_PER_SEC ); - std::cout << "Paths extraction time = " << seconds << std::endl; - - std::cout << "Final seed: " << paths->GetSeed( 0 ) << std::endl; - - // Create polydata - vtkSmartPointer< vtkPoints > points = - vtkSmartPointer< vtkPoints >::New( ); - vtkSmartPointer< vtkCellArray > cells = - vtkSmartPointer< vtkCellArray >::New( ); - vtkSmartPointer< vtkFloatArray > scalars = - vtkSmartPointer< vtkFloatArray >::New( ); - - const TDijkstra::TVertices& endpoints = paths->GetEndPoints( ); - const TDijkstra::TTree& tree = paths->GetFullTree( ); - TDijkstra::TVertices::const_iterator epIt = endpoints.begin( ); - for( unsigned int epId = 0; epIt != endpoints.end( ); ++epIt, ++epId ) - { - double pd = double( epId ) / double( endpoints.size( ) - 1 ); - - TDijkstra::TVertex idx = *epIt; - do - { - TImage::PointType pnt; - input_image->TransformIndexToPhysicalPoint( idx, pnt ); - - points->InsertNextPoint( pnt[ 0 ], pnt[ 1 ], pnt[ 2 ] ); - scalars->InsertNextTuple1( pd ); - if( idx != *epIt ) - { - cells->InsertNextCell( 2 ); - cells->InsertCellPoint( points->GetNumberOfPoints( ) - 2 ); - cells->InsertCellPoint( points->GetNumberOfPoints( ) - 1 ); - - } // fi - idx = tree.find( idx )->second.first; - - } while( idx != tree.find( idx )->second.first ); - - } // rof - - vtkSmartPointer< vtkPolyData > vtk_tree = - vtkSmartPointer< vtkPolyData >::New( ); - vtk_tree->SetPoints( points ); - vtk_tree->SetLines( cells ); - vtk_tree->GetPointData( )->SetScalars( scalars ); - - view.AddPolyData( vtk_tree ); - view.Render( ); - view.Start( ); - - itk::ImageFileWriter< TImage >::Pointer segmentation_writer = - itk::ImageFileWriter< TImage >::New( ); - segmentation_writer->SetInput( segmentor->GetOutput( ) ); - segmentation_writer->SetFileName( output_segmentation_fn ); - - itk::ImageFileWriter< TDistanceMap >::Pointer dmap_writer = - itk::ImageFileWriter< TDistanceMap >::New( ); - dmap_writer->SetInput( distanceMap->GetOutput( ) ); - dmap_writer->SetFileName( output_distancemap_fn ); - - itk::ImageFileWriter< TDistanceMap >::Pointer dijk_writer = - itk::ImageFileWriter< TDistanceMap >::New( ); - dijk_writer->SetInput( paths->GetOutput( ) ); - dijk_writer->SetFileName( output_dijkstra_fn ); - - try - { - segmentation_writer->Update( ); - dmap_writer->Update( ); - dijk_writer->Update( ); - } - catch( itk::ExceptionObject& err ) - { - std::cerr << "Error caught: " << err << std::endl; - return( -1 ); - - } // yrt - - return( 0 ); -} - -// eof - $RCSfile$ diff --git a/appli/examples/example_Image_Dijkstra_AbsoluteDifferenceCost.cxx b/appli/examples/example_Image_Dijkstra_AbsoluteDifferenceCost.cxx deleted file mode 100644 index 47affc1..0000000 --- a/appli/examples/example_Image_Dijkstra_AbsoluteDifferenceCost.cxx +++ /dev/null @@ -1,164 +0,0 @@ -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -// ------------------------------------------------------------------------- -const unsigned int Dim = 3; -typedef float TInputPixel; -typedef float TOutputPixel; - -typedef itk::Image< TInputPixel, Dim > TInputImage; -typedef itk::Image< TOutputPixel, Dim > TOutputImage; -typedef itk::ImageToVTKImageFilter< TInputImage > TVTKInputImage; - -// ------------------------------------------------------------------------- -int main( int argc, char* argv[] ) -{ - if( argc < 8 ) - { - std::cerr - << "Usage: " << argv[ 0 ] - << " input_image input_seeds output_image" - << " neighborhood_order stop_at_one_front" - << " init_seed end_seed" - << std::endl; - return( 1 ); - - } // fi - std::string input_image_fn = argv[ 1 ]; - std::string input_seeds_fn = argv[ 2 ]; - std::string output_image_fn = argv[ 3 ]; - unsigned int neighborhood_order = std::atoi( argv[ 4 ] ); - bool stop_at_one_front = ( std::atoi( argv[ 5 ] ) != 0 ); - unsigned int init_seed = std::atoi( argv[ 6 ] ); - unsigned int end_seed = std::atoi( argv[ 7 ] ); - - // Read image - itk::ImageFileReader< TInputImage >::Pointer input_image_reader = - itk::ImageFileReader< TInputImage >::New( ); - input_image_reader->SetFileName( input_image_fn ); - try - { - input_image_reader->Update( ); - } - catch( itk::ExceptionObject& err ) - { - std::cerr - << "Error while reading image from " << input_image_fn << ": " - << err << std::endl; - return( 1 ); - - } // yrt - TInputImage::ConstPointer input_image = input_image_reader->GetOutput( ); - TVTKInputImage::Pointer vtk_input_image = TVTKInputImage::New( ); - vtk_input_image->SetInput( input_image ); - vtk_input_image->Update( ); - - // Show input image and let some interaction - fpa::VTK::ImageMPR view; - view.SetBackground( 0.3, 0.2, 0.8 ); - view.SetSize( 600, 600 ); - view.SetImage( vtk_input_image->GetOutput( ) ); - - // Allow some interaction - view.Render( ); - view.Start( ); - - // Prepare region grow filter and cost function - typedef fpa::Image::Dijkstra< TInputImage, TOutputImage > TFilter; - typedef fpa::Image::Functors:: - ImageAbsoluteDifferenceCostFunction< TFilter::TInputImage, TFilter::TResult > - TCost; - - TCost::Pointer cost = TCost::New( ); - - TFilter::Pointer filter = TFilter::New( ); - filter->SetInput( input_image ); - filter->SetCostFunction( cost ); - filter->SetConversionFunction( NULL ); - filter->SetNeighborhoodOrder( neighborhood_order ); - filter->SetStopAtOneFront( stop_at_one_front ); - - // Get user-given seeds - std::ifstream input_seeds_str( input_seeds_fn.c_str( ) ); - if( !input_seeds_str ) - { - std::cerr << "Error opening \"" << input_seeds_fn << "\"" << std::endl; - return( 1 ); - - } // fi - - unsigned int nSeeds; - input_seeds_str >> nSeeds; - std::vector< TInputImage::IndexType > input_seeds; - for( unsigned int s = 0; s < nSeeds; s++ ) - { - TInputImage::IndexType idx; - input_seeds_str >> idx[ 0 ] >> idx[ 1 ] >> idx[ 2 ]; - input_seeds.push_back( idx ); - - } // rof - input_seeds_str.close( ); - - filter->AddSeed( input_seeds[ init_seed ], 0 ); - filter->AddSeed( input_seeds[ end_seed ], 0 ); - - // Prepare graphical debugger - typedef fpa::VTK::Image3DObserver< TFilter, vtkRenderWindow > TDebugger; - TDebugger::Pointer debugger = TDebugger::New( ); - debugger->SetRenderWindow( view.GetWindow( ) ); - debugger->SetRenderPercentage( 0.0001 ); - filter->AddObserver( itk::AnyEvent( ), debugger ); - filter->ThrowEventsOn( ); - - // Go! - filter->Update( ); - - // Save final total cost map - itk::ImageFileWriter< TOutputImage >::Pointer output_image_writer = - itk::ImageFileWriter< TOutputImage >::New( ); - output_image_writer->SetFileName( output_image_fn ); - output_image_writer->SetInput( filter->GetOutput( ) ); - try - { - output_image_writer->Update( ); - } - catch( itk::ExceptionObject& err ) - { - std::cerr - << "Error while writing image to " << output_image_fn << ": " - << err << std::endl; - return( 1 ); - - } // yrt - - return( 0 ); -} - -// eof - $RCSfile$ diff --git a/appli/examples/example_Image_Dijkstra_CostFromInput.cxx b/appli/examples/example_Image_Dijkstra_CostFromInput.cxx deleted file mode 100644 index 65003e2..0000000 --- a/appli/examples/example_Image_Dijkstra_CostFromInput.cxx +++ /dev/null @@ -1,177 +0,0 @@ -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -// ------------------------------------------------------------------------- -const unsigned int Dim = 2; -typedef unsigned char TInputPixel; -typedef float TOutputPixel; - -typedef itk::Image< TInputPixel, Dim > TInputImage; -typedef itk::Image< TOutputPixel, Dim > TOutputImage; -typedef itk::ImageToVTKImageFilter< TInputImage > TVTKInputImage; - -// ------------------------------------------------------------------------- -int main( int argc, char* argv[] ) -{ - if( argc < 5 ) - { - std::cerr - << "Usage: " << argv[ 0 ] - << " input_image output_image neighborhood_order stop_at_one_front" - << std::endl; - return( 1 ); - - } // fi - std::string input_image_fn = argv[ 1 ]; - std::string output_image_fn = argv[ 2 ]; - unsigned int neighborhood_order = std::atoi( argv[ 3 ] ); - bool stop_at_one_front = ( std::atoi( argv[ 4 ] ) != 0 ); - - // Read image - itk::ImageFileReader< TInputImage >::Pointer input_image_reader = - itk::ImageFileReader< TInputImage >::New( ); - input_image_reader->SetFileName( input_image_fn ); - try - { - input_image_reader->Update( ); - } - catch( itk::ExceptionObject& err ) - { - std::cerr - << "Error while reading image from " << input_image_fn << ": " - << err << std::endl; - return( 1 ); - - } // yrt - TInputImage::ConstPointer input_image = input_image_reader->GetOutput( ); - TVTKInputImage::Pointer vtk_input_image = TVTKInputImage::New( ); - vtk_input_image->SetInput( input_image ); - vtk_input_image->Update( ); - - // VTK visualization - vtkSmartPointer< vtkImageActor > actor = - vtkSmartPointer< vtkImageActor >::New( ); - actor->SetInputData( vtk_input_image->GetOutput( ) ); - - vtkSmartPointer< vtkRenderer > renderer = - vtkSmartPointer< vtkRenderer >::New( ); - renderer->SetBackground( 0.1, 0.2, 0.7 ); - renderer->AddActor( actor ); - vtkSmartPointer< vtkRenderWindow > window = - vtkSmartPointer< vtkRenderWindow >::New( ); - window->SetSize( 800, 800 ); - window->AddRenderer( renderer ); - - // Correct camera due to the loaded image - vtkCamera* camera = renderer->GetActiveCamera( ); - camera->SetViewUp( 0, -1, 0 ); - camera->SetPosition( 0, 0, -1 ); - camera->SetFocalPoint( 0, 0, 0 ); - - // VTK interaction - vtkSmartPointer< vtkInteractorStyleImage > imageStyle = - vtkSmartPointer< vtkInteractorStyleImage >::New( ); - vtkSmartPointer< vtkRenderWindowInteractor > interactor = - vtkSmartPointer< vtkRenderWindowInteractor >::New( ); - interactor->SetInteractorStyle( imageStyle ); - window->SetInteractor( interactor ); - - // Create the widget and its representation - vtkSmartPointer< vtkPointHandleRepresentation3D > handle = - vtkSmartPointer< vtkPointHandleRepresentation3D >::New( ); - handle->GetProperty( )->SetColor( 1, 0, 0 ); - vtkSmartPointer< vtkSeedRepresentation > rep = - vtkSmartPointer< vtkSeedRepresentation >::New( ); - rep->SetHandleRepresentation( handle ); - - vtkSmartPointer< vtkSeedWidget > widget = - vtkSmartPointer< vtkSeedWidget >::New( ); - widget->SetInteractor( interactor ); - widget->SetRepresentation( rep ); - - // Let some interaction - interactor->Initialize( ); - renderer->ResetCamera( ); - window->Render( ); - widget->On( ); - interactor->Start( ); - - // Prepare region grow filter - typedef fpa::Image::Dijkstra< TInputImage, TOutputImage > TFilter; - TFilter::Pointer filter = TFilter::New( ); - filter->SetInput( input_image ); - filter->SetNeighborhoodOrder( neighborhood_order ); - filter->SetStopAtOneFront( stop_at_one_front ); - - // Get user-given seeds - for( unsigned int s = 0; s < rep->GetNumberOfSeeds( ); s++ ) - { - double pos[ 3 ]; - rep->GetSeedWorldPosition( s, pos ); - - TInputImage::PointType pnt; - pnt[ 0 ] = TInputImage::PointType::ValueType( pos[ 0 ] ); - pnt[ 1 ] = TInputImage::PointType::ValueType( pos[ 1 ] ); - - TInputImage::IndexType idx; - if( input_image->TransformPhysicalPointToIndex( pnt, idx ) ) - filter->AddSeed( idx, 0 ); - - } // rof - - // Prepare graphical debugger - typedef fpa::VTK::Image2DObserver< TFilter, vtkRenderWindow > TDebugger; - TDebugger::Pointer debugger = TDebugger::New( ); - debugger->SetRenderWindow( window ); - debugger->SetRenderPercentage( 0.001 ); - filter->AddObserver( itk::AnyEvent( ), debugger ); - filter->ThrowEventsOn( ); - - // Go! - filter->Update( ); - - // Save final total cost map - itk::ImageFileWriter< TOutputImage >::Pointer output_image_writer = - itk::ImageFileWriter< TOutputImage >::New( ); - output_image_writer->SetFileName( output_image_fn ); - output_image_writer->SetInput( filter->GetOutput( ) ); - try - { - output_image_writer->Update( ); - } - catch( itk::ExceptionObject& err ) - { - std::cerr - << "Error while writing image to " << output_image_fn << ": " - << err << std::endl; - return( 1 ); - - } // yrt - - return( 0 ); -} - -// eof - $RCSfile$ diff --git a/appli/examples/example_Image_Dijkstra_CostFromRGBInput.cxx b/appli/examples/example_Image_Dijkstra_CostFromRGBInput.cxx deleted file mode 100644 index c181359..0000000 --- a/appli/examples/example_Image_Dijkstra_CostFromRGBInput.cxx +++ /dev/null @@ -1,178 +0,0 @@ -#include -#include -#include -#include - -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -// ------------------------------------------------------------------------- -const unsigned int Dim = 2; -typedef itk::RGBPixel< unsigned char > TInputPixel; -typedef float TOutputPixel; - -typedef itk::Image< TInputPixel, Dim > TInputImage; -typedef itk::Image< TOutputPixel, Dim > TOutputImage; -typedef itk::ImageToVTKImageFilter< TInputImage > TVTKInputImage; - -// ------------------------------------------------------------------------- -int main( int argc, char* argv[] ) -{ - if( argc < 5 ) - { - std::cerr - << "Usage: " << argv[ 0 ] - << " input_image output_image neighborhood_order stop_at_one_front" - << std::endl; - return( 1 ); - - } // fi - std::string input_image_fn = argv[ 1 ]; - std::string output_image_fn = argv[ 2 ]; - unsigned int neighborhood_order = std::atoi( argv[ 3 ] ); - bool stop_at_one_front = ( std::atoi( argv[ 4 ] ) != 0 ); - - // Read image - itk::ImageFileReader< TInputImage >::Pointer input_image_reader = - itk::ImageFileReader< TInputImage >::New( ); - input_image_reader->SetFileName( input_image_fn ); - try - { - input_image_reader->Update( ); - } - catch( itk::ExceptionObject& err ) - { - std::cerr - << "Error while reading image from " << input_image_fn << ": " - << err << std::endl; - return( 1 ); - - } // yrt - TInputImage::ConstPointer input_image = input_image_reader->GetOutput( ); - TVTKInputImage::Pointer vtk_input_image = TVTKInputImage::New( ); - vtk_input_image->SetInput( input_image ); - vtk_input_image->Update( ); - - // VTK visualization - vtkSmartPointer< vtkImageActor > actor = - vtkSmartPointer< vtkImageActor >::New( ); - actor->SetInputData( vtk_input_image->GetOutput( ) ); - - vtkSmartPointer< vtkRenderer > renderer = - vtkSmartPointer< vtkRenderer >::New( ); - renderer->SetBackground( 0.1, 0.2, 0.7 ); - renderer->AddActor( actor ); - vtkSmartPointer< vtkRenderWindow > window = - vtkSmartPointer< vtkRenderWindow >::New( ); - window->SetSize( 800, 800 ); - window->AddRenderer( renderer ); - - // Correct camera due to the loaded image - vtkCamera* camera = renderer->GetActiveCamera( ); - camera->SetViewUp( 0, -1, 0 ); - camera->SetPosition( 0, 0, -1 ); - camera->SetFocalPoint( 0, 0, 0 ); - - // VTK interaction - vtkSmartPointer< vtkInteractorStyleImage > imageStyle = - vtkSmartPointer< vtkInteractorStyleImage >::New( ); - vtkSmartPointer< vtkRenderWindowInteractor > interactor = - vtkSmartPointer< vtkRenderWindowInteractor >::New( ); - interactor->SetInteractorStyle( imageStyle ); - window->SetInteractor( interactor ); - - // Create the widget and its representation - vtkSmartPointer< vtkPointHandleRepresentation3D > handle = - vtkSmartPointer< vtkPointHandleRepresentation3D >::New( ); - handle->GetProperty( )->SetColor( 1, 0, 0 ); - vtkSmartPointer< vtkSeedRepresentation > rep = - vtkSmartPointer< vtkSeedRepresentation >::New( ); - rep->SetHandleRepresentation( handle ); - - vtkSmartPointer< vtkSeedWidget > widget = - vtkSmartPointer< vtkSeedWidget >::New( ); - widget->SetInteractor( interactor ); - widget->SetRepresentation( rep ); - - // Let some interaction - interactor->Initialize( ); - renderer->ResetCamera( ); - window->Render( ); - widget->On( ); - interactor->Start( ); - - // Prepare region grow filter - typedef fpa::Image::Dijkstra< TInputImage, TOutputImage > TFilter; - TFilter::Pointer filter = TFilter::New( ); - filter->SetInput( input_image ); - filter->SetNeighborhoodOrder( neighborhood_order ); - filter->SetStopAtOneFront( stop_at_one_front ); - - // Get user-given seeds - for( unsigned int s = 0; s < rep->GetNumberOfSeeds( ); s++ ) - { - double pos[ 3 ]; - rep->GetSeedWorldPosition( s, pos ); - - TInputImage::PointType pnt; - pnt[ 0 ] = TInputImage::PointType::ValueType( pos[ 0 ] ); - pnt[ 1 ] = TInputImage::PointType::ValueType( pos[ 1 ] ); - - TInputImage::IndexType idx; - if( input_image->TransformPhysicalPointToIndex( pnt, idx ) ) - filter->AddSeed( idx, 0 ); - - } // rof - - // Prepare graphical debugger - typedef fpa::VTK::Image2DObserver< TFilter, vtkRenderWindow > TDebugger; - TDebugger::Pointer debugger = TDebugger::New( ); - debugger->SetRenderWindow( window ); - debugger->SetRenderPercentage( 0.001 ); - filter->AddObserver( itk::AnyEvent( ), debugger ); - filter->ThrowEventsOn( ); - - // Go! - filter->Update( ); - - // Save final total cost map - itk::ImageFileWriter< TOutputImage >::Pointer output_image_writer = - itk::ImageFileWriter< TOutputImage >::New( ); - output_image_writer->SetFileName( output_image_fn ); - output_image_writer->SetInput( filter->GetOutput( ) ); - try - { - output_image_writer->Update( ); - } - catch( itk::ExceptionObject& err ) - { - std::cerr - << "Error while writing image to " << output_image_fn << ": " - << err << std::endl; - return( 1 ); - - } // yrt - - return( 0 ); -} - -// eof - $RCSfile$ diff --git a/appli/examples/example_Image_Dijkstra_DanielssonCost.cxx b/appli/examples/example_Image_Dijkstra_DanielssonCost.cxx deleted file mode 100644 index 3eb387f..0000000 --- a/appli/examples/example_Image_Dijkstra_DanielssonCost.cxx +++ /dev/null @@ -1,204 +0,0 @@ -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -// ------------------------------------------------------------------------- -const unsigned int Dim = 2; -typedef unsigned char TInputPixel; -typedef float TOutputPixel; - -typedef itk::Image< TInputPixel, Dim > TInputImage; -typedef itk::Image< TOutputPixel, Dim > TOutputImage; -typedef itk::ImageToVTKImageFilter< TInputImage > TVTKInputImage; - -// ------------------------------------------------------------------------- -int main( int argc, char* argv[] ) -{ - if( argc < 5 ) - { - std::cerr - << "Usage: " << argv[ 0 ] - << " input_image output_image neighborhood_order stop_at_one_front" - << std::endl; - return( 1 ); - - } // fi - std::string input_image_fn = argv[ 1 ]; - std::string output_image_fn = argv[ 2 ]; - unsigned int neighborhood_order = std::atoi( argv[ 3 ] ); - bool stop_at_one_front = ( std::atoi( argv[ 4 ] ) != 0 ); - - // Read image - itk::ImageFileReader< TInputImage >::Pointer input_image_reader = - itk::ImageFileReader< TInputImage >::New( ); - input_image_reader->SetFileName( input_image_fn ); - try - { - input_image_reader->Update( ); - } - catch( itk::ExceptionObject& err ) - { - std::cerr - << "Error while reading image from " << input_image_fn << ": " - << err << std::endl; - return( 1 ); - - } // yrt - TInputImage::ConstPointer input_image = input_image_reader->GetOutput( ); - TVTKInputImage::Pointer vtk_input_image = TVTKInputImage::New( ); - vtk_input_image->SetInput( input_image ); - vtk_input_image->Update( ); - - // VTK visualization - vtkSmartPointer< vtkImageActor > actor = - vtkSmartPointer< vtkImageActor >::New( ); - actor->SetInputData( vtk_input_image->GetOutput( ) ); - - vtkSmartPointer< vtkRenderer > renderer = - vtkSmartPointer< vtkRenderer >::New( ); - renderer->SetBackground( 0.1, 0.2, 0.7 ); - renderer->AddActor( actor ); - vtkSmartPointer< vtkRenderWindow > window = - vtkSmartPointer< vtkRenderWindow >::New( ); - window->SetSize( 800, 800 ); - window->AddRenderer( renderer ); - - // Correct camera due to the loaded image - vtkCamera* camera = renderer->GetActiveCamera( ); - camera->SetViewUp( 0, -1, 0 ); - camera->SetPosition( 0, 0, -1 ); - camera->SetFocalPoint( 0, 0, 0 ); - - // VTK interaction - vtkSmartPointer< vtkInteractorStyleImage > imageStyle = - vtkSmartPointer< vtkInteractorStyleImage >::New( ); - vtkSmartPointer< vtkRenderWindowInteractor > interactor = - vtkSmartPointer< vtkRenderWindowInteractor >::New( ); - interactor->SetInteractorStyle( imageStyle ); - window->SetInteractor( interactor ); - - // Create the widget and its representation - vtkSmartPointer< vtkPointHandleRepresentation3D > handle = - vtkSmartPointer< vtkPointHandleRepresentation3D >::New( ); - handle->GetProperty( )->SetColor( 1, 0, 0 ); - vtkSmartPointer< vtkSeedRepresentation > rep = - vtkSmartPointer< vtkSeedRepresentation >::New( ); - rep->SetHandleRepresentation( handle ); - - vtkSmartPointer< vtkSeedWidget > widget = - vtkSmartPointer< vtkSeedWidget >::New( ); - widget->SetInteractor( interactor ); - widget->SetRepresentation( rep ); - - // Let some interaction - interactor->Initialize( ); - renderer->ResetCamera( ); - window->Render( ); - widget->On( ); - interactor->Start( ); - - // Invert input image - itk::MinimumMaximumImageCalculator< TInputImage >::Pointer minmax = - itk::MinimumMaximumImageCalculator< TInputImage >::New( ); - minmax->SetImage( input_image ); - minmax->Compute( ); - - itk::InvertIntensityImageFilter< TInputImage >::Pointer invert = - itk::InvertIntensityImageFilter< TInputImage >::New( ); - invert->SetInput( input_image ); - invert->SetMaximum( minmax->GetMaximum( ) ); - - itk::DanielssonDistanceMapImageFilter< TInputImage, TOutputImage >::Pointer dmap = - itk::DanielssonDistanceMapImageFilter< TInputImage, TOutputImage >::New( ); - dmap->SetInput( invert->GetOutput( ) ); - dmap->InputIsBinaryOn( ); - dmap->SquaredDistanceOn( ); - dmap->UseImageSpacingOn( ); - dmap->Update( ); - - typedef fpa::Base::Functors::InvertCostFunction< TOutputPixel > TFunction; - TFunction::Pointer function = TFunction::New( ); - - // Prepare region grow filter - typedef fpa::Image::Dijkstra< TOutputImage, TOutputImage > TFilter; - TFilter::Pointer filter = TFilter::New( ); - filter->SetInput( dmap->GetOutput( ) ); - filter->SetConversionFunction( function ); - filter->SetNeighborhoodOrder( neighborhood_order ); - filter->SetStopAtOneFront( stop_at_one_front ); - - // Get user-given seeds - for( unsigned int s = 0; s < rep->GetNumberOfSeeds( ); s++ ) - { - double pos[ 3 ]; - rep->GetSeedWorldPosition( s, pos ); - - TInputImage::PointType pnt; - pnt[ 0 ] = TInputImage::PointType::ValueType( pos[ 0 ] ); - pnt[ 1 ] = TInputImage::PointType::ValueType( pos[ 1 ] ); - - TInputImage::IndexType idx; - if( input_image->TransformPhysicalPointToIndex( pnt, idx ) ) - filter->AddSeed( idx, 0 ); - - } // rof - - // Prepare graphical debugger - typedef fpa::VTK::Image2DObserver< TFilter, vtkRenderWindow > TDebugger; - TDebugger::Pointer debugger = TDebugger::New( ); - debugger->SetRenderWindow( window ); - debugger->SetRenderPercentage( 0.001 ); - filter->AddObserver( itk::AnyEvent( ), debugger ); - filter->ThrowEventsOn( ); - - // Go! - filter->Update( ); - - // Save final total cost map - itk::ImageFileWriter< TOutputImage >::Pointer output_image_writer = - itk::ImageFileWriter< TOutputImage >::New( ); - output_image_writer->SetFileName( output_image_fn ); - output_image_writer->SetInput( filter->GetOutput( ) ); - try - { - output_image_writer->Update( ); - } - catch( itk::ExceptionObject& err ) - { - std::cerr - << "Error while writing image to " << output_image_fn << ": " - << err << std::endl; - return( 1 ); - - } // yrt - - return( 0 ); -} - -// eof - $RCSfile$ diff --git a/appli/examples/example_Image_Dijkstra_DanielssonCost_TwoSeedsPath.cxx b/appli/examples/example_Image_Dijkstra_DanielssonCost_TwoSeedsPath.cxx deleted file mode 100644 index 8a5eab0..0000000 --- a/appli/examples/example_Image_Dijkstra_DanielssonCost_TwoSeedsPath.cxx +++ /dev/null @@ -1,253 +0,0 @@ -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -// ------------------------------------------------------------------------- -const unsigned int Dim = 2; -typedef unsigned char TInputPixel; -typedef float TOutputPixel; - -typedef itk::Image< TInputPixel, Dim > TInputImage; -typedef itk::Image< TOutputPixel, Dim > TOutputImage; -typedef itk::ImageToVTKImageFilter< TInputImage > TVTKInputImage; - -// ------------------------------------------------------------------------- -int main( int argc, char* argv[] ) -{ - if( argc < 5 ) - { - std::cerr - << "Usage: " << argv[ 0 ] - << " input_image output_image neighborhood_order stop_at_one_front" - << std::endl; - return( 1 ); - - } // fi - std::string input_image_fn = argv[ 1 ]; - std::string output_image_fn = argv[ 2 ]; - unsigned int neighborhood_order = std::atoi( argv[ 3 ] ); - bool stop_at_one_front = ( std::atoi( argv[ 4 ] ) != 0 ); - - // Read image - itk::ImageFileReader< TInputImage >::Pointer input_image_reader = - itk::ImageFileReader< TInputImage >::New( ); - input_image_reader->SetFileName( input_image_fn ); - try - { - input_image_reader->Update( ); - } - catch( itk::ExceptionObject& err ) - { - std::cerr - << "Error while reading image from " << input_image_fn << ": " - << err << std::endl; - return( 1 ); - - } // yrt - TInputImage::ConstPointer input_image = input_image_reader->GetOutput( ); - TVTKInputImage::Pointer vtk_input_image = TVTKInputImage::New( ); - vtk_input_image->SetInput( input_image ); - vtk_input_image->Update( ); - - // VTK visualization - vtkSmartPointer< vtkImageActor > actor = - vtkSmartPointer< vtkImageActor >::New( ); - actor->SetInputData( vtk_input_image->GetOutput( ) ); - - vtkSmartPointer< vtkRenderer > renderer = - vtkSmartPointer< vtkRenderer >::New( ); - renderer->SetBackground( 0.1, 0.2, 0.7 ); - renderer->AddActor( actor ); - vtkSmartPointer< vtkRenderWindow > window = - vtkSmartPointer< vtkRenderWindow >::New( ); - window->SetSize( 800, 800 ); - window->AddRenderer( renderer ); - - // Correct camera due to the loaded image - vtkCamera* camera = renderer->GetActiveCamera( ); - camera->SetViewUp( 0, -1, 0 ); - camera->SetPosition( 0, 0, -1 ); - camera->SetFocalPoint( 0, 0, 0 ); - - // VTK interaction - vtkSmartPointer< vtkInteractorStyleImage > imageStyle = - vtkSmartPointer< vtkInteractorStyleImage >::New( ); - vtkSmartPointer< vtkRenderWindowInteractor > interactor = - vtkSmartPointer< vtkRenderWindowInteractor >::New( ); - interactor->SetInteractorStyle( imageStyle ); - window->SetInteractor( interactor ); - - // Create the widget and its representation - vtkSmartPointer< vtkPointHandleRepresentation3D > handle = - vtkSmartPointer< vtkPointHandleRepresentation3D >::New( ); - handle->GetProperty( )->SetColor( 1, 0, 0 ); - vtkSmartPointer< vtkSeedRepresentation > rep = - vtkSmartPointer< vtkSeedRepresentation >::New( ); - rep->SetHandleRepresentation( handle ); - - vtkSmartPointer< vtkSeedWidget > widget = - vtkSmartPointer< vtkSeedWidget >::New( ); - widget->SetInteractor( interactor ); - widget->SetRepresentation( rep ); - - // Let some interaction - interactor->Initialize( ); - renderer->ResetCamera( ); - window->Render( ); - widget->On( ); - interactor->Start( ); - - // Invert input image - itk::MinimumMaximumImageCalculator< TInputImage >::Pointer minmax = - itk::MinimumMaximumImageCalculator< TInputImage >::New( ); - minmax->SetImage( input_image ); - minmax->Compute( ); - - itk::InvertIntensityImageFilter< TInputImage >::Pointer invert = - itk::InvertIntensityImageFilter< TInputImage >::New( ); - invert->SetInput( input_image ); - invert->SetMaximum( minmax->GetMaximum( ) ); - - itk::DanielssonDistanceMapImageFilter< TInputImage, TOutputImage >::Pointer dmap = - itk::DanielssonDistanceMapImageFilter< TInputImage, TOutputImage >::New( ); - dmap->SetInput( invert->GetOutput( ) ); - dmap->InputIsBinaryOn( ); - dmap->SquaredDistanceOn( ); - dmap->UseImageSpacingOn( ); - dmap->Update( ); - - typedef fpa::Base::Functors::InvertCostFunction< TOutputPixel > TFunction; - TFunction::Pointer function = TFunction::New( ); - - // Prepare region grow filter - typedef fpa::Image::Dijkstra< TOutputImage, TOutputImage > TFilter; - TFilter::Pointer filter = TFilter::New( ); - filter->SetInput( dmap->GetOutput( ) ); - filter->SetConversionFunction( function ); - filter->SetNeighborhoodOrder( neighborhood_order ); - filter->SetStopAtOneFront( stop_at_one_front ); - - // Get user-given seeds - for( unsigned int s = 0; s < rep->GetNumberOfSeeds( ); s++ ) - { - double pos[ 3 ]; - rep->GetSeedWorldPosition( s, pos ); - - TInputImage::PointType pnt; - pnt[ 0 ] = TInputImage::PointType::ValueType( pos[ 0 ] ); - pnt[ 1 ] = TInputImage::PointType::ValueType( pos[ 1 ] ); - - TInputImage::IndexType idx; - if( input_image->TransformPhysicalPointToIndex( pnt, idx ) ) - filter->AddSeed( idx, 0 ); - - } // rof - - // Prepare graphical debugger - typedef fpa::VTK::Image2DObserver< TFilter, vtkRenderWindow > TDebugger; - TDebugger::Pointer debugger = TDebugger::New( ); - debugger->SetRenderWindow( window ); - debugger->SetRenderPercentage( 0.001 ); - filter->AddObserver( itk::AnyEvent( ), debugger ); - filter->ThrowEventsOn( ); - - // Go! - filter->Update( ); - - // Save final total cost map - itk::ImageFileWriter< TOutputImage >::Pointer output_image_writer = - itk::ImageFileWriter< TOutputImage >::New( ); - output_image_writer->SetFileName( output_image_fn ); - output_image_writer->SetInput( filter->GetOutput( ) ); - try - { - output_image_writer->Update( ); - } - catch( itk::ExceptionObject& err ) - { - std::cerr - << "Error while writing image to " << output_image_fn << ": " - << err << std::endl; - return( 1 ); - - } // yrt - - // Draw the path between the two seeds - if( filter->GetNumberOfSeeds( ) > 1 ) - { - TInputImage::IndexType a = filter->GetSeed( 0 ); - TInputImage::IndexType b = - filter->GetSeed( filter->GetNumberOfSeeds( ) - 1 ); - - std::vector< TInputImage::IndexType > path; - filter->GetMinimumSpanningTree( )->GetPath( path, a, b ); - - typedef itk::Image< itk::RGBAPixel< unsigned char >, Dim > TColorImage; - TColorImage::Pointer path_image = TColorImage::New( ); - path_image->SetLargestPossibleRegion( - input_image->GetLargestPossibleRegion( ) - ); - path_image->SetRequestedRegion( input_image->GetRequestedRegion( ) ); - path_image->SetBufferedRegion( input_image->GetBufferedRegion( ) ); - path_image->SetSpacing( input_image->GetSpacing( ) ); - path_image->SetOrigin( input_image->GetOrigin( ) ); - path_image->SetDirection( input_image->GetDirection( ) ); - path_image->Allocate( ); - - unsigned char background[ 4 ] = { 0, 0, 0, 0 }; - unsigned char color[ 4 ] = { 255, 0, 0, 255 }; - path_image->FillBuffer( itk::RGBAPixel< unsigned char >( background ) ); - - for( unsigned int pId = 0; pId < path.size( ); ++pId ) - path_image->SetPixel( - path[ pId ], itk::RGBAPixel< unsigned char >( color ) - ); - - itk::ImageToVTKImageFilter< TColorImage >::Pointer vtk_path_image = - itk::ImageToVTKImageFilter< TColorImage >::New( ); - vtk_path_image->SetInput( path_image ); - vtk_path_image->Update( ); - - vtkSmartPointer< vtkImageActor > path_image_actor = - vtkSmartPointer< vtkImageActor >::New( ); - path_image_actor->SetInputData( vtk_path_image->GetOutput( ) ); - renderer->AddActor( path_image_actor ); - - // More interaction - window->Render( ); - widget->Off( ); - interactor->Start( ); - - } // fi - - return( 0 ); -} - -// eof - $RCSfile$ diff --git a/appli/examples/example_Image_Dijkstra_EndPointDetection.cxx b/appli/examples/example_Image_Dijkstra_EndPointDetection.cxx deleted file mode 100644 index 9e79437..0000000 --- a/appli/examples/example_Image_Dijkstra_EndPointDetection.cxx +++ /dev/null @@ -1,331 +0,0 @@ -#include -#include -#include -#include -#include - -#include -#include - -#include - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "fpa_Utility.h" - -// ------------------------------------------------------------------------- -const unsigned int Dim = 3; -typedef unsigned char TPixel; -typedef float TScalar; -typedef itk::Image< TPixel, Dim > TImage; -typedef itk::Image< TScalar, Dim > TScalarImage; - -// ------------------------------------------------------------------------- -int main( int argc, char* argv[] ) -{ - if( argc < 7 ) - { - std::cerr - << "Usage: " << argv[ 0 ] << std::endl - << "\tinput_image" << std::endl - << "\toutput_labels" << std::endl - << "\toutput_minimum_spanning_tree" << std::endl - << "\toutput_endpoints" << std::endl - << "\toutput_bifurcations" << std::endl - << "\toutput_branches" << std::endl - << std::endl; - return( 1 ); - - } // fi - std::string input_image_fn = argv[ 1 ]; - std::string output_labels_fn = argv[ 2 ]; - std::string output_minimum_spanning_tree_fn = argv[ 3 ]; - std::string output_endpoints_fn = argv[ 4 ]; - std::string output_bifurcations_fn = argv[ 5 ]; - std::string output_branches_fn = argv[ 6 ]; - - // Read image - TImage::Pointer input_image; - std::string err = fpa_Utility::ReadImage( input_image, input_image_fn ); - if( err != "" ) - { - std::cerr << err << std::endl; - return( 1 ); - - } // fi - - // Show image and wait for, at least, one seed - itk::ImageToVTKImageFilter< TImage >::Pointer vtk_input_image = - itk::ImageToVTKImageFilter< TImage >::New( ); - vtk_input_image->SetInput( input_image ); - vtk_input_image->Update( ); - - vtkSmartPointer outline = - vtkSmartPointer::New(); - outline->SetBounds(vtk_input_image->GetOutput( )->GetBounds()); - - vtkSmartPointer mapper = - vtkSmartPointer::New( ); - mapper->SetInputConnection( outline->GetOutputPort( ) ); - - vtkSmartPointer actor = - vtkSmartPointer::New( ); - actor->SetMapper( mapper ); - vtkSmartPointer aRenderer = - vtkSmartPointer::New(); - vtkSmartPointer renWin = - vtkSmartPointer::New(); - renWin->AddRenderer(aRenderer); - - vtkSmartPointer iren = - vtkSmartPointer::New(); - iren->SetRenderWindow(renWin); - - aRenderer->AddActor( actor ); -iren->Initialize(); - iren->Start(); - - /* - fpa_Utility::Viewer2DWithSeeds viewer; - viewer.SetImage( vtk_input_image->GetOutput( ) ); - while( viewer.GetNumberOfSeeds( ) == 0 ) - viewer.Start( ); - */ - - // Compute squared distance map - itk::SignedMaurerDistanceMapImageFilter< TImage, TScalarImage >::Pointer - dmap = - itk::SignedMaurerDistanceMapImageFilter< TImage, TScalarImage >::New( ); - dmap->SetInput( input_image ); - dmap->SetBackgroundValue( TPixel( 0 ) ); - dmap->InsideIsPositiveOn( ); - dmap->SquaredDistanceOn( ); - dmap->UseImageSpacingOn( ); - - std::time_t start, end; - std::time( &start ); - dmap->Update( ); - std::time( &end ); - std::cout - << "Distance map time = " - << std::difftime( end, start ) - << "s." << std::endl; - - // Prepare cost conversion function - typedef fpa::Base::Functors::InvertCostFunction< TScalar > TCostFunction; - TCostFunction::Pointer cost_f = TCostFunction::New( ); - - // Prepare Dijkstra filter - typedef fpa::Image:: - DijkstraWithEndPointDetection< TScalarImage, TScalarImage > TFilter; - TFilter::Pointer filter = TFilter::New( ); - filter->SetInput( dmap->GetOutput( ) ); - filter->SetConversionFunction( cost_f ); - filter->SetNeighborhoodOrder( 2 ); - filter->StopAtOneFrontOff( ); - - // Associate seed - TImage::PointType pnt; - TImage::IndexType idx; - /* - viewer.GetSeed( pnt, 0 ); - */ - pnt[ 0 ] = 0.879066; - pnt[ 1 ] = -109.36591; - pnt[ 2 ] = 1942.480988; - - if( input_image->TransformPhysicalPointToIndex( pnt, idx ) ) - filter->AddSeed( idx, 0 ); - - // Prepare graphical debugger - typedef fpa::VTK::Image3DObserver< TFilter, vtkRenderWindow > TDebugger; - TDebugger::Pointer debugger = TDebugger::New( ); - debugger->SetRenderWindow( renWin ); - debugger->SetRenderPercentage( 0.0001 ); - filter->AddObserver( itk::AnyEvent( ), debugger ); - filter->ThrowEventsOn( ); - - // Go! - std::time( &start ); - filter->Update( ); - std::time( &end ); - std::cout - << "Extraction time = " - << std::difftime( end, start ) - << "s." << std::endl; - - // Create new actors - typedef vtkSmartPointer< fpa::VTK::UniqueVerticesToPolyDataFilter< TFilter::TUniqueVertices, TFilter::TInputImage > > TVertices2PD; - - TVertices2PD endpoints2pd = TVertices2PD::New( ); - endpoints2pd->SetInput( filter->GetEndPoints( ) ); - endpoints2pd->SetImage( filter->GetInput( ) ); - endpoints2pd->Update( ); - - vtkSmartPointer< vtkPolyDataMapper > endpoints_mapper = - vtkSmartPointer< vtkPolyDataMapper >::New( ); - endpoints_mapper->SetInputConnection( endpoints2pd->GetOutputPort( ) ); - - vtkSmartPointer< vtkActor > endpoints_actor = - vtkSmartPointer< vtkActor >::New( ); - endpoints_actor->SetMapper( endpoints_mapper ); - endpoints_actor->GetProperty( )->SetColor( 0, 1, 0 ); - endpoints_actor->GetProperty( )->SetPointSize( 5 ); - aRenderer->AddActor( endpoints_actor ); - - TVertices2PD bifurcations2pd = TVertices2PD::New( ); - bifurcations2pd->SetInput( filter->GetBifurcations( ) ); - bifurcations2pd->SetImage( filter->GetInput( ) ); - bifurcations2pd->Update( ); - - vtkSmartPointer< vtkPolyDataMapper > bifurcations_mapper = - vtkSmartPointer< vtkPolyDataMapper >::New( ); - bifurcations_mapper->SetInputConnection( bifurcations2pd->GetOutputPort( ) ); - - vtkSmartPointer< vtkActor > bifurcations_actor = - vtkSmartPointer< vtkActor >::New( ); - bifurcations_actor->SetMapper( bifurcations_mapper ); - bifurcations_actor->GetProperty( )->SetColor( 1, 0, 0 ); - bifurcations_actor->GetProperty( )->SetPointSize( 5 ); - aRenderer->AddActor( bifurcations_actor ); - - // Some more interaction and finish -iren->Initialize(); - iren->Start(); - - // Save results - err = fpa_Utility::SaveImage( filter->GetLabelImage( ), output_labels_fn ); - if( err != "" ) - std::cerr << err << std::endl; - - fpa::IO::MinimumSpanningTreeWriter< TFilter::TMinimumSpanningTree >::Pointer - mst_writer = - fpa::IO::MinimumSpanningTreeWriter< TFilter::TMinimumSpanningTree >::New( ); - mst_writer->SetInput( filter->GetMinimumSpanningTree( ) ); - mst_writer->SetFileName( output_minimum_spanning_tree_fn ); - mst_writer->Update( ); - - fpa::IO::UniqueValuesContainerWriter< TFilter::TUniqueVertices >::Pointer - endpoints_writer = - fpa::IO::UniqueValuesContainerWriter< TFilter::TUniqueVertices >::New( ); - endpoints_writer->SetInput( filter->GetEndPoints( ) ); - endpoints_writer->SetFileName( output_endpoints_fn ); - endpoints_writer->Update( ); - - fpa::IO::UniqueValuesContainerWriter< TFilter::TUniqueVertices >::Pointer - bifurcations_writer = - fpa::IO::UniqueValuesContainerWriter< TFilter::TUniqueVertices >::New( ); - bifurcations_writer->SetInput( filter->GetBifurcations( ) ); - bifurcations_writer->SetFileName( output_bifurcations_fn ); - bifurcations_writer->Update( ); - - fpa::IO::MatrixValuesContainerWriter< TFilter::TBranches >::Pointer - branches_writer = - fpa::IO::MatrixValuesContainerWriter< TFilter::TBranches >::New( ); - branches_writer->SetInput( filter->GetBranches( ) ); - branches_writer->SetFileName( output_branches_fn ); - branches_writer->Update( ); - - return( 0 ); -} - -// eof - $RCSfile$ - -/* TODO - vtkSmartPointer< vtkPoints > simple_branches_points = - vtkSmartPointer< vtkPoints >::New( ); - vtkSmartPointer< vtkCellArray > simple_branches_cells = - vtkSmartPointer< vtkCellArray >::New( ); - - vtkSmartPointer< vtkPoints > detailed_branches_points = - vtkSmartPointer< vtkPoints >::New( ); - vtkSmartPointer< vtkCellArray > detailed_branches_cells = - vtkSmartPointer< vtkCellArray >::New( ); - vtkSmartPointer< vtkFloatArray > detailed_branches_scalars = - vtkSmartPointer< vtkFloatArray >::New( ); - - TFilter::TBranches::ConstIterator brIt = branches->Begin( ); - for( ; brIt != branches->End( ); ++brIt ) - { - // Branch's first point - TImage::PointType first_point; - input_image->TransformIndexToPhysicalPoint( brIt->first, first_point ); - unsigned long first_id = simple_branches_points->GetNumberOfPoints( ); - simple_branches_points->InsertNextPoint( - first_point[ 0 ], first_point[ 1 ], first_point[ 2 ] - ); - - TFilter::TBranches::ConstRowIterator brRowIt = branches->Begin( brIt ); - for( ; brRowIt != branches->End( brIt ); ++brRowIt ) - { - // Branch's second point - TImage::PointType second_point; - input_image-> - TransformIndexToPhysicalPoint( brRowIt->first, second_point ); - unsigned long second_id = simple_branches_points->GetNumberOfPoints( ); - simple_branches_points->InsertNextPoint( - second_point[ 0 ], second_point[ 1 ], second_point[ 2 ] - ); - simple_branches_cells->InsertNextCell( 2 ); - simple_branches_cells->InsertCellPoint( first_id ); - simple_branches_cells->InsertCellPoint( second_id ); - - // Detailed path - double pathId = double( brRowIt->second - 1 ) / double( nBranches - 1 ); - TFilter::TVertices path; - mst->GetPath( path, brIt->first, brRowIt->first ); - TFilter::TVertices::const_iterator pIt = path.begin( ); - for( ; pIt != path.end( ); ++pIt ) - { - TImage::PointType path_point; - input_image->TransformIndexToPhysicalPoint( *pIt, path_point ); - detailed_branches_points->InsertNextPoint( - path_point[ 0 ], path_point[ 1 ], path_point[ 2 ] - ); - detailed_branches_scalars->InsertNextTuple1( pathId ); - if( pIt != path.begin( ) ) - { - unsigned long nPoints = - detailed_branches_points->GetNumberOfPoints( ); - detailed_branches_cells->InsertNextCell( 2 ); - detailed_branches_cells->InsertCellPoint( nPoints - 2 ); - detailed_branches_cells->InsertCellPoint( nPoints - 1 ); - - } // fi - - } // rof - - } // rof - - } // rof - vtkSmartPointer< vtkPolyData > simple_branches_polydata = - vtkSmartPointer< vtkPolyData >::New( ); - simple_branches_polydata->SetPoints( simple_branches_points ); - simple_branches_polydata->SetLines( simple_branches_cells ); - view.AddPolyData( simple_branches_polydata, 1, 0, 1, 1 ); - - vtkSmartPointer< vtkPolyData > detailed_branches_polydata = - vtkSmartPointer< vtkPolyData >::New( ); - detailed_branches_polydata->SetPoints( detailed_branches_points ); - detailed_branches_polydata->SetLines( detailed_branches_cells ); - detailed_branches_polydata-> - GetPointData( )->SetScalars( detailed_branches_scalars ); - view.AddPolyData( detailed_branches_polydata, 1 ); - - // Let some more interaction - view.Render( ); - view.Start( ); - - return( 0 ); - } -*/ - -// eof - $RCSfile$ diff --git a/appli/examples/example_Image_Dijkstra_EndPointDetection_WithoutVTK.cxx b/appli/examples/example_Image_Dijkstra_EndPointDetection_WithoutVTK.cxx deleted file mode 100644 index 1a8b476..0000000 --- a/appli/examples/example_Image_Dijkstra_EndPointDetection_WithoutVTK.cxx +++ /dev/null @@ -1,249 +0,0 @@ -#include -#include -#include -#include -#include - -#include - -#include -#include -#include - -#include - -#include - -#include -#include - -#include -#include -#include - -// ------------------------------------------------------------------------- -const unsigned int Dim = 3; -typedef unsigned char TPixel; -typedef float TScalar; - -typedef itk::Image< TPixel, Dim > TImage; -typedef itk::Image< TScalar, Dim > TScalarImage; - -// ------------------------------------------------------------------------- -template< class I > -void ReadImage( typename I::Pointer& image, const std::string& filename ); - -template< class I > -void SaveImage( const I* image, const std::string& filename ); - -template< class I, class O > -void DistanceMap( - const typename I::Pointer& input, typename O::Pointer& output - ); - -// ------------------------------------------------------------------------- -int main( int argc, char* argv[] ) -{ - if( argc < 12 ) - { - std::cerr - << "Usage: " << argv[ 0 ] << std::endl - << " input_image" << std::endl - << " seed_x seed_y seed_z" << std::endl - << " output_distancemap" << std::endl - << " output_costmap" << std::endl - << " output_labels" << std::endl - << " output_minimum_spanning_tree" << std::endl - << " output_endpoints" << std::endl - << " output_bifurcations" << std::endl - << " output_branches" << std::endl - << std::endl; - return( 1 ); - - } // fi - std::string input_image_fn = argv[ 1 ]; - double seed_x = std::atof( argv[ 2 ] ); - double seed_y = std::atof( argv[ 3 ] ); - double seed_z = std::atof( argv[ 4 ] ); - std::string distancemap_fn = argv[ 5 ]; - std::string output_costmap_fn = argv[ 6 ]; - std::string output_labels_fn = argv[ 7 ]; - std::string mst_output_fn = argv[ 8 ]; - std::string endpoints_output_fn = argv[ 9 ]; - std::string bifurcations_output_fn = argv[ 10 ]; - std::string branches_output_fn = argv[ 11 ]; - - // Read image - TImage::Pointer input_image; - try - { - ReadImage< TImage >( input_image, input_image_fn ); - } - catch( itk::ExceptionObject& err ) - { - std::cerr - << "Error caught while reading \"" - << input_image_fn << "\": " << err - << std::endl; - return( 1 ); - - } // yrt - - // Get seed - double p[ 3 ]; - TImage::PointType pnt; - TImage::IndexType seed; - pnt[ 0 ] = seed_x; - pnt[ 1 ] = seed_y; - pnt[ 2 ] = seed_z; - input_image->TransformPhysicalPointToIndex( pnt, seed ); - - // Compute squared distance map - TScalarImage::Pointer dmap; - DistanceMap< TImage, TScalarImage >( input_image, dmap ); - - // Prepare cost conversion function - typedef fpa::Base::Functors::InvertCostFunction< TScalar > TFunction; - TFunction::Pointer function = TFunction::New( ); - - // Prepare Dijkstra filter - typedef fpa::Image::DijkstraWithEndPointDetection< TScalarImage, TScalarImage > TFilter; - TFilter::Pointer filter = TFilter::New( ); - filter->SetInput( dmap ); - filter->SetConversionFunction( function ); - filter->SetNeighborhoodOrder( 2 ); - filter->StopAtOneFrontOff( ); - filter->AddSeed( seed, TScalar( 0 ) ); - - // Go! - std::time_t start, end; - std::time( &start ); - filter->Update( ); - std::time( &end ); - std::cout - << "Extraction time = " - << std::difftime( end, start ) - << " s." << std::endl; - - // Outputs - const TFilter::TOutputImage* accumulated_costs = filter->GetOutput( ); - const TFilter::TLabelImage* labeled_image = filter->GetLabelImage( ); - const TFilter::TMinimumSpanningTree* mst = filter->GetMinimumSpanningTree( ); - const TFilter::TUniqueVertices* endpoints = filter->GetEndPoints( ); - const TFilter::TUniqueVertices* bifurcations = filter->GetBifurcations( ); - const TFilter::TBranches* branches = filter->GetBranches( ); - unsigned long nBranches = filter->GetNumberOfBranches( ); - - // Save outputs - SaveImage( dmap.GetPointer( ), distancemap_fn ); - SaveImage( accumulated_costs, output_costmap_fn ); - SaveImage( labeled_image, output_labels_fn ); - - fpa::IO::MinimumSpanningTreeWriter< TFilter::TMinimumSpanningTree >::Pointer - mst_writer = - fpa::IO::MinimumSpanningTreeWriter< TFilter::TMinimumSpanningTree >::New( ); - mst_writer->SetInput( mst ); - mst_writer->SetFileName( mst_output_fn ); - mst_writer->Update( ); - - fpa::IO::UniqueValuesContainerWriter< TFilter::TUniqueVertices >::Pointer - endpoints_writer = - fpa::IO::UniqueValuesContainerWriter< TFilter::TUniqueVertices >::New( ); - endpoints_writer->SetInput( endpoints ); - endpoints_writer->SetFileName( endpoints_output_fn ); - endpoints_writer->Update( ); - - fpa::IO::UniqueValuesContainerWriter< TFilter::TUniqueVertices >::Pointer - bifurcations_writer = - fpa::IO::UniqueValuesContainerWriter< TFilter::TUniqueVertices >::New( ); - bifurcations_writer->SetInput( bifurcations ); - bifurcations_writer->SetFileName( bifurcations_output_fn ); - bifurcations_writer->Update( ); - - fpa::IO::MatrixValuesContainerWriter< TFilter::TBranches >::Pointer - branches_writer = - fpa::IO::MatrixValuesContainerWriter< TFilter::TBranches >::New( ); - branches_writer->SetInput( branches ); - branches_writer->SetFileName( branches_output_fn ); - branches_writer->Update( ); - - return( 0 ); -} - -// ------------------------------------------------------------------------- -template< class I > -void ReadImage( typename I::Pointer& image, const std::string& filename ) -{ - typename itk::ImageFileReader< I >::Pointer reader = - itk::ImageFileReader< I >::New( ); - reader->SetFileName( filename ); - reader->Update( ); - - typename itk::MinimumMaximumImageCalculator< I >::Pointer minmax = - itk::MinimumMaximumImageCalculator< I >::New( ); - minmax->SetImage( reader->GetOutput( ) ); - minmax->Compute( ); - double vmin = double( minmax->GetMinimum( ) ); - double vmax = double( minmax->GetMaximum( ) ); - - typename itk::ShiftScaleImageFilter< I, I >::Pointer shift = - itk::ShiftScaleImageFilter< I, I >::New( ); - shift->SetInput( reader->GetOutput( ) ); - shift->SetScale( vmax - vmin ); - shift->SetShift( vmin / ( vmax - vmin ) ); - shift->Update( ); - - image = shift->GetOutput( ); - image->DisconnectPipeline( ); -} - -// ------------------------------------------------------------------------- -template< class I > -void SaveImage( const I* image, const std::string& filename ) -{ - typename itk::ImageFileWriter< I >::Pointer writer = - itk::ImageFileWriter< I >::New( ); - writer->SetInput( image ); - writer->SetFileName( filename ); - try - { - writer->Update( ); - } - catch( itk::ExceptionObject& err ) - { - std::cerr - << "Error saving \"" << filename << "\": " << err - << std::endl; - - } // yrt -} - -// ------------------------------------------------------------------------- -template< class I, class O > -void DistanceMap( - const typename I::Pointer& input, typename O::Pointer& output - ) -{ - typename itk::SignedMaurerDistanceMapImageFilter< I, O >::Pointer dmap = - itk::SignedMaurerDistanceMapImageFilter< I, O >::New( ); - dmap->SetInput( input ); - dmap->SetBackgroundValue( ( typename I::PixelType )( 0 ) ); - dmap->InsideIsPositiveOn( ); - dmap->SquaredDistanceOn( ); - dmap->UseImageSpacingOn( ); - - std::time_t start, end; - std::time( &start ); - dmap->Update( ); - std::time( &end ); - std::cout - << "Distance map time = " - << std::difftime( end, start ) - << " s." << std::endl; - - output = dmap->GetOutput( ); - output->DisconnectPipeline( ); -} - -// eof - $RCSfile$ - diff --git a/appli/examples/example_Image_Dijkstra_LabelSkeleton.cxx b/appli/examples/example_Image_Dijkstra_LabelSkeleton.cxx deleted file mode 100644 index 4e65d9d..0000000 --- a/appli/examples/example_Image_Dijkstra_LabelSkeleton.cxx +++ /dev/null @@ -1,421 +0,0 @@ -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -// ------------------------------------------------------------------------- -const unsigned int Dim = 3; -typedef unsigned char TPixel; -typedef float TScalar; - -typedef itk::Image< TPixel, Dim > TImage; -typedef itk::Image< TScalar, Dim > TScalarImage; -typedef itk::ImageToVTKImageFilter< TImage > TVTKInputImage; - -// ------------------------------------------------------------------------- -template< class I > -void ReadImage( typename I::Pointer& image, const std::string& filename ); - -template< class I > -void SaveImage( const I* image, const std::string& filename ); - -// ------------------------------------------------------------------------- -template< class F > -class SkeletonCostFunction - : public fpa::Image::Functors::ImageCostFunction< typename F::TInputImage, typename F::TResult > -{ -public: - typedef fpa::Image::Functors::ImageCostFunction< typename F::TInputImage, typename F::TResult > Superclass; - typedef SkeletonCostFunction Self; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; - - typedef typename Superclass::TInputImage TInputImage; - typedef typename Superclass::TResult TResult; - typedef typename Superclass::TIndex TIndex; - -public: - itkNewMacro( Self ); - itkTypeMacro( SkeletonCostFunction, fpa_Image_Functors_ImageCostFunction ); - -public: - virtual void SetInputImage( const TInputImage* img ) - { - this->Superclass::SetInputImage( img ); - - typename TInputImage::SpacingType spac = img->GetSpacing( ); - typename TInputImage::SpacingType::ValueType min_spac = spac[ 0 ]; - for( unsigned int d = 1; d < TInputImage::ImageDimension; ++d ) - min_spac = ( spac[ d ] < min_spac )? spac[ d ]: min_spac; - this->m_Distance = TResult( min_spac ); - } - - virtual TResult Evaluate( const TIndex& v, const TIndex& p ) const - { - TResult res = this->Superclass::Evaluate( v, p ); - if( res > TResult( 0 ) ) - return( this->m_Distance ); - else - return( TResult( -1 ) ); - } - -protected: - SkeletonCostFunction( ) - : Superclass( ) - { } - virtual ~SkeletonCostFunction( ) - { } - -private: - // Purposely not implemented - SkeletonCostFunction( const Self& ); - void operator=( const Self& ); - -protected: - TResult m_Distance; -}; - -// ------------------------------------------------------------------------- -int main( int argc, char* argv[] ) -{ - if( argc < 11 ) - { - std::cerr - << "Usage: " << argv[ 0 ] << std::endl - << " input_image" << std::endl - << " seed_x seed_y seed_z" << std::endl - << " output_costmap" << std::endl - << " output_labels" << std::endl - << " output_minimum_spanning_tree" << std::endl - << " output_endpoints" << std::endl - << " output_bifurcations" << std::endl - << " output_branches" << std::endl - << std::endl; - return( 1 ); - - } // fi - std::string input_image_fn = argv[ 1 ]; - std::string output_costmap_fn = argv[ 5 ]; - std::string output_labels_fn = argv[ 6 ]; - std::string mst_output_fn = argv[ 7 ]; - std::string endpoints_output_fn = argv[ 8 ]; - std::string bifurcations_output_fn = argv[ 9 ]; - std::string branches_output_fn = argv[ 10 ]; - - // Get seed - TImage::PointType pnt; - pnt[ 0 ] = TImage::PointType::ValueType( std::atof( argv[ 2 ] ) ); - pnt[ 1 ] = TImage::PointType::ValueType( std::atof( argv[ 3 ] ) ); - pnt[ 2 ] = TImage::PointType::ValueType( std::atof( argv[ 4 ] ) ); - - // Read image - TImage::Pointer input_image; - try - { - ReadImage< TImage >( input_image, input_image_fn ); - } - catch( itk::ExceptionObject& err ) - { - std::cerr - << "Error caught while reading \"" - << input_image_fn << "\": " << err - << std::endl; - return( 1 ); - - } // yrt - - TVTKInputImage::Pointer vtk_input_image = TVTKInputImage::New( ); - vtk_input_image->SetInput( input_image ); - vtk_input_image->Update( ); - - // Show input image and let some interaction - fpa::VTK::ImageMPR view; - view.SetBackground( 0.3, 0.2, 0.8 ); - view.SetSize( 500, 500 ); - view.SetImage( vtk_input_image->GetOutput( ) ); - - vtkSmartPointer< vtkImageMarchingCubes > mc = - vtkSmartPointer< vtkImageMarchingCubes >::New( ); - mc->SetInputData( vtk_input_image->GetOutput( ) ); - mc->SetValue( 0, 1e-1 ); - mc->Update( ); - view.AddPolyData( mc->GetOutput( ), 1, 1, 1, 0.4 ); - - // Allow some interaction and wait for, at least, one seed - view.Render( ); - view.Start( ); - - // Transform seed - TImage::IndexType seed; - input_image->TransformPhysicalPointToIndex( pnt, seed ); - - // Prepare Dijkstra filter - typedef fpa::Image::DijkstraWithEndPointDetection< TImage, TScalarImage > TFilter; - typedef SkeletonCostFunction< TFilter > TFunction; - - TFunction::Pointer function = TFunction::New( ); - - TFilter::Pointer filter = TFilter::New( ); - filter->SetInput( input_image ); - filter->SetCostFunction( function ); - filter->SetNeighborhoodOrder( 2 ); - filter->SetSafetyNeighborhoodSize( 0 ); - filter->StopAtOneFrontOff( ); - filter->CorrectSeedsOff( ); - filter->CorrectEndPointsOff( ); - filter->AddSeed( seed, TScalar( 0 ) ); - - // Prepare graphical debugger - typedef fpa::VTK::Image3DObserver< TFilter, vtkRenderWindow > TDebugger; - TDebugger::Pointer debugger = TDebugger::New( ); - debugger->SetRenderWindow( view.GetWindow( ) ); - debugger->SetRenderPercentage( 0.0000001 ); - filter->AddObserver( itk::AnyEvent( ), debugger ); - filter->ThrowEventsOn( ); - - // Go! - std::time_t start, end; - std::time( &start ); - filter->Update( ); - std::time( &end ); - std::cout - << "Extraction time = " - << std::difftime( end, start ) - << " s." << std::endl; - - // Outputs - const TFilter::TOutputImage* accumulated_costs = filter->GetOutput( ); - const TFilter::TLabelImage* labeled_image = filter->GetLabelImage( ); - const TFilter::TMinimumSpanningTree* mst = filter->GetMinimumSpanningTree( ); - const TFilter::TUniqueVertices* endpoints = filter->GetEndPoints( ); - const TFilter::TUniqueVertices* bifurcations = filter->GetBifurcations( ); - const TFilter::TBranches* branches = filter->GetBranches( ); - unsigned long nBranches = filter->GetNumberOfBranches( ); - - // Save outputs - SaveImage( accumulated_costs, output_costmap_fn ); - SaveImage( labeled_image, output_labels_fn ); - - fpa::IO::MinimumSpanningTreeWriter< TFilter::TMinimumSpanningTree >::Pointer - mst_writer = - fpa::IO::MinimumSpanningTreeWriter< TFilter::TMinimumSpanningTree >::New( ); - mst_writer->SetInput( mst ); - mst_writer->SetFileName( mst_output_fn ); - mst_writer->Update( ); - - fpa::IO::UniqueValuesContainerWriter< TFilter::TUniqueVertices >::Pointer - endpoints_writer = - fpa::IO::UniqueValuesContainerWriter< TFilter::TUniqueVertices >::New( ); - endpoints_writer->SetInput( endpoints ); - endpoints_writer->SetFileName( endpoints_output_fn ); - endpoints_writer->Update( ); - - fpa::IO::UniqueValuesContainerWriter< TFilter::TUniqueVertices >::Pointer - bifurcations_writer = - fpa::IO::UniqueValuesContainerWriter< TFilter::TUniqueVertices >::New( ); - bifurcations_writer->SetInput( bifurcations ); - bifurcations_writer->SetFileName( bifurcations_output_fn ); - bifurcations_writer->Update( ); - - fpa::IO::MatrixValuesContainerWriter< TFilter::TBranches >::Pointer - branches_writer = - fpa::IO::MatrixValuesContainerWriter< TFilter::TBranches >::New( ); - branches_writer->SetInput( branches ); - branches_writer->SetFileName( branches_output_fn ); - branches_writer->Update( ); - - // Show endpoints - vtkSmartPointer< vtkPoints > endpoints_points = - vtkSmartPointer< vtkPoints >::New( ); - vtkSmartPointer< vtkCellArray > endpoints_cells = - vtkSmartPointer< vtkCellArray >::New( ); - for( - TFilter::TUniqueVertices::ConstIterator epIt = endpoints->Begin( ); - epIt != endpoints->End( ); - ++epIt - ) - { - TImage::PointType pnt; - input_image->TransformIndexToPhysicalPoint( *epIt, pnt ); - endpoints_points->InsertNextPoint( pnt[ 0 ], pnt[ 1 ], pnt[ 2 ] ); - endpoints_cells->InsertNextCell( 1 ); - endpoints_cells-> - InsertCellPoint( endpoints_points->GetNumberOfPoints( ) - 1 ); - - } // rof - vtkSmartPointer< vtkPolyData > endpoints_polydata = - vtkSmartPointer< vtkPolyData >::New( ); - endpoints_polydata->SetPoints( endpoints_points ); - endpoints_polydata->SetVerts( endpoints_cells ); - view.AddPolyData( endpoints_polydata, 0, 0, 1, 1 ); - - // Show bifurcations - vtkSmartPointer< vtkPoints > bifurcations_points = - vtkSmartPointer< vtkPoints >::New( ); - vtkSmartPointer< vtkCellArray > bifurcations_cells = - vtkSmartPointer< vtkCellArray >::New( ); - for( - TFilter::TUniqueVertices::ConstIterator bfIt = bifurcations->Begin( ); - bfIt != bifurcations->End( ); - ++bfIt - ) - { - TImage::PointType pnt; - input_image->TransformIndexToPhysicalPoint( *bfIt, pnt ); - bifurcations_points->InsertNextPoint( pnt[ 0 ], pnt[ 1 ], pnt[ 2 ] ); - bifurcations_cells->InsertNextCell( 1 ); - bifurcations_cells-> - InsertCellPoint( bifurcations_points->GetNumberOfPoints( ) - 1 ); - - } // rof - vtkSmartPointer< vtkPolyData > bifurcations_polydata = - vtkSmartPointer< vtkPolyData >::New( ); - bifurcations_polydata->SetPoints( bifurcations_points ); - bifurcations_polydata->SetVerts( bifurcations_cells ); - view.AddPolyData( bifurcations_polydata, 0, 1, 0, 1 ); - - // Show branches (simple and detailed) - vtkSmartPointer< vtkPoints > simple_branches_points = - vtkSmartPointer< vtkPoints >::New( ); - vtkSmartPointer< vtkCellArray > simple_branches_cells = - vtkSmartPointer< vtkCellArray >::New( ); - - vtkSmartPointer< vtkPoints > detailed_branches_points = - vtkSmartPointer< vtkPoints >::New( ); - vtkSmartPointer< vtkCellArray > detailed_branches_cells = - vtkSmartPointer< vtkCellArray >::New( ); - vtkSmartPointer< vtkFloatArray > detailed_branches_scalars = - vtkSmartPointer< vtkFloatArray >::New( ); - - TFilter::TBranches::ConstIterator brIt = branches->Begin( ); - for( ; brIt != branches->End( ); ++brIt ) - { - // Branch's first point - TImage::PointType first_point; - input_image->TransformIndexToPhysicalPoint( brIt->first, first_point ); - unsigned long first_id = simple_branches_points->GetNumberOfPoints( ); - simple_branches_points->InsertNextPoint( - first_point[ 0 ], first_point[ 1 ], first_point[ 2 ] - ); - - TFilter::TBranches::ConstRowIterator brRowIt = branches->Begin( brIt ); - for( ; brRowIt != branches->End( brIt ); ++brRowIt ) - { - // Branch's second point - TImage::PointType second_point; - input_image-> - TransformIndexToPhysicalPoint( brRowIt->first, second_point ); - unsigned long second_id = simple_branches_points->GetNumberOfPoints( ); - simple_branches_points->InsertNextPoint( - second_point[ 0 ], second_point[ 1 ], second_point[ 2 ] - ); - simple_branches_cells->InsertNextCell( 2 ); - simple_branches_cells->InsertCellPoint( first_id ); - simple_branches_cells->InsertCellPoint( second_id ); - - // Detailed path - double pathId = double( brRowIt->second - 1 ) / double( nBranches - 1 ); - TFilter::TVertices path; - mst->GetPath( path, brIt->first, brRowIt->first ); - TFilter::TVertices::const_iterator pIt = path.begin( ); - for( ; pIt != path.end( ); ++pIt ) - { - TImage::PointType path_point; - input_image->TransformIndexToPhysicalPoint( *pIt, path_point ); - detailed_branches_points->InsertNextPoint( - path_point[ 0 ], path_point[ 1 ], path_point[ 2 ] - ); - detailed_branches_scalars->InsertNextTuple1( pathId ); - if( pIt != path.begin( ) ) - { - unsigned long nPoints = - detailed_branches_points->GetNumberOfPoints( ); - detailed_branches_cells->InsertNextCell( 2 ); - detailed_branches_cells->InsertCellPoint( nPoints - 2 ); - detailed_branches_cells->InsertCellPoint( nPoints - 1 ); - - } // fi - - } // rof - - } // rof - - } // rof - vtkSmartPointer< vtkPolyData > simple_branches_polydata = - vtkSmartPointer< vtkPolyData >::New( ); - simple_branches_polydata->SetPoints( simple_branches_points ); - simple_branches_polydata->SetLines( simple_branches_cells ); - view.AddPolyData( simple_branches_polydata, 1, 0, 1, 1 ); - - vtkSmartPointer< vtkPolyData > detailed_branches_polydata = - vtkSmartPointer< vtkPolyData >::New( ); - detailed_branches_polydata->SetPoints( detailed_branches_points ); - detailed_branches_polydata->SetLines( detailed_branches_cells ); - detailed_branches_polydata-> - GetPointData( )->SetScalars( detailed_branches_scalars ); - view.AddPolyData( detailed_branches_polydata, 1 ); - - // Let some more interaction - view.Render( ); - view.Start( ); - - return( 0 ); -} - -// ------------------------------------------------------------------------- -template< class I > -void ReadImage( typename I::Pointer& image, const std::string& filename ) -{ - typename itk::ImageFileReader< I >::Pointer reader = - itk::ImageFileReader< I >::New( ); - reader->SetFileName( filename ); - reader->Update( ); - image = reader->GetOutput( ); - image->DisconnectPipeline( ); -} - -// ------------------------------------------------------------------------- -template< class I > -void SaveImage( const I* image, const std::string& filename ) -{ - typename itk::ImageFileWriter< I >::Pointer writer = - itk::ImageFileWriter< I >::New( ); - writer->SetInput( image ); - writer->SetFileName( filename ); - try - { - writer->Update( ); - } - catch( itk::ExceptionObject& err ) - { - std::cerr - << "Error saving \"" << filename << "\": " << err - << std::endl; - - } // yrt -} - -// eof - $RCSfile$ diff --git a/appli/examples/example_Image_IncrementalRegionGrow_Thresholds.cxx b/appli/examples/example_Image_IncrementalRegionGrow_Thresholds.cxx deleted file mode 100644 index 3261b60..0000000 --- a/appli/examples/example_Image_IncrementalRegionGrow_Thresholds.cxx +++ /dev/null @@ -1,235 +0,0 @@ -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include -#include -#include - -/* - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - - #include - #include -*/ - -// ------------------------------------------------------------------------- -const unsigned int Dim = 3; -typedef short TInputPixel; -typedef short TOutputPixel; - -typedef itk::Image< TInputPixel, Dim > TInputImage; -typedef itk::Image< TOutputPixel, Dim > TOutputImage; -typedef itk::ImageToVTKImageFilter< TInputImage > TVTKInputImage; - -// ------------------------------------------------------------------------- -int main( int argc, char* argv[] ) -{ - if( argc < 8 ) - { - std::cerr - << "Usage: " << argv[ 0 ] << std::endl - << "\tinput_image" << std::endl - << "\toutput_image" << std::endl - << "\tneighborhood_order" << std::endl - << "\tstop_at_one_front" << std::endl - << "\tinit_threshold" << std::endl - << "\tend_threshold" << std::endl - << "\tsamples" << std::endl - << "\t[input_seeds]" << std::endl; - return( 1 ); - - } // fi - std::string input_image_fn = argv[ 1 ]; - std::string output_image_fn = argv[ 2 ]; - unsigned int neighborhood_order = std::atoi( argv[ 3 ] ); - bool stop_at_one_front = ( std::atoi( argv[ 4 ] ) != 0 ); - TInputPixel init_threshold = TInputPixel( std::atof( argv[ 5 ] ) ); - TInputPixel end_threshold = TInputPixel( std::atof( argv[ 6 ] ) ); - unsigned int samples = TInputPixel( std::atof( argv[ 7 ] ) ); - std::string input_seeds_fn = ( argc >= 9 )? argv[ 8 ]: ""; - - // Read image - itk::ImageFileReader< TInputImage >::Pointer input_image_reader = - itk::ImageFileReader< TInputImage >::New( ); - input_image_reader->SetFileName( input_image_fn ); - try - { - input_image_reader->Update( ); - } - catch( itk::ExceptionObject& err ) - { - std::cerr - << "Error while reading image from " << input_image_fn << ": " - << err << std::endl; - return( 1 ); - - } // yrt - TInputImage::ConstPointer input_image = input_image_reader->GetOutput( ); - TVTKInputImage::Pointer vtk_input_image = TVTKInputImage::New( ); - vtk_input_image->SetInput( input_image ); - vtk_input_image->Update( ); - - // Show input image and let some interaction - fpa::VTK::ImageMPR view; - view.SetBackground( 0.3, 0.2, 0.8 ); - view.SetSize( 600, 600 ); - view.SetImage( vtk_input_image->GetOutput( ) ); - view.Render( ); - - // Read seeds - std::vector< TInputImage::IndexType > input_seeds; - if( input_seeds_fn != "" ) - { - std::ifstream input_seeds_str( input_seeds_fn.c_str( ) ); - if( input_seeds_str ) - { - unsigned int nSeeds; - input_seeds_str >> nSeeds; - for( unsigned int i = 0; i < nSeeds; ++i ) - { - TInputImage::PointType pnt; - input_seeds_str >> pnt[ 0 ] >> pnt[ 1 ] >> pnt[ 2 ]; - - TInputImage::IndexType idx; - input_image_reader->GetOutput( )-> - TransformPhysicalPointToIndex( pnt, idx ); - input_seeds.push_back( idx ); - - view.AddSeed( pnt[ 0 ], pnt[ 1 ], pnt[ 2 ] ); - - } // rof - input_seeds_str.close( ); - } - else - std::cerr << "Error reading \"" << input_seeds_fn << "\"" << std::endl; - - } // fi - - // Allow some interaction - view.Render( ); - if( input_seeds.size( ) == 0 ) - { - while( view.GetNumberOfSeeds( ) == 0 ) - view.Start( ); - - for( unsigned int i = 0; i < view.GetNumberOfSeeds( ); ++i ) - { - double p[ 3 ]; - view.GetSeed( i, p ); - - TInputImage::PointType pnt; - pnt[ 0 ] = p[ 0 ]; - pnt[ 1 ] = p[ 1 ]; - pnt[ 2 ] = p[ 2 ]; - - TInputImage::IndexType idx; - input_image_reader->GetOutput( )-> - TransformPhysicalPointToIndex( pnt, idx ); - input_seeds.push_back( idx ); - - } // rof - } - else - view.Start( ); - - // Prepare region grow filter and cost function - typedef fpa::Image:: - IncrementalRegionGrow< TInputImage, TOutputImage > TFilter; - typedef fpa::Image::Functors:: - RegionGrowThresholdFunction< TInputImage > TFunction; - - TFilter::Pointer filter = TFilter::New( ); - filter->SetInput( input_image_reader->GetOutput( ) ); - - /* - typedef fpa::Image::Dijkstra< TInputImage, TOutputImage > TFilter; - typedef fpa::Image::Functors:: - ImageAbsoluteDifferenceCostFunction< TFilter::TInputImage, TFilter::TResult > - TCost; - - TCost::Pointer cost = TCost::New( ); - - TFilter::Pointer filter = TFilter::New( ); - filter->SetInput( input_image ); - filter->SetCostFunction( cost ); - filter->SetConversionFunction( NULL ); - filter->SetNeighborhoodOrder( neighborhood_order ); - filter->SetStopAtOneFront( stop_at_one_front ); - - // Get user-given seeds - std::ifstream input_seeds_str( input_seeds_fn.c_str( ) ); - if( !input_seeds_str ) - { - std::cerr << "Error opening \"" << input_seeds_fn << "\"" << std::endl; - return( 1 ); - - } // fi - - unsigned int nSeeds; - input_seeds_str >> nSeeds; - std::vector< TInputImage::IndexType > input_seeds; - for( unsigned int s = 0; s < nSeeds; s++ ) - { - TInputImage::IndexType idx; - input_seeds_str >> idx[ 0 ] >> idx[ 1 ] >> idx[ 2 ]; - input_seeds.push_back( idx ); - - } // rof - input_seeds_str.close( ); - - filter->AddSeed( input_seeds[ init_seed ], 0 ); - filter->AddSeed( input_seeds[ end_seed ], 0 ); - - // Prepare graphical debugger - typedef fpa::VTK::Image3DObserver< TFilter, vtkRenderWindow > TDebugger; - TDebugger::Pointer debugger = TDebugger::New( ); - debugger->SetRenderWindow( view.GetWindow( ) ); - debugger->SetRenderPercentage( 0.0001 ); - filter->AddObserver( itk::AnyEvent( ), debugger ); - filter->ThrowEventsOn( ); - - // Go! - filter->Update( ); - - // Save final total cost map - itk::ImageFileWriter< TOutputImage >::Pointer output_image_writer = - itk::ImageFileWriter< TOutputImage >::New( ); - output_image_writer->SetFileName( output_image_fn ); - output_image_writer->SetInput( filter->GetOutput( ) ); - try - { - output_image_writer->Update( ); - } - catch( itk::ExceptionObject& err ) - { - std::cerr - << "Error while writing image to " << output_image_fn << ": " - << err << std::endl; - return( 1 ); - - } // yrt - */ - - return( 0 ); -} - -// eof - $RCSfile$ diff --git a/appli/examples/example_Image_RegionGrow_AllPixels.cxx b/appli/examples/example_Image_RegionGrow_AllPixels.cxx deleted file mode 100644 index db7db5f..0000000 --- a/appli/examples/example_Image_RegionGrow_AllPixels.cxx +++ /dev/null @@ -1,101 +0,0 @@ -#include -#include -#include -#include - -#include -#include - -#include -#include -#include - -#include "fpa_Utility.h" - -// ------------------------------------------------------------------------- -const unsigned int Dim = 2; -typedef unsigned char TPixel; -typedef itk::Image< TPixel, Dim > TImage; - -// ------------------------------------------------------------------------- -int main( int argc, char* argv[] ) -{ - if( argc < 4 ) - { - std::cerr - << "Usage: " << argv[ 0 ] - << " input_image neighborhood_order stop_at_one_front" - << std::endl; - return( 1 ); - - } // fi - std::string input_image_fn = argv[ 1 ]; - unsigned int neighborhood_order = std::atoi( argv[ 2 ] ); - bool stop_at_one_front = ( std::atoi( argv[ 3 ] ) != 0 ); - - // Read image - TImage::Pointer input_image; - std::string err = fpa_Utility::ReadImage( input_image, input_image_fn ); - if( err != "" ) - { - std::cerr << err << std::endl; - return( 1 ); - - } // fi - - // Show image and wait for, at least, one seed - itk::ImageToVTKImageFilter< TImage >::Pointer vtk_input_image = - itk::ImageToVTKImageFilter< TImage >::New( ); - vtk_input_image->SetInput( input_image ); - vtk_input_image->Update( ); - - fpa_Utility::Viewer2DWithSeeds viewer; - viewer.SetImage( vtk_input_image->GetOutput( ) ); - while( viewer.GetNumberOfSeeds( ) == 0 ) - viewer.Start( ); - - // Region growing types - typedef fpa::Image::RegionGrow< TImage > TFilter; - typedef fpa::Image::Functors:: - RegionGrowAllBelongsFunction< TImage > TFunction; - - // Prepare region grow function - TFunction::Pointer function = TFunction::New( ); - - // Prepare region grow filter - TFilter::Pointer filter = TFilter::New( ); - filter->SetInput( input_image ); - filter->SetGrowingFunction( function ); - filter->SetNeighborhoodOrder( neighborhood_order ); - filter->SetOutsideValue( TPixel( 0 ) ); - filter->SetInsideValue( std::numeric_limits< TPixel >::max( ) ); - filter->SetStopAtOneFront( stop_at_one_front ); - - // Associate seeds - for( unsigned long s = 0; s < viewer.GetNumberOfSeeds( ); ++s ) - { - TImage::PointType pnt; - TImage::IndexType idx; - viewer.GetSeed( pnt, s ); - if( input_image->TransformPhysicalPointToIndex( pnt, idx ) ) - filter->AddSeed( idx, 0 ); - - } // rof - - // Prepare graphical debugger - typedef fpa::VTK::Image2DObserver< TFilter, vtkRenderWindow > TDebugger; - TDebugger::Pointer debugger = TDebugger::New( ); - debugger->SetRenderWindow( viewer.Window ); - debugger->SetRenderPercentage( 0.01 ); - filter->AddObserver( itk::AnyEvent( ), debugger ); - filter->ThrowEventsOn( ); - - // Go! - filter->Update( ); - - // Some more interaction and finish - viewer.Start( ); - return( 0 ); -} - -// eof - $RCSfile$ diff --git a/appli/examples/example_Image_RegionGrow_AllRGBPixels.cxx b/appli/examples/example_Image_RegionGrow_AllRGBPixels.cxx deleted file mode 100644 index c46c758..0000000 --- a/appli/examples/example_Image_RegionGrow_AllRGBPixels.cxx +++ /dev/null @@ -1,103 +0,0 @@ -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include - -#include "fpa_Utility.h" - -// ------------------------------------------------------------------------- -const unsigned int Dim = 2; -typedef unsigned char TPixel; -typedef itk::Image< itk::RGBPixel< TPixel >, Dim > TColorImage; -typedef itk::Image< TPixel, Dim > TImage; - -// ------------------------------------------------------------------------- -int main( int argc, char* argv[] ) -{ - if( argc < 4 ) - { - std::cerr - << "Usage: " << argv[ 0 ] - << " input_image neighborhood_order stop_at_one_front" - << std::endl; - return( 1 ); - - } // fi - std::string input_image_fn = argv[ 1 ]; - unsigned int neighborhood_order = std::atoi( argv[ 2 ] ); - bool stop_at_one_front = ( std::atoi( argv[ 3 ] ) != 0 ); - - // Read image - TColorImage::Pointer input_image; - std::string err = fpa_Utility::ReadImage( input_image, input_image_fn ); - if( err != "" ) - { - std::cerr << err << std::endl; - return( 1 ); - - } // fi - - // Show image and wait for, at least, one seed - itk::ImageToVTKImageFilter< TColorImage >::Pointer vtk_input_image = - itk::ImageToVTKImageFilter< TColorImage >::New( ); - vtk_input_image->SetInput( input_image ); - vtk_input_image->Update( ); - - fpa_Utility::Viewer2DWithSeeds viewer; - viewer.SetImage( vtk_input_image->GetOutput( ) ); - while( viewer.GetNumberOfSeeds( ) == 0 ) - viewer.Start( ); - - // Region growing types - typedef fpa::Image::RegionGrow< TColorImage, TImage > TFilter; - typedef fpa::Image::Functors:: - RegionGrowAllBelongsFunction< TColorImage > TFunction; - - // Prepare region grow function - TFunction::Pointer function = TFunction::New( ); - - // Prepare region grow filter - TFilter::Pointer filter = TFilter::New( ); - filter->SetInput( input_image ); - filter->SetGrowingFunction( function ); - filter->SetNeighborhoodOrder( neighborhood_order ); - filter->SetOutsideValue( TPixel( 0 ) ); - filter->SetInsideValue( std::numeric_limits< TPixel >::max( ) ); - filter->SetStopAtOneFront( stop_at_one_front ); - - // Associate seeds - for( unsigned long s = 0; s < viewer.GetNumberOfSeeds( ); ++s ) - { - TImage::PointType pnt; - TImage::IndexType idx; - viewer.GetSeed( pnt, s ); - if( input_image->TransformPhysicalPointToIndex( pnt, idx ) ) - filter->AddSeed( idx, 0 ); - - } // rof - - // Prepare graphical debugger - typedef fpa::VTK::Image2DObserver< TFilter, vtkRenderWindow > TDebugger; - TDebugger::Pointer debugger = TDebugger::New( ); - debugger->SetRenderWindow( viewer.Window ); - debugger->SetRenderPercentage( 0.01 ); - filter->AddObserver( itk::AnyEvent( ), debugger ); - filter->ThrowEventsOn( ); - - // Go! - filter->Update( ); - - // Some more interaction and finish - viewer.Start( ); - return( 0 ); -} - -// eof - $RCSfile$ diff --git a/appli/examples/example_Image_RegionGrow_ConnectedPixels.cxx b/appli/examples/example_Image_RegionGrow_ConnectedPixels.cxx deleted file mode 100644 index 4f65ce6..0000000 --- a/appli/examples/example_Image_RegionGrow_ConnectedPixels.cxx +++ /dev/null @@ -1,98 +0,0 @@ -#include -#include -#include -#include - -#include -#include - -#include -#include -#include - -#include "fpa_Utility.h" - -// ------------------------------------------------------------------------- -const unsigned int Dim = 2; -typedef unsigned char TPixel; -typedef itk::Image< TPixel, Dim > TImage; - -// ------------------------------------------------------------------------- -int main( int argc, char* argv[] ) -{ - if( argc < 3 ) - { - std::cerr - << "Usage: " << argv[ 0 ] - << " input_image neighborhood_order" - << std::endl; - return( 1 ); - - } // fi - std::string input_image_fn = argv[ 1 ]; - unsigned int neighborhood_order = std::atoi( argv[ 2 ] ); - - // Read image - TImage::Pointer input_image; - std::string err = fpa_Utility::ReadImage( input_image, input_image_fn ); - if( err != "" ) - { - std::cerr << err << std::endl; - return( 1 ); - - } // fi - - // Show image and wait for, at least, one seed - itk::ImageToVTKImageFilter< TImage >::Pointer vtk_input_image = - itk::ImageToVTKImageFilter< TImage >::New( ); - vtk_input_image->SetInput( input_image ); - vtk_input_image->Update( ); - - fpa_Utility::Viewer2DWithSeeds viewer; - viewer.SetImage( vtk_input_image->GetOutput( ) ); - while( viewer.GetNumberOfSeeds( ) == 0 ) - viewer.Start( ); - - // Region growing types - typedef fpa::Image::RegionGrow< TImage > TFilter; - typedef fpa::Image::Functors:: - RegionGrowThresholdFunction< TImage > TFunction; - - // Prepare region grow function - TFunction::Pointer function = TFunction::New( ); - - // Prepare region grow filter - TFilter::Pointer filter = TFilter::New( ); - filter->SetInput( input_image ); - filter->SetGrowingFunction( function ); - filter->SetNeighborhoodOrder( neighborhood_order ); - filter->SetOutsideValue( TPixel( 0 ) ); - filter->SetInsideValue( std::numeric_limits< TPixel >::max( ) ); - filter->StopAtOneFrontOff( ); - - // Associate seed - TImage::PointType pnt; - TImage::IndexType idx; - viewer.GetSeed( pnt, 0 ); - if( input_image->TransformPhysicalPointToIndex( pnt, idx ) ) - filter->AddSeed( idx, 0 ); - function->SetLowerThreshold( input_image->GetPixel( idx ) ); - function->SetUpperThreshold( input_image->GetPixel( idx ) ); - - // Prepare graphical debugger - typedef fpa::VTK::Image2DObserver< TFilter, vtkRenderWindow > TDebugger; - TDebugger::Pointer debugger = TDebugger::New( ); - debugger->SetRenderWindow( viewer.Window ); - debugger->SetRenderPercentage( 0.01 ); - filter->AddObserver( itk::AnyEvent( ), debugger ); - filter->ThrowEventsOn( ); - - // Go! - filter->Update( ); - - // Some more interaction and finish - viewer.Start( ); - return( 0 ); -} - -// eof - $RCSfile$ diff --git a/appli/examples/example_Image_RegionGrow_ConnectedRGBPixels.cxx b/appli/examples/example_Image_RegionGrow_ConnectedRGBPixels.cxx deleted file mode 100644 index 0dc0137..0000000 --- a/appli/examples/example_Image_RegionGrow_ConnectedRGBPixels.cxx +++ /dev/null @@ -1,100 +0,0 @@ -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include - -#include "fpa_Utility.h" - -// ------------------------------------------------------------------------- -const unsigned int Dim = 2; -typedef unsigned char TPixel; -typedef itk::Image< itk::RGBPixel< TPixel >, Dim > TColorImage; -typedef itk::Image< TPixel, Dim > TImage; - -// ------------------------------------------------------------------------- -int main( int argc, char* argv[] ) -{ - if( argc < 3 ) - { - std::cerr - << "Usage: " << argv[ 0 ] - << " input_image neighborhood_order" - << std::endl; - return( 1 ); - - } // fi - std::string input_image_fn = argv[ 1 ]; - unsigned int neighborhood_order = std::atoi( argv[ 2 ] ); - - // Read image - TColorImage::Pointer input_image; - std::string err = fpa_Utility::ReadImage( input_image, input_image_fn ); - if( err != "" ) - { - std::cerr << err << std::endl; - return( 1 ); - - } // fi - - // Show image and wait for, at least, one seed - itk::ImageToVTKImageFilter< TColorImage >::Pointer vtk_input_image = - itk::ImageToVTKImageFilter< TColorImage >::New( ); - vtk_input_image->SetInput( input_image ); - vtk_input_image->Update( ); - - fpa_Utility::Viewer2DWithSeeds viewer; - viewer.SetImage( vtk_input_image->GetOutput( ) ); - while( viewer.GetNumberOfSeeds( ) == 0 ) - viewer.Start( ); - - // Region growing types - typedef fpa::Image::RegionGrow< TColorImage, TImage > TFilter; - typedef fpa::Image::Functors:: - RegionGrowThresholdFunction< TColorImage > TFunction; - - // Prepare region grow function - TFunction::Pointer function = TFunction::New( ); - - // Prepare region grow filter - TFilter::Pointer filter = TFilter::New( ); - filter->SetInput( input_image ); - filter->SetGrowingFunction( function ); - filter->SetNeighborhoodOrder( neighborhood_order ); - filter->SetOutsideValue( TPixel( 0 ) ); - filter->SetInsideValue( std::numeric_limits< TPixel >::max( ) ); - filter->StopAtOneFrontOff( ); - - // Associate seed - TImage::PointType pnt; - TImage::IndexType idx; - viewer.GetSeed( pnt, 0 ); - if( input_image->TransformPhysicalPointToIndex( pnt, idx ) ) - filter->AddSeed( idx, 0 ); - function->SetLowerThreshold( input_image->GetPixel( idx ) ); - function->SetUpperThreshold( input_image->GetPixel( idx ) ); - - // Prepare graphical debugger - typedef fpa::VTK::Image2DObserver< TFilter, vtkRenderWindow > TDebugger; - TDebugger::Pointer debugger = TDebugger::New( ); - debugger->SetRenderWindow( viewer.Window ); - debugger->SetRenderPercentage( 0.01 ); - filter->AddObserver( itk::AnyEvent( ), debugger ); - filter->ThrowEventsOn( ); - - // Go! - filter->Update( ); - - // Some more interaction and finish - viewer.Start( ); - return( 0 ); -} - -// eof - $RCSfile$ diff --git a/appli/examples/example_Image_RegionGrow_GaussianModelEstimation.cxx b/appli/examples/example_Image_RegionGrow_GaussianModelEstimation.cxx deleted file mode 100644 index 914e3fa..0000000 --- a/appli/examples/example_Image_RegionGrow_GaussianModelEstimation.cxx +++ /dev/null @@ -1,173 +0,0 @@ -#include -#include -#include -#include - -#include -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -// ------------------------------------------------------------------------- -const unsigned int Dim = 2; -typedef unsigned char TPixel; -typedef float TScalar; - -typedef itk::Image< itk::RGBPixel< TPixel >, Dim > TColorImage; -typedef itk::Image< TPixel, Dim > TImage; -typedef itk::ImageToVTKImageFilter< TColorImage > TVTKImage; - -// ------------------------------------------------------------------------- -int main( int argc, char* argv[] ) -{ - if( argc < 4 ) - { - std::cerr - << "Usage: " << argv[ 0 ] - << " input_image neighborhood_order support [model_file]" - << std::endl; - return( 1 ); - - } // fi - std::string input_image_fn = argv[ 1 ]; - unsigned int neighborhood_order = std::atoi( argv[ 2 ] ); - unsigned long support = std::atoi( argv[ 3 ] ); - - // Read image - itk::ImageFileReader< TColorImage >::Pointer input_image_reader = - itk::ImageFileReader< TColorImage >::New( ); - input_image_reader->SetFileName( input_image_fn ); - try - { - input_image_reader->Update( ); - } - catch( itk::ExceptionObject& err ) - { - std::cerr - << "Error while reading image from " << input_image_fn << ": " - << err << std::endl; - return( 1 ); - - } // yrt - TColorImage::ConstPointer input_image = input_image_reader->GetOutput( ); - TVTKImage::Pointer vtk_input_image = TVTKImage::New( ); - vtk_input_image->SetInput( input_image ); - vtk_input_image->Update( ); - - // VTK visualization - vtkSmartPointer< vtkImageActor > actor = - vtkSmartPointer< vtkImageActor >::New( ); - actor->SetInputData( vtk_input_image->GetOutput( ) ); - - vtkSmartPointer< vtkRenderer > renderer = - vtkSmartPointer< vtkRenderer >::New( ); - renderer->SetBackground( 0.1, 0.2, 0.7 ); - renderer->AddActor( actor ); - vtkSmartPointer< vtkRenderWindow > window = - vtkSmartPointer< vtkRenderWindow >::New( ); - window->SetSize( 800, 800 ); - window->AddRenderer( renderer ); - - // Correct camera due to the loaded image - vtkCamera* camera = renderer->GetActiveCamera( ); - camera->SetViewUp( 0, -1, 0 ); - camera->SetPosition( 0, 0, -1 ); - camera->SetFocalPoint( 0, 0, 0 ); - - // VTK interaction - vtkSmartPointer< vtkInteractorStyleImage > imageStyle = - vtkSmartPointer< vtkInteractorStyleImage >::New( ); - vtkSmartPointer< vtkRenderWindowInteractor > interactor = - vtkSmartPointer< vtkRenderWindowInteractor >::New( ); - interactor->SetInteractorStyle( imageStyle ); - window->SetInteractor( interactor ); - - // Create the widget and its representation - vtkSmartPointer< vtkPointHandleRepresentation3D > handle = - vtkSmartPointer< vtkPointHandleRepresentation3D >::New( ); - handle->GetProperty( )->SetColor( 1, 0, 0 ); - vtkSmartPointer< vtkSeedRepresentation > rep = - vtkSmartPointer< vtkSeedRepresentation >::New( ); - rep->SetHandleRepresentation( handle ); - - vtkSmartPointer< vtkSeedWidget > widget = - vtkSmartPointer< vtkSeedWidget >::New( ); - widget->SetInteractor( interactor ); - widget->SetRepresentation( rep ); - - // Let some interaction - interactor->Initialize( ); - renderer->ResetCamera( ); - window->Render( ); - widget->On( ); - interactor->Start( ); - - // Prepare region grow function - typedef fpa::Image::Functors::GaussianModelEstimatorFunction< TColorImage, TScalar > TFunction; - TFunction::Pointer function = TFunction::New( ); - function->SetModelSupport( support ); - if( argc > 4 ) - function->LoadModelFromFile( argv[ 4 ] ); - - // Prepare region grow filter - typedef fpa::Image::RegionGrow< TColorImage, TImage > TFilter; - TFilter::Pointer filter = TFilter::New( ); - filter->SetInput( input_image ); - filter->SetMembershipFunction( function ); - filter->SetNeighborhoodOrder( neighborhood_order ); - filter->SetOutsideValue( TPixel( 0 ) ); - filter->SetInsideValue( std::numeric_limits< TPixel >::max( ) ); - filter->StopAtOneFrontOff( ); - - // Get user-given seeds - for( unsigned int s = 0; s < rep->GetNumberOfSeeds( ); s++ ) - { - double pos[ 3 ]; - rep->GetSeedWorldPosition( s, pos ); - - TImage::PointType pnt; - pnt[ 0 ] = TImage::PointType::ValueType( pos[ 0 ] ); - pnt[ 1 ] = TImage::PointType::ValueType( pos[ 1 ] ); - - TImage::IndexType idx; - if( input_image->TransformPhysicalPointToIndex( pnt, idx ) ) - filter->AddSeed( idx, 0 ); - - } // rof - - // Prepare graphical debugger - typedef fpa::VTK::Image2DObserver< TFilter, vtkRenderWindow > TDebugger; - TDebugger::Pointer debugger = TDebugger::New( ); - debugger->SetRenderWindow( window ); - debugger->SetRenderPercentage( 0.001 ); - filter->AddObserver( itk::AnyEvent( ), debugger ); - filter->ThrowEventsOn( ); - - // Go! - filter->Update( ); - - window->Render( ); - widget->Off( ); - interactor->Start( ); - - return( 0 ); -} - -// eof - $RCSfile$ diff --git a/appli/examples/example_IncrementalRegionGrow_Thresholds.cxx b/appli/examples/example_IncrementalRegionGrow_Thresholds.cxx deleted file mode 100644 index 47affc1..0000000 --- a/appli/examples/example_IncrementalRegionGrow_Thresholds.cxx +++ /dev/null @@ -1,164 +0,0 @@ -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -// ------------------------------------------------------------------------- -const unsigned int Dim = 3; -typedef float TInputPixel; -typedef float TOutputPixel; - -typedef itk::Image< TInputPixel, Dim > TInputImage; -typedef itk::Image< TOutputPixel, Dim > TOutputImage; -typedef itk::ImageToVTKImageFilter< TInputImage > TVTKInputImage; - -// ------------------------------------------------------------------------- -int main( int argc, char* argv[] ) -{ - if( argc < 8 ) - { - std::cerr - << "Usage: " << argv[ 0 ] - << " input_image input_seeds output_image" - << " neighborhood_order stop_at_one_front" - << " init_seed end_seed" - << std::endl; - return( 1 ); - - } // fi - std::string input_image_fn = argv[ 1 ]; - std::string input_seeds_fn = argv[ 2 ]; - std::string output_image_fn = argv[ 3 ]; - unsigned int neighborhood_order = std::atoi( argv[ 4 ] ); - bool stop_at_one_front = ( std::atoi( argv[ 5 ] ) != 0 ); - unsigned int init_seed = std::atoi( argv[ 6 ] ); - unsigned int end_seed = std::atoi( argv[ 7 ] ); - - // Read image - itk::ImageFileReader< TInputImage >::Pointer input_image_reader = - itk::ImageFileReader< TInputImage >::New( ); - input_image_reader->SetFileName( input_image_fn ); - try - { - input_image_reader->Update( ); - } - catch( itk::ExceptionObject& err ) - { - std::cerr - << "Error while reading image from " << input_image_fn << ": " - << err << std::endl; - return( 1 ); - - } // yrt - TInputImage::ConstPointer input_image = input_image_reader->GetOutput( ); - TVTKInputImage::Pointer vtk_input_image = TVTKInputImage::New( ); - vtk_input_image->SetInput( input_image ); - vtk_input_image->Update( ); - - // Show input image and let some interaction - fpa::VTK::ImageMPR view; - view.SetBackground( 0.3, 0.2, 0.8 ); - view.SetSize( 600, 600 ); - view.SetImage( vtk_input_image->GetOutput( ) ); - - // Allow some interaction - view.Render( ); - view.Start( ); - - // Prepare region grow filter and cost function - typedef fpa::Image::Dijkstra< TInputImage, TOutputImage > TFilter; - typedef fpa::Image::Functors:: - ImageAbsoluteDifferenceCostFunction< TFilter::TInputImage, TFilter::TResult > - TCost; - - TCost::Pointer cost = TCost::New( ); - - TFilter::Pointer filter = TFilter::New( ); - filter->SetInput( input_image ); - filter->SetCostFunction( cost ); - filter->SetConversionFunction( NULL ); - filter->SetNeighborhoodOrder( neighborhood_order ); - filter->SetStopAtOneFront( stop_at_one_front ); - - // Get user-given seeds - std::ifstream input_seeds_str( input_seeds_fn.c_str( ) ); - if( !input_seeds_str ) - { - std::cerr << "Error opening \"" << input_seeds_fn << "\"" << std::endl; - return( 1 ); - - } // fi - - unsigned int nSeeds; - input_seeds_str >> nSeeds; - std::vector< TInputImage::IndexType > input_seeds; - for( unsigned int s = 0; s < nSeeds; s++ ) - { - TInputImage::IndexType idx; - input_seeds_str >> idx[ 0 ] >> idx[ 1 ] >> idx[ 2 ]; - input_seeds.push_back( idx ); - - } // rof - input_seeds_str.close( ); - - filter->AddSeed( input_seeds[ init_seed ], 0 ); - filter->AddSeed( input_seeds[ end_seed ], 0 ); - - // Prepare graphical debugger - typedef fpa::VTK::Image3DObserver< TFilter, vtkRenderWindow > TDebugger; - TDebugger::Pointer debugger = TDebugger::New( ); - debugger->SetRenderWindow( view.GetWindow( ) ); - debugger->SetRenderPercentage( 0.0001 ); - filter->AddObserver( itk::AnyEvent( ), debugger ); - filter->ThrowEventsOn( ); - - // Go! - filter->Update( ); - - // Save final total cost map - itk::ImageFileWriter< TOutputImage >::Pointer output_image_writer = - itk::ImageFileWriter< TOutputImage >::New( ); - output_image_writer->SetFileName( output_image_fn ); - output_image_writer->SetInput( filter->GetOutput( ) ); - try - { - output_image_writer->Update( ); - } - catch( itk::ExceptionObject& err ) - { - std::cerr - << "Error while writing image to " << output_image_fn << ": " - << err << std::endl; - return( 1 ); - - } // yrt - - return( 0 ); -} - -// eof - $RCSfile$ diff --git a/appli/examples/example_ShowSkeleton.cxx b/appli/examples/example_ShowSkeleton.cxx deleted file mode 100644 index ae522ac..0000000 --- a/appli/examples/example_ShowSkeleton.cxx +++ /dev/null @@ -1,254 +0,0 @@ -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -// ------------------------------------------------------------------------- -const unsigned int Dim = 3; -typedef unsigned char TPixel; - -typedef itk::Image< TPixel, Dim > TImage; -typedef itk::ImageToVTKImageFilter< TImage > TVTKInputImage; - -typedef fpa::Image::DijkstraWithEndPointDetection< TImage, TImage > TFilter; -typedef TFilter::TMinimumSpanningTree TMinimumSpanningTree; -typedef TFilter::TUniqueVertices TUniqueVertices; -typedef TFilter::TBranches TBranches; -typedef TFilter::TVertices TVertices; - -// ------------------------------------------------------------------------- -int main( int argc, char* argv[] ) -{ - if( argc < 6 ) - { - std::cerr - << "Usage: " << argv[ 0 ] << std::endl - << " input_image" << std::endl - << " input_minimum_spanning_tree" << std::endl - << " input_endpoints" << std::endl - << " input_bifurcations" << std::endl - << " input_branches" << std::endl - << std::endl; - return( 1 ); - - } // fi - std::string input_image_fn = argv[ 1 ]; - std::string mst_input_fn = argv[ 2 ]; - std::string endpoints_input_fn = argv[ 3 ]; - std::string bifurcations_input_fn = argv[ 4 ]; - std::string branches_input_fn = argv[ 5 ]; - - // Read image - itk::ImageFileReader< TImage >::Pointer input_image_reader = - itk::ImageFileReader< TImage >::New( ); - input_image_reader->SetFileName( input_image_fn ); - input_image_reader->Update( ); - TImage::ConstPointer input_image = input_image_reader->GetOutput( ); - - TVTKInputImage::Pointer vtk_input_image = TVTKInputImage::New( ); - vtk_input_image->SetInput( input_image ); - vtk_input_image->Update( ); - - // Read minimum spanning tree - fpa::IO::MinimumSpanningTreeReader< TMinimumSpanningTree >::Pointer - mst_input_reader = - fpa::IO::MinimumSpanningTreeReader< TMinimumSpanningTree >::New( ); - mst_input_reader->SetFileName( mst_input_fn ); - mst_input_reader->Update( ); - TMinimumSpanningTree::ConstPointer mst_input = mst_input_reader->GetOutput( ); - - fpa::IO::UniqueValuesContainerReader< TUniqueVertices >::Pointer - endpoints_input_reader = - fpa::IO::UniqueValuesContainerReader< TUniqueVertices >::New( ); - endpoints_input_reader->SetFileName( endpoints_input_fn ); - endpoints_input_reader->Update( ); - TUniqueVertices::ConstPointer endpoints_input = endpoints_input_reader->GetOutput( ); - - fpa::IO::UniqueValuesContainerReader< TUniqueVertices >::Pointer - bifurcations_input_reader = - fpa::IO::UniqueValuesContainerReader< TUniqueVertices >::New( ); - bifurcations_input_reader->SetFileName( bifurcations_input_fn ); - bifurcations_input_reader->Update( ); - TUniqueVertices::ConstPointer bifurcations_input = - bifurcations_input_reader->GetOutput( ); - - fpa::IO::MatrixValuesContainerReader< TBranches >::Pointer - branches_input_reader = - fpa::IO::MatrixValuesContainerReader< TBranches >::New( ); - branches_input_reader->SetFileName( branches_input_fn ); - branches_input_reader->Update( ); - TBranches::ConstPointer branches_input = branches_input_reader->GetOutput( ); - unsigned int nBranches = branches_input_reader->GetNumberOfLabels( ); - - // Show input image and let some interaction - fpa::VTK::ImageMPR view; - view.SetBackground( 0.3, 0.2, 0.8 ); - view.SetSize( 800, 800 ); - view.SetImage( vtk_input_image->GetOutput( ) ); - - vtkSmartPointer< vtkImageMarchingCubes > mc = - vtkSmartPointer< vtkImageMarchingCubes >::New( ); - mc->SetInputData( vtk_input_image->GetOutput( ) ); - mc->SetValue( 0, 1e-1 ); - mc->Update( ); - view.AddPolyData( mc->GetOutput( ), 1, 1, 1, 0.4 ); - - // Show endpoints - vtkSmartPointer< vtkPoints > endpoints_points = - vtkSmartPointer< vtkPoints >::New( ); - vtkSmartPointer< vtkCellArray > endpoints_cells = - vtkSmartPointer< vtkCellArray >::New( ); - for( - TUniqueVertices::ConstIterator epIt = endpoints_input->Begin( ); - epIt != endpoints_input->End( ); - ++epIt - ) - { - TImage::PointType pnt; - input_image->TransformIndexToPhysicalPoint( *epIt, pnt ); - endpoints_points->InsertNextPoint( pnt[ 0 ], pnt[ 1 ], pnt[ 2 ] ); - endpoints_cells->InsertNextCell( 1 ); - endpoints_cells-> - InsertCellPoint( endpoints_points->GetNumberOfPoints( ) - 1 ); - - } // rof - vtkSmartPointer< vtkPolyData > endpoints_polydata = - vtkSmartPointer< vtkPolyData >::New( ); - endpoints_polydata->SetPoints( endpoints_points ); - endpoints_polydata->SetVerts( endpoints_cells ); - view.AddPolyData( endpoints_polydata, 0, 0, 1, 1 ); - - // Show bifurcations - vtkSmartPointer< vtkPoints > bifurcations_points = - vtkSmartPointer< vtkPoints >::New( ); - vtkSmartPointer< vtkCellArray > bifurcations_cells = - vtkSmartPointer< vtkCellArray >::New( ); - for( - TUniqueVertices::ConstIterator bfIt = bifurcations_input->Begin( ); - bfIt != bifurcations_input->End( ); - ++bfIt - ) - { - TImage::PointType pnt; - input_image->TransformIndexToPhysicalPoint( *bfIt, pnt ); - bifurcations_points->InsertNextPoint( pnt[ 0 ], pnt[ 1 ], pnt[ 2 ] ); - bifurcations_cells->InsertNextCell( 1 ); - bifurcations_cells-> - InsertCellPoint( bifurcations_points->GetNumberOfPoints( ) - 1 ); - - } // rof - vtkSmartPointer< vtkPolyData > bifurcations_polydata = - vtkSmartPointer< vtkPolyData >::New( ); - bifurcations_polydata->SetPoints( bifurcations_points ); - bifurcations_polydata->SetVerts( bifurcations_cells ); - view.AddPolyData( bifurcations_polydata, 0, 1, 0, 1 ); - - // Show branches (simple and detailed) - vtkSmartPointer< vtkPoints > simple_branches_points = - vtkSmartPointer< vtkPoints >::New( ); - vtkSmartPointer< vtkCellArray > simple_branches_cells = - vtkSmartPointer< vtkCellArray >::New( ); - - vtkSmartPointer< vtkPoints > detailed_branches_points = - vtkSmartPointer< vtkPoints >::New( ); - vtkSmartPointer< vtkCellArray > detailed_branches_cells = - vtkSmartPointer< vtkCellArray >::New( ); - vtkSmartPointer< vtkFloatArray > detailed_branches_scalars = - vtkSmartPointer< vtkFloatArray >::New( ); - - TBranches::ConstIterator brIt = branches_input->Begin( ); - for( ; brIt != branches_input->End( ); ++brIt ) - { - // Branch's first point - TImage::PointType first_point; - input_image->TransformIndexToPhysicalPoint( brIt->first, first_point ); - unsigned long first_id = simple_branches_points->GetNumberOfPoints( ); - simple_branches_points->InsertNextPoint( - first_point[ 0 ], first_point[ 1 ], first_point[ 2 ] - ); - - TBranches::ConstRowIterator brRowIt = branches_input->Begin( brIt ); - for( ; brRowIt != branches_input->End( brIt ); ++brRowIt ) - { - // Branch's second point - TImage::PointType second_point; - input_image-> - TransformIndexToPhysicalPoint( brRowIt->first, second_point ); - unsigned long second_id = simple_branches_points->GetNumberOfPoints( ); - simple_branches_points->InsertNextPoint( - second_point[ 0 ], second_point[ 1 ], second_point[ 2 ] - ); - simple_branches_cells->InsertNextCell( 2 ); - simple_branches_cells->InsertCellPoint( first_id ); - simple_branches_cells->InsertCellPoint( second_id ); - - // Detailed path - double pathId = double( brRowIt->second - 1 ) / double( nBranches - 1 ); - TVertices path; - mst_input->GetPath( path, brIt->first, brRowIt->first ); - TVertices::const_iterator pIt = path.begin( ); - for( ; pIt != path.end( ); ++pIt ) - { - TImage::PointType path_point; - input_image->TransformIndexToPhysicalPoint( *pIt, path_point ); - detailed_branches_points->InsertNextPoint( - path_point[ 0 ], path_point[ 1 ], path_point[ 2 ] - ); - detailed_branches_scalars->InsertNextTuple1( pathId ); - if( pIt != path.begin( ) ) - { - unsigned long nPoints = - detailed_branches_points->GetNumberOfPoints( ); - detailed_branches_cells->InsertNextCell( 2 ); - detailed_branches_cells->InsertCellPoint( nPoints - 2 ); - detailed_branches_cells->InsertCellPoint( nPoints - 1 ); - - } // fi - - } // rof - - } // rof - - } // rof - vtkSmartPointer< vtkPolyData > simple_branches_polydata = - vtkSmartPointer< vtkPolyData >::New( ); - simple_branches_polydata->SetPoints( simple_branches_points ); - simple_branches_polydata->SetLines( simple_branches_cells ); - view.AddPolyData( simple_branches_polydata, 1, 0, 1, 1 ); - - vtkSmartPointer< vtkPolyData > detailed_branches_polydata = - vtkSmartPointer< vtkPolyData >::New( ); - detailed_branches_polydata->SetPoints( detailed_branches_points ); - detailed_branches_polydata->SetLines( detailed_branches_cells ); - detailed_branches_polydata-> - GetPointData( )->SetScalars( detailed_branches_scalars ); - view.AddPolyData( detailed_branches_polydata, 1 ); - - // Allow some interaction - view.Render( ); - view.Start( ); - - return( 0 ); -} - -// eof - $RCSfile$ diff --git a/appli/examples/example_Thinning.cxx b/appli/examples/example_Thinning.cxx deleted file mode 100644 index abd6144..0000000 --- a/appli/examples/example_Thinning.cxx +++ /dev/null @@ -1,40 +0,0 @@ -#include "itkBinaryThinningImageFilter.h" -#include "itkImage.h" -#include "itkImageFileReader.h" -#include "itkImageFileWriter.h" -#include "itkRescaleIntensityImageFilter.h" - -typedef itk::Image ImageType; - -int main(int argc, char *argv[]) -{ - - typedef itk::ImageFileReader ImageReader; - ImageReader::Pointer reader = ImageReader::New(); - std::string fileName = argv[1]; - reader->SetFileName(fileName); - reader->Update(); - ImageType::Pointer image = reader->GetOutput(); - - typedef itk::BinaryThinningImageFilter BinaryThinningImageFilterType; - BinaryThinningImageFilterType::Pointer binaryThinningImageFilter = BinaryThinningImageFilterType::New(); - binaryThinningImageFilter->SetInput(image); - binaryThinningImageFilter->Update(); - - // Rescale the image so that it can be seen (the output is 0 and 1, we want 0 and 255) - typedef itk::RescaleIntensityImageFilter< ImageType, ImageType > RescaleType; - RescaleType::Pointer rescaler = RescaleType::New(); - rescaler->SetInput( binaryThinningImageFilter->GetOutput() ); - rescaler->SetOutputMinimum(0); - rescaler->SetOutputMaximum(255); - rescaler->Update(); - - typedef itk::ImageFileWriter< ImageType > WriterType; - WriterType::Pointer writer = WriterType::New(); - writer->SetFileName(argv[2]); - writer->SetInput(rescaler->GetOutput()); - writer->Update(); - - return EXIT_SUCCESS; -} - diff --git a/appli/examples/fpa_Utility.h b/appli/examples/fpa_Utility.h deleted file mode 100644 index 4cdf521..0000000 --- a/appli/examples/fpa_Utility.h +++ /dev/null @@ -1,157 +0,0 @@ -#ifndef __FPA__UTILITY__H__ -#define __FPA__UTILITY__H__ - -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace fpa_Utility -{ - /** - */ - struct Viewer2DWithSeeds - { - vtkSmartPointer< vtkImageData > Image; - vtkSmartPointer< vtkImageActor > ImageActor; - vtkSmartPointer< vtkRenderer > Renderer; - vtkSmartPointer< vtkRenderWindow > Window; - vtkSmartPointer< vtkInteractorStyleImage > Style; - vtkSmartPointer< vtkRenderWindowInteractor > Interactor; - vtkSmartPointer< vtkPointHandleRepresentation3D > Handle; - vtkSmartPointer< vtkSeedRepresentation > Representation; - vtkSmartPointer< vtkSeedWidget > Widget; - - Viewer2DWithSeeds( ) - { - this->ImageActor = vtkSmartPointer< vtkImageActor >::New( ); - this->Renderer = vtkSmartPointer< vtkRenderer >::New( ); - this->Window = vtkSmartPointer< vtkRenderWindow >::New( ); - this->Style = vtkSmartPointer< vtkInteractorStyleImage >::New( ); - this->Interactor = vtkSmartPointer< vtkRenderWindowInteractor >::New( ); - this->Handle = vtkSmartPointer< vtkPointHandleRepresentation3D >::New( ); - this->Representation = vtkSmartPointer< vtkSeedRepresentation >::New( ); - this->Widget = vtkSmartPointer< vtkSeedWidget >::New( ); - - this->Renderer->SetBackground( 0.1, 0.2, 0.7 ); - this->Window->SetSize( 600, 600 ); - this->Window->AddRenderer( this->Renderer ); - this->Interactor->SetInteractorStyle( this->Style ); - this->Window->SetInteractor( this->Interactor ); - this->Handle->GetProperty( )->SetColor( 1, 0, 0 ); - this->Representation->SetHandleRepresentation( this->Handle ); - this->Widget->SetInteractor( this->Interactor ); - this->Widget->SetRepresentation( this->Representation ); - } - void SetImage( vtkImageData* image ) - { - this->Image = image; - this->ImageActor->SetInputData( this->Image ); - this->Renderer->AddActor( this->ImageActor ); - - // Correct camera due to the loaded image - vtkCamera* camera = this->Renderer->GetActiveCamera( ); - camera->SetViewUp( 0, -1, 0 ); - camera->SetPosition( 0, 0, -1 ); - camera->SetFocalPoint( 0, 0, 0 ); - - // Prepare visualization - this->Interactor->Initialize( ); - this->Renderer->ResetCamera( ); - } - void Render( ) - { - this->Window->Render( ); - } - void Start( ) - { - this->Window->Render( ); - this->Widget->On( ); - this->Interactor->Start( ); - } - unsigned long GetNumberOfSeeds( ) const - { - return( this->Representation->GetNumberOfSeeds( ) ); - } - - template< class P > - bool GetSeed( P& seed, unsigned long i ) - { - if( i < this->Representation->GetNumberOfSeeds( ) ) - { - double pos[ 3 ]; - this->Representation->GetSeedWorldPosition( i, pos ); - - seed[ 0 ] = ( typename P::ValueType )( pos[ 0 ] ); - seed[ 1 ] = ( typename P::ValueType )( pos[ 1 ] ); - - return( true ); - } - else - return( false ); - } - }; - - // ----------------------------------------------------------------------- - template< class Ip > - std::string ReadImage( Ip& image, const std::string& fname ) - { - typename itk::ImageFileReader< typename Ip::ObjectType >::Pointer r = - itk::ImageFileReader< typename Ip::ObjectType >::New( ); - r->SetFileName( fname ); - try - { - r->Update( ); - } - catch( itk::ExceptionObject& err ) - { - std::stringstream str; - str << "Error while reading image from " << fname << ": " << err; - return( str.str( ) ); - - } // yrt - image = r->GetOutput( ); - image->DisconnectPipeline( ); - return( "" ); - } - - // ----------------------------------------------------------------------- - template< class I > - std::string SaveImage( const I* image, const std::string& fname ) - { - typename itk::ImageFileWriter< I >::Pointer w = - itk::ImageFileWriter< I >::New( ); - w->SetInput( image ); - w->SetFileName( fname ); - try - { - w->Update( ); - } - catch( itk::ExceptionObject& err ) - { - std::stringstream str; - str << "Error while reading image from " << fname << ": " << err; - return( str.str( ) ); - - } // yrt - return( "" ); - } - -} // ecapseman - -#endif // __FPA__UTILITY__H__ - -// eof - $RCSfile$ diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt deleted file mode 100644 index 44467ab..0000000 --- a/cmake/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -CONFIGURE_FILE( - FrontAlgorithmsConfig.cmake.in - ${PROJECT_BINARY_DIR}/FrontAlgorithmsConfig.cmake - @ONLY - ) - -## ======================== -## == Installation rules == -## ======================== - -INSTALL( - FILES - ${PROJECT_BINARY_DIR}/FrontAlgorithmsConfig.cmake - DESTINATION share/cmake - ) - -## eof - $RCSfile$ diff --git a/cmake/FrontAlgorithmsConfig.cmake.in b/cmake/FrontAlgorithmsConfig.cmake.in deleted file mode 100644 index e84ecba..0000000 --- a/cmake/FrontAlgorithmsConfig.cmake.in +++ /dev/null @@ -1,37 +0,0 @@ -# ========================= -# == Include directories == -# ========================= - -INCLUDE_DIRECTORIES( - @PROJECT_SOURCE_DIR@/lib - @PROJECT_BINARY_DIR@/lib - @PROJECT_SOURCE_DIR@/lib/fpa_Instances - @PROJECT_BINARY_DIR@/lib/fpa_Instances - @CMAKE_INSTALL_PREFIX@/include - ) - -# ========================= -# == Library directories == -# ========================= - -IF(MSVC) - LINK_DIRECTORIES( - @PROJECT_BINARY_DIR@/$(ConfigurationName) - @CMAKE_INSTALL_PREFIX@/bin - @CMAKE_INSTALL_PREFIX@/lib - ) -ELSE(MSVC) - LINK_DIRECTORIES( - @PROJECT_BINARY_DIR@ - @CMAKE_INSTALL_PREFIX@/bin - @CMAKE_INSTALL_PREFIX@/lib - ) -ENDIF(MSVC) - -# =================== -# == Library names == -# =================== - -SET(FrontAlgorithms_LIBRARY FrontAlgorithms) - -## eof - $RCSfile$ diff --git a/cmake/fpa_Policies.cmake b/cmake/fpa_Policies.cmake deleted file mode 100644 index a26f448..0000000 --- a/cmake/fpa_Policies.cmake +++ /dev/null @@ -1,13 +0,0 @@ -SET( - policies - CMP0015 - CMP0020 - CMP0042 - ) -FOREACH(policy ${policies}) - IF(POLICY ${policy}) - CMAKE_POLICY(SET ${policy} NEW) - ENDIF(POLICY ${policy}) -ENDFOREACH(policy) - -## eof - $RCSfile$ diff --git a/data/binary_test_2D_00.png b/data/binary_test_2D_00.png deleted file mode 100644 index fbe9d39bd59189ecf7f8ef87e48abde2f3d01953..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5192 zcma)9c{o)6_aD=ZI}EO|PKi5=td%v|KIR(BAZe2=Yhx|DN_LmVP#8-{ib^R-krY`A z@reqNiYy^ZWhrGDe6K#w@BiO@p1Yj$exLI?=XK6=-_J=nc)&!Ee-l3rhZ8hq7#_yq zHo)sQh$(QZn{CUn7r~!l8-&9Nh_2r}xSU)mOvx8)YGK6pnO|H;NsAJfXoRV@cpbF~ zru+H$xcLTSA`V9nbaM%IW5Q>>f<0jqQ;UPl?QVQHoM^47A#yb2`nC({b$L%f zAN+ba&2J>U#}W!JiLbGyhW19FGcQ&}0n5ef8#3Z$LummE*9jo%!F{{Y?1ivTz9#oA zAJ8Bg=?R=3ia&5rBGU7GSY-yz{}c%I=To_Fh51pwmA4}9kaW2vnja-FMQ9p~zkN_3 za-9FxV0`UCuv*_>is&{N-?N}t-F5-5X$EP3vu(f53v|e+)C&u`^2V6P!Om>J=>9Q> zet8n0xh^fdD_k-}X>2|6!AB;sFwACAK&1R)H_5QeMpZw!Jv~HRpvLXAM84}0UoU9_ zo-z#gen_45)Z#>zHu~B_pt2C^JJRHBx0UE>r-x8gGOoEGicVJbK`=pHy?g-8X4 zdR5-9wspO|9AQBY40fx$S8MyDXX!#bgC%WmQ&Qx2ENL{v{ffjUk^*w^mmEkJvO*~qK*vD;16xxl$&Ey=i`C^Hj<_BqHk;-bt13Yk zx^^TWmTC&I_SPoG8gb-x1&04H88-u#t(UFTSnA9)xPe2F2kD_yMiW2Z&`xrom7fgx zIR_y;hgfYN>!#u<&MjeDAbre&aYe8)Qfh7n|7fjKa&zEHusT4zEY|v>Zcx=Je4+U8 zol`Y2c~Kpcc^<{j>{G?e3oScql{sr`bx{Kcgje$4F8B47B_1!+j9QMWm5H$Rh^lfd zEjxU9cVtZOd#CbE3id@66#I={o{Y#9+H|$#RPyGmJl5dnYpuIcDKk4Fe^)c7dMM#@ znC|rZyrH%&4mP`V;v+<6{U*b7iu~T2_vF8F(Jp$i?gMIBfkOL1Deo29SrMiQYs zcHMK5(E0nNh5N5tCVe{o!iP?87}zuDyL_Yjo>h!dOLF$dT$pwXw^*njMuSAkbPbk# z2IjlkI2KtKbFF)+E!n&L0<422XPbA}>BQD6+{=YO$;DB8D#fH8_&Spe89SsLDx?Fl z@L&1`_oJW}ivewPZ$UTw@U|KJDV}^taEh&}!WJ$%tM7Rta+I47J=okik$n2J+CvQo zmYPUo!RML`*_C@(mDHq=ozA>5pz=00$b(498H5_Q%)fxNs{Xx9rY6R-L<(r^#vlR2RCs)+Xj9uq5g=V|xDWI$)ta_3e3 z{Pq$whojqnOsQU>0S$jbnNdvy{Lhzs)?sKqOV&t79!%8!EkZ|O|GG5zqi=nzj7=~E z7-qs!LocWFEeL4ttFeuILECL~k-u2vG!g88q}i*Xu583-z^wXr|Qd)5wOhdrmYgqK09!vGCx_@481& zDI{?zRY8UWCr>I%hywfWC&{m=AaA$oFByZ#%(p`_0b>I-%I`o_w>hOk#DHTLJboC6q?an1%Mc)Jo`~dnk)hhItr)3HbLnVk`$n!zwpnUfp0|9cIg>FxWyv`giiTGS`r15iCd$dr?4P}H0mc_h zYUCzeTlwHo4VUfgkh+nmy_H$#Nu{lD{9HlB1}ZW35Cy{0s#6D40i_-4=e zlaBv(RLiCn5i}KO<%8DCq%Hi)$iqoy0xzm2%sFSFcNRZ!2`;T9Y>_zW z&N0oyciaYeWOggmE+29c5^sD777nZ$w}vMu&4EBzKWVq%*pc6n?0rTh9KG!fEfG6ObrYsRh7e^Ys$mt^S(+7FLyk0 z9DR}>BO8fis%CPf^871L51j^P&sRhp5qRH{R@kc(?65~@=Dx$S>*JEiZG+CIU+lhn zku8{Is5^tHG?jag?~QwsNsKb_ega3N@V&A#gHHA`%!0SzpqD;+m>+6Kv_03 z6Q(&J)p1sfkzGD#=W0AI!M;1;mUpRE)xsi;5^M-{KIC{cJX+F(^Do-Sx^^F;cwJEd zCHNQ-$eD1Pc3lafwmk%Nw$OUN7`3822~>7aCzQ<%Kb-khq{i_5fEO`?%^^8^teB%-w(WZewqj*uAWX;LxX< zN>WI<*xDyT+DA#C!wF{Nt}oQqsK-Wg?*jyfUt> z9M7+6zVErZyPB~T8DtqjL& zxvpx!o3Vyqil615zH;5B-s&!ekD7`Ulce&^AF34mY1aHK>I%T~2^>y) z>@K3KKehpV>Oy`eIH7lf;m_@VS$%sukyLRTjs%BsQb)(k*KDrK)hV%YUM`H}U&}G^ z)!M?hwd+M4My!f271D~PDM(q^R7-0~%4(au8Pw)E9WPcpRy8gCIrv3rQ8}rgdnc>2 z`gr!qhg?md8<;%;v2yS14;C?e)pp#sIAX6B+x?_dwxVk2grw@RH_y?yEk;A$j-gFO z_F1DtcAr(*lBMpONMW+y4=)-E2wR(N20$vZZKDVuVkg`e|2O9bkF2N8yX$JA&Q4oRv*K`;U6q=bs z9?GB`P3%uOd|)>Ndg}7sP8aEWn2`kw9fkm`MR}0usHmM(q(U$iZ}>MFy!=viw`jo( zi2hXA%9a-cVm6@g(gq+#9))=sJaYd9eOrhEbZmwhb?XeQvtkUP^`HT?o(~>syqK(L zvJWFeJO>LqnhL^5+xQ(33ZQW_c3tu5%Ti7mB+oWuU`$}L#M!fGJ!Ak`@SxvX!m+@> zw}Z9k+HLvORgj9~?MX1e!}?sh4s$_{O3(}iW?kbk;&Y{dyAm)5re)D54j{*`ZDa!- zd(-{;{F?%KqhY8B`|%0;qGF$v%)$oLzf@G)~)9ugocQ(DTsOu&+ml_@J-xoj!m z3M%*el&)S@0O?f=0V9_Q&pA6Ib3@!w^@0>xzH5u24guN|6*Fz5ILi0rs;s=llD!e9P8zm>g4%b%D`7{5n~`8`wr;k zhyJRD|8X_qU|Ea^t+RQjVS^u~onN?Pu4H7Tn)El3Xn4A>z@w&qV$=?^h`}|8q9Kn- zK)@vCfei(U7@o|q1?lV7a&hnzAPaxpn}7IQqYRQ+lYB{GO{J~M)k_dEjMh^G z=e~HHhuM32wBBqpI0lkV+R^EvfZtNXQ*ks7a|N)?HzS51i0+QB2|}@)a8fmalQ7@{`WtYZ+5C{9a4eiNJ!(=gz>B#0 zMtM4;(Xtm3hLglTt;{@2r!wAa*+oJlT#amQJr^K{92$%#H%c9@7pAkx0Nhgi?4p1K z(kB)zWLRH z+ zrL!So8DGw(T#7iG1e+6E)6ZZ1-ChUW4K+`6J;VK-AZ5VG+Vr^hy>H`}lzNU4n!8YQ z-u8OYN}Ui2YYDc>8HrQ6E63DE|FmaXarGi@=eO_5*s*=9z@>Kz7vOH9vbgNx3kc27 zEa;t2qyWlpjLO+q3UK!XL!x*q9X#B~QL}C1x`2p^RGQJrRtP<+PQ7jsC$0{MytwzhR%xE5SrbX_&b%sc3QKH}YoJKA);Y_j&TNSiM&a5gm6dXBE zIr+QFKhAJSL5rCLTL~(!&UX=QI*2Psp7vf^Zg`Uls zQzwZ}9^3s;iNgr6rH`$hkz}1xwJ%Yjlj7i)MBCZca8~g>yAl;V9Sk&1)yXSjw$y#~ z{&7}qZUbp#CFpdwVsq}sJ?5GAnSPjuD_0-Q)T|Oe=){IUo-SoxJveLmy65V2S3&Q` z(9z`c*c9^S&+9Q=NSzt|Xecd?0eJ?UH%cXT;7NdgI2+mrV`n1`J2t*gy8|&G27^cIw_JebuptMN3_%2E zBDAS5^H&TIFdPFrgZ}~jUtE7rkrV%&_v>bZqDcNI0k7xjpZjhj3Bbl1Jp=8S^(pV4 zL}*{W9)=4vD6+*qXUK|2F~dJ0LZbRVE_OC diff --git a/data/ones_image.png b/data/ones_image.png deleted file mode 100644 index f7afaab3a8241507fc085fd4450f6bfa393ef4db..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1697 zcmeAS@N?(olHy`uVBq!ia0y~yU{(NO4xj+TKk3LVK#H@#BeIx*fm;}a85w5HkpK#^ zmw5WRvftxo=F>J^eIwQZC?uO15>euupPQSSR|4cRFgO>bCYGe8D3oWGWGJ|M`Ua%v zrLr?Hu!(!RIEGZ*dV6^zF9QR|VS`iu-M=%HvHfoG@MPPuh9yD3fJ1_Xhl!1`xxw*( zLV^GY6B2@`L{Wty!~iu9Nfm|=1Kd`)Dl9@Cm|{roh3Ui)Lh%(u6^0N@Gm={|gfN1` zfCE#gV>BR<6A>s7M*|X(sUTs2k^Fd=FoZBdZ8RVmN3%A#WQHdV%<{0A#4_?jG~?Ve VY>s=^oN@!z9iFa!F6*2UngGDBTyX#Z diff --git a/data/workspaces/workspace_airwaysappli.wxml b/data/workspaces/workspace_airwaysappli.wxml deleted file mode 100644 index 9b80164..0000000 --- a/data/workspaces/workspace_airwaysappli.wxml +++ /dev/null @@ -1,73 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/doc/UML/fpa.dia b/doc/UML/fpa.dia deleted file mode 100644 index 8ed637d5d84ae80a5ad9bf0ad473ccfdc1189409..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4287 zcmZ{lWmFX0!iAMa>28MZM!LHj=}?dc0ZHjbnxTi1mL5b}x`ytCp$3qa7>5wJ`o8zq zx4wIxwe~ve{5*T@y=mhyp8Y*Y$fp(-A67*uJJ0K_e~ep};XDeBl#6Tnv~1+KUbzXM zaxs9Py-!edO-=7y-h3P#q6_7FWR}4d(4@c<19Ijc{7Ak2abVS@y}pPHM~?9~ay2>n zW;RdByLO>ubjst~-QBR-{XGcYc$)I^;yo-)RXwo(WnXvQs?B5t>A^vAaxzdH7sI{_ zCMLl4`QQnEiRplT#{d4b`nB^bNZlwHAwWog_T zcJ|osMP!fq)%uv3>L42X4_%p4N#84M74D^&5Qiqd1J!F>Y4G&B+!d{IPImtAs3Q+Tn;1?7~#D~AI+Mj>7Z%ukhSM(C`Vj%Y-WNKr5v+SE?1 zFR)i3#D=r9$&=S%B@)u@t~H&@UwA*TtqPH{;bwv&W!wvx(y)->8F@8WEL7>l7xjyd zu|B1=$`-ufgjyyw7c=<6#DATIb!5^rWhoEu??MsLAm`Nk??vmhc|C_6US@~X$xE3J z-wRHJ3$+HIQ&#oMlq79sAoR6jv4!~Dn3?eg$CR0g#ko?LU{YGXebb#?`*-X{Kj(g9 zWjyX2ed)=^yA_R=9ds%It$3`~tDo0PYPsM?X|JB$(cs$~`(w@HAtu@BU=n~_u*fgN z`{qWdUamKxC?awS$58Vz%G zDEA(OC1s!gys)iyXAdWEKhh`p1r@B>PB%9IEcG@f$PY`D?vYpv{TE#|3JDStJY!Plm{yERE3Wo^MGGux-!!oz;Ojwjs zL{`z+o6Q*OrCMTIVgBgB0gvP^m(2QD!k8wd-(-Rvkv8LC5xjIKQ_OC=9G=AJyJ+Q! z3if`J!GCp@9>_00?A?gJxPdl^C-N|vTN^PvpfP)jZ30B}BTVJ_J=Sjx1NtOLG)81t zYeT2xSC|au=;JAcuBeZ)`a`~AzEiU{p;YwyFkyb*d@i;*inGu5;ec>odwBA*!6%`Y z29>-KIu+4R6WnStDBWD@4S|BRU+!hv1OU2Y27z*A@iwkJT20NL$g8b&flQSKaTzmd zmEz*SCRrC#$sn%~h;xK@2>6(qhtR05sZbcTWi{-BVA+gCNJieb(s+nwcaO^sHzA7! zYYq-9v8}%pA#6YA`+KpZ`@VRH4QG$qGF$Lvo0NdsvzXa3A>Ip4JMkGOc{Qy;P=6e( zbyqB~3p?p!qpF0u75tGXW`+NL>@bXLCU6_?3>CS#^Fw;{+R?=7CSLJ8&MzU)kG_T3 zn#fo*SOxlI62jx&`O}*nQ~2}GSflZyXPVy_IF!*Xur$9T;wChrjXHM`|MsQ{4yv8J z*cUs5hF&H`YYo!04?pjkN7 zGqZ{gu`ckCb(mA=$ooO` zK$bs)v7~Y5=<9Q(1eI<}X|X&!u%Ek}pxfmnu98p)Nb_#Ko4PmqhYWY57tf=paH1feQ+7Y6KnoKz zd#Sf@+|gT0Sbfds=&sldFtSlJkeDm`7|;8Dz6229VaB2;=ve@*^^nn?M}*3%spI2e zV4$ENA+gB=tje3S2L# zbZ$%r!2w}`PSEFVm#?jmKMhpG$o0dpejL&OJSE&50BIDE(mOE65EJ$Ic~YbX$OyBbHdd9|ord6LvwQKDd7wV*m#j)5uOK zOi4H>{t83sUSWu9!iVtv3z;N@?^*-WkhNO7lQ0ytpG@ALC_ZiT7ZZb%y`qF6?5#-) zKHe~Rj?A9QAo*(^y2&K-yp7ls#Y>jNOpkg(340xr;S z^aR=4S=tXgwCNsyQgwlcTgR}{(DG>d4vUJhJXbAaIzZLvIAOcblhALVba~0=*-jZWTUX?ai^55GgW5LgyYN=sl5_mc`IyPW`7O)p0^#)4RC4DXwb}ie)x^A zaB{I`J9;4U7M&ujkepL5Pmvzyc9WA#J}Ok|vmEcm&;TXj`CNe?j|TJ*>JxKH4i3l; zI*(9rQ{W21u>WH=EE0o}>FP8hR;!$QyE+4Mg!1ky?&`{kknLk+DeI#i6~g!;hPhp8mU$Hve8GJDB#$l;d~loCir*dhyAfXQO-NF{@e!|v zQ_#er!!#*qp(|reTvQh}Pq?>iJHYlqf@aE^xUz&}G^bn@#9qDkML6;hA*>syi@B3% zewQ$hnQE)rU<=nZ&z+oN(u37|SAg_^m9w#U$7k76eR(2Otbx`c8ZLN?gwMGU9Utv1Dt10c8 zSZr3j+$?q!XfiHp25DAE5m&vxm7Nxu_Z(UxGZ1X^aD=L5WQA+Xh*ld=v!1_O!e;0^Ku{;0`epEqrLzii zl6be1cJ^>M8~L;k$JU1|rMFJ0gV?#ZNjd}vhAwhB1jdU>_)v3!rLNPC$(FAX{-f)+ zk+*XV0<4C`6G(>a8l`3ZPj;kCfbh-CGGi$a?tIYab@G%i@7Se^W(OOZNh?g(1`-Ux ztRp}J_QBB~BSZz%BdY+R+5)L|X;@QlyYw`T3m8N6Olu5hNh+26Z zgv%}V-OdqCtZF?p5n|#N8@fhHx+w=KG!I@e8KD$;_lId|cBG^NR7A#R1FLT}BkGrTio*v7cbD^j(vqQIA^mBg^vz8#f%1s^ zWUpD$C<<|XDqf_Ftx$X%3_uF87RDBZdbUh<53uI_xpN{ zlGAnd0IXBeZ14tdE*D6$N;5}O8z+G!AwFPUdIQGM@!Q~Xd z8SBqHim6x(ax-vs#WaHpWitP2uN0n{S{0J*wWJi?Wi`nLw zX_qKEwDBtxu1NGgLaxheRc8$eah#t19DvBh{q0<}k7udtZ5>sJk>!(Hu`=@u1Ie3W z(~RU-Cj1%`33Bx8(F*{U7?n5~y$+-qFgJGZO#6*ER+mGj;v{KcL#EpPi>~EVTSK!? zoNr%|2kNFJh`kLsrC2&&PX)M06`XMV+My-nm;0%RVx{oEL?UG?Ui)BtIANuwOY@=g zHqKs-rt(ENH%;G;P&jv&!}Q=r5~jrVf@X z@8c%e{~Zd^`otAg@{EoNQNFE*de@8-V3z|JB>Gu2^`8V?B$2Z4TvS^~G$4=)? zbu=OPyHQ2aa8c&T=E+>3VLTf_ zjE|BeXV#ZnVLg2ox{nxbe>(r@nYRr0F3{)8UY6ciE0y;J?5U?IGe03A74J%(PH#kYkkR?*M(Q%mEV6=Ykl0$LJ3_By0cJ+a{?gRF+gH z>}Lb&@=uO1c}jFFJXE=EKu84)WH`3+V;hxkj|!USM03o!zoV$r=>PAdAtib%|0!#| z#=WzWGuA`?UI0dGkjDjAr;;L3X8qB7x|>LuNT>+tnW3uOPN@BtwD?Q z{_85lJR$qE_oD@C?}4PD=l2S=`t}O7EGB*Z^uIGO2&P!qF9QLYD3xMuLDAlo96%^B zWLv3XHlRuYL2n|z=o1NJGvX;s4$!s9aO%4*jiz_ZbURU_5XzzhRjbUZ-S70Z^KY(v zbd7tBdf~Vv1Pw>qC4PJU-ne<#ru_HLDFmW`%(oj`k9JTF>XGwr1 z@kk1(N;y+?R=8oi=Qz9a#8jnbc7Y(h#oXw`lxSLbA#R!k!Wzlv;;N(b%mT;gaPuUl zey<;P{0;eqo#EHl9l#>z#T<5ZYLl5v zAG<|A1FGymccTU6ZV@rW^LH`cf~#l7*T=rY#PVLayX)Hsk-X4;%>OBDF@%#>Zn;v! zNL(Zi4Kle)@b`vrW=Bw|k0Hb5q2RIRtbyv19HZe;G_=$`hu<8uV5`bE#{Gge{8+jP z)0eSHVYV*Sp14J37R)rpQ{N8{sj7QAM)t0O(4JrNSNKo^h}sZ&<{U;Omgc2?#nS)f8_H@ yAge_>M9=Sj`&8QheF%c7^C7<5g1_Q%%_v@apgR@p{@&_=HW~A3%oz#k*?$1;FJepp diff --git a/lib/Airways/AirwaysLib/CMakeLists.txt b/lib/Airways/AirwaysLib/CMakeLists.txt deleted file mode 100644 index 712dc25..0000000 --- a/lib/Airways/AirwaysLib/CMakeLists.txt +++ /dev/null @@ -1,43 +0,0 @@ -## ============================= -## = Set names and directories = -## ============================= - -SET(lib_NAME TempAirwaysAppli_AirwaysLib) - -INCLUDE_DIRECTORIES( - ${CMAKE_CURRENT_SOURCE_DIR}/../MathLib - ${CMAKE_CURRENT_BINARY_DIR}/../MathLib - ) - -## =============== -## = Source code = -## =============== - -FILE(GLOB lib_HEADERS_H "${CMAKE_CURRENT_SOURCE_DIR}/*.h") -FILE(GLOB lib_HEADERS_HPP "${CMAKE_CURRENT_SOURCE_DIR}/*.hpp") -FILE(GLOB lib_HEADERS_HXX "${CMAKE_CURRENT_SOURCE_DIR}/*.hxx") -FILE(GLOB lib_SOURCES_C "${CMAKE_CURRENT_SOURCE_DIR}/*.c") -FILE(GLOB lib_SOURCES_CPP "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp") -FILE(GLOB lib_SOURCES_CXX "${CMAKE_CURRENT_SOURCE_DIR}/*.cxx") - -## ===================== -## = Compilation rules = -## ===================== - -ADD_LIBRARY( - ${lib_NAME} - SHARED - ${lib_SOURCES_C} - ${lib_SOURCES_CPP} - ${lib_SOURCES_CXX} - ) -GENERATE_EXPORT_HEADER( - ${lib_NAME} - BASE_NAME ${lib_NAME} - EXPORT_MACRO_NAME ${lib_NAME}_EXPORT - EXPORT_FILE_NAME ${CMAKE_CURRENT_BINARY_DIR}/${lib_NAME}_Export.h - STATIC_DEFINE ${lib_NAME}_BUILT_AS_STATIC - ) -TARGET_LINK_LIBRARIES(${lib_NAME} TempAirwaysAppli_MathLib ${ITK_LIBRARIES} ${VTK_LIBRARIES}) - -## eof - $RCSfile$ diff --git a/lib/Airways/AirwaysLib/airwaysEdge.cxx b/lib/Airways/AirwaysLib/airwaysEdge.cxx deleted file mode 100644 index 56a9084..0000000 --- a/lib/Airways/AirwaysLib/airwaysEdge.cxx +++ /dev/null @@ -1,739 +0,0 @@ -/* - * airwaysEdge.cxx - * - * Created on: May 12, 2014 - * Author: caceres - */ - -#include "airwaysEdge.h" -#include - -namespace airways -{ - -Edge::Edge() : m_id(0), m_source(NULL), m_target(NULL), m_mark(false), m_angle(0), m_length( - 0), m_eDistance(0), m_aRadius(0), m_minRadius(0), m_maxRadius(0) -{ - -} - -Edge::Edge(Edge* edge) : m_id(0), m_source(NULL), m_target(NULL), m_mark(false), m_angle(0), m_length( - 0), m_eDistance(0), m_aRadius(0), m_minRadius(0), m_maxRadius(0) -{ - this->m_id = edge->m_id; - this->m_source = edge->m_source; - this->m_target = edge->m_target; - this->m_angle = edge->m_angle; - this->m_length = edge->m_length; - this->m_eDistance = edge->m_eDistance; - this->m_vec_pair_posVox_rad = edge->m_vec_pair_posVox_rad; - this->m_aRadius = edge->m_aRadius; - this->m_minRadius = edge->m_minRadius; - this->m_maxRadius = edge->m_maxRadius; -} - -Edge::~Edge() -{ -} - -int Edge::GetAngle() const -{ - return this->m_angle; -} - -double Edge::GetARadius() const -{ - return this->m_aRadius; -} - -double Edge::GetEDistance() const -{ - return this->m_eDistance; -} - -double Edge::GetLength() const -{ - return this->m_length; -} - -double Edge::GetMaxRadius() const -{ - return this->m_maxRadius; -} - -double Edge::GetMinRadius() const -{ - return this->m_minRadius; -} - -Node* Edge::GetSource() const -{ - return this->m_source; -} - -Node* Edge::GetTarget() const -{ - return this->m_target; -} - -const vec_pair_posVox_rad& Edge::GetEdgeInfo() const -{ - return m_vec_pair_posVox_rad; -} - -bool Edge::IsMarked() const -{ - return this->m_mark; -} - -bool Edge::IsPointInfluencedByEdge(float point_x, float point_y, float point_z) const -{ - // Variables - float minDistance = -1.0; - bool first = true; - float distanceTemp = 0.0; - bool influenced = false; - Vec3 vector(point_x, point_y, point_z); - - // Iterate over all voxel in the edge - vec_pair_posVox_rad::const_iterator it = this->m_vec_pair_posVox_rad.begin(); - for (; it != this->m_vec_pair_posVox_rad.end() && !influenced; ++it) - { - // Get the vector from the compared source to each voxel - Vec3 voxel_actual = ((*it).first); - //Vec3 source_actual = this->m_source->GetCoords( ); - //Vec3 vector_actual(voxel_actual - source_actual); - - // Get the difference vector - Vec3 vector_diff = vector - voxel_actual; - - // Get the distance - distanceTemp = vector_diff.Norm(); - - // Get the minimum - if(first) - { - minDistance = distanceTemp; - first = false; - if(minDistance < ((*it).second*1.8)) - influenced = true; - } - else if(distanceTemp < minDistance) - { - minDistance = distanceTemp; - if(minDistance < ((*it).second)*1.8) - influenced = true; - } - } - - return influenced; -} - -void Edge::SetAngle(const double& angle) -{ - this->m_angle = angle; -} - -void Edge::SetARadius(const double& aRadius) -{ - this->m_aRadius = aRadius; -} - -void Edge::SetEDistance(const double& eDistance) -{ - this->m_eDistance = eDistance; -} - -void Edge::SetLength(const double& length) -{ - this->m_length = length; -} - -void Edge::SetMaxRadius(const unsigned int& maxRadius) -{ - this->m_maxRadius = maxRadius; -} - -void Edge::SetMinRadius(const unsigned int& minRadius) -{ - this->m_minRadius = minRadius; -} - -void Edge::SetSource(Node* source) -{ - this->m_source = source; -} - -void Edge::SetTarget(Node* target) -{ - this->m_target = target; -} - -void Edge::AddSkeletonPairInfo(const pair_posVox_rad& skPairInfo) -{ - this->m_vec_pair_posVox_rad.push_back(skPairInfo); -} - -void Edge::SetSkeletonPairVector(const vec_pair_posVox_rad& skPInfoVector) -{ - this->m_vec_pair_posVox_rad = skPInfoVector; - UpdateEdgeInfo(); -} - -void Edge::UpdateEdgeInfo() -{ - if (this->m_vec_pair_posVox_rad.empty()) - { - std::cout << " ------------------------ This edge has no information" << std::endl; - std::cout << "Source:" << this->m_source->GetCoords() << std::endl; - std::cout << "Target:" << this->m_target->GetCoords() << std::endl; - return; - } - double min = std::numeric_limits::max(); - double max = std::numeric_limits::min(); - double average = 0; - vec_pair_posVox_rad::iterator it = this->m_vec_pair_posVox_rad.begin(); - for (; it != this->m_vec_pair_posVox_rad.end(); ++it) - { - pair_posVox_rad info = *it; - average += info.second; - if (info.second < min) - min = info.second; - else if (info.second > max) - max = info.second; - } - this->m_aRadius = average / this->m_vec_pair_posVox_rad.size(); - this->m_minRadius = min; - this->m_maxRadius = max; -} - -double Edge::CompareWith(Edge* edge) -{ - //std::cout << "Comparing ... " << std::endl; - // To compared the edges, the distance in each component - // is calculated and a distance function between edges is calculated. - // The components are: - // - Each component of the quaternion (son-parent quaterion). (4 components) - // - Edge distance - // - Edge average radius - - // Difference in each quaternion component - // p - // | - // | - // | - // s - // / - // / - // / - // g - /*const Edge* edgeActualParent = this->m_source->GetEdge( ); - Vec3 sourceActualParent = edgeActualParent->m_source->GetCoords( ); - Vec3 targetActualParent = edgeActualParent->m_target->GetCoords( ); - Vec3 sourceActual = this->m_source->GetCoords( ); - Vec3 targetActual = this->m_target->GetCoords( ); - - Vec3 sp_actual( sourceActualParent - targetActualParent ); - Vec3 sg_actual( targetActual - sourceActual ); - - const Edge* edgeComparedParent = edge.m_source->GetEdge( ); - Vec3 sourceComparedParent = edgeComparedParent->m_source->GetCoords( ); - Vec3 targetComparedParent = edgeComparedParent->m_target->GetCoords( ); - Vec3 sourceCompared = edge.m_source->GetCoords( ); - Vec3 targetCompared = edge.m_target->GetCoords( ); - - Vec3 sp_compared( sourceComparedParent - targetComparedParent ); - Vec3 sg_compared( targetCompared - sourceCompared ); - - Quaternion q_actual(sp_actual, sg_actual); - Quaternion q_compared(sp_compared, sg_compared); - - float dif_r = q_actual.getR() - q_compared.getR(); - float dif_i = q_actual.getI() - q_compared.getI(); - float dif_j = q_actual.getJ() - q_compared.getJ(); - float dif_k = q_actual.getK() - q_compared.getK(); - float dif_distance = this->m_length - edge.m_length; - float dif_radius = this->m_aRadius - edge.m_aRadius; - */ - double distanceEdge = GetDistanceToEdge(edge); - - //std::cout << "Comparing ... OK" << std::endl; - - return distanceEdge; -} - -float Edge::GetDistanceToEdge(Edge* edge) -{ - // a. The parent edges must be aligned before calculate the distance. - // b. Parent end-points are aligned also. - // Steps a and b represent a rotation and a translation respectively. - // c. For each point in the actual Edge (this) the closest point in the - // compared edge is found. This distance is calculated and then averaged - // for all the points. Must be done in both ways? - // We can take the maximum of both distances max(D(a,b),D(b,a)) - - // Variables - float averageDistance = 0.0; - float numPoints = 0; - - // Get the parent Edges - /*const Edge* edgeActualParent = this->m_source->GetEdge( ); - Vec3 sourceActualParent = edgeActualParent->m_source->GetCoords( ); - Vec3 targetActualParent = edgeActualParent->m_target->GetCoords( ); - Vec3 sourceActual = this->m_source->GetCoords( ); - Vec3 targetActual = this->m_target->GetCoords( ); - - Vec3 sp_actual( sourceActualParent - targetActualParent ); - Vec3 sg_actual( targetActual - sourceActual ); - - const Edge* edgeComparedParent = edge.m_source->GetEdge( ); - Vec3 sourceComparedParent = edgeComparedParent->m_source->GetCoords( ); - Vec3 targetComparedParent = edgeComparedParent->m_target->GetCoords( ); - Vec3 sourceCompared = edge.m_source->GetCoords( ); - Vec3 targetCompared = edge.m_target->GetCoords( ); - - Vec3 sp_compared( sourceComparedParent - targetComparedParent ); - Vec3 sg_compared( targetCompared - sourceCompared ); - - //Get the quaternion between parents - Quaternion q_parent(sp_actual, sp_compared); - - // Get the translation vector to translate the compared parent to the actual parent - const Vec3 transParents( targetActualParent - targetComparedParent); - */ - - // Iterate over the voxels in the compared edge - for(vec_pair_posVox_rad::iterator it = edge->m_vec_pair_posVox_rad.begin(); it != edge->m_vec_pair_posVox_rad.end(); ++it) - { - // Get the vector from the compared source to each voxel in the compared edge - Vec3 voxel_actual = (*it).first; - /*Vec3 vector_compared(voxel_actual - sourceCompared); - - // Rotate the vector using the parental quaternion - Vec3 vector_compared_rotated = q_parent.rotateVector(vector_compared); - */ - - // Find the distance to the closest point in the actual edge - //averageDistance += getDistanceToClosestPoint(sourceActual+vector_compared_rotated); - averageDistance += this->GetSmallestDistanceToPoint(voxel_actual); - - ++numPoints; - } - - // Get the average value - if(numPoints > 0) - averageDistance = averageDistance / numPoints; - - return averageDistance; -} - -float Edge::GetDistanceToTranslatedEdge(Edge* edge, Vec3 vector_translation) -{ - // a. The parent edges must be aligned before calculate the distance. - // b. Parent end-points are aligned also. - // Steps a and b represent a rotation and a translation respectively. - // c. For each point in the actual Edge (this) the closest point in the - // compared edge is found. This distance is calculated and then averaged - // for all the points. Must be done in both ways? - // We can take the maximum of both distances max(D(a,b),D(b,a)) - - // Variables - float averageDistance = 0.0; - float numPoints = 0; - - // Iterate over the voxels in the compared edge - for(vec_pair_posVox_rad::iterator it = edge->m_vec_pair_posVox_rad.begin(); it != edge->m_vec_pair_posVox_rad.end(); ++it) - { - // Get the vector from the compared source to each voxel in the compared edge - Vec3 voxel_actual = (*it).first; - - // Translate the voxel - Vec3 voxel_translated = voxel_actual + vector_translation; - - // Find the distance to the closest point in the actual edge - averageDistance += this->GetSmallestDistanceToPoint(voxel_translated); - - ++numPoints; - } - - // Get the average value - if(numPoints > 0) - averageDistance = averageDistance / numPoints; - - return averageDistance; -} - -float Edge::GetDistanceWeigthedToTranslatedEdge(Edge* edge, Vec3 vector_translation) -{ - // a. The parent edges must be aligned before calculate the distance. - // b. Parent end-points are aligned also. - // Steps a and b represent a rotation and a translation respectively. - // c. For each point in the actual Edge (this) the closest point in the - // compared edge is found. This distance is calculated and then averaged - // for all the points. Must be done in both ways? - // We can take the maximum of both distances max(D(a,b),D(b,a)) - - // Variables - double alfa = 4; // Weight for duplicated closest points - float distance_average = 0.0; - float distance_actual = 0.0; - float numPoints = 0; - std::map map_vector_pair_vector_distance; // Map to save the correspondences between the given edge voxels and this voxels, and the distance between them. - - // Iterate over the voxels in the compared edge - for(vec_pair_posVox_rad::iterator it = edge->m_vec_pair_posVox_rad.begin(); it != edge->m_vec_pair_posVox_rad.end(); ++it) - { - // Get the vector from the compared source to each voxel in the compared edge - Vec3 voxel_actual = (*it).first; - - // Translate the voxel - Vec3 voxel_translated = voxel_actual + vector_translation; - - // Find the distance to the closest point in the actual edge - Vec3 point_closest = this->GetClosestPoint(voxel_translated, distance_actual); - distance_average += distance_actual; - - // Add the link - pair_posVox_rad pair_vector_distance(voxel_actual, distance_actual); - map_vector_pair_vector_distance[point_closest].push_back(pair_vector_distance); - - ++numPoints; - } - - // Add the weight to shared closest points - float distance_weighted = 0.0; - for(std::map::iterator it = map_vector_pair_vector_distance.begin(); it != map_vector_pair_vector_distance.end(); ++it) - { - vec_pair_posVox_rad vector_pair_vector_distance = (*it).second; - if(vector_pair_vector_distance.size() > 1) - { - for(vec_pair_posVox_rad::iterator it_vector = vector_pair_vector_distance.begin(); it_vector != vector_pair_vector_distance.end(); ++it_vector) - distance_weighted += (*it_vector).second * alfa; - } - else - { - for(vec_pair_posVox_rad::iterator it_vector = vector_pair_vector_distance.begin(); it_vector != vector_pair_vector_distance.end(); ++it_vector) - distance_weighted += (*it_vector).second; - } - } - - // Get the average value - if(numPoints > 0) - { - distance_average = distance_average / numPoints; - distance_weighted = distance_weighted / numPoints; - } - - //std::cout << "[DistanceW;DistAvg][" << distance_weighted << ";" << distance_average << "];;"; - //return distance_average; - return distance_weighted; -} - -float Edge::GetDistanceToPoint(Vec3 point) -{ - // Variables - bool first = true; - float distance = 0.0; - - // Iterate over all voxel in the edge - vec_pair_posVox_rad::iterator it = this->m_vec_pair_posVox_rad.begin(); - for (; it != this->m_vec_pair_posVox_rad.end(); ++it) - { - // Get the vector from the compared source to each voxel - Vec3 voxel_actual = ((*it).first); - - // Get the difference vector - Vec3 vector_diff = point - voxel_actual; - - // Get the distance - distance += vector_diff.Norm(); - } - - return distance; -} - - -float Edge::GetSmallestDistanceToPoint(Vec3 vector) -{ - // Variables - float minDistance = -1.0; - bool first = true; - float distanceTemp = 0.0; - - // Iterate over all voxel in the edge - vec_pair_posVox_rad::iterator it = this->m_vec_pair_posVox_rad.begin(); - for (; it != this->m_vec_pair_posVox_rad.end(); ++it) - { - // Get the vector from the compared source to each voxel - Vec3 voxel_actual = ((*it).first); - //Vec3 source_actual = this->m_source->GetCoords( ); - //Vec3 vector_actual(voxel_actual - source_actual); - - // Get the difference vector - Vec3 vector_diff = vector - voxel_actual; - - // Get the distance - distanceTemp = vector_diff.Norm(); - - // Get the minimum - if(first) - { - minDistance = distanceTemp; - first = false; - } - else if(distanceTemp < minDistance) - minDistance = distanceTemp; - } - - return minDistance; -} - -Vec3 Edge::GetClosestPoint(Vec3 vector, float& distance) -{ - // Variables - Vec3 point_closest; - bool first = true; - float distanceTemp = 0.0; - - // Iterate over all voxel in the edge - vec_pair_posVox_rad::iterator it = this->m_vec_pair_posVox_rad.begin(); - for (; it != this->m_vec_pair_posVox_rad.end(); ++it) - { - // Get the vector from the compared source to each voxel - Vec3 voxel_actual = ((*it).first); - //Vec3 source_actual = this->m_source->GetCoords( ); - //Vec3 vector_actual(voxel_actual - source_actual); - - // Get the difference vector - Vec3 vector_diff = vector - voxel_actual; - - // Get the distance - distanceTemp = vector_diff.Norm(); - - // Get the minimum - if(first) - { - point_closest = voxel_actual; - distance = distanceTemp; - first = false; - } - else if(distanceTemp < distance) - { - point_closest = voxel_actual; - distance = distanceTemp; - } - } - - return point_closest; -} - -Edge* Edge::ConcatenateToSuperior(Edge* superior) -{ - if(superior == NULL) - return new Edge(this); - - // Check concatenation condition in the nodes - if(superior->GetTarget()->GetCoords() != this->GetSource()->GetCoords()) - { - std::cout << "Edge::ConcatenateToSuperior - superior.target != actualEdge.source. Actual idNode:" << this->m_id << std::endl; - std::cout << "[superior.target;actualEdge.source]: [" << superior->GetTarget()->GetCoords() << ";" << this->GetSource()->GetCoords() << "]" << std::endl; - return NULL; - } - - // Check concatenation condition in the edge information - vec_pair_posVox_rad vectorInfo_thisEdge = this->GetEdgeInfo(); // Actual edge information - vec_pair_posVox_rad vectorInfo_superiorEdge = superior->GetEdgeInfo(); // Superior edge information - - // Check that last superior edge position is equal to first initial actual edge position - if(vectorInfo_superiorEdge[vectorInfo_superiorEdge.size()-1].first != vectorInfo_thisEdge[0].first) - { - std::cout << "Edge::ConcatenateToSuperior - superior.info[end] != actualEdge.info[begin]. Actual idNode:" << this->m_id << std::endl; - return NULL; - } - - // Change the superior edge target, the superior length, and the euclidian distance - superior->SetTarget(this->GetTarget()); - superior->SetLength(superior->GetLength()+this->GetLength()-1); - superior->SetEDistance(superior->GetEDistance()+this->GetEDistance()); - - // Add the position information - vec_pair_posVox_rad::iterator it_actualInfo = vectorInfo_thisEdge.begin(); - ++it_actualInfo; // Skip the first position because is it shared between both edges - for(; it_actualInfo != vectorInfo_thisEdge.end(); ++it_actualInfo) - vectorInfo_superiorEdge.push_back((*it_actualInfo)); - - // Set the new information - superior->SetSkeletonPairVector(vectorInfo_superiorEdge); - - return superior; - -} - -Edge& Edge::operator=(Edge& edge) -{ - this->m_mark = edge.m_mark; - this->m_angle = edge.m_angle; - this->m_length = edge.m_length; - this->m_eDistance = edge.m_eDistance; - this->m_aRadius = edge.m_aRadius; - this->m_minRadius = edge.m_minRadius; - this->m_maxRadius = edge.m_maxRadius; - this->m_source = edge.m_source; - this->m_target = edge.m_target; - this->m_vec_pair_posVox_rad = edge.m_vec_pair_posVox_rad; - return *this; -} - -const Edge& Edge::operator=(const Edge& edge) -{ - this->m_mark = edge.m_mark; - this->m_angle = edge.m_angle; - this->m_length = edge.m_length; - this->m_eDistance = edge.m_eDistance; - this->m_aRadius = edge.m_aRadius; - this->m_minRadius = edge.m_minRadius; - this->m_maxRadius = edge.m_maxRadius; - this->m_source = edge.m_source; - this->m_target = edge.m_target; - this->m_vec_pair_posVox_rad = edge.m_vec_pair_posVox_rad; - return *this; -} - -bool Edge::operator==(const Edge& edge) - { - bool cmp1 = true; - bool cmp2 = true; - bool cmp3 = true; - bool cmp4 = true; - bool cmp5 = true; - bool cmp6 = true; - /*if (this->m_angle != edge.m_angle) - { - double max = - this->m_angle >= edge.m_angle ? this->m_angle : edge.m_angle; - double tol = 0.3 * max; - double diff = this->m_angle - edge.m_angle; - if (!((-tol <= diff) && (diff <= tol))) - cmp1 = false; - }*/ - if (this->m_length != edge.m_length) - { - double max = - this->m_length >= edge.m_length ? this->m_length : edge.m_length; - double tol = 0.3 * max; - double diff = abs(this->m_length - edge.m_length); - if (diff > tol) - cmp2 = false; - } - if (this->m_eDistance != edge.m_eDistance) - { - double max = - this->m_eDistance >= edge.m_eDistance ? - this->m_eDistance : edge.m_eDistance; - double tol = 0.3 * max; - double diff = abs(this->m_eDistance - edge.m_eDistance); - if (diff > tol) - cmp3 = false; - } - /*if (this->m_aRadius != edge.m_aRadius) - { - double max = - this->m_aRadius >= edge.m_aRadius ? - this->m_aRadius : edge.m_aRadius; - double tol = 0.3 * max; - double diff = abs(this->m_aRadius - edge.m_aRadius); - if (diff > tol) - cmp4 = false; - } - if (this->m_minRadius != edge.m_minRadius) - { - double max = - this->m_minRadius >= edge.m_minRadius ? - this->m_minRadius : edge.m_minRadius; - double tol = 0.3 * max; - double diff = abs(this->m_minRadius - edge.m_minRadius); - if (diff > tol) - cmp5 = false; - } - if (this->m_maxRadius != edge.m_maxRadius) - { - double max = - this->m_maxRadius >= edge.m_maxRadius ? - this->m_maxRadius : edge.m_maxRadius; - double tol = 0.3 * max; - double diff = abs(this->m_maxRadius - edge.m_maxRadius); - if (diff > tol) - cmp6 = false; - }*/ - return (cmp1 && cmp2 && cmp3 && cmp4 && cmp5 && cmp6); - } - -bool Edge::operator!=(const Edge& edge) - { - return !(*this == edge); - } - -bool Edge::operator<(const Edge& edge) -{ - bool cmp1 = true; - bool cmp2 = true; - if (this->m_length != edge.m_length) - { - double max = - this->m_length >= edge.m_length ? this->m_length : edge.m_length; - double tol = 0.3 * max; - double diff = abs(this->m_length - edge.m_length); - if (diff > tol) - cmp2 = false; - } - if (this->m_eDistance != edge.m_eDistance) - { - double max = - this->m_eDistance >= edge.m_eDistance ? - this->m_eDistance : edge.m_eDistance; - double tol = 0.3 * max; - double diff = abs(this->m_eDistance - edge.m_eDistance); - if (diff > tol) - cmp2 = false; - } - if (cmp1 && cmp2) - return false; - if ((this->m_length < edge.m_length) - || (this->m_eDistance < edge.m_eDistance)) - return true; - return false; - -} - -bool Edge::operator>(const Edge& edge) -{ - bool cmp1 = true; - bool cmp2 = true; - if (this->m_length != edge.m_length) - { - double max = - this->m_length >= edge.m_length ? this->m_length : edge.m_length; - double tol = 0.3 * max; - double diff = abs(this->m_length - edge.m_length); - if (diff > tol) - cmp2 = false; - } - if (this->m_eDistance != edge.m_eDistance) - { - double max = - this->m_eDistance >= edge.m_eDistance ? - this->m_eDistance : edge.m_eDistance; - double tol = 0.3 * max; - double diff = abs(this->m_eDistance - edge.m_eDistance); - if (diff > tol) - cmp2 = false; - } - if (cmp1 && cmp2) - return false; - if ((this->m_length > edge.m_length) - || (this->m_eDistance > edge.m_eDistance)) - return true; - return false; -} - -} /* namespace airways */ diff --git a/lib/Airways/AirwaysLib/airwaysEdge.h b/lib/Airways/AirwaysLib/airwaysEdge.h deleted file mode 100644 index 8157793..0000000 --- a/lib/Airways/AirwaysLib/airwaysEdge.h +++ /dev/null @@ -1,323 +0,0 @@ -/* - * airwaysEdge.h - * - * Created on: May 12, 2014 - * Author: caceres - */ - -#ifndef AIRWAYSEDGE_H_ -#define AIRWAYSEDGE_H_ - -#include -#include -#include -#include -#include - -#include "airwaysNode.h" -#include "Quaternion.h" -#include - -/** - * @brief Airways project namespace - */ -namespace airways -{ - -/* - * Pair of which means the position of the skeleton point - * between two nodes (including branch-points) and it radius (obtained from - * the Danielsson's distance map algorithm) - */ -typedef std::pair pair_posVox_rad; - -/* - * A vector stocking all the points between two nodes - */ -typedef std::vector vec_pair_posVox_rad; - -class Node; - -/* - * This class represents an edge in a tree. Particularly, this edge represents the relation from child to father. - * This means that the edge source corresponds to the father and the target to the child. This implies that the root - * node has a NULL edge. - */ -class TempAirwaysAppli_AirwaysLib_EXPORT Edge -{ -public: - /*! - * Default constructor - */ - Edge(); - - /*! - * Alternative constructor (copy) - * @param edge - */ - Edge(Edge* edge); - - /*! - * Destructor - */ - virtual ~Edge(); - - - //Getters - - /*! - * This method returns the angle between two vectors using its parent as - * reference - * @return - */ - int GetAngle() const; - - /*! - * This method returns the Average radius between two branch-points - * @return - */ - double GetARadius() const; - - /*! - * This method returns the euclidean distance between two branch-points - * @return - */ - double GetEDistance() const; - - /*! - * This method returns the geodesic distance between two branch-points - * @return - */ - double GetLength() const; - - /*! - * This method returns the maximum radius between two branch-points - * @return - */ - double GetMaxRadius() const; - - /*! - * This method returns the minimum radius between two branch-points - * @return - */ - double GetMinRadius() const; - - /*! - * This method returns the source node of an edge - * @return - */ - Node* GetSource() const; - - /*! - * This method returns the target node of an edge - * @return - */ - Node* GetTarget() const; - - /*! - * This method returns the SKPairInfoVector of an edge - * @return - */ - const vec_pair_posVox_rad& GetEdgeInfo() const; - - /*! - * This method returns true if an edge is marked - * @return - */ - bool IsMarked() const; - - /** - * Method that returns if a voxel is influenced by this edge, i.e. if the distance - * to the closest voxel of the edge is smaller than the radius on the closest voxel. - * @param x,y,z are the voxel positions in coordinates x, y, and z respectively. - * @return true is the voxel is influenced, false otherwise - */ - bool IsPointInfluencedByEdge(float point_x, float point_y, float point_z) const; - - //Setters and Modifiers - - /*! - * This method sets the angle between two vectors using its parent - * as reference - * @param angle - */ - void SetAngle(const double& angle); - - /*! - * This method sets the average radius between two nodes - * @param aRadius - */ - void SetARadius(const double& aRadius); - - - /*! - * This method sets the Euclidean distance between two nodes - * @param eDistance - */ - void SetEDistance(const double& eDistance); - - /*! - * This method sets the geodesical length between two nodes - * @param length - */ - void SetLength(const double& length); - - /*! - * This method sets the maximum radius between two nodes - * @param maxRadius - */ - void SetMaxRadius(const unsigned int& maxRadius); - - /*! - * This method sets the minimum radius between two nodes - * @param minRadius - */ - void SetMinRadius(const unsigned int& minRadius); - - /*! - * This method sets the source node of an edge - * @param source - */ - void SetSource(Node* source); - - /*! - * This method sets the target node of an edge - * @param target - */ - void SetTarget(Node* target); - - /*! - * This method adds a pair into skPInfoVector - * @param skPairInfo - */ - void AddSkeletonPairInfo(const pair_posVox_rad& skPairInfo); - - /*! - * This method sets the skPInfoVector - * @param skPInfoVector - */ - void SetSkeletonPairVector(const vec_pair_posVox_rad& skPInfoVector); - - /*! - * This method updates all the attributes of an edge using the information - * provided from m_skInfoPairVector attribute. - */ - void UpdateEdgeInfo(); - - /** - * Method that compares two edges. - * @pre The actual and the edge given by parameter both have a parent edge - * @param edge is the edge to be compared with - * @return the evalation value - */ - double CompareWith(Edge* edge); - - /** - * Method that obtains the distance between two edges - * @param edge is the edge to be compared with - * @return the average distance from all points in the given edge - * to this edge. The distance from each in point in the edge to this - * edge is defined as the minimum distance to all the point in this - * edge. - */ - float GetDistanceToEdge(Edge* edge); - - float GetDistanceToTranslatedEdge(Edge* edge, Vec3 vector_translation); - - /** - * Method that returns the distance point to point to the edge given by parameter. - * Additionally, the points that share the same closest point receive more weight in the distance. - * @param edge is the edge to be compared with - * @param vector_translation is the translation vector to translate the given edge - * @return the weigthed distance to the given edge - */ - float GetDistanceWeigthedToTranslatedEdge(Edge* edge, Vec3 vector_translation); - - /** - * Method that calculates the distance from edge to one point in the space - * @point is the point in the space - * @return the distance from edge to one point in the space - */ - float GetDistanceToPoint(Vec3 point); - - /** - * Method that returns the smallest distance of the edge voxels to the given voxel (represented as a vector) - * @param vector is the point to be compared - * @return the smallest distance of the edge voxels to the given voxel - */ - float GetSmallestDistanceToPoint(Vec3 vector); - - /** - * Method that returns the closest point in the edge to the given point (represented as a vector) and the distance between them (by parameter) - * @param vector is the point to be compared - * @param distance is the returned distance to the closes point - * @return the closest vector and the minimum distance of the point to the points in the edge by parameter. - */ - Vec3 GetClosestPoint(Vec3 vector, float& distance); - - /** - * Method that concatenates the actual edge to a superior one given by parameter - * @param superior is the superio edge. The target of the superior edge must be the source of the actual edge - * in terms of voxel position. - * @return the composed edge to the superior edge - */ - Edge* ConcatenateToSuperior(Edge* superior); - - //Operator Overload - - Edge& operator=(Edge& edge); - - const Edge& operator=(const Edge& edge); - - bool operator==(const Edge& edge); - - bool operator!=(const Edge& edge); - - bool operator<(const Edge& edge); - - bool operator>(const Edge& edge); - -protected: - - unsigned int m_id; - - /** - * Source node representing the father - */ - Node* m_source; - - /** - * Target node representing the child - */ - Node* m_target; - - bool m_mark; //!Mark attribute - - double m_angle; //!Angle between two vectors having its parent as reference - - double m_length; //!Geodesic distance - - double m_eDistance; //!Euclidean distance - - double m_aRadius; //!Average radius between two nodes - - unsigned int m_minRadius; //!Minimum radius between two nodes - - unsigned int m_maxRadius; //!Maximum radius between two nodes - - /*! - * The m_vec_pair_posVox_rad is a vector containing all centerline points, - * in real coordinates of the image, and radius information of an edge. - * i.e., for each point of the skeleton between two nodes there is a pair - * - */ - vec_pair_posVox_rad m_vec_pair_posVox_rad; - - friend class AirwaysTree; //!Friend class AirwaysTree - - friend class Node; //!Friend class Node -}; - -} /* namespace airways */ - -#endif /* AIRWAYSEDGE_H_ */ diff --git a/lib/Airways/AirwaysLib/airwaysNode.cxx b/lib/Airways/AirwaysLib/airwaysNode.cxx deleted file mode 100644 index 27f6845..0000000 --- a/lib/Airways/AirwaysLib/airwaysNode.cxx +++ /dev/null @@ -1,1655 +0,0 @@ -/* - * airwaysNode.cxx - * - * Created on: May 12, 2014 - * Author: Diego Cáceres - * - * Modified by: Alfredo Morales Pinzón - */ - -#include - -#include "airwaysNode.h" - -namespace airways -{ - -Node::Node() : m_id(0), m_children(), m_edge(NULL), m_coords(0, 0, 0), m_level(-1), m_mark(false) -{ -} - -Node::Node(const Vec3& coord) : m_id(0), m_children(), m_edge(NULL), m_level(-1), m_mark(false) -{ - this->m_coords = coord; - this->m_level = 0; -} - -Node::Node(Node* node) : m_id(0), m_children(), m_mark(false) -{ - this->m_coords = node->m_coords; - this->m_level = node->m_level; - this->m_edge = new Edge(node->m_edge); -} - -Node::~Node() -{ -} - -//Getters - -const std::vector& Node::GetChildren() const -{ - return this->m_children; -} - -const unsigned int Node::GetId() const -{ - return this->m_id; -} - -const Vec3& Node::GetCoords() const -{ - return this->m_coords; -} - -Edge* Node::GetEdge() const -{ - return this->m_edge; -} - -Node* Node::GetFather() const -{ - return this->father; -} - -unsigned int Node::GetLevel() const -{ - return this->m_level; -} - -int Node::GetDepthById(unsigned int idNode) const -{ - if( this->m_id == idNode) - return 0; - - vec_nodes::const_iterator it = this->m_children.begin(); - for( ; it != this->m_children.end(); ++it) - { - if((*it)->HasNodeId(idNode)) - return 1 + (*it)->GetDepthById(idNode); - } - - std::cout << "GetDepthById - The idNode: " << idNode << "does not exist" << std::endl; - - return -1; -} - -unsigned int Node::GetWeight() const -{ - if(this->IsLeaf()) - return 1; - - unsigned int weight = 0; - - vec_nodes::const_iterator it = this->m_children.begin(); - for( ; it != this->m_children.end(); ++it) - weight += (*it)->GetWeight(); - - return 1 + weight; -} - -unsigned int Node::GetHeight() const -{ - unsigned int heightChildren = 0; - - vec_nodes::const_iterator it=this->m_children.begin(); - for( ; it != this->m_children.end(); ++it) - { - unsigned int actualHeight = (*it)->GetHeight(); - if(actualHeight > heightChildren) - heightChildren = actualHeight; - } - - // Return my heigh plus my children height - return 1 + heightChildren; -} - -unsigned int Node::GetNumberOfChildren() const -{ - return this->m_children.size(); -} - -unsigned int Node::GetNumberOfNonMarkedChildren( unsigned int depth ) const -{ - if(depth > 0) - { - unsigned int nonMarked = 0; - - for(vec_nodes::const_iterator it = this->m_children.begin(); it != this->m_children.end(); ++it) - { - if( !(*it)->m_mark ) - ++nonMarked; - nonMarked += (*it)->GetNumberOfNonMarkedChildren( depth - 1 ); - } - return nonMarked; - } - return 0; -} - -unsigned int Node::GetNumberOfLeafs() const -{ - if(this->IsLeaf()) - return 1; - - unsigned int leafs = 0; - vec_nodes::const_iterator it = this->m_children.begin(); - for( ; it != this->m_children.end(); ++it) - leafs += (*it)->GetNumberOfLeafs(); - - return leafs; -} - -Node* Node::GetNodeById(unsigned int nId) -{ - // Base case - if( m_id == nId) - return this; - - Node* node_searched = NULL; - - // Search in the children - vec_nodes::iterator it_children = m_children.begin(); - for( ; it_children != m_children.end() && node_searched == NULL; ++it_children) - node_searched = (*it_children)->GetNodeById(nId); - - return node_searched; -} - -Node* Node::GetClosestBranchNodeToPoint(float point_x, float point_y, float point_z, float &distance) -{ - // Get the actual distance - distance = GetBranchDistanceToPoint(point_x, point_y, point_z); - - // Make as closest "this" node - Node* node_closest = this; - - // Iterate over the children - vec_nodes::iterator it_children = m_children.begin(); - for( ; it_children != m_children.end(); ++it_children) - { - // Get actual child distance - float distance_actual = 0; - Node* bestNodeChild = (*it_children)->GetClosestBranchNodeToPoint(point_x, point_y, point_z, distance_actual); - - // If the child distance is smaller then switch - if(distance_actual < distance) - { - node_closest = bestNodeChild; - distance = distance_actual; - } - } - - return node_closest; -} - -Node* Node::GetClosestNodeToPoint(Vec3 position, double& distance) -{ - // Calculate actual distance to point - Vec3 vector_diff = position - this->m_coords; - distance = vector_diff.Norm(); - - if(this->IsLeaf()) - return this; - - // Variables - double actualDistance = -1; - Node* node_Best = this; - Node* node_Actual = NULL; - - // Check the children and get the best - for(vec_nodes::const_iterator it = this->m_children.begin(); it != this->m_children.end(); ++it) - { - node_Actual = (*it)->GetClosestNodeToPoint(position, actualDistance); - - if(actualDistance < distance) - { - node_Best = node_Actual; - distance = actualDistance; - } - } - - if(actualDistance == -1) - std::cout << "GetClosestNodeToPoint NOT FOUND!" << std::endl; - - return node_Best; -} - -float Node::GetBranchDistanceToPoint(int voxel_x, int voxel_y, int voxel_z) -{ - Vec3 voxel(voxel_x,voxel_y, voxel_z); - if(this->m_edge != NULL) - return this->m_edge->GetSmallestDistanceToPoint(voxel); - else - { - Vec3 vector_diff = this->m_coords - voxel; - return vector_diff.Norm(); - } -} - -bool Node::HasMinimumLevels(int levels) -{ - if(levels == 1) - return true; - - bool minimum = false; - - vec_nodes::iterator it=this->m_children.begin(); - for( ; it != this->m_children.end() && !minimum; ++it) - if((*it)->HasMinimumLevels(levels-1)) - minimum = true; - - return minimum; -} - -bool Node::IsLeaf() const -{ - return this->m_children.empty(); -} - -bool Node::IsMarked() const -{ - return this->m_mark; -} - -bool Node::HasMarkedChildren() const -{ - if(this->IsLeaf()) - return false; - - // Check the children - vec_nodes::const_iterator it = this->m_children.begin(); - for( ; it != this->m_children.end(); ++it) - if( (*it)->IsMarked() || (*it)->HasMarkedChildren()) - return true; - - return false; -} - -bool Node::HasNode(Node* node_searched) const -{ - if(this->m_id == node_searched->m_id) - return true; - - bool found = false; - - vec_nodes::const_iterator it = this->m_children.begin(); - for( ; it != this->m_children.end() && !found; ++it) - if( (*it)->HasNode(node_searched) ) - found = true; - - return found; -} - -bool Node::HasNodeId(unsigned int id_node_searched) const -{ - // If this is the node then return true - if(this->m_id == id_node_searched) - return true; - - // Search in the children - bool found = false; - vec_nodes::const_iterator it = this->m_children.begin(); - for( ; it != this->m_children.end() && !found; ++it) - if( (*it)->HasNodeId(id_node_searched) ) - found = true; - - return found; -} - -bool Node::IsPointInfluencedByNode(float point_x, float point_y, float point_z) const -{ - if(this->m_edge) - return m_edge->IsPointInfluencedByEdge(point_x, point_y, point_z); - - return false; -} - -void Node::GetBrancheNodesInfluencingPoint(float point_x, float point_y, float point_z, vec_nodes& vec_nodes_influence) -{ - if(this->IsPointInfluencedByNode(point_x, point_y, point_z)) - vec_nodes_influence.push_back(this); - - vec_nodes::const_iterator it = this->m_children.begin(); - for( ; it != this->m_children.end(); ++it) - (*it)->GetBrancheNodesInfluencingPoint(point_x, point_y, point_z, vec_nodes_influence); -} - -void Node::GetChildrenUptoDepth(unsigned int Q, vec_nodes& fathers) -{ - if(Q > 0) - { - vec_nodes::const_iterator it = this->m_children.begin(); - for( ; it != this->m_children.end(); ++it) - { - fathers.push_back((*it)); - (*it)->GetChildrenUptoDepth(Q-1, fathers); - } - /*// Add this node - fathers.push_back(this); - - // If the depth is greater that 1 then add the children of this node - if(Q > 1) - { - vec_nodes::const_iterator it = this->m_children.begin(); - for( ; it != this->m_children.end(); ++it) - (*it)->GetChildrenUptoDepth(Q-1, fathers); - }*/ - } -} - -void Node::CompareSubTreesOrkiszMorales(Node* nodeB, unsigned int Q, unsigned int F, vec_nodes& commonA, vec_nodes& commonB, vec_nodes& nonCommonA, vec_nodes& nonCommonB, map_id_vecnodes& map_A_to_B, map_id_vecnodes& map_B_to_A, std::vector< std::pair< pair_nodes, pair_nodes > >& vector_pair_edges) -{ - //std::cout << "---------------------------------------------------------" << std::endl; - //std::cout << "Comparing [A,B]: " << this->m_id << "," << nodeB->m_id << std::endl; - - // Variables - double distanceAtoB = 0; - double distanceBtoA = 0; - Node* node_bestA = NULL; - Node* node_bestB = NULL; - - // Algorithm - // The algorithm is recursive it is implemented the node class. The idea is to overlap the initial nodes of the subtrees - // and find the best branch correspondence for the first level of the trees. - // Hypothesis: It is supposed that the roots of the trees are common, so the algorithm does not run in the root nodes - // 1. Translate one of the subtree so that the initial nodes overlap. - // 2. While one of the trees has non-marked child - // 2.1 Compare each child to all the branches is the other tree. - // 2.2 Select the pair, child and branch in the other tree, that has the lowest distance function. - // 2.3 Add the pair and the distance to the final result. - // 2.4 Mark the nodes - // 2.5 Find and mark the omitted nodes in the similar branch. If the selected branch has more that 2 nodes it means that intermediary nodes do not have correspondence. - // 2.6 Run the process (First step) using the found pair of nodes. - - //1. Translate one of the subtree so that the initial nodes overlap. - // The translation must be applied later - - Vec3 vector_trans_B_to_A = this->m_coords - nodeB->m_coords; - - // ------------------------ - // ------------------------ - // Making the matching faster - std::multimap map_dist_pairNodes_A_to_B = this->CalculateDistanceToAllBranches_FatherAndFamily(nodeB, Q, F); - std::multimap map_dist_pairNodes_B_to_A = nodeB->CalculateDistanceToAllBranches_FatherAndFamily(this, Q, F); - - // ------------------------ - // ------------------------ - - while( this->GetNumberOfNonMarkedChildren( Q ) > 0 && nodeB->GetNumberOfNonMarkedChildren( Q ) > 0 ) - { - // 2.1 Compare each child to all the branches is the other tree. - - // 2.1.1 Get best translated branch from A to B - //std::pair pair_A_to_B = this->GetClosestBranch_FatherAndFamily(nodeB); - // 2.1.2 Get best translated branch from B to A - //std::pair pair_B_to_A = nodeB->GetClosestBranch_FatherAndFamily(this); - - // ------------------------ - // ------------------------ - // Making the matching faster - // Get the next best pair - std::pair pair_A_to_B = GetPairWithClosestDistance_FirstNodeNonMarked(map_dist_pairNodes_A_to_B); - std::pair pair_B_to_A = GetPairWithClosestDistance_FirstNodeNonMarked(map_dist_pairNodes_B_to_A); - - if( ! pair_A_to_B.second.first || ! pair_A_to_B.second.second ) - std::cout << "There is no closest-non-marked branch!" << std::endl; - - distanceAtoB = pair_A_to_B.first; - distanceBtoA = pair_B_to_A.first; - - //std::map map_dist_pairNodes_A_to_B = this->CalculateDistanceToAllBranches_FatherAndFamily(nodeB); - //std::map map_dist_pairNodes_B_to_A = nodeB->CalculateDistanceToAllBranches_FatherAndFamily(this); - // ------------------------ - // ------------------------ - - - // Assign the distances - //distanceAtoB = pair_A_to_B.second; - //distanceBtoA = pair_B_to_A.second; - - // 2.2 Select the pair, child and branch in the other tree, that has the lowest distance function. - if(distanceAtoB < distanceBtoA) - { - //node_bestA = pair_A_to_B.first.first; - //node_bestB = pair_A_to_B.first.second; - node_bestA = pair_A_to_B.second.first; - node_bestB = pair_A_to_B.second.second; - - //std::cout << "Best Pair [A',B]: " << node_bestA->m_id << "," << node_bestB->m_id << std::endl; - - // 2.2.1 Check that there are no topological problems before adding the pair - // Search all the nodes in the tree A linked to the found best node in B - vec_nodes nodesA_linkedToBestB = map_B_to_A[node_bestB->m_id]; - - // Look for topological problems - bool topo_problem = false; - for(vec_nodes::iterator it = nodesA_linkedToBestB.begin(); it != nodesA_linkedToBestB.end() && !topo_problem; ++it) - { - if( ! ( (*it)->HasNode( node_bestA ) || node_bestA->HasNode( (*it) ) ) ) - { - topo_problem = true; - //std::cout << "Topological problem adding node:" << node_bestA->m_id << std::endl; - } - } - - if(! topo_problem) - { - // 2.3 Add the pair and the distance to the final result. - commonA.push_back(node_bestA); - commonB.push_back(node_bestB); - map_A_to_B[node_bestA->m_id].push_back(node_bestB); - map_B_to_A[node_bestB->m_id].push_back(node_bestA); - - // Add the edge link - pair_nodes pair_edgeA(this, node_bestA); - pair_nodes pair_edgeB(nodeB, node_bestB); - std::pair< pair_nodes, pair_nodes > pair_edge(pair_edgeA, pair_edgeB); - vector_pair_edges.push_back(pair_edge); - - - // 2.4 Mark the nodes - node_bestA->Mark(); - node_bestB->Mark(); - - // 2.5 Find and mark the omitted nodes in the similar branch. If the selected branch has more that 2 nodes it means that intermediary nodes do not have correspondence. - Node* node_nextA = this->GetNextNodeInPathToNode(node_bestA); - //bool markedA = node_nextA->MarkNodesUntilNode(node_bestA); - //if(!markedA) - // std::cout << "NodeA not found for marking [A]:" << node_bestA->m_id << std::endl; - - Node* node_nextB = nodeB->GetNextNodeInPathToNode(node_bestB); - //bool markedB = node_nextB->MarkNodesUntilNode(node_bestB); - //if(!markedB) - // std::cout << "NodeB not found for marking [B]:" << node_bestB->m_id << std::endl; - - // 2.6 Run the process (First step) using the found pair of nodes. - node_bestA->CompareSubTreesOrkiszMorales(node_bestB, Q, F, commonA, commonB, nonCommonA, nonCommonB, map_A_to_B, map_B_to_A, vector_pair_edges); - } - else - { - // 2.4 Mark the wrong node - node_bestA->Mark(); - nonCommonA.push_back(node_bestA); - } - } - else - { - //node_bestA = pair_B_to_A.first.second; - //node_bestB = pair_B_to_A.first.first; - node_bestA = pair_B_to_A.second.second; - node_bestB = pair_B_to_A.second.first; - - //std::cout << "Best Pair [A,B']: " << node_bestA->m_id << "," << node_bestB->m_id << std::endl; - - // 2.29 Check that there are no topological problems before adding the pair - // 2.291 Search all the nodes in the A tree linked to the found best node in B - vec_nodes nodesB_linkedToBestA = map_A_to_B[node_bestA->m_id]; - - // 2.292 Look for topological problems - bool topo_problem = false; - for(vec_nodes::iterator it = nodesB_linkedToBestA.begin(); it != nodesB_linkedToBestA.end() && !topo_problem; ++it) - { - if( ! ( (*it)->HasNode(node_bestB) || node_bestB->HasNode( (*it) ) ) ) - { - topo_problem = true; - //std::cout << "Topological problem adding node:" << node_bestB->m_id << std::endl; - } - } - - if(! topo_problem) - { - // 2.3 Add the pair and the distance to the final result. - commonA.push_back(node_bestA); - commonB.push_back(node_bestB); - map_A_to_B[node_bestA->m_id].push_back(node_bestB); - map_B_to_A[node_bestB->m_id].push_back(node_bestA); - - // Add the edge link - pair_nodes pair_edgeA(this, node_bestA); - pair_nodes pair_edgeB(nodeB, node_bestB); - std::pair< pair_nodes, pair_nodes > pair_edge(pair_edgeA, pair_edgeB); - vector_pair_edges.push_back(pair_edge); - - // 2.4 Mark the nodes - node_bestA->Mark(); - node_bestB->Mark(); - - // 2.5 Find and mark the omitted nodes in the similar branch. If the selected branch has more that 2 nodes it means that intermediary nodes do not have correspondence. - Node* node_nextA = this->GetNextNodeInPathToNode(node_bestA); - //bool markedA = node_nextA->MarkNodesUntilNode(node_bestA); - //if(!markedA) - // std::cout << "NodeA not found for marking [A]:" << node_bestA->m_id << std::endl; - - Node* node_nextB = nodeB->GetNextNodeInPathToNode(node_bestB); - //bool markedB = node_nextB->MarkNodesUntilNode(node_bestB); - //if(!markedB) - // std::cout << "NodeB not found for marking [B]:" << node_bestB->m_id << std::endl; - - // 2.6 Run the process (First step) using the found pair of nodes. - //node_bestB->CompareSubTreesOrkiszMorales(node_bestA, commonB, commonA, nonCommonB, nonCommonA, map_B_to_A, map_A_to_B, vector_pair_edges); - node_bestA->CompareSubTreesOrkiszMorales(node_bestB, Q, F, commonA, commonB, nonCommonA, nonCommonB, map_A_to_B, map_B_to_A, vector_pair_edges); - } - else - { - // 2.4 Mark the wrong node - node_bestB->Mark(); - nonCommonB.push_back(node_bestB); - } - } - - } - //std::cout << "OUT Comparing [A,B]: " << this->m_id << "," << nodeB->m_id << std::endl; - //std::cout << "---------------------------------------------------------" << std::endl; -} - -std::pair< std::pair, double> Node::GetBestBranches_ActualTranslatedOneLevelBranches_To_AllPossibleBranches(Node* nodeB) -{ - // Variables - double distance = -1; - double distance_bestFinal = -1; - Node* node_A_bestFinal = NULL; - Node* node_B_bestFinal = NULL; - bool first = true; - - // Get the translation vector for root ovelapping - Vec3 vector_trans_A_to_B = nodeB->m_coords - this->m_coords; - - // Iterate over my children - for(vec_nodes::iterator it_A = this->m_children.begin(); it_A != this->m_children.end(); ++it_A) - { - if( !(*it_A)->IsMarked() ) - { - // Get the position of the actual child of this node - Vec3 position_actual = (*it_A)->m_coords; - - // Translate the position - Vec3 position_translated = position_actual + vector_trans_A_to_B; - - // Find the "closest" node in the subtree nodeB using a distance function - // a. Distance to ending point - //Node* bestNode_actual = nodeB->GetClosestRelativeToPoint(position_translated, distance); - // b. Distance point to point - Node* bestNode_actual = nodeB->GetClosestRelativeToBranch( (*it_A)->m_edge, vector_trans_A_to_B, distance); - - if(first) - { - first = false; - node_A_bestFinal = (*it_A); - node_B_bestFinal = bestNode_actual; - distance_bestFinal = distance; - } - else if(distance < distance_bestFinal) - { - node_A_bestFinal = (*it_A); - node_B_bestFinal = bestNode_actual; - distance_bestFinal = distance; - } - } - } - - if(first) - std::cout << "GetBestTranslatedBranchFromOtherTree NOT FOUND!" << std::endl; - - pair_nodes pair_best(node_A_bestFinal, node_B_bestFinal); - std::pair best_pair_score(pair_best, distance_bestFinal); - return best_pair_score; -} - -std::multimap< double, std::pair > Node::CalculateDistanceToAllBranches_FatherAndFamily(Node* node_gradfather, unsigned int Q, unsigned int F) -{ - // "this" is a grandfather node - // Variables - std::multimap< double, pair_nodes > map_dist_pairNodeNode; - double distance_actual = -1; - - // Get the translation vector for root overlapping - Vec3 vector_trans_A_to_B_grandfathers = node_gradfather->m_coords - this->m_coords; - - // Get all the possible "fathers" based on Q - vec_nodes fathers; - this->GetChildrenUptoDepth(Q, fathers); - //fathers = this->m_children; - - // Iterate over my children which actually are fathers - - //vec_nodes::iterator it_father = this->m_children.begin(); - vec_nodes::iterator it_father = fathers.begin(); - //for( ; it_father != this->m_children.end(); ++it_father) - for( ; it_father != fathers.end(); ++it_father) - { - if( ! (*it_father)->IsMarked() ) - { - - Node* node_actualBest = node_gradfather->GetClosestRelativeFatherAndFamily( this, (*it_father), F, vector_trans_A_to_B_grandfathers, distance_actual); - - pair_nodes pair_actual((*it_father), node_actualBest); - - std::pair actual_dist_pair(distance_actual,pair_actual); - map_dist_pairNodeNode.insert(actual_dist_pair); - } - } - - return map_dist_pairNodeNode; -} - - -/*std::pair< std::pair, double> Node::GetClosestBranch_FatherAndFamily(Node* node_gradfather) -{ - // "this" is a grandfather node - // Variables - double distance_actual = -1; - double distance_bestFinal = -1; - Node* node_A_bestFinal = NULL; - Node* node_B_bestFinal = NULL; - bool first = true; - - // Get the translation vector for root overlapping - Vec3 vector_trans_A_to_B_grandfathers = node_gradfather->m_coords - this->m_coords; - - // Iterate over my children which actually are fathers - vec_nodes::iterator it_father = this->m_children.begin(); - for( ; it_father != this->m_children.end(); ++it_father) - { - if( !(*it_father)->IsMarked() ) - { - // Get the position of the actual child of this node - //Vec3 position_actualFather = (*it_father)->m_coords; - - // Find the "closest" node in the subtree nodeB using a distance function - // a. Distance to ending point - // Translate the position - //Vec3 position_translated = position_actualFather + vector_trans_A_to_B_grandfathers; - //Node* bestNode_actual = nodeB->GetClosestRelativeToPoint(position_translated, distance); - // b. Distance point to point - Node* node_actualBest = node_gradfather->GetClosestRelativeFatherAndFamily( (*it_father), vector_trans_A_to_B_grandfathers, distance_actual); - - if(first) - { - first = false; - node_A_bestFinal = (*it_father); - node_B_bestFinal = node_actualBest; - distance_bestFinal = distance_actual; - } - else if(distance_actual < distance_bestFinal) - { - node_A_bestFinal = (*it_father); - node_B_bestFinal = node_actualBest; - distance_bestFinal = distance_actual; - } - } - } - - if(first) - std::cout << "GetBestTranslatedBranchFromOtherTree NOT FOUND!" << std::endl; - - pair_nodes pair_best(node_A_bestFinal, node_B_bestFinal); - std::pair best_pair_score(pair_best, distance_bestFinal); - return best_pair_score; -} -*/ - -Node* Node::GetClosestRelativeToPoint(Vec3 position, double& distance) -{ - if(this->IsLeaf()) - { - distance = -1; - return NULL; - } - - distance = -1; - bool first = true; - double actualDistance = -1; - Node* node_Best = NULL; - Node* node_Actual = NULL; - - for(vec_nodes::const_iterator it = this->m_children.begin(); it != this->m_children.end(); ++it) - { - node_Actual = (*it)->GetClosestNodeToPoint(position, actualDistance); - - if(first) - { - first = false; - node_Best = node_Actual; - distance = actualDistance; - } - else if(actualDistance < distance) - { - node_Best = node_Actual; - distance = actualDistance; - } - } - - if(first) - std::cout << "GetClosestRelativeToPoint NOT FOUND!" << std::endl; - - if(!node_Best) - std::cout << "GetClosestRelativeToPoint NULL!" << std::endl; - - return node_Best; -} - -Node* Node::GetClosestRelativeToBranch(Edge* branch, Vec3 vector_translation, double& distance) -{ - if(this->IsLeaf()) - { - distance = -1; - //std::cout << "GetClosestRelativeToBranch -- This node is a leaf" << std::endl; - return NULL; - } - - distance = -1; - bool first = true; - double actualDistance = -1; - Node* node_Best = NULL; - Node* node_Actual = NULL; - - for(vec_nodes::const_iterator it = this->m_children.begin(); it != this->m_children.end(); ++it) - { - node_Actual = (*it)->GetClosestBranchToTranslatedBranch(branch,vector_translation, actualDistance, NULL); - - if(first) - { - first = false; - node_Best = node_Actual; - distance = actualDistance; - } - else if(actualDistance < distance) - { - node_Best = node_Actual; - distance = actualDistance; - } - } - - if(first) - std::cout << "GetClosestRelativeToPoint NOT FOUND!" << std::endl; - - if(!node_Best) - std::cout << "GetClosestRelativeToPoint NULL!" << std::endl; - - return node_Best; -} - -Node* Node::GetClosestRelativeFatherAndFamily(Node* node_grandfather, Node* node_father, unsigned int F, Vec3 vector_translation, double& distance) -{ - // "this" is a grandfather node - - distance = -1; - if(this->IsLeaf()) - return NULL; - - bool first = true; - double actualDistance = -1; - Node* node_Best = NULL; - Node* node_Actual = NULL; - - // Iterate over the children of this granfather which means - // iterate over the fathers - vec_nodes::const_iterator it_father = this->m_children.begin(); - - for( ; it_father != this->m_children.end(); ++it_father) - { - node_Actual = (*it_father)->GetClosestFatherAndFamilyToTranslatedFatherAndFamily(node_grandfather, node_father, F, vector_translation, actualDistance, NULL); - - if(first) - { - first = false; - node_Best = node_Actual; - distance = actualDistance; - } - else if(actualDistance < distance) - { - node_Best = node_Actual; - distance = actualDistance; - } - } - - if(first) - std::cout << "GetClosestRelativeToPoint NOT FOUND!" << std::endl; - - if(!node_Best) - std::cout << "GetClosestRelativeToPoint NULL!" << std::endl; - - return node_Best; -} - -Node* Node::GetClosestBranchToTranslatedBranch(Edge* branch, Vec3 vector_translation, double& distance, Edge* edgeSuperior) -{ - Node* node_best = this; - Node* node_Actual = NULL; - Edge* edge_composed = NULL; - - // Joint the superior edge with this edge - edge_composed = this->ConcatenateEdgeToSuperiorEdge(edgeSuperior); - - distance = edge_composed->GetDistanceToTranslatedEdge(branch, vector_translation); - distance += branch->GetDistanceToTranslatedEdge(edge_composed, -vector_translation); - //distance = edge_composed->GetDistanceWeigthedToTranslatedEdge(branch, vector_translation); - //distance += branch->GetDistanceWeigthedToTranslatedEdge(edge_composed, -vector_translation); - //std::cout << "DW[thisId,toBranchTargetId,Dist]:[" << this->m_id << "," << branch->GetTarget()->GetId() << "," << distance << "]"; - - // Lance the recursion and the the minumum distance and node - double distance_actual = -1; - - // Check the children and get the best - for(vec_nodes::iterator it = this->m_children.begin(); it != this->m_children.end(); ++it) - { - Edge* edge_forChild = new Edge(edge_composed); - node_Actual = (*it)->GetClosestBranchToTranslatedBranch(branch, vector_translation, distance_actual, edge_forChild); - - if(distance_actual < distance) - { - node_best = node_Actual; - distance = distance_actual; - } - delete(edge_forChild); - } - - return node_best; -} - -Node* Node::GetClosestFatherAndFamilyToTranslatedFatherAndFamily(Node* node_grandfather, Node* node_father, unsigned int F, Vec3 vector_translation, double& distance, Edge* edgeSuperior) -{ - // "this" is a father node_father - Node* node_best = this; // Best matching node is "this" in the beginnig. - Node* node_Actual = NULL; - Edge* edge_composed = NULL; - - // Joint the superior edge with this edge - edge_composed = this->ConcatenateEdgeToSuperiorEdge(edgeSuperior); - - //distance = edge_composed->GetDistanceToTranslatedEdge(branch, vector_translation); - //distance += branch->GetDistanceToTranslatedEdge(edge_composed, -vector_translation); - - //Edge* branch_father = node_father->m_edge; - Edge* branch_father = node_father->GetEdgeToAncestor(node_grandfather, NULL); - if( branch_father == NULL ) - std::cout << "No branch father" << std::endl; - - - distance = edge_composed->GetDistanceWeigthedToTranslatedEdge(branch_father, vector_translation); - distance += branch_father->GetDistanceWeigthedToTranslatedEdge(edge_composed, -vector_translation); - - // Find the family distance from the node_father family to this family - double distance_family_A_to_B = 0; - // Add the distances to the family, up to one generation by the moment - Vec3 vector_translation_child_A_to_B = this->m_coords - node_father->m_coords; // Vector that align the fathers - - // Get the family up to depth F - vec_nodes family; - node_father->GetChildrenUptoDepth(F, family); - //vec_nodes family = node_father->m_children; - - vec_nodes::iterator it_child_other = family.begin(); - for(; it_child_other != family.end(); ++it_child_other) - { - // Create the "child" edge - Edge* childEdge = (*it_child_other)->GetEdgeToAncestor(node_father, NULL); - //Edge* childEdge = (*it_child_other)->m_edge; - - double distance_child = 0; - if(this->IsLeaf()) - { - // The distance of the each point edge to the root point because the fathers are aligned - distance_child = childEdge->GetDistanceToPoint(this->m_coords); - } - else - { - this->GetClosestRelativeToBranch(childEdge,vector_translation_child_A_to_B, distance_child); - } - distance_family_A_to_B += distance_child; - } - - distance += distance_family_A_to_B; - - // Find the family distance from this family to node_father family - double distance_family_B_to_A = 0; - - // Add the distances to the family, up to one generation by the moment - Vec3 vector_translation_child_B_to_A = node_father->m_coords - this->m_coords; // Vector that align the fathers - - // Get the family up to depth F - vec_nodes my_family; - this->GetChildrenUptoDepth(F, my_family); - //vec_nodes my_family = this->m_children; - - vec_nodes::iterator it_child_my = my_family.begin(); - for(; it_child_my != my_family.end(); ++it_child_my) - { - // Create the "child" edge - Edge* my_childEdge = (*it_child_my)->GetEdgeToAncestor(this, NULL); - //Edge* my_childEdge = (*it_child_my)->m_edge; - - double distance_child = 0; - if(node_father->IsLeaf()) - { - // The distance of the each point edge to the root point because the fathers are aligned - distance_child = my_childEdge->GetDistanceToPoint(node_father->m_coords); - } - else - { - node_father->GetClosestRelativeToBranch(my_childEdge, vector_translation_child_B_to_A, distance_child); - } - distance_family_B_to_A += distance_child; - } - - distance += distance_family_B_to_A; - - //std::cout << "DW[thisId,toBranchTargetId,Dist]:[" << this->m_id << "," << branch->GetTarget()->GetId() << "," << distance << "]"; - - // Lance the recursion and the minimum distance and node_father - double distance_actual = -1; - - // Check the children and get the best - vec_nodes::iterator it = this->m_children.begin(); - for( ; it != this->m_children.end(); ++it) - { - Edge* edge_forChild = new Edge(edge_composed); - node_Actual = (*it)->GetClosestFatherAndFamilyToTranslatedFatherAndFamily(node_grandfather, node_father, F, vector_translation, distance_actual, edge_forChild); - - if(distance_actual < distance) - { - node_best = node_Actual; - distance = distance_actual; - } - delete(edge_forChild); - } - - return node_best; -} - -const Node* Node::GetClosestCommonAscendingNode() const -{ - Node* node_closestCommonAscendingNode = NULL; - - if(this->m_edge) - { - if(this->m_edge->GetSource()->IsMarked() || this->m_edge->GetSource()->HasMarkedChildren()) - node_closestCommonAscendingNode = this->m_edge->GetSource(); - else - return this->m_edge->GetSource()->GetClosestCommonAscendingNode(); - } - - return node_closestCommonAscendingNode; -} - -bool Node::MarkNodesUntilNode(Node* nodeB) -{ - this->Mark(); - - if(this->m_id == nodeB->m_id) - return true; - - bool found = false; - bool actualFound = false; - for(vec_nodes::const_iterator it = this->m_children.begin(); it != this->m_children.end(); ++it) - { - actualFound = (*it)->MarkNodesUntilNode(nodeB); - - if(actualFound) - found = true; - } - - return found; -} - -Node* Node::GetNextNodeInPathToNode(Node* node_searched) -{ - Node* nextNode = NULL; - for(vec_nodes::const_iterator it = this->m_children.begin(); it != this->m_children.end() && !nextNode; ++it) - { - if( (*it)->HasNode(node_searched) ) - nextNode = (*it); - } - - return nextNode; -} - -void Node::GetPathToNode(Node* node_end, vec_nodes& vector_pathNodes) -{ - if(!this->HasNode(node_end)) - return; - - vector_pathNodes.push_back(this); - for(vec_nodes::const_iterator it = this->m_children.begin(); it != this->m_children.end(); ++it) - (*it)->GetPathToNode(node_end, vector_pathNodes); -} - -void Node::MarkPathFromNodeToNode(Node* node_begin, Node* node_end) -{ - if(this->m_id == node_begin->m_id) - { - if(this->HasNode(node_end)) - this->MarkPathNodesToNode(node_end); - } - else - for(vec_nodes::const_iterator it = this->m_children.begin(); it != this->m_children.end(); ++it) - (*it)->MarkPathFromNodeToNode(node_begin, node_end); -} - -void Node::MarkPathNodesToNode(Node* node_end) -{ - if(this->HasNode(node_end)) - this->Mark(); - - for(vec_nodes::const_iterator it = this->m_children.begin(); it != this->m_children.end(); ++it) - (*it)->MarkPathNodesToNode(node_end); -} - -Node* Node::GetDetachedRootCopy() -{ - Node* node_copy = new Node(this); - - // Change properties for root node - Node* root_detached = new Node(); - root_detached->m_coords = node_copy->m_edge->GetSource()->GetCoords(); - root_detached->m_edge = NULL; - vec_nodes vector_new; - vector_new.push_back(node_copy); - root_detached->m_children = vector_new; - - // Change properties for the copy node - node_copy->m_edge->SetSource(root_detached); - - return root_detached; -} - -bool Node::CompareNodes(Node* nodeTreeB) -{ - if (this == NULL && nodeTreeB == NULL) - return true; - else if (this == NULL || nodeTreeB == NULL) - return false; - vec_nodes::iterator it = this->m_children.begin(); - for (; it != this->m_children.end(); ++it) - { - if ((*it)->m_mark) - continue; - bool suc = false; - vec_nodes::iterator it2 = nodeTreeB->m_children.begin(); - for (; it2 != nodeTreeB->m_children.end(); ++it2) - suc = (*it)->CompareNodes(*it2); - if (!suc) - return false; - } //for - if (*this != *nodeTreeB) - return false; - this->m_mark = true; - nodeTreeB->m_mark = true; - return true; -} - -Edge* Node::GetComposedEdge(unsigned int idNode) -{ - // If this is the node, then a copy edge (to the parent) is returned - if(this->m_id == idNode) - { - //std::cout << "This is the searched idNode: " << this->m_id << std::endl; - Edge* nEdge = new Edge(this->m_edge); - return nEdge; - } - - - Edge* composedEdge = NULL; - - for(std::vector::iterator it = this->m_children.begin(); it != this->m_children.end(); ++it) - { - // If one of my children has the composed node, then my edge must be added - // and the composed edge is returned - Edge* childEdge = (*it)->GetComposedEdge(idNode); - if(childEdge) - { - //std::cout << "My id: " << this->m_id << ", Looking for: " << idNode << std::endl; - return AddChildEdgeInformation(childEdge); - } - } - - return composedEdge; -} - -Edge* Node::AddChildEdgeInformation(Edge* nEdge) -{ - // If this is the root then the edge to be compose is null, so the same edge must be returned - if(this->m_edge == NULL) - { - //std::cout << "This is the root node" << std::endl; - return nEdge; - } - - // New information vector - vec_pair_posVox_rad vector_newInformation; - vec_pair_posVox_rad actualEdgeInformation = this->m_edge->GetEdgeInfo(); - vec_pair_posVox_rad composedInformation = nEdge->GetEdgeInfo(); - - // Check that last and initial information, from this and the other edge respectively, are equal. - if(actualEdgeInformation[actualEdgeInformation.size()-1].first != composedInformation[0].first) - { - - std::cout << "actualEdgeInformation[0;end]: [" << actualEdgeInformation[0].first << ";" << actualEdgeInformation[actualEdgeInformation.size()-1].first << "], Points: " << actualEdgeInformation.size() << std::endl; - std::cout << "ActualEdge[source;target]: [" << this->m_edge->GetSource()->GetCoords() << "];[" << this->m_edge->GetTarget()->GetCoords() << "]" << std::endl; - std::cout << "-- -- -- " << std::endl; - std::cout << "composedInformation[0;end]: [" << composedInformation[0].first << ";" << composedInformation[composedInformation.size()-1].first << "], Points: " << composedInformation.size() << std::endl; - std::cout << "AddChildEdge[source;target]: [" << nEdge->GetSource()->GetCoords() << "];[" << nEdge->GetTarget()->GetCoords() << "]" << std::endl; - std::cout << "End and initial information are not equal! : " << actualEdgeInformation[actualEdgeInformation.size()-1].first << " , " << composedInformation[0].first << std::endl; - - - std::cout << "Print composed edge information" << std::endl; - std::cout << "Composed [source, target] " << nEdge->GetSource()->GetCoords() << "];[" << nEdge->GetTarget()->GetCoords() << "]" << std::endl; - std::cout << "Composed information using iterator:" << std::endl; - - for(vec_pair_posVox_rad::const_iterator it_composed = nEdge->GetEdgeInfo().begin(); it_composed != nEdge->GetEdgeInfo().end(); ++it_composed) - std::cout << "[" << (*it_composed).first << "], "; - } - - // Change the source - nEdge->SetSource(this->m_edge->GetSource()); - - // Change properties - nEdge->SetLength(nEdge->GetLength()+this->m_edge->GetLength()); - nEdge->SetEDistance(nEdge->GetEDistance()+this->m_edge->GetEDistance()); - - // Create the new information vector and calculate the new radii attributes - for(vec_pair_posVox_rad::iterator it_actual = actualEdgeInformation.begin(); it_actual != actualEdgeInformation.end(); ++it_actual) - vector_newInformation.push_back((*it_actual)); - - bool connectionVoxel = true; - for(vec_pair_posVox_rad::iterator it_composed = composedInformation.begin(); it_composed != composedInformation.end(); ++it_composed) - { - if(connectionVoxel) - connectionVoxel = false; - else - vector_newInformation.push_back((*it_composed)); - } - - // Set the new information - nEdge->SetSkeletonPairVector(vector_newInformation); - - return nEdge; -} - -Edge* Node::GetEdgeToAncestor(Node* node_ancestor, Edge* edge) -{ - Edge* edge_composed = NULL; - - // Compose the edge - if(edge == NULL) - edge_composed = new Edge(this->m_edge); - else - edge_composed = edge->ConcatenateToSuperior(new Edge(this->m_edge)); - - // Check if the father is the ancestor - if(this->m_edge->GetSource()->GetId() == node_ancestor->GetId()) - return edge_composed; - - return this->m_edge->GetSource()->GetEdgeToAncestor(node_ancestor, edge_composed); -} - -Edge* Node::ConcatenateEdgeToSuperiorEdge(Edge* superiorEdge) -{ - if(superiorEdge == NULL) - return new Edge(this->m_edge); - - // Check concatenation condition in the nodes - if(superiorEdge->GetTarget()->GetCoords() != this->m_edge->GetSource()->GetCoords()) - { - std::cout << "Node::ConcatenateEdgeToSuperiorEdge - superiorEdge.target != actualEdge.source. Actual idNode:" << this->m_id << std::endl; - std::cout << "[superiorEdge.target;actualEdge.source]: [" << superiorEdge->GetTarget()->GetCoords() << ";" << this->m_edge->GetSource()->GetCoords() << "]" << std::endl; - return NULL; - } - - // Check concatenation condition in the edge information - vec_pair_posVox_rad vectorInfo_thisEdge = this->m_edge->GetEdgeInfo(); // Actual edge information - vec_pair_posVox_rad vectorInfo_superiorEdge = superiorEdge->GetEdgeInfo(); // Superior edge information - - // Check that last superior edge position is equal to first initial actual edge position - if(vectorInfo_superiorEdge[vectorInfo_superiorEdge.size()-1].first != vectorInfo_thisEdge[0].first) - { - std::cout << "Node::ConcatenateEdgeToSuperiorEdge - superiorEdge.info[end] != actualEdge.info[begin]. Actual idNode:" << this->m_id << std::endl; - return NULL; - } - - // Change the superior edge target, the superior length, and the euclidian distance - superiorEdge->SetTarget(this->m_edge->GetTarget()); - superiorEdge->SetLength(superiorEdge->GetLength()+this->m_edge->GetLength()-1); - superiorEdge->SetEDistance(superiorEdge->GetEDistance()+this->m_edge->GetEDistance()); - - // Add the position information - vec_pair_posVox_rad::iterator it_actualInfo = vectorInfo_thisEdge.begin(); - ++it_actualInfo; // Skip the first position because is it shared between both edges - for(; it_actualInfo != vectorInfo_thisEdge.end(); ++it_actualInfo) - vectorInfo_superiorEdge.push_back((*it_actualInfo)); - - // Set the new information - superiorEdge->SetSkeletonPairVector(vectorInfo_superiorEdge); - - return superiorEdge; -} - -bool Node::FindSimilarEdgeByAccumulation(Node* nodeB, Node* nodeBAcc) -{ - bool firstTime = false; - if (nodeBAcc == NULL) - { - nodeBAcc = new Node(); - nodeBAcc->m_edge = new Edge(); - firstTime = true; - } //if - nodeBAcc->m_coords = nodeB->m_coords; - nodeBAcc->m_level = this->m_level; - Edge* edgeBAcc = nodeBAcc->m_edge; - Edge* edgeB = nodeB->m_edge; - edgeBAcc->m_angle = edgeB->m_angle; - edgeBAcc->m_eDistance = edgeB->m_eDistance; - if (!firstTime) - { - edgeBAcc->m_length += edgeB->m_length; - //edgeBAcc->m_aRadius = (edgeB->m_aRadius + edgeBAcc->m_aRadius) / 2.0; - edgeBAcc->m_maxRadius = edgeB->m_maxRadius > edgeBAcc->m_maxRadius ? edgeB->m_maxRadius : edgeBAcc->m_maxRadius; - edgeBAcc->m_minRadius = edgeB->m_minRadius < edgeBAcc->m_minRadius ? edgeB->m_minRadius : edgeBAcc->m_minRadius; - } //fi - else - { - edgeBAcc->m_length = edgeB->m_length; - edgeBAcc->m_aRadius = edgeB->m_aRadius; - edgeBAcc->m_maxRadius = edgeB->m_maxRadius; - edgeBAcc->m_minRadius = edgeB->m_minRadius; - } //else - - if (*this == *nodeBAcc) - return true; - Node* aux = NULL; - bool suc = false; - vec_nodes::iterator it = nodeB->m_children.begin(); - for (; it != nodeB->m_children.end(); ++it) - { - aux = *it; - if (this->FindSimilarEdgeByAccumulation(aux, nodeBAcc)) - { - suc = true; - break; - } //if - } //for - if (suc) - { - nodeB = aux; - return true; - }//if - return false; -} - -bool Node::FindMarked(Node* result) -{ - vec_nodes::iterator it = this->m_children.begin(); - for (; it != this->m_children.end(); ++it) - if ((*it)->m_mark) - { - result = *it; - return true; - } //if - else if ((*it)->FindMarked(result)) - return true; - result = NULL; - return false; -} - -bool Node::MarkPath(Node* nodeB) -{ - if (this == NULL || nodeB == NULL) - return false; - //comparing addresses - if (this == nodeB) - { - nodeB->m_mark = true; - return true; - } //if - vec_nodes::iterator it = this->m_children.begin(); - for (; it != this->m_children.end(); ++it) - if ((*it)->MarkPath(nodeB)) - { - (*it)->m_mark = true; - return true; - } //if - return false; - -} - -unsigned int Node::GetCost(Node* nodeB) -{ - if (this == NULL || nodeB == NULL) - return 0; - unsigned int maxCost = 0; - if (*this == *nodeB) - { - vec_nodes::iterator it = this->m_children.begin(); - for (; it != this->m_children.end(); ++it) - { - vec_nodes::iterator it2 = nodeB->m_children.begin(); - for (; it2 != nodeB->m_children.end(); ++it2) - { - unsigned int currentCost = (*it)->GetCost(*it2); - if (currentCost > maxCost) - maxCost = currentCost; - } //for - } //for - maxCost += 1; - } //if - return maxCost; -} - - -//Setters and Modifiers - -void Node::SetId(unsigned int nM_id) -{ - m_id = nM_id; -} - - -void Node::AddChild(Node* node) -{ - this->m_children.push_back(node); -} - -void Node::SetChildren(std::vector& children) -{ - this->m_children = children; -} - -void Node::SetFather(Node* nFather) -{ - father = nFather; -} - -void Node::SetEdge(Edge* edge) -{ - this->m_edge = edge; -} - -void Node::SetCoords(const Vec3& coords) -{ - this->m_coords = coords; -} - -void Node::SetLevel(const int& level) -{ - this->m_level = level; -} - -bool Node::DeleteNodeById(unsigned int nId) -{ - if(this->IsLeaf()) - return false; - - bool deleted = false; - - vec_nodes::iterator it = this->m_children.begin(); - while(it != this->m_children.end() && !deleted) - { - if((*it)->m_id == nId) - { - it = m_children.erase(it); - deleted = true; - } - else - ++it; - } - - if(!deleted) - { - for(vec_nodes::const_iterator it = this->m_children.begin(); it != this->m_children.end() && !deleted; ++it) - { - deleted = (*it)->DeleteNodeById(nId); - } - } - - return deleted; -} - -void Node::MergeNodes(Node* nodeB) -{ - if (nodeB == NULL) - return; - this->m_coords = nodeB->m_coords; - Edge* edgeA = this->m_edge; - Edge* edgeB = nodeB->m_edge; - edgeA->m_angle = edgeB->m_angle; - edgeA->m_eDistance = edgeB->m_eDistance; - edgeA->m_length += edgeB->m_length; - edgeA->m_aRadius = (edgeB->m_aRadius + edgeA->m_aRadius) / 2.0; - edgeA->m_maxRadius = edgeB->m_maxRadius > edgeA->m_maxRadius ? edgeB->m_maxRadius : edgeA->m_maxRadius; - edgeA->m_minRadius = edgeB->m_minRadius < edgeA->m_minRadius ? edgeB->m_minRadius : edgeA->m_minRadius; - edgeA->m_vec_pair_posVox_rad.insert(edgeA->m_vec_pair_posVox_rad.end(), edgeB->m_vec_pair_posVox_rad.begin(), edgeB->m_vec_pair_posVox_rad.end()); -} - -void Node::Mark() -{ - this->m_mark = true; -} - -void Node::UnMark() -{ - this->m_mark = false; -} - -void Node::UpdateLevels(unsigned int level) -{ - this->m_level = level; - level++; - vec_nodes::iterator it = this->m_children.begin(); - for (; it != this->m_children.end(); ++it) - (*it)->UpdateLevels(level); -} - -void Node::printUpToLevel(int level) -{ - // Print myself - cout << "level" << level << " " << m_coords << " || " << endl; - if(level == 1) - return; - - // Print my children - for (vec_nodes::iterator it = this->m_children.begin(); it != this->m_children.end(); ++it) - { - (*it)->printUpToLevel(level-1); - } -} - -void Node::printNodeAndChildrenIds( ) -{ - std::cout << "------------------------------------------" << std::endl; - std::cout << "Id: " << this->m_id << std::endl; - - // Print children - for(vec_nodes::const_iterator it = this->m_children.begin(); it != this->m_children.end(); ++it) - std::cout << (*it)->m_id << ";"; - - // Recursion - for(vec_nodes::const_iterator it = this->m_children.begin(); it != this->m_children.end(); ++it) - (*it)->printNodeAndChildrenIds( ); -} - -void Node::printChildrenIds( ) -{ - std::cout << "------------------------------------------" << std::endl; - std::cout << "Id: " << this->m_id << std::endl; - - // Print children - for(vec_nodes::const_iterator it = this->m_children.begin(); it != this->m_children.end(); ++it) - std::cout << (*it)->m_id << ";"; -} - -void Node::createQuaternionsUpToLevel(int level, int requiredLevel) -{ - //cout << "Level:" << requiredLevel-level <= 2 && this->HasMinimumLevels(2)) - { - // 1. Take the vector to each son (SP - The vector that points from the son to the parent [P-S]). - // 2. For each son take each vector from son to grandson (SG - the vector that points from the son to the grandson [G-S]) - // 3. For each combination SP-SG calculate the quaternion - for(vec_nodes::iterator it = this->m_children.begin(); it != this->m_children.end(); ++it) - { - // Create vector from son to parent (SP = [P - S]) - Vec3 sp(this->m_coords - (*it)->m_coords); - - // Get the mean radius for the parent-son branch - double radMeanSP=(*it)->m_edge->GetARadius(); - - // Get distance son to parent - double distSonParent = (*it)->m_edge->GetEDistance(); - - // Get the vectors from son to each grandson (SG = [G - S] ) - for(vec_nodes::iterator itps = (*it)->m_children.begin(); itps != (*it)->m_children.end(); ++itps) - { - // Build the sg vector and get the quaternion - Vec3 sg((*itps)->m_coords - (*it)->m_coords); - Quaternion q(sp, sg); - - // Get distance son to grandson - double distSonGrandson = (*itps)->m_edge->GetEDistance(); - - // Get the mean radius for the son-grandson branch - double radMeanSG=(*itps)->m_edge->GetARadius(); - - //cout << "Vectors:" << ps << sg <m_coords << " " << sp << " " << sg << " " << q << " " << distSonParent << " " << distSonGrandson << " " << radMeanSP << " " << radMeanSG << endl; - } - } - - for(vec_nodes::iterator it = this->m_children.begin(); it != this->m_children.end(); ++it) - { - (*it)->createQuaternionsUpToLevel(level-1, requiredLevel); - } - } -} - -std::pair > Node::GetPairWithClosestDistance_FirstNodeNonMarked(std::multimap map_dist_pairNodes) -{ - // Variables - bool pairFound = false; - std::pair pairNodes_null (NULL, NULL); - std::pair > pair_closest_dist_pairNodes (-1, pairNodes_null); - - std::multimap::iterator it = map_dist_pairNodes.begin(); - - for( ; it != map_dist_pairNodes.end() && !pairFound; ++it) - { - if( ! (*it).second.first->IsMarked() ) - { - pair_closest_dist_pairNodes.first=(*it).first; - pair_closest_dist_pairNodes.second=(*it).second; - pairFound = true; - } - } - - return pair_closest_dist_pairNodes; -} - -void Node::getStasticsBifurcations(int* p) -{ - int numBif = this->m_children.size(); - if(numBif>0 && numBif<=6) - p[numBif-1]=p[numBif-1]+1; - - for(vec_nodes::iterator it = this->m_children.begin(); it != this->m_children.end(); ++it) - { - (*it)->getStasticsBifurcations(p); - } -} - -//Operator Overloads - -Node &Node::operator=(Node & node) -{ - this->m_children = node.m_children; - this->m_edge = node.m_edge; - this->m_coords = node.m_coords; - this->m_level = node.m_level; - this->m_mark = node.m_mark; - return *this; -} - -const Node&Node::operator=(const Node& node) -{ - this->m_children = node.m_children; - this->m_edge = node.m_edge; - this->m_coords = node.m_coords; - this->m_level = node.m_level; - this->m_mark = node.m_mark; - return *this; -} - -bool Node::operator ==(const Node& node) -{ - bool comp = false; - if (this->m_edge == NULL && this->m_edge != NULL) - return false; - else if (this->m_edge != NULL && this->m_edge == NULL) - return false; - else if (this->m_edge == NULL && this->m_edge == NULL) - comp = true; - else - comp = ((*this->m_edge) == (*node.m_edge)); - bool ret = (/*(this->m_coords == node.m_coords) - && (this->m_children.size() == node.m_children.size()) - && */(this->m_level == node.m_level) && comp); - return ret; -} - -bool Node::operator !=(const Node& node) -{ - bool comp = false; - if (this->m_edge == NULL && this->m_edge != NULL) - return false; - else if (this->m_edge != NULL && this->m_edge == NULL) - return false; - else if (this->m_edge == NULL && this->m_edge == NULL) - comp = true; - else - comp = ((*this->m_edge) == (*node.m_edge)); - return (/*(this->m_coords != node.m_coords) - && (this->m_children.size() != node.m_children.size()) - && */(this->m_level != node.m_level) && !comp); -} - -bool Node::operator <(const Node& node) -{ - bool comp = false; - if (this->m_edge == NULL && this->m_edge != NULL) - return false; - else if (this->m_edge != NULL && this->m_edge == NULL) - return false; - else if (this->m_edge == NULL && this->m_edge == NULL) - comp = false; - else - comp = ((*this->m_edge) < (*node.m_edge)); - return comp; -} - -bool Node::operator >(const Node& node) -{ - bool comp = false; - if (this->m_edge == NULL && this->m_edge != NULL) - return false; - else if (this->m_edge != NULL && this->m_edge == NULL) - return false; - else if (this->m_edge == NULL && this->m_edge == NULL) - comp = false; - else - comp = ((*this->m_edge) > (*node.m_edge)); - return comp; -} - -} /* namespace airways */ diff --git a/lib/Airways/AirwaysLib/airwaysNode.h b/lib/Airways/AirwaysLib/airwaysNode.h deleted file mode 100644 index cdffe31..0000000 --- a/lib/Airways/AirwaysLib/airwaysNode.h +++ /dev/null @@ -1,597 +0,0 @@ -/* - * airwaysNode.h - * - * Created on: May 12, 2014 - * Author: caceres - * - * Modified by: Alfredo Morales Pinzón - */ - -#ifndef AIRWAYSNODE_H_ -#define AIRWAYSNODE_H_ - -#include -#include - -#include "../MathLib/vec3.h" -#include "airwaysEdge.h" -#include "Quaternion.h" -#include - -// Namespaces -using namespace std; - -namespace airways -{ - -class AirwaysTree; -class Edge; - -/* - * This class represents a node in a tree. - */ -class TempAirwaysAppli_AirwaysLib_EXPORT Node -{ - -public: - - // Pair of nodes - typedef std::pair pair_nodes; - - // Vector of nodes - typedef std::vector vec_nodes; - - // Map to link an id node to a list of nodes - typedef std::map< unsigned int, vec_nodes > map_id_vecnodes; - - /*! - * This is the default constructor - */ - Node(); - - /*! - * This is the alternative constructor - * @param coord - */ - Node(const Vec3& coord); - - /*! - * This is the alternative constructor (copy) - * @param node - */ - Node(Node* node); - - /*! - * This is the destructor - */ - virtual ~Node(); - - //Getters - - /*! - * This method returns the vector of the node children (const) - * @return - */ - const std::vector& GetChildren() const; - - /** - * Method that returns the node id - * @return the id of the node - */ - const unsigned int GetId() const; - - /*! - * This method returns the spatial position of a node - * @return - */ - const Vec3& GetCoords() const; - - /* - * Method that returns the edge between the current node and its parent - * @return the edge - */ - Edge* GetEdge() const; - - /* - * Method that returns the father - * @return the father - */ - Node* GetFather() const; - - /* - * This method returns the level of the node - * @return the level of the node - */ - unsigned int GetLevel() const; - - /** - * Method that returns the depth of the node whose id is given by parameter - * @pre the node exist in the sub-tree - * @param idNode is the search node id - * @return the depth of the node up to the actual node - */ - int GetDepthById(unsigned int idNode) const; - - /** - * Method that returns the weight of the tree - * @return the weight of the tree which is the number of nodes in the tree. - */ - unsigned int GetWeight() const; - - /** - * Method that returns the height of the tree - * @return the height of the tree - */ - unsigned int GetHeight() const; - - /*! - * This method returns the size of the children vector - * @return the number of children - */ - unsigned int GetNumberOfChildren() const; - - /** - * Method that returns the number of children non-marked - * @param depth is the depth up to which the non-marked child are taken into account - * @return the number of children non-marked - */ - unsigned int GetNumberOfNonMarkedChildren( unsigned int depth ) const; - - /** - * Method that returns the number of leafs in the node and its children - * @return the number of leafs in the in the node and its children - */ - unsigned int GetNumberOfLeafs( ) const; - - /** - * This method returns the node that has the requested id - * @param nId is the requested id - * @return is the node that has the requested id, NULL if the node is not found. - */ - Node* GetNodeById(unsigned int nId); - - /** - * Method that returns the closest node to the givel voxel - * The closes node is the one whose path (skeleton) to the father has the closest point to the given point. - * @param voxel_x x componente of the voxel - * @param voxel_y y componente of the voxel - * @param voxel_z z componente of the voxel - * @param distance return the distance to the closest node - * @return the closest node to the given voxel - */ - Node* GetClosestBranchNodeToPoint(float point_x, float point_y, float point_z, float &distance); - - /** - * Method that returns the closest node to the position given by parameter - * @param position is the position to be compares with - * @param distance is the minimum distance found - * return the closest node to the position given by parameter - */ - Node* GetClosestNodeToPoint(Vec3 position, double& distance); - - /** - * Method that return the closest distance of the node skeleton - * @param voxel_x x componente of the voxel - * @param voxel_y y componente of the voxel - * @param voxel_z z componente of the voxel - * @return the closest distance of the node skeleton - */ - float GetBranchDistanceToPoint(int voxel_x, int voxel_y, int voxel_z); - - /** - * Method that returns if the tree has a minimum of levels - * @return true if the tree has the minimum of levels, false otherwise - */ - bool HasMinimumLevels(int levels); - - - /*! - * This method returns true if the node is a leaf - * @return - */ - bool IsLeaf() const; - - /*! - * This method returns true if the node is marked - * @return - */ - bool IsMarked() const; - - /** - * Method that tells if a node has marked children - * @return true if the node has marked children, false otherwise - */ - bool HasMarkedChildren() const; - - /** - * Method that returns if a node is in the descending set of nodes - * @return true is the given node is in the descending set of nodes, false otherwise - */ - bool HasNode(Node* node_searched) const; - - /** - * Method that return if a node is in the tree - * @param id_node_searched id of the searched node - * @return true is the node is in the tree, false otherwise - */ - bool HasNodeId(unsigned int id_node_searched) const; - - /** - * Method that returns if a voxel is influenced by a node, i.e. if the distance - * to the closest voxel of the edge is smaller than the radius on the closest voxel. - * @param x,y,z are the voxel positions in coordinates x, y, and z respectively. - * @return true is the voxel is influenced, false otherwise. - */ - bool IsPointInfluencedByNode(float point_x, float point_y, float point_z) const; - - /** - * Method that returns the list of nodes that influence the given point - * @param point_x, point_y, point_z are the position of the point in real coordinates x, y, and z respectively. - * @param vec_nodes_influence vector to save the nodes - */ - void GetBrancheNodesInfluencingPoint(float point_x, float point_y, float point_z, vec_nodes& vec_nodes_influence); - - /** - * Method that adds to a vector all the children with a maximum depth Q from actual node. - * If Q = 0, no nodes are added. - * @param Q the depth to find the children - * @param fathers vector to return the children - */ - void GetChildrenUptoDepth(unsigned int Q, vec_nodes& fathers); - - /** - * This method compares the subtrees that start in this node and one given by parameter. - * @param nodeB is the stating node of the subtree to be compared with - * @param Q is the depth to select "fathers" nodes - * @param F is the depth to select "family" nodes - * @param commonA vector to save the common nodes for this subtree - * @param commonA vector to save the common nodes for the subtree given by parameter - * @param nonCommonA vector to save the non-common nodes for this subtree - * @param nonCommonB vector to save the non-common nodes for the subtree given by parameter - */ - void CompareSubTreesOrkiszMorales(Node* nodeB, unsigned int Q, unsigned int F, vec_nodes& commonA, vec_nodes& commonB, vec_nodes& nonCommonA, vec_nodes& nonCommonB, map_id_vecnodes& map_A_to_B, map_id_vecnodes& map_B_to_A, std::vector< std::pair< pair_nodes, pair_nodes > >& vector_pair_edges); - - /** - * Method that returns the pair of branches (one node for each tree) that has the minimum distance after root overlapping. - * Valid branches for the actual node are the one level branches those the branches up to this child (height = 2). - * Root overlapping means the translation of branch so that root overlap. - * @pre: The actual branch is not marked. - * @param nodeB is the subtree root node to be compared with - * @return the pair of branches (one node for each tree) that has the minimum distance after root overlapping - */ - std::pair< std::pair, double> GetBestBranches_ActualTranslatedOneLevelBranches_To_AllPossibleBranches(Node* nodeB); - - /** - * Method that returns all the distances to all the non-marked branches, i.e., the end node of the branch is non-marked, - * inside a multimap (key, value) structure where the value elementent corresponds to the compared branches. - * @param node_gradfather is the grandfather node to be compared - * @param Q is the depth to select "fathers" - * @param F is the depth to select "family" nodes - * @return multimap where the key is the distance between branches and the value is the pair of compared branches end-nodes. - */ - std::multimap< double, std::pair > CalculateDistanceToAllBranches_FatherAndFamily(Node* node_gradfather, unsigned int Q, unsigned int F); - - /** - * Method is executed by grandfather nodes. It returns the closest pair of nodes, - * one must be my child and the other one of the relatives given node. - * The closest pair is the one that has the minimal distance between the children and the families. - * The distance is the sum of fathers distances and family distances. - * @param nodeB is the node to be compared with - * @return the closest pair of nodes, one must be my child and the other on of the relatives given node. - */ - //std::pair< std::pair, double> GetClosestBranch_FatherAndFamily(Node* nodeB); - - /** - * Method that returns the closest relative node, all the nodes but this, whose position is the closest to the point given by parameter - * @param position is the point to be compared with - * @param distance is the minimum distance found in the relatives - * @return the closest relative node, all the nodes but this, whose position is the closest to the point given by parameter - */ - Node* GetClosestRelativeToPoint(Vec3 position, double& distance); - - - Node* GetClosestRelativeToBranch(Edge* branch, Vec3 vector_translation, double& distance); - - /** - * Method that returns the closest node to the given by node. - * Closest involve the distance between fathers and family. - * @param node_grandfather is the father of the "node_father" which can be different from the direct father. - * this is the case when the father distance is the algorithm, given by Q, is greater than 1. - * @param node_father is the node to be compared with - * @param F is the depth to select "family" nodes - * @param vector_translation is the translation vector to translate the "father" branch - * @param distance is the distance to be returned by parameter - * @return the closest node to the given by node. - */ - Node* GetClosestRelativeFatherAndFamily(Node* node_grandfather, Node* node_father, unsigned int F, Vec3 vector_translation, double& distance); - - Node* GetClosestBranchToTranslatedBranch(Edge* branch, Vec3 vector_translation, double& distance, Edge* edgeSuperior); - - /** - * This method returns the closest father and family, in this subtree, that is the closest to the subtree given by parameter - * The returned node represents the father. - * @param node_grandfather is the father of the "node_father" which can be different from the direct father. - * this is the case when the father distance is the algorithm, given by Q, is greater than 1. - * @param node_father is the node father to be compared with - * @param F is the depth to select "family" nodes - * @param vector_translation is the translation vector to translation the father given by parameter - * @param distance is the closest distances to be returned by parameter - * @param edgeSuperior is a superior edge where the actual edge must be attached - * @returns the closest father and family, in this subtree, that is the closest to the subtree given by parameter - */ - Node* GetClosestFatherAndFamilyToTranslatedFatherAndFamily(Node* node_grandfather, Node* node_father, unsigned int F, Vec3 vector_translation, double& distance, Edge* edgeSuperior); - - /** - * Method that return the closest ascending node that is marked as common. - * A common node may common if: - * (1) it is marked or (2) one of their descendants is marked - * return the closest ascending common node. NULL is there is no such node. - */ - const Node* GetClosestCommonAscendingNode() const; - - /** - * Method that marks all nodes between this node and the one given by parameter. If the searched node is not found then all nodes are marked. - * @param nodeB is the searched node - * @return true is the node was found, false otherwise - */ - bool MarkNodesUntilNode(Node* nodeB); - - Node* GetNextNodeInPathToNode(Node* node_searched); - - /** - * Method that returns the path from the actual node to the searched node - * @param node_end is the searched node - * @param vector_pathNodes vector_pathNodesis the vector to return the path - */ - void GetPathToNode(Node* node_end, vec_nodes& vector_pathNodes); - - void MarkPathFromNodeToNode(Node* node_begin, Node* node_end); - - void MarkPathNodesToNode(Node* node_end); - - /** - * Method that returns a root with a copy of this node as single child - * @return a root with a copy of this node as single child - */ - Node* GetDetachedRootCopy(); - - /*! - * This method return true if two nodes are equals - * @param nodeTreeB - * @return - */ - bool CompareNodes(Node* nodeTreeB); - - /** - * Method that returns a new composed edge from this node to the searched node. - * @param idNode is the searched id node - * @return the edge to the searched node. Null if the node is not found. - */ - Edge* GetComposedEdge(unsigned int idNode); - - /** - * Method that composes the actual edge with the edge given by parameter - * @param nEdge edge to be composed with - * @return final composed edge - */ - Edge* AddChildEdgeInformation(Edge* nEdge); - - /** - * Method that returns a "composed edge" up to the ancestor - * @pre the ancesto node must be a real ancestor - * @param node_ancestor is the ancestor node to with the edge must be composed - * @param edge is the actual composed edge. NULL if the fist iteration - * @return the composed edge up to the ancesto node - */ - Edge* GetEdgeToAncestor(Node* node_ancestor, Edge* edge); - - /** - * Method that concatenates the actual edge to a superior edge given by parameter. - * As the given edge is superior then the actual edge must be concatenate at the end of the superior edge, - * this means that superiorEdge.target must equal to the actualEdge.source. - * @param superiorEdge is the superior edge where the actual edge must be added - * @return - a copy of the actual edge if the superior edge is NULL - * - if superiorEdge.target == actualEdge.source the the superior edge with the actual edge concatenated - * - NULL otherwise (superiorEdge.target != actualEdge.source) - */ - Edge* ConcatenateEdgeToSuperiorEdge(Edge* superiorEdge); - - /*! - * This method returns true if the accumulation of a set of nodes are equals - * (in tolerance) to the compared node (this). This method tries to find - * edges in the case of edge losses. - * When this method returns true, NodeB pointer is replaced to the node (target) - * found by accumulation (See the report to understand what this means). - * @param nodeB - Current node to compare - * @param nodeBAcc - Accumulator Node (Optional) - * @return - */ - bool FindSimilarEdgeByAccumulation(Node* nodeB, Node* nodeBAcc = NULL); - - /*! - * This method returns true if there is a marked node along the hierarchy - * @param result - * @return - */ - bool FindMarked(Node* result); - - /*! - * This method marks the path between two nodes and returns true if a path - * has found. - * @param nodeB - * @return - */ - bool MarkPath(Node* nodeB); - - /*! - * This method returns the cost between two nodes. - * @param nodeB - * @return - */ - unsigned int GetCost(Node* nodeB); - - //Setters and Modifiers - - /* - * Method that sets the id of the node - * @param nM_id is the new id - */ - void SetId(unsigned int nM_id); - - /*! - * This method adds a node in the children vector - * @param node is the node to be added - */ - void AddChild(Node* node); - - /*! - * This method sets the children vector - * @param children - */ - void SetChildren(std::vector& children); - - /** - * Method that sets the father - * @param nFather is the father - */ - void SetFather(Node* nFather); - - /*! - * This method sets an edge between the current node and its parent - * @param edge - */ - void SetEdge(Edge* edge); - - /*! - * This method sets the coordinates of the node - * @param coords - */ - void SetCoords(const Vec3& coords); - - /** - * Method that sets the level of the node - * @param level is the level of the node - */ - void SetLevel(const int& level); - - /** - * Method that deleted a node and all his children, from the tree - * @return true if the node was deleted (found), false otherwise - */ - bool DeleteNodeById(unsigned int nId); - - /*! - * This method merges the nodeB into this - * @param nodeB - */ - void MergeNodes(Node* nodeB); - - /*! - * This method marks a node - */ - void Mark(); - - /*! - * This method unmarks a node - */ - void UnMark(); - - /*! - * This method update all levels along the hierarchy - * @param level - */ - void UpdateLevels(unsigned int level = 0); - - - /** - * Method that prints the tree up to a given level - * @param level where the print must finish - */ - void printUpToLevel(int level); - - void printNodeAndChildrenIds( ); - - void printChildrenIds( ); - - /** - * Method that creates the quaternions of the airways up the maxLevel - * @param level is the level where the extraction must end - * @param requiredLevel is the required level until the extraction must be done - * @pre level >= 2 - */ - void createQuaternionsUpToLevel(int level, int requiredLevel); - - /** - * Method that returns the closest pair node, based on their distance, having the first node of the pair as non-marked. - * The pair is found on the given a multimap of distances and pair of nodes. It is supposed that the multimap sorts - * the elements by its key. In this case the key corresponds to the distance. - * @param map_dist_pairNodes is the map containing the distances (keys) and the pair of nodes (value) - * @return the closest pair nodes, based on their distance, given a multimap of distances and pair of nodes. If - * no pair was found with the pair node nonmaked, a null pair is returned. - * Actually the method returns the pair and its distances in a pair - */ - std::pair > GetPairWithClosestDistance_FirstNodeNonMarked(std::multimap map_dist_pairNodes); - - /** - * Add the statistics of number of bifurcations in the tree to the array given by parameter - * @param p array to save the statistics - */ - void getStasticsBifurcations(int* p); - - //Operator Overloads - - Node& operator=(Node& node); - - const Node& operator=(const Node& node); - - bool operator ==(const Node& node); - - bool operator !=(const Node& node); - - bool operator <(const Node& node); - - bool operator >(const Node& node); - -protected: - - /** - * Node id - */ - unsigned int m_id; - - /** - * Children nodes vector - */ - vec_nodes m_children; - - /** - * Father node - */ - Node* father; - - /** - * Edge between the current node and its parent. - * The source of the edge corresponds to the parent en the target to the child, - * in this case to "this" node. - */ - Edge* m_edge; - - /** - * Spatial 3D position of the node in real coordinates of the image - */ - Vec3 m_coords; - - /** - * Node level - */ - int m_level; - - /** - * Node mark - */ - bool m_mark; -}; - -} /* namespace airways */ - -#endif /* AIRWAYSNODE_H_ */ diff --git a/lib/Airways/AirwaysLib/airwaysTree.cxx b/lib/Airways/AirwaysLib/airwaysTree.cxx deleted file mode 100644 index 0f0f821..0000000 --- a/lib/Airways/AirwaysLib/airwaysTree.cxx +++ /dev/null @@ -1,2251 +0,0 @@ -/* - * airwaysTree.txx - * - * Created on: May 3, 2014 - * Author: caceres@creatis.insa-lyon.fr - * Modifications by: Alfredo Morales Pinzón - */ - -#ifndef _AIRWAYS_TREE_TXX_ -#define _AIRWAYS_TREE_TXX_ - -#include "airwaysTree.h" - -namespace airways -{ - -AirwaysTree::AirwaysTree() : m_root(NULL) -{ - -} - -//Ceron -AirwaysTree::AirwaysTree(TInputImage::Pointer img, TInputImage::Pointer img_skele, Node* root, bool shouldUpdate){ - this->m_root = root; - this->m_root->SetLevel(0); - this->m_img = img; - this->m_skeleton = img_skele; - //TODO: Should this calculate levels and populate edges and nodes vectors? - FillTree(root); - if(shouldUpdate) this->UpdateEdges(); -} - -void AirwaysTree::FillTree(Node* node){ - //std::cout << "Calls fill tree for " << node->GetCoords() << std::endl; - this->m_nodes.push_back(node); - node->SetId(this->m_nodes.size()); - if(node->GetEdge() != NULL){ - this->m_edges.push_back(node->GetEdge()); - node->GetEdge()->UpdateEdgeInfo(); - } - int level = node->GetLevel(); - //std::cout << "Node is at level " << level << std::endl; - vec_nodes::const_iterator it = node->GetChildren().begin(); - for (; it != node->GetChildren().end(); ++it){ - (*it)->SetLevel(level+1); - this->FillTree(*it); - } -} - -AirwaysTree::AirwaysTree(TInputImage::Pointer img, TInputImage::Pointer img_sk, Node* root) -{ - this->m_root = root; - this->m_root->SetLevel(0); - this->m_skeleton = img_sk; - this->m_img = img; - this->UpdateEdges(); -} - -AirwaysTree::AirwaysTree(TInputImage::Pointer image_airwaySegmentation, TInputImage::Pointer image_skeletonDM, EdgeVector& vector_edges, Edge* edge_trachea) -{ - std::cout << "AirwaysTree::AirwaysTree(TInputImage::Pointer img, TInputImage::Pointer img_sk, EdgeVector& tEdgeVector, Edge* trachea)" << std::endl; - std::cout << "Edges to add:" << vector_edges.size() << std::endl; - - if(edge_trachea == NULL) - std::cout << "The trachea edge is NULL" << std::endl; - - // Set the attribtes - this->m_skeleton = image_skeletonDM; - this->m_img = image_airwaySegmentation; - this->m_root = edge_trachea->m_source; - this->m_root->SetLevel(0); - - this->m_nodes.push_back(edge_trachea->m_source); // Add the first node, the root to the nodes of the tree - edge_trachea->m_source->SetId(this->m_nodes.size());// Set the root id - - // Insert the trachea edge - this->Insert(edge_trachea); - - // Insert all edges - unsigned int iniSize = vector_edges.size(); - - while (!vector_edges.empty()) - { - bool oneEdgeAdded = false; - EdgeVector::iterator it = vector_edges.begin(); - while (it != vector_edges.end()) - { - if (this->Insert(*it)) - { - std::cout << "Edges added: [" << (*it)->GetSource()->GetCoords() << "]->[" << (*it)->GetTarget()->GetCoords() << "], missing: " << vector_edges.size()-1 << std::endl; - oneEdgeAdded = true; - it = vector_edges.erase(it); - } - else - ++it; - } //while - - // If there are edges to be added but they could not be added - if(!oneEdgeAdded) - { - std::cout << "Edges not added:" << vector_edges.size() << std::endl; - for (EdgeVector::iterator it = vector_edges.begin(); it != vector_edges.end(); ++it) - std::cout << "Edge missing: [" << (*it)->GetSource()->GetCoords() << "]->[" << (*it)->GetTarget()->GetCoords() << "]" << std::endl; - break; - } - // AMP: I did not find any explanation for this "exception" - /*count++; - if (count == iniSize) - { - std::cout << "handled exception: arwaysTree.txx, AirwaysTree" << std::endl; - break; - } //if - */ - } //while - this->UpdateEdges(); - - std::cout << "AirwaysTree::AirwaysTree(TInputImage::Pointer img, TInputImage::Pointer img_sk, EdgeVector& tEdgeVector, Edge* trachea) ... OK" << std::endl; -} - -AirwaysTree::~AirwaysTree() -{ - -} - -Node* AirwaysTree::GetRoot() const -{ - return this->m_root; -} - -std::string AirwaysTree::GetImageName() const -{ - return (this->m_img_name); -} - -std::string AirwaysTree::GetResultPath() const -{ - return (this->m_result_path); -} - -TInputImage::Pointer AirwaysTree::GetSegmentedImage() const -{ - return this->m_img; -} - -TInputImage::Pointer AirwaysTree::GetSkeletonImage() const -{ - return this->m_skeleton; -} - -const Node* AirwaysTree::GetNode(const Vec3 nodeCoords) const -{ - return this->GetNode(nodeCoords); -} - -Node* AirwaysTree::GetNodeById(unsigned int nId) -{ - return this->m_root->GetNodeById(nId); -} - -int AirwaysTree::GetDepthById(unsigned int nId) -{ - return this->m_root->GetDepthById(nId); -} - -unsigned int AirwaysTree::CountMarkedNodes(Node* current) const -{ - if (current == NULL) - current = this->m_root; - Node* aux = NULL; - bool found = current->FindMarked(aux); - if (!found && !current->IsMarked()) - return 0; - if (aux != NULL && found) - current = aux; - unsigned int count = 1; - vec_nodes::const_iterator it = current->GetChildren().begin(); - for (; it != current->GetChildren().end(); ++it) - count += this->CountMarkedNodes(*it); - return count; -} - -unsigned int AirwaysTree::GetWeight( ) const -{ - if (this->m_root == NULL) - return 0; - - return this->m_root->GetWeight(); -} - -unsigned int AirwaysTree::GetHeight(Node* current) const -{ - if (current == NULL) - current = this->m_root; - if (current->IsLeaf()) - return 1; - unsigned int max = 0; - vec_nodes::const_iterator it = current->GetChildren().begin(); - for (; it != current->GetChildren().end(); ++it) - { - unsigned int cMax = this->GetHeight(*it); - if (cMax > max) - max = cMax; - } //rof - if (current == this->m_root) - return max; - return ++max; -} - -unsigned int AirwaysTree::GetLevels(Node* current, unsigned int cLevel) const -{ - if (current == NULL) - current = this->m_root; - if (current->IsLeaf()) - return current->GetLevel(); - unsigned int maxLevel = cLevel; - vec_nodes::const_iterator it = current->GetChildren().begin(); - for (; it != current->GetChildren().end(); ++it) - { - unsigned int level = this->GetLevels(*it, maxLevel); - if (level > maxLevel) - maxLevel = level; - } //rof - return maxLevel; -} - -unsigned int AirwaysTree::GetNumberOfLeafs( ) const -{ - if(!this->m_root) - return 0; - - return this->m_root->GetNumberOfLeafs( ); -} - -const EdgeVector& AirwaysTree::GetEdges() const -{ - return this->m_edges; -} - -const vec_nodes& AirwaysTree::GetNodes() const -{ - return this->m_nodes; -} - -const Node* AirwaysTree::GetClosestBrachNodeToIndex(float point_x, float point_y, float point_z) const -{ - float distance = 0; - Node* closestNode = this->m_root->GetClosestBranchNodeToPoint(point_x, point_y, point_z, distance); - return closestNode; -} - -void AirwaysTree::GetBrancheNodesInfluencingPoint(float point_x, float point_y, float point_z, vec_nodes& vec_nodes_influence) -{ - if(this->m_root) - { - std::cout << "AirwaysTree::GetBrancheNodesInfluencingPoint" << std::endl; - this->m_root->GetBrancheNodesInfluencingPoint(point_x, point_y, point_z, vec_nodes_influence); - } -} - -AirwaysTree& AirwaysTree::GetTreeFromMarkedNodes(Node* currentNode, AirwaysTree* tree) -{ - if (tree == NULL) - { - if (!this->m_root->IsMarked()) - return *(new AirwaysTree()); - currentNode = this->m_root; - tree = new AirwaysTree(); - Node* current = new Node(currentNode->GetCoords()); - tree->SetRoot(current); - vec_nodes::const_iterator it = currentNode->GetChildren().begin(); - for (; it != currentNode->GetChildren().end(); ++it) - this->GetTreeFromMarkedNodes(*it, tree); - this->ImageReconstruction(tree->m_img); - //this->ImageReconstruction(tree->m_skeleton); - return *tree; - } //fi - if (currentNode->IsMarked()) - { - Edge* edge = new Edge(); - *edge = *currentNode->GetEdge(); - Node* target = new Node(currentNode->GetCoords()); - edge->m_target = target; - tree->Insert(edge); - vec_nodes::const_iterator it = currentNode->GetChildren().begin(); - for (; it != currentNode->GetChildren().end(); ++it) - this->GetTreeFromMarkedNodes(*it, tree); - } //fi - return *(new AirwaysTree()); -} - -AirwaysTree& AirwaysTree::GetSubTreeFromNode(Node* node, AirwaysTree* tree) -{ - if (tree == NULL) - { - tree = new AirwaysTree(); - Node* current = new Node(node->GetCoords()); - tree->SetRoot(current); - vec_nodes::const_iterator it = node->GetChildren().begin(); - for (; it != node->GetChildren().end(); ++it) - this->GetSubTreeFromNode(*it, tree); - this->ImageReconstructionFromNode(tree->m_img, node); - //this->ImageReconstructionFromNode(tree->m_skeleton, node, true); - return *tree; - } //fi - Edge* edge = new Edge(); - *edge = *node->GetEdge(); - Node* target = new Node(node->GetCoords()); - edge->m_target = target; - tree->Insert(edge); - vec_nodes::const_iterator it = node->GetChildren().begin(); - for (; it != node->GetChildren().end(); ++it) - this->GetSubTreeFromNode(*it, tree); - - return *(new AirwaysTree()); -} - -AirwaysTree& AirwaysTree::GetSubTreeByLevels(const int& level, Node* node, - AirwaysTree* tree) -{ - if (tree == NULL) - { - node = this->m_root; - tree = new AirwaysTree(); - Node* current = new Node(node->GetCoords()); - tree->SetRoot(current); - if (node->GetLevel() <= level) - { - node->Mark(); - vec_nodes::const_iterator it = node->GetChildren().begin(); - for (; it != node->GetChildren().end(); ++it) - this->GetSubTreeByLevels(level, *it, tree); - } //fi - if (node->GetLevel() == level) - { - DuplicatorType::Pointer duplicator = DuplicatorType::New(); - duplicator->SetInputImage(this->m_img); - duplicator->Update(); - tree->m_img = duplicator->GetOutput(); - duplicator->SetInputImage(this->m_skeleton); - duplicator->Update(); - tree->m_skeleton = duplicator->GetOutput(); - } //if - else - { - this->ImageReconstruction(tree->m_img); - //this->ImageReconstruction(tree->m_skeleton, true); - } //else - this->UnMarkAll(); - return *tree; - } //fi - if (node->GetLevel() <= level) - { - node->Mark(); - Edge* edge = new Edge(); - *edge = *node->GetEdge(); - Node* target = new Node(node->GetCoords()); - edge->m_target = target; - tree->Insert(edge); - vec_nodes::const_iterator it = node->GetChildren().begin(); - for (; it != node->GetChildren().end(); ++it) - this->GetSubTreeByLevels(level, *it, tree); - if (node->GetChildren().size() == 1) - { - Node* child = *(node->GetChildren().begin()); - node->MergeNodes(child); - const Edge* edge = (child)->GetEdge(); - //removing from nodeVector and edgeVector - EdgeVector::iterator it2 = this->m_edges.begin(); - for (; it2 != this->m_edges.end(); ++it2) - if (edge == *it2) - { - this->m_edges.erase(it2); - break; - } //if - vec_nodes::iterator it3 = this->m_nodes.begin(); - for (; it3 != this->m_nodes.end(); ++it3) - if (child == *it3) - { - this->m_nodes.erase(it3); - break; - } //if - } //if - } //if - return *(new AirwaysTree()); -} - -AirwaysTree& AirwaysTree::GetSubTreeByLength(const double& length, Node* node, - AirwaysTree* tree, double cLenght) -{ - if (tree == NULL) - { - node = this->m_root; - tree = new AirwaysTree(); - Node* current = new Node(node->GetCoords()); - tree->SetRoot(current); - node->Mark(); - vec_nodes::const_iterator it = node->GetChildren().begin(); - for (; it != node->GetChildren().end(); ++it) - this->GetSubTreeByLength(length, *it, tree); - this->ImageReconstruction(tree->m_img); - //this->ImageReconstruction(tree->m_skeleton, true); - this->UnMarkAll(); - return *tree; - } //fi - cLenght += node->GetEdge()->m_length; - if (cLenght <= length) - { - node->Mark(); - Edge* edge = new Edge(); - *edge = *node->GetEdge(); - Node* target = new Node(node->GetCoords()); - edge->m_target = target; - tree->Insert(edge); - vec_nodes::const_iterator it = node->GetChildren().begin(); - for (; it != node->GetChildren().end(); ++it) - this->GetSubTreeByLength(length, *it, tree, cLenght); - if (node->GetChildren().size() == 1) - { - Node* child = *(node->GetChildren().begin()); - node->MergeNodes(child); - const Edge* edge = (child)->GetEdge(); - //removing from nodeVector and edgeVector - EdgeVector::iterator it2 = this->m_edges.begin(); - for (; it2 != this->m_edges.end(); ++it2) - if (edge == *it2) - { - this->m_edges.erase(it2); - break; - } //if - vec_nodes::iterator it3 = this->m_nodes.begin(); - for (; it3 != this->m_nodes.end(); ++it3) - if (child == *it3) - { - this->m_nodes.erase(it3); - break; - } //if - } //if - } //if - return *(new AirwaysTree()); -} - -AirwaysTree& AirwaysTree::GetSubTreeByRadius(const double& radius, Node* node, - AirwaysTree* tree, double cRadius) -{ - if (tree == NULL) - { - node = this->m_root; - tree = new AirwaysTree(); - Node* current = new Node(node->GetCoords()); - tree->SetRoot(current); - node->Mark(); - vec_nodes::const_iterator it = node->GetChildren().begin(); - for (; it != node->GetChildren().end(); ++it) - this->GetSubTreeByRadius(radius, *it, tree); - this->ImageReconstruction(tree->m_img); - //this->ImageReconstruction(tree->m_skeleton, true); - this->UnMarkAll(); - return *tree; - } //fi - cRadius += node->GetEdge()->m_aRadius; - if (cRadius >= radius) - { - node->Mark(); - Edge* edge = new Edge(); - *edge = *node->GetEdge(); - Node* target = new Node(node->GetCoords()); - edge->m_target = target; - tree->Insert(edge); - vec_nodes::const_iterator it = node->GetChildren().begin(); - for (; it != node->GetChildren().end(); ++it) - this->GetSubTreeByRadius(radius, *it, tree, cRadius); - if (node->GetChildren().size() == 1) - { - Node* child = *(node->GetChildren().begin()); - node->MergeNodes(child); - const Edge* edge = (child)->GetEdge(); - //removing from nodeVector and edgeVector - EdgeVector::iterator it2 = this->m_edges.begin(); - for (; it2 != this->m_edges.end(); ++it2) - if (edge == *it2) - { - this->m_edges.erase(it2); - break; - } //if - vec_nodes::iterator it3 = this->m_nodes.begin(); - for (; it3 != this->m_nodes.end(); ++it3) - if (child == *it3) - { - this->m_nodes.erase(it3); - break; - } //if - } //if - } //if - return *(new AirwaysTree()); -} - -void AirwaysTree::MarkLevels(const int& level, Node* currentNode) -{ - if (currentNode == NULL) - currentNode = this->m_root; - if (currentNode->GetLevel() <= level) - { - currentNode->Mark(); - vec_nodes::const_iterator it = currentNode->GetChildren().begin(); - for (; it != currentNode->GetChildren().end(); it++) - this->MarkLevels(level, *it); - } //if -} - -bool AirwaysTree::IsEmpty() const -{ - return this->m_root == NULL; -} - -bool AirwaysTree::IsNodeInsidePath(unsigned int idNode_starting, unsigned int idNode_ending, unsigned int idNode_searched) -{ - // Check if the starting point exist - Node* node_starting = this->m_root->GetNodeById(idNode_starting); - if(!node_starting) - return false; - - // Check if the searched node exist in the subtree of the starting node - Node* node_searched = node_starting->GetNodeById(idNode_searched); - if(!node_searched) - return false; - - // Check if the ending node exist in the subtree of the searched node - if(!node_searched->HasNodeId(idNode_ending)) - return false; - - // If all conditions were true then the node is in the path - return true; -} - -void AirwaysTree::SetRoot(Node* root) -{ - this->m_root = root; - this->m_root->SetLevel(0); - this->m_nodes.push_back(this->m_root); -} - -void AirwaysTree::SetImageName(const std::string& img_name) -{ - this->m_img_name = img_name; -} - -void AirwaysTree::SetResultPath(const std::string& folderPath) -{ - this->m_result_path = folderPath; -} - -bool AirwaysTree::Insert(Edge* edge) -{ - if (this->m_root == NULL) - return false; - // Search if the source or target coordinates exist in the tree - Node* source = this->GetNode(edge->m_source->GetCoords()); - Node* target = this->GetNode(edge->m_target->GetCoords()); - - // If the source and the target coordinates do not exist then the - // edge can not be added, also if both exist in the tree. - if ( ( source == NULL && target == NULL ) || ( source != NULL && target != NULL) ) - return false; - else if (source == NULL && target != NULL) // If target was found - { - // Change the direction of the edge - edge->m_target = edge->m_source; - edge->m_source = target; - } - else - edge->m_source = source; - - // Set the target and source nodes for the Edge - edge->m_target->SetEdge(edge); - edge->m_target->SetLevel(edge->m_source->GetLevel() + 1); - edge->m_source->AddChild(edge->m_target); - - - // Add the new child node - this->m_nodes.push_back(edge->m_target); - this->m_edges.push_back(edge); - - // Set the id node - edge->m_target->SetId(this->m_nodes.size()); - return true; -} - -void AirwaysTree::UnMarkAll(Node* currentNode) -{ - if (currentNode == NULL) - currentNode = this->m_root; - currentNode->UnMark(); - - vec_nodes::const_iterator it = currentNode->GetChildren().begin(); - for (; it != currentNode->GetChildren().end(); ++it) - this->UnMarkAll(*it); -} - -void AirwaysTree::UpdateLevels(unsigned int levels) -{ - this->m_root->UpdateLevels(levels); -} - -void AirwaysTree::CompareTreesOrkiszMorales(AirwaysTree& treeB, unsigned int Q, unsigned int F, vec_nodes& commonA, vec_nodes& commonB, vec_nodes& nonCommonA, vec_nodes& nonCommonB, std::map< unsigned int, std::vector >& map_A_to_B, std::map< unsigned int, std::vector >& map_B_to_A, std::vector< std::pair< std::pair, std::pair > >& vector_pair_edges_A_to_B) -{ - // Algorithm - // The algorithm is recursive it is implemented the node class. The idea is to overlap the initial nodes of the subtrees - // and find the best branch correspondence for the first level of the trees. - // Hypothesis: It is supposed that the roots of the trees are common, so the algorithm does not run in the root nodes - // 1. Translate one of the subtree so that the initial nodes overlap. - // 2. While one of the trees has non-marked child - // 2.1 Compare each child to all the branches is the other tree. - // 2.2 Select the pair, child and branch in the other tree, that has the lowest distance function. - // 2.3 Add the pair and the distance to the final result. - // 2.4 Mark the nodes - // 2.5 Find and mark the omitted nodes in the similar branch. If the selected branch has more that 2 nodes it means that intemediary nodes do not have correpondece. - // 2.6 Run the process (First step) using the found pair of nodes. - - if( !this->IsEmpty() && !treeB.IsEmpty() ) - { - - // ---------------------------- - // ---- Pre-Matching steps ---- - - // Get the root nodes - Node* root_A = this->m_root; - Node* root_B = treeB.m_root; - - // Mark the roots - root_A->Mark(); - root_B->Mark(); - - // Add the root match - map_A_to_B[root_A->GetId()].push_back(root_B); - map_B_to_A[root_B->GetId()].push_back(root_A); - - // Add the root nodes match - pair_nodes pair_edgeA(root_A, root_A); - pair_nodes pair_edgeB(root_B, root_B); - std::pair< pair_nodes, pair_nodes > pairRoorNodes_edge(pair_edgeA, pair_edgeB); - vector_pair_edges_A_to_B.push_back(pairRoorNodes_edge); - - // ---------------------------- - // ----- Run the comparison---- - - root_A->CompareSubTreesOrkiszMorales(root_B, Q, F, commonA, commonB, nonCommonA, nonCommonB, map_A_to_B, map_B_to_A, vector_pair_edges_A_to_B); - - } - else - std::cout << "Trees are empties." << std::endl; -} - -void AirwaysTree::MarkPathFromNodeToNode(Node* node_begin, Node* node_end) -{ - if(this->m_root) - this->m_root->MarkPathFromNodeToNode(node_begin, node_end); -} - -void AirwaysTree::CompareTrees(AirwaysTree& treeB) -{ - // Compare all the "branches" (paths) in treeA with all branches in treeB - Vector_Pair_PairNodes_Score vectorPairNodesScore = this->CompareAllBranches(treeB); - - std::cout << "Vector pairs size:" << vectorPairNodesScore.size() << std::endl; - - // Algorithm to find the comment branches (paths) - // Until one of the trees is empty - // 1. Find the pair, with at least one leaf in the pair, with the lowest score - // 2. Compare the score of the father node of the leaf, or one of the leafs, with the correspondent pair leaf - // If the score is lower that the score of the actual pair - // - The compared leaf is not common. Mark the compared leaf, delete the compared leave and save the leaf as not common. - // If the score is greater - // - The leafs are common then mark both leafs as commons. Mark both leaves, delete them and save them as common leafs. - - // Variables - //AirwaysTree* tree_copyA = this->GetCopy(); - //AirwaysTree* tree_copyB = treeB.GetCopy(); - - //NodeVector nonCommonNodes_A; - //NodeVector commonNodes_A; - //NodeVector nonCommonNodes_B; - //NodeVector commonNodes_B; - - std::map nonCommonNodes_A; - std::map commonNodes_A; - std::map nonCommonNodes_B; - std::map commonNodes_B; - - // Until one of the trees is not empty - while( this->GetWeight() > 1 && treeB.GetWeight() > 1 ) - { - // Print the weight of the trees - std::cout << "Weight [A,B]: [" << this->GetWeight() << "," << treeB.GetWeight() << "]" << std::endl; - std::cout << "Leafs [A,B]: [" << this->GetNumberOfLeafs() << "," << treeB.GetNumberOfLeafs() << "]" << std::endl; - std::cout << "Vector pairs size:" << vectorPairNodesScore.size() << std::endl; - - - // 1. Find the pair, with at least one leaf in the pair, with the lowest score - Pair_PairNodes_Score pair_nonMarked = this->GetBestLeaf(vectorPairNodesScore); - Node* node_actualA = pair_nonMarked.first.first; - Node* node_actualB = pair_nonMarked.first.second; - double score_actual = pair_nonMarked.second; - - // 2. Take the leaf (L) and his father (F), the other node is called (O). Compare the score of the father node (F) with the correspondent pair leaf (O). - if(node_actualA->IsLeaf()) - { - //const Edge* edgeActual = node_actualA->GetEdge(); - //Node* targetActual = edgeActual->GetTarget(); - //const unsigned int id_father = targetActual->GetId(); - //double score_fatherA_to_B = this->GetPairNodes_Score(vectorPairNodesScore, 0, node_actualB->GetId()); - double score_fatherA_to_B = this->GetPairNodes_Score(vectorPairNodesScore, node_actualA->GetEdge()->GetTarget()->GetId(), node_actualB->GetId()); - //double score_fatherA_to_B = pair_fatherA_to_B.second; - // If the score is lower than the score of the actual pair - if(score_fatherA_to_B < score_actual) - { - //- The compared leaf is not common. Mark the compared leaf, delete the compared leave and save the leaf as not common. - node_actualA->Mark(); - std::map::iterator it; - it=nonCommonNodes_A.find(node_actualA->GetId()); - if(it==nonCommonNodes_A.end()) - nonCommonNodes_A[node_actualA->GetId()] = node_actualA; - //nonCommonNodes_A.push_back(node_actualA); - } - // If the score is greater - else - { - // - The leafs are common then mark both leafs as commons. Mark both leaves, delete them and save them as common leafs. - node_actualA->Mark(); - node_actualB->Mark(); - - std::map::iterator it; - it=commonNodes_B.find(node_actualB->GetId()); - if(it==commonNodes_B.end()) - commonNodes_B[node_actualB->GetId()] = node_actualB; - - it=commonNodes_A.find(node_actualA->GetId()); - if(it==commonNodes_A.end()) - { - std::cout << "CommonNode A:" << node_actualA->GetId() << std::endl; - commonNodes_A[node_actualA->GetId()] = node_actualA; - } - - //commonNodes_B.push_back(node_actualB); - //commonNodes_A.push_back(node_actualA); - } - this->DeleteNodeById(node_actualA->GetId()); - this->DeleteEntriesByIdNode(vectorPairNodesScore, 0, node_actualA->GetId()); - } - else - { - double score_fatherB_to_A = this->GetPairNodes_Score(vectorPairNodesScore, node_actualA->GetId(), node_actualB->GetEdge()->GetTarget()->GetId()); - //double score_fatherB_to_A = pair_fatherB_to_A.second; - // If the score is lower that the score of the actual pair - if(score_fatherB_to_A < score_actual) - { - //- The compared leaf is not common. Mark the compared leaf, delete the compared leave and save the leaf as not common. - node_actualB->Mark(); - std::map::iterator it; - it=nonCommonNodes_B.find(node_actualB->GetId()); - if(it==nonCommonNodes_B.end()) - nonCommonNodes_B[node_actualB->GetId()] = node_actualB; - //nonCommonNodes_B.push_back(node_actualB); - } - // If the score is greater - else - { - // - The leafs are common then mark both leafs as commons. Mark both leaves, delete them and save them as common leafs. - node_actualA->Mark(); - node_actualB->Mark(); - //commonNodes_B.push_back(node_actualB); - //commonNodes_A.push_back(node_actualA); - - std::map::iterator it; - it=commonNodes_B.find(node_actualB->GetId()); - if(it==commonNodes_B.end()) - commonNodes_B[node_actualB->GetId()] = node_actualB; - - it=commonNodes_A.find(node_actualA->GetId()); - if(it==commonNodes_A.end()) - commonNodes_A[node_actualA->GetId()] = node_actualA; - } - treeB.DeleteNodeById(node_actualB->GetId()); - this->DeleteEntriesByIdNode(vectorPairNodesScore, 1, node_actualB->GetId()); - } - } - - // Print the results - std::cout << "Non-CommonNodes [A,B]" << nonCommonNodes_A.size() << ", " << nonCommonNodes_B.size() << std::endl; - std::cout << "CommonNodes [A,B]" << commonNodes_A.size() << ", " << commonNodes_B.size() << std::endl; - - // Get the branches with the lowest difference - /*bool first = true; - double lowestValue = 0; - Pair_Node_Node bestPairNodes; - int iteration = 1; - for(Vector_Pair_PairNodes_Score::iterator it = vectorPairNodesScore.begin(); it != vectorPairNodesScore.end(); ++it ) - { - if(first) - { - lowestValue = (*it).second; - bestPairNodes = (*it).first; - first = false; - } - else if( (*it).second < lowestValue ) - { - lowestValue = (*it).second; - bestPairNodes = (*it).first; - } - } - - // Print the best pair of nodes - if(vectorPairNodesScore.size() > 0) - std::cout << "Best pair: Node A:" << (bestPairNodes).first->GetId() << ", Node B:" << (bestPairNodes).second->GetId() << std::endl; - */ - - /*// AMP - This code was commented after a meeting with Leonardo Florez - // We make the hypothesis that both roots are equal and - // that the root has only one child. - // The comparison of two branches implies the alignment - // of the mother branches and then the comparison of the - // daughters branches using intrinsic characteristics of - // each branch and a distance function between both. - - if (this->IsEmpty() || treeB.IsEmpty()) - { - std::cout << "One or both airways are empty." << std::endl; - return; - } - - Edge actualRootEdge = this->m_root->GetEdge(); - Edge comparedRootEdge = treeB.m_root->GetEdge(); - - // By the hypothesis, both root edges are similar. So we have to compared - // the edged of the root edges. - actualRootEdge.compareChildEdges(comparedRootEdge); - */ -} - -Pair_PairNodes_Score AirwaysTree::GetBestLeaf(Vector_Pair_PairNodes_Score vectorPairNodesScore) -{ - // Variables - Pair_PairNodes_Score pairNodesScore_final; - bool first = true; - - for(Vector_Pair_PairNodes_Score::iterator it = vectorPairNodesScore.begin(); it != vectorPairNodesScore.end(); ++it) - { - // Check that one of the node is a leaf - pair_nodes pair_actual = (*it).first; - Node* a = pair_actual.first; - Node* b = pair_actual.second; - if( a->IsLeaf() || b->IsLeaf() ) - { - if(first) - { - first = false; - pairNodesScore_final = (*it); - } - else if((*it).second < pairNodesScore_final.second) - { - pairNodesScore_final = (*it); - } - } - } - - if(first) - std::cout << "Best leaf not found" << std::endl; - - return pairNodesScore_final; -} - -double AirwaysTree::GetPairNodes_Score(Vector_Pair_PairNodes_Score vectorPairNodesScore, const unsigned int idA, const unsigned int idB) -{ - bool found = false; - double score = -1; - - for(Vector_Pair_PairNodes_Score::iterator it = vectorPairNodesScore.begin(); it != vectorPairNodesScore.end(); ++it) - { - // Check that one of the node is a leaf - pair_nodes pair_actual = (*it).first; - Node* a = pair_actual.first; - Node* b = pair_actual.second; - if( a->GetId() == idA && b->GetId() == idB ) - { - found = true; - score = (*it).second; - } - } - - if(!found) - std::cout << "Pair of Ids not found: " << idA << ", " << idB << std::endl; - - return score; -} - -bool AirwaysTree::DeleteNodeById(unsigned int nId) -{ - bool deleted = false; - if(m_root->GetId() == nId) - { - delete(m_root); - m_root = NULL; - return true; - } - - return this->m_root->DeleteNodeById(nId); -} - -unsigned int AirwaysTree::DeleteEntriesByIdNode(Vector_Pair_PairNodes_Score& vectorPairNodesScore, unsigned int component, unsigned int nId) -{ - unsigned int pairs_deleted = 0; - - Vector_Pair_PairNodes_Score::iterator it = vectorPairNodesScore.begin(); - while(it != vectorPairNodesScore.end()) - { - // Check that one of the node is a leaf - pair_nodes pair_actual = (*it).first; - unsigned int id_actual = -1; - if(component == 0) - id_actual = pair_actual.first->GetId(); - else - id_actual = pair_actual.second->GetId(); - - if( id_actual == nId) - { - it = vectorPairNodesScore.erase(it); - ++pairs_deleted; - } - else - ++it; - } - - std::cout << "Pairs deleted: " << pairs_deleted << std::endl; - - return pairs_deleted; -} - -AirwaysTree* AirwaysTree::GetCopy() -{ - return NULL; -} - -Vector_Pair_PairNodes_Score AirwaysTree::CompareAllBranches(AirwaysTree& treeB) -{ - std::cout << "Compare all branches ..." << std::endl; - // Variables - int nodesA = this->m_nodes.size(); - int nodesB = treeB.m_nodes.size(); - - Vector_Pair_PairNodes_Score vectorPairNodesScore; - - // For all the actual branches ( nodes different from the root) - for(unsigned int idA = 2; idA <= nodesA; ++idA) - { - // Get the actual branch in A - Edge* branchA = this->GetComposedEdge(idA); - - //Get the final actual node in A - Node* node_actualA = this->GetNodeById(idA); - - std::cout << "IdA: " << idA << std::endl; - - // For all the branches in B tree - for(unsigned int idB = 2; idB <= nodesB; ++idB) - { - // Get the actual branch in B - Edge* branchB = treeB.GetComposedEdge(idB); - - //Get the final actual node in B - Node* node_actualB = treeB.GetNodeById(idB); - - // Get the score from A to B and from B to A - double scoreA2B = branchA->CompareWith(branchB); - double scoreB2A = branchB->CompareWith(branchA); - - // Get the final score - // Options: - // A. Maximum score - //double score = scoreB2A > scoreA2B ? scoreB2A : scoreA2B ; - - // B. Sum of scores - double score = scoreB2A + scoreA2B; - - // Build the pair of nodes - pair_nodes actualPairNodes(node_actualA, node_actualB); - - Pair_PairNodes_Score actualPairNodesScore(actualPairNodes, score); - vectorPairNodesScore.push_back(actualPairNodesScore); - - //std::cout << "IdA: " << idA << ", IdB: " << idB << ", score: " << score << ", ... OK" << std::endl; - delete(branchB); - } - delete(branchA); - } - - std::cout << "Compare all branches ... OK" << std::endl; - return vectorPairNodesScore; -} - -Edge* AirwaysTree::GetComposedEdge(unsigned int idNode) -{ - return this->m_root->GetComposedEdge(idNode); -} - -AirwaysTree* AirwaysTree::GetSingleDetachedTreeNodeById(unsigned int nId) -{ - AirwaysTree* tree_detached = NULL; - Node* node_searched = this->GetNodeById(nId); - if(node_searched) - { - Node* node_root_detached = node_searched->GetDetachedRootCopy(); - tree_detached = new AirwaysTree(); - tree_detached->m_root = node_root_detached; - } - else - std::cout << "Node not found" << std::endl; - return tree_detached; -} - -void AirwaysTree::SubIsomorphism(AirwaysTree& treeB) -{ - if (this->IsEmpty() || treeB.IsEmpty()) - return; - //Marking the root node - this->m_root->Mark(); - treeB.m_root->Mark(); - - //iterating children - first step - vec_nodes::const_iterator it = this->m_root->GetChildren().begin(); - for (; it != this->m_root->GetChildren().end(); ++it) - { - unsigned int totalCost = 0; - Node* currentB = NULL; - Node* currentA = *it; - if (currentA->IsMarked()) - continue; - vec_nodes::const_iterator it2 = treeB.m_root->GetChildren().begin(); - for (; it2 != treeB.m_root->GetChildren().end(); ++it2) - { - if ((*it2)->IsMarked()) - continue; - unsigned int currentCost = (*it)->GetCost(*it2); - if (totalCost < currentCost) - { - currentB = *it2; - totalCost = currentCost; - } //if - } //for - if (currentB != NULL) - if (*currentA == *currentB) - this->GetSubTreeByDetachingNode(currentA).SubIsomorphism( - treeB.GetSubTreeByDetachingNode(currentB)); - } //for - //end of first step - //second step - it = this->m_root->GetChildren().begin(); - for (; it != this->m_root->GetChildren().end(); ++it) - { - if ((*it)->IsMarked()) - continue; - vec_nodes::const_iterator it2 = treeB.m_root->GetChildren().begin(); - for (; it2 != treeB.m_root->GetChildren().end(); ++it2) - { - Node* currentB = *it2; - Node* currentA = *it; - if (*currentB > *currentA) - continue; - if (currentA->FindSimilarEdgeByAccumulation(currentB)) - { - AirwaysTree subTreeA = this->GetSubTreeByDetachingNode( - currentA); - AirwaysTree subTreeB = treeB.GetSubTreeByDetachingNode( - currentB); - subTreeB.UpdateLevels((*it2)->GetLevel()); - subTreeA.SubIsomorphism(subTreeB); - treeB.m_root->UpdateLevels(treeB.m_root->GetLevel()); - currentA->Mark(); - if (!(*it2)->MarkPath(currentB)) - std::cout << "Error finding path" << std::endl; - break; - } //if - } //for - } //for - vec_nodes::const_iterator it2 = treeB.m_root->GetChildren().begin(); - for (; it2 != treeB.m_root->GetChildren().end(); ++it2) - { - if ((*it2)->IsMarked()) - continue; - it = this->m_root->GetChildren().begin(); - for (; it != this->m_root->GetChildren().end(); ++it) - { - Node* currentB = *it2; - Node* currentA = *it; - if (*currentA > *currentB) - continue; - if (currentB->FindSimilarEdgeByAccumulation(currentA)) - { - AirwaysTree subTreeA = this->GetSubTreeByDetachingNode( - currentA); - AirwaysTree subTreeB = treeB.GetSubTreeByDetachingNode( - currentB); - subTreeA.UpdateLevels((*it)->GetLevel()); - subTreeA.SubIsomorphism(subTreeB); - this->m_root->UpdateLevels(this->m_root->GetLevel()); - currentB->Mark(); - if (!(*it)->MarkPath(currentA)) - std::cout << "Error finding path" << std::endl; - break; - } //if - } //for - } - //End of second step -} - -bool AirwaysTree::Isomorphism(AirwaysTree& tree) -{ - if ((this->GetWeight() != tree.GetWeight()) - || (this->GetHeight() != tree.GetHeight())) - return false; - return this->m_root->CompareNodes(tree.m_root); -} - -void AirwaysTree::ImageReconstructionFromNode(TInputImage::Pointer& result, Node* node, bool skeleton) -{ - if (node == NULL) - return; - //Finding the center of the sphere - const Edge* edge = node->GetEdge(); - if (edge == NULL) - return; - //making a copy of the current image - TInputImage::Pointer copy; - DuplicatorType::Pointer duplicator = DuplicatorType::New(); - if (skeleton) - duplicator->SetInputImage(this->m_skeleton); - else - duplicator->SetInputImage(this->m_img); - duplicator->Update(); - copy = duplicator->GetOutput(); - //First remove the node brothers -- the following code in a way does not - // make sense but I'll just comment it if it is necessary - /*Node* parent = edge->m_source; - NodeVector::iterator pIt = parent->m_children.begin(); - for (; pIt != parent->m_children.end(); ++pIt) - if ((*pIt) != node) - this->RemoveBranchFromImage(copy, node); - //end of brother removal*/ - pair_posVox_rad center; - vec_pair_posVox_rad::const_iterator it = edge->m_vec_pair_posVox_rad.begin(); - for (; it != edge->m_vec_pair_posVox_rad.end(); ++it) - if (edge->m_source->GetCoords() == (*it).first) - center = *it; - //converting to index - TInputImage::PointType point; - point[0] = center.first[0]; - point[1] = center.first[1]; - point[2] = center.first[2]; - TInputImage::IndexType indCenter; - if (skeleton) - this->m_skeleton->TransformPhysicalPointToIndex(point, indCenter); - else - this->m_img->TransformPhysicalPointToIndex(point, indCenter); - //creating itk sphere - SphereType::Pointer sphere = SphereType::New(); - sphere->SetRadius(center.second * 4); - SphereType::InputType sphereCenter; - sphereCenter[0] = indCenter[0]; - sphereCenter[1] = indCenter[1]; - sphereCenter[2] = indCenter[2]; - sphere->SetCenter(sphereCenter); - - //testing code - // std::cout<<"center = "<< indCenter << std::endl; - //std::cout << "Radio = " << center.second << std::endl; - TInputImage::SizeType regionSize; - regionSize[0] = 8 * center.second; - regionSize[1] = 8 * center.second; - regionSize[2] = 8 * center.second; - //std::cout << "RegionSize = " << regionSize << std::endl; - - TInputImage::IndexType regionIndex; - regionIndex[0] = indCenter[0] - center.second * 4; - regionIndex[1] = indCenter[1] - center.second * 4; - regionIndex[2] = indCenter[2] - center.second * 4; - // std::cout << "regionIndex = " << regionIndex << std::endl; - - TInputImage::RegionType region; - region.SetSize(regionSize); - region.SetIndex(regionIndex); - RegionIterator it2(copy, region); - while (!it2.IsAtEnd()) - { - TInputImage::IndexType ind = it2.GetIndex(); - SphereType::InputType point; - point[0] = ind[0]; - point[1] = ind[1]; - point[2] = ind[2]; - SphereType::OutputType output = sphere->Evaluate(point); - if (output) - it2.Set(0); - ++it2; - } - - /* - * First region growing - Segmenting the wanted branch to be removed - * Removing the branch from the image - */ - if (!ComputeSimpleRegionGrowing(copy, this->m_root->GetCoords())) - return; - SubtractImageFilterType::Pointer subtractFilter = - SubtractImageFilterType::New(); - if (skeleton) - subtractFilter->SetInput1(this->m_skeleton); - else - subtractFilter->SetInput1(this->m_img); - subtractFilter->SetInput2(copy); - subtractFilter->Update(); - TInputImage::Pointer diff = subtractFilter->GetOutput(); - /* - * Second region growing - Cleaning the resulting image - */ - Node* leaf = this->GetLeaf(node); - if (ComputeSimpleRegionGrowing(diff, leaf->GetCoords())) - result = diff; - else - std::cout << "problemas" << std::endl; - //cin.ignore().get(); //Pause Command for Linux Terminal - -} - -void AirwaysTree::ImageReconstruction(TInputImage::Pointer& result, bool skeleton, Node* node) -{ - if (node == NULL) - { - DuplicatorType::Pointer duplicator = DuplicatorType::New(); - if (skeleton) - duplicator->SetInputImage(this->m_skeleton); - else - duplicator->SetInputImage(this->m_img); - duplicator->Update(); - result = duplicator->GetOutput(); - node = this->m_root; - } //if - if (!node->IsMarked()) - { - this->RemoveBranchFromImage(result, node); - return; - } - vec_nodes::const_iterator it = node->GetChildren().begin(); - for (; it != node->GetChildren().end(); ++it) - this->ImageReconstruction(result, skeleton, *it); - -} - -void AirwaysTree::ImageReconstructionBySpheres(TInputImage::Pointer& result, Node* node, bool useMarks) -{ - if (node == NULL) - { - node = this->m_root; - DuplicatorType::Pointer duplicator = DuplicatorType::New(); - duplicator->SetInputImage(m_img); - duplicator->Update(); - result = duplicator->GetOutput(); - //Removing white pixels -- cleaning image - TInputImage::RegionType lRegion = result->GetLargestPossibleRegion(); - RegionIterator it(result, lRegion); - while (!it.IsAtEnd()) - { - it.Set(0); - ++it; - } //while - } //if - if (node->IsMarked() || !useMarks) - { - this->CreateSpheres(result, node); - vec_nodes::const_iterator it = node->GetChildren().begin(); - for (; it != node->GetChildren().end(); ++it) - this->ImageReconstructionBySpheres(result, *it); - } //if -} - -Node* AirwaysTree::GetNode(const Vec3 nodeCoords, Node* current) -{ - if (current == NULL) - current = this->m_root; - if (current->GetCoords() == nodeCoords) - return current; - vec_nodes::const_iterator it = current->GetChildren().begin(); - for (; it != current->GetChildren().end(); ++it) - { - Node* child = GetNode(nodeCoords, *it); - if (child != NULL) - return child; - } //rof - return NULL; -} - -Node* AirwaysTree::GetLeaf(Node* current) -{ - if (current == NULL) - current = this->m_root; - if (current->IsLeaf()) - return current; - vec_nodes::const_iterator it = current->GetChildren().begin(); - Node* node = NULL; - unsigned int maxHeight = 0; - for (; it != current->GetChildren().end(); ++it) - { - unsigned int cHeight = this->GetHeight(*it); - if (maxHeight <= cHeight) - { - maxHeight = cHeight; - node = *it; - } //if - } //for - if (node != NULL) - return this->GetLeaf(node); - return NULL; -} - -void AirwaysTree::UpdateEdges(Node* node) -{ - if (node == NULL) - node = this->m_root; - - if (node->GetEdge() != NULL) - { - Edge* edge = node->GetEdge(); - //edge->m_skInfoPairVector = this->GetSkeletonInfoFromEdge(edge->m_source->GetCoords(), edge->m_target->GetCoords()); - edge->SetSkeletonPairVector( this->GetSkeletonInfoFromEdge(edge->m_source->GetCoords(), edge->m_target->GetCoords()) ); - node->GetEdge()->UpdateEdgeInfo(); - } - vec_nodes::const_iterator it = node->GetChildren().begin(); - for (; it != node->GetChildren().end(); ++it) - this->UpdateEdges(*it); -} - -AirwaysTree& AirwaysTree::GetSubTreeByDetachingNode(Node* node) -{ - AirwaysTree* tree = new AirwaysTree(); - tree->m_root = node; - return *tree; -} - -DiGraph_EdgePair AirwaysTree::AddBoostEdge(const pair_posVox_rad& source, const pair_posVox_rad& target, DiGraph& graph) -{ - bool vFound[2] = { false, false }; - DiGraph_VertexDescriptor vDescriptor[2]; - - //Remember that DiGraph_VertexIteratorPair, first = begin, second = end - DiGraph_VertexIndexMap index = get(boost::vertex_index, graph); - - //Search the vertex in the graph - for (DiGraph_VertexIteratorPair vPair = boost::vertices(graph); vPair.first != vPair.second && (!vFound[0] || !vFound[1]); ++vPair.first) - { - // Get the current information [vector, intensity] - pair_posVox_rad current = graph[index[*vPair.first]]; - - // Check if current is equal to the source or target vertex - if (current.first == source.first) - { - vDescriptor[0] = index[*vPair.first]; - vFound[0] = true; - } //if - else if (current.first == target.first) - { - vDescriptor[1] = index[*vPair.first]; - vFound[1] = true; - } //if - } //for - - // If one of the vertices is not in the graph, adds the new vertex - - // Add the vertices if they are not in the graph - if (!vFound[0]) - vDescriptor[0] = boost::add_vertex(source, graph); - if (!vFound[1]) - vDescriptor[1] = boost::add_vertex(target, graph); - - // Check if the edge exist in the graph - // boost::edge returns the pair, with bool=true is the edge exists - DiGraph_EdgePair edgeC1 = boost::edge(vDescriptor[0], vDescriptor[1],graph); - DiGraph_EdgePair edgeC2 = boost::edge(vDescriptor[1], vDescriptor[0],graph); - - // If the edge does not exist, then add it - if (!edgeC1.second && !edgeC2.second) - { - DiGraph_EdgePair nEdge = boost::add_edge(vDescriptor[0], vDescriptor[1], graph); - return nEdge; - } //if - - // If an edge has not been added then -> second = false - // Remove the added vertices because the edge already exists. - if (!vFound[0]) - boost::remove_vertex(vDescriptor[0], graph); - - if (!vFound[1]) - boost::remove_vertex(vDescriptor[1], graph); - - edgeC1.second = false; - edgeC1.second = false; - - return edgeC1; -} - -bool AirwaysTree::FindNeighborhood(DiGraph& graph, Vec3Queue& queue, Vec3List& used, const Vec3& end, ConstNeighborhoodIterator& iterator) -{ - if (queue.empty()) - return false; - - // Get the next pixel in the queue - Vec3 current = queue.front(); - - // Put the pixel in the used list - used.push_back(current); - - // Delete next pixel from the queu - queue.pop(); - - //AMP//iterator.GoToBegin(); - //AMP//while (!iterator.IsAtEnd()) - //AMP//{ - - // AMP commented - /*unsigned int centerIndex = iterator.GetCenterNeighborhoodIndex(); - TInputImage::IndexType index = iterator.GetIndex(centerIndex); - SKPairInfo src(Vec3(index[0], index[1], index[2]), - iterator.GetPixel(iterator.GetCenterNeighborhoodIndex())); - if (src.first != current) - { - ++iterator; - continue; - } //if - */ - //PMA commented - - // AMP - - // Set the current index to the actual pixel - TInputImage::IndexType indexActual; - indexActual[0] = current[0]; - indexActual[1] = current[1]; - indexActual[2] = current[2]; - - // Place the iterator in the actual index - iterator.SetLocation(indexActual); - - // Create the pair [vector, intensity] for the actual index - pair_posVox_rad src(current, iterator.GetPixel(iterator.GetCenterNeighborhoodIndex())); - - // PMA - - // Iterate over the neighbors - for (unsigned int i = 0; i < iterator.Size(); i++) - { - //AMP//if (iterator.GetPixel(i) != 0 && i != centerIndex) - - // If the intensity is not zero and it's the center - if (iterator.GetPixel(i) != 0 && i != iterator.GetCenterNeighborhoodIndex()) - { - // Get the index of the iterator - TInputImage::IndexType ind = iterator.GetIndex(i); - - // Create the target pair [vector, intensity] for the target - pair_posVox_rad target(Vec3(ind[0], ind[1], ind[2]), iterator.GetPixel(i)); - - // Add the edge to the graph - bool added = AddBoostEdge(src, target, graph).second; - - // If it could not be added then it is because it already exist, then go to next neighboor - if (!added) - continue; - - // The edge was added. Stop the adding process if the target vertex was reached. - if (target.first == end) - return true; - - // If it the edge was added and it is not the target then add it to the queue, if and only if - // it was not already used. - if (std::find(used.begin(), used.end(), target.first)== used.end()) - queue.push(target.first); - }//if - }//for - //AMP//break; - //AMP//} //while - return false; -} - -DiGraph AirwaysTree::GetGraphShortestPath(const DiGraph& graph, const Vec3& begin, const Vec3& end) -{ - // Variables - DiGraph ret; // Returning graph with the shortest path - DiGraph_EdgeIterator ei, eo; // Initial and final iterators - - // Iterate over the edges of the graph - boost::tie(ei, eo) = boost::edges(graph); - for (; ei != eo; ++ei) - { - // Get the source of the actual edge - pair_posVox_rad src = graph[boost::source(*ei, graph)]; - - // If the source corresponds to the begin pixel - if (src.first == begin) - { - // Get the target of the actual edge - pair_posVox_rad target = graph[boost::target(*ei, graph)]; - - // If the actual target corresponds to the end pixel - if (target.first == end) - { - // Add the edge to the final path - AddBoostEdge(src, target, ret); - - //AMP - std::cout << "Add final target [src]-[ target]:[" << src.first << "]-[" << target.first << "], numVertices:" << boost::num_vertices(ret) << std::endl; - //PMA - - // Return the path - return ret; - } - - // If the actual target does not correspond to the end pixel, then add it to the returning path - // and run the shortest path with the target of the actual edge. - ret = GetGraphShortestPath(graph, target.first, end); - - // If the path is empty then the iteration continues - if (boost::num_vertices(ret) == 0) - continue; - - // if not return ret + new edge - // If the path was found then add the actual edge and return the path - AddBoostEdge(src, target, ret); - //AMP - //std::cout << "Add found edge [src]-[ target]:[" << src.first << "]-[" << target.first << "], numVertices:" << boost::num_vertices(ret) << std::endl; - //PMA - return ret; - - }//fi - } - return ret; -} - -vec_pair_posVox_rad AirwaysTree::GetGraphShortestPath_AMP(const DiGraph& graph, const Vec3& begin, const Vec3& end) -{ - //std::cout << "SKPairInfoVector AirwaysTree::GetGraphShortestPath_AMP(const DiGraph& graph, const Vec3& begin, const Vec3& end)" << std::endl; - // Variables - vec_pair_posVox_rad path; - DiGraph ret; // Returning graph with the shortest path - DiGraph_EdgeIterator ei, eo; // Initial and final iterators - - // Iterate over the edges of the graph - boost::tie(ei, eo) = boost::edges(graph); - for (; ei != eo; ++ei) - { - // Get the source of the actual edge - pair_posVox_rad src = graph[boost::source(*ei, graph)]; - - // If the source corresponds to the begin pixel - if (src.first == begin) - { - // Get the target of the actual edge - pair_posVox_rad target = graph[boost::target(*ei, graph)]; - - // If the actual target corresponds to the end pixel - if (target.first == end) - { - // Add the edge to the final path - AddBoostEdge(src, target, ret); - path.push_back(target); - path.push_back(src); - - //AMP - //std::cout << "Add final target [src]-[ target]:[" << src.first << "]-[" << target.first << "], numVertices:" << boost::num_vertices(ret) << ", path_size:" << path.size() << std::endl; - //PMA - - // Return the path - //std::cout << "SKPairInfoVector AirwaysTree::GetGraphShortestPath_AMP(const DiGraph& graph, const Vec3& begin, const Vec3& end) ... FIRST ... OK" << std::endl; - return path; - } - - //std::cout << "Not yet in the target voxel" << std::endl; - // If the actual target does not correspond to the end pixel, then add it to the returning path - // and run the shortest path with the target of the actual edge. - path = GetGraphShortestPath_AMP(graph, target.first, end); - //std::cout << "Path found, path size:" << path.size() << std::endl; - - // If the path is empty then the iteration continues - if (path.size() == 0) - continue; - - // if not return ret + new edge - // If the path was found then add the actual edge and return the path - AddBoostEdge(src, target, ret); - path.push_back(src); - //AMP - //std::cout << "Add found edge [src]-[ target]:[" << src.first << "]-[" << target.first << "], numVertices:" << boost::num_vertices(ret) << ", path_size:" << path.size() << std::endl; - //PMA - //std::cout << "SKPairInfoVector AirwaysTree::GetGraphShortestPath_AMP(const DiGraph& graph, const Vec3& begin, const Vec3& end) ... SECOND ... OK" << std::endl; - return path; - - }//fi - } - - //std::cout << "SKPairInfoVector AirwaysTree::GetGraphShortestPath_AMP(const DiGraph& graph, const Vec3& begin, const Vec3& end) ... END ... OK" << std::endl; - return path; -} - -vec_pair_posVox_rad AirwaysTree::GetSkeletonInfoFromEdge(const Vec3& source, const Vec3& target) -{ - //converting to pixel - TInputImage::PointType pointSource; - pointSource[0] = source[0]; - pointSource[1] = source[1]; - pointSource[2] = source[2]; - - TInputImage::PointType pointTarget; - pointTarget[0] = target[0]; - pointTarget[1] = target[1]; - pointTarget[2] = target[2]; - - TInputImage::IndexType indexSource; - TInputImage::IndexType indexTarget; - - this->m_skeleton->TransformPhysicalPointToIndex(pointSource, indexSource); - this->m_skeleton->TransformPhysicalPointToIndex(pointTarget, indexTarget); - //end of conversion - - // AMP // Print the initial and final voxels to verify their positions - //std::cout << "Begin: [" << indexSource[0] << "," << indexSource[1] << "," << indexSource[2] << "] -- " << this->m_skeleton->GetPixel(indexSource) << std::endl; - //std::cout << "End: [" << indexTarget[0] << "," << indexTarget[1] << "," << indexTarget[2] << "] -- " << this->m_skeleton->GetPixel(indexTarget) << std::endl; - //std::cout << "BeginVoxel: [" << pointSource[0] << "," << pointSource[1] << "," << pointSource[2] << "]"<< std::endl; - //std::cout << "EndVoxel: [" << pointTarget[0] << "," << pointTarget[1] << "," << pointTarget[2] << "]" << std::endl; - // PMA // - - Vec3 sourcePxl(indexSource[0], indexSource[1], indexSource[2]); - Vec3 targetPxl(indexTarget[0], indexTarget[1], indexTarget[2]); - - // AMP // Commented - /* - // Compute the distance in each direction and add "21" in each one - float dstX = beginPxl.EculideanDistance( - Vec3(endPxl[0], beginPxl[1], beginPxl[2])) + 21; - float dstY = beginPxl.EculideanDistance( - Vec3(beginPxl[0], endPxl[1], beginPxl[2])) + 21; - float dstZ = beginPxl.EculideanDistance( - Vec3(beginPxl[0], beginPxl[1], endPxl[2])) + 21; - - //start point - TInputImage::IndexType index; - index[0] = beginPxl[0] < endPxl[0] ? beginPxl[0] : endPxl[0]; - index[1] = beginPxl[1] < endPxl[1] ? beginPxl[1] : endPxl[1]; - index[2] = beginPxl[2] < endPxl[2] ? beginPxl[2] : endPxl[2]; - - index[0] -= index[0] <= 10 ? 0 : 10; - index[1] -= index[1] <= 10 ? 0 : 10; - index[2] -= index[2] <= 10 ? 0 : 10; - - - //size of region - TInputImage::SizeType size; - size[0] = ceil(dstX); - size[1] = ceil(dstY); - size[2] = ceil(dstZ); - - TInputImage::RegionType region; - region.SetSize(size); - region.SetIndex(index); - - //ConstNeighborhoodIterator iterator(radius, this->m_skeleton, region); - // PMA // Commented - */ - - TInputImage::SizeType radius; - radius[0] = 1; - radius[1] = 1; - radius[2] = 1; - ConstNeighborhoodIterator iterator(radius, this->m_skeleton, this->m_skeleton->GetLargestPossibleRegion()); - - DiGraph graph; - Vec3Queue queue; - Vec3List used; - - // Set the first pixel as starting pixel - queue.push(sourcePxl); - - //FindNeighborhood(graph, queue, used, endPxl, iterator); - - // Add to the graph all the connected voxel until the ending pixel is found - bool endFound = false; - while (!queue.empty() && !endFound) - endFound = FindNeighborhood(graph, queue, used, targetPxl, iterator); - - if(!endFound) - std::cout << "***************** END NOT FOUND!!!!" << std::endl; - else - std::cout << "***************** END FOUND!!!! - Graph Vertices:" << boost::num_vertices(graph) << ", Graph Edges:" << boost::num_edges(graph) << std::endl; - - // Get the shortest path between the begin and end pixels - //std::cout << "GetGraphShortestPath [from]-[to]:[" << sourcePxl << "]-[" << targetPxl << "]" << std::endl; - //DiGraph result = GetGraphShortestPath(graph, sourcePxl, targetPxl); - vec_pair_posVox_rad path = GetGraphShortestPath_AMP(graph, sourcePxl, targetPxl); - //std::cout << "GetGraphShortestPath ... OK , numVertices:" << boost::num_vertices(result) << std::endl; - - //AMP - bool beginPixelFound = false; - bool endPixelFound = false; - vec_pair_posVox_rad vector; - - for(vec_pair_posVox_rad::reverse_iterator it_path = path.rbegin(); it_path != path.rend(); ++it_path) - { - TInputImage::IndexType ind; - ind[0] = (*it_path).first[0]; - ind[1] = (*it_path).first[1]; - ind[2] = (*it_path).first[2]; - //std::cout << "["<< (*it_path).first << "], "; - - // To avoid precision problems - if (indexSource == ind) - { - beginPixelFound = true; - (*it_path).first = source; - } - else if (indexTarget == ind) - { - endPixelFound = true; - (*it_path).first = target; - } - else - { - TInputImage::PointType pnt; - this->m_skeleton->TransformIndexToPhysicalPoint(ind, pnt); - (*it_path).first = Vec3(pnt[0], pnt[1], pnt[2]); - } - vector.push_back((*it_path)); - } - //vector = path; - //PMA - - // Variables to iterate over the shortest path and save the results - /*// AMP - DiGraph_VertexIterator i, e; - SKPairInfoVector vector; - - // Iterate over the shortest path and add each vertex in real coordinates - boost::tie(i, e) = boost::vertices(result); - std::cout << "Inserting ... [begin,end]: [" << begin << "], [" << end << "]" << std::endl; - for (; i != e; ++i) - //for (; e != i; --e) - { - // Get the actual vertex - SKPairInfo vertex = result[*i]; - //SKPairInfo vertex = result[*e]; - std::cout << "["<< vertex.first << "], "; - - // Get the index (voxel position) of the actual vertex - TInputImage::IndexType ind; - ind[0] = vertex.first[0]; - ind[1] = vertex.first[1]; - ind[2] = vertex.first[2]; - - // To avoid precision problems - if (indexBegin == ind) - { - beginPixelFound = true; - vertex.first = begin; - } - else if (indexEnd == ind) - { - endPixelFound = true; - vertex.first = end; - } - else - { - TInputImage::PointType pnt; - this->m_skeleton->TransformIndexToPhysicalPoint(ind, pnt); - vertex.first = Vec3(pnt[0], pnt[1], pnt[2]); - } - vector.push_back(vertex); - } - std::cout << "Inserting ... OK" << std::endl; - - - *///AMP - - - if(!beginPixelFound) - std::cout << "Begin not found: "<< source << std::endl; - if(!endPixelFound) - std::cout << "End not found:" << target << std::endl; - - return vector; -} - -bool AirwaysTree::ComputeSimpleRegionGrowing(TInputImage::Pointer& img, - const Vec3 seedPtn) -{ - TInputImage::PointType targetPtn; - targetPtn[0] = seedPtn[0]; - targetPtn[1] = seedPtn[1]; - targetPtn[2] = seedPtn[2]; - TInputImage::IndexType seed; - img->TransformPhysicalPointToIndex(targetPtn, seed); - if (img->GetPixel(seed) == 0) - { - //std::cout << "seed is 0" << std::endl; - return false; - } - ConnectedFilterType::Pointer neighborhoodConnected = - ConnectedFilterType::New(); - neighborhoodConnected->SetLower(1); - neighborhoodConnected->SetUpper(1); - neighborhoodConnected->SetReplaceValue(1); - neighborhoodConnected->SetSeed(seed); - neighborhoodConnected->SetInput(img); - neighborhoodConnected->Update(); - img = neighborhoodConnected->GetOutput(); - return true; -} - -void AirwaysTree::RemoveBranchFromImage(TInputImage::Pointer& img, Node* node) -{ - //typedef itk::ImageFileWriter WriterType; - //Finding the center of the sphere - const Edge* edge = node->GetEdge(); - if (edge == NULL) - return; - pair_posVox_rad center; - vec_pair_posVox_rad::const_iterator it = edge->m_vec_pair_posVox_rad.begin(); - for (; it != edge->m_vec_pair_posVox_rad.end(); ++it) - if (edge->m_source->GetCoords() == (*it).first) - center = *it; - //converting to index - TInputImage::PointType point; - point[0] = center.first[0]; - point[1] = center.first[1]; - point[2] = center.first[2]; - TInputImage::IndexType indCenter; - img->TransformPhysicalPointToIndex(point, indCenter); - double radius = center.second; - //creating itk sphere - SphereType::Pointer sphere = SphereType::New(); - SphereType::InputType sphereCenter; - sphereCenter[0] = indCenter[0]; - sphereCenter[1] = indCenter[1]; - sphereCenter[2] = indCenter[2]; - sphere->SetCenter(sphereCenter); - unsigned int objCount = 0; - unsigned int obj3Count = 0; // to assure 3 Connected obj - //Number of connected components, children_size + parent - unsigned int nCConnex = edge->m_source->GetNumberOfChildren() + 1; - TInputImage::Pointer copy; - //std::cout << "entró" << std::endl; - while (objCount < nCConnex || obj3Count <= nCConnex) - { - if (objCount >= 3) - obj3Count++; - radius += 1.0; - sphere->SetRadius(radius); - //making a copy of the current image - DuplicatorType::Pointer duplicator = DuplicatorType::New(); - duplicator->SetInputImage(img); - duplicator->Update(); - copy = duplicator->GetOutput(); - - //testing code - // std::cout<<"center = "<< indCenter << std::endl; - //std::cout << "Radio = " << center.second << std::endl; - TInputImage::SizeType regionSize; - regionSize[0] = 4 * radius; - regionSize[1] = 4 * radius; - regionSize[2] = 4 * radius; - //std::cout << "RegionSize = " << regionSize << std::endl; - TInputImage::SizeType size = img->GetLargestPossibleRegion().GetSize(); - TInputImage::IndexType regionIndex; - regionIndex[0] = indCenter[0] - (radius * 2); - if (regionIndex[0] < 0) - regionIndex[0] = indCenter[0]; - else if (regionIndex[0] > (unsigned int) size[0]) - regionIndex[0] = size[0]; - regionIndex[1] = indCenter[1] - (radius * 2); - if (regionIndex[1] < 0) - regionIndex[1] = indCenter[1]; - else if (regionIndex[1] > (unsigned int) size[1]) - regionIndex[1] = size[1]; - regionIndex[2] = indCenter[2] - (radius * 2); - if (regionIndex[2] < 0) - regionIndex[2] = indCenter[2]; - else if (regionIndex[2] > (unsigned int) size[2]) - regionIndex[2] = size[2]; - int diff[3]; - diff[0] = size[0] - (regionSize[0] + regionIndex[0]); - diff[1] = size[1] - (regionSize[1] + regionIndex[1]); - diff[2] = size[2] - (regionSize[2] + regionIndex[2]); - //std::cout << "(1) Region Index = " << regionIndex << std::endl; - //std::cout << "(1) Region size = " << regionSize << std::endl; - if (diff[0] < 0) - regionSize[0] = size[0] - regionIndex[0]; - if (diff[1] < 0) - regionSize[1] = size[1] - regionIndex[1]; - if (diff[2] < 0) - regionSize[2] = size[2] - regionIndex[2]; - // std::cout << "regionIndex = " << regionIndex << std::endl; - //std::cout << "(2) Region Index = " << regionIndex << std::endl; - //std::cout << "(2) Region size = " << regionSize << std::endl; - TInputImage::RegionType region; - region.SetSize(regionSize); - region.SetIndex(regionIndex); - RegionIterator it2(copy, region); - while (!it2.IsAtEnd()) - { - TInputImage::IndexType ind = it2.GetIndex(); - SphereType::InputType point; - point[0] = ind[0]; - point[1] = ind[1]; - point[2] = ind[2]; - SphereType::OutputType output = sphere->Evaluate(point); - if (output) - it2.Set(0); - ++it2; - } //while - if (node->IsLeaf()) - { - TInputImage::PointType ptn; - ptn[0] = node->GetCoords()[0]; - ptn[1] = node->GetCoords()[1]; - ptn[2] = node->GetCoords()[2]; - TInputImage::IndexType tgt; - img->TransformPhysicalPointToIndex(ptn, tgt); - if (img->GetPixel(tgt) == 0) - { - std::cout << "It entered here!!!!" << std::endl; - return; - } - } //if - CastFilterType::Pointer castFilter = CastFilterType::New(); - castFilter->SetInput(copy); - castFilter->Update(); - ConnectedComponentImageFilterType::Pointer connFilter = - ConnectedComponentImageFilterType::New(); - connFilter->SetFullyConnected(true); - connFilter->SetInput(castFilter->GetOutput()); - connFilter->Update(); - objCount = connFilter->GetObjectCount(); - //test - /*WriterType::Pointer writer = WriterType::New(); - writer->SetInput(copy); - writer->SetFileName("output_antes.mhd"); - writer->Update();*/ - } //while - //std::cout << "salio" << std::endl; - /* - * First region growing - Segmenting the wanted branch to be removed - * Removing the branch from the image - */ - Node* leaf = this->GetLeaf(node); - if (!ComputeSimpleRegionGrowing(copy, leaf->GetCoords())) - return; - SubtractImageFilterType::Pointer subtractFilter = - SubtractImageFilterType::New(); - subtractFilter->SetInput1(img); - subtractFilter->SetInput2(copy); - subtractFilter->Update(); - TInputImage::Pointer diff = subtractFilter->GetOutput(); - /* - * Second region growing - Cleaning the resulting image - */ - if (ComputeSimpleRegionGrowing(diff, this->m_root->GetCoords())) - img = diff; - /*else - std::cout << "problemas" << std::endl;*/ - //cin.ignore().get(); //Pause Command for Linux Terminal -} - -//Metodo obsoleto, ya no nos interesa la reconstruccion por esferas -void AirwaysTree::CreateSpheres(TInputImage::Pointer& img, Node* node) -{ - if (node->GetEdge() == NULL) - return; - const Edge* edge = node->GetEdge(); - vec_pair_posVox_rad::const_iterator it = edge->m_vec_pair_posVox_rad.begin(); - for (; it != edge->m_vec_pair_posVox_rad.end(); ++it) - { - //converting to index - TInputImage::PointType point; - point[0] = (*it).first[0]; - point[1] = (*it).first[1]; - point[2] = (*it).first[2]; - TInputImage::IndexType indexPoint; - img->TransformPhysicalPointToIndex(point, indexPoint); - //creating itk sphere - SphereType::Pointer sphere = SphereType::New(); - sphere->SetRadius((*it).second); - SphereType::InputType sphereCenter; - sphereCenter[0] = indexPoint[0]; - sphereCenter[1] = indexPoint[1]; - sphereCenter[2] = indexPoint[2]; - sphere->SetCenter(sphereCenter); - //creating region - TInputImage::SizeType regionSize; - regionSize[0] = 4 * (*it).second; - regionSize[1] = 4 * (*it).second; - regionSize[2] = 4 * (*it).second; - TInputImage::IndexType regionIndex; - regionIndex[0] = indexPoint[0] - 2 * ceil((*it).second); - regionIndex[1] = indexPoint[1] - 2 * ceil((*it).second); - regionIndex[2] = indexPoint[2] - 2 * ceil((*it).second); - TInputImage::RegionType region; - region.SetSize(regionSize); - region.SetIndex(regionIndex); - RegionIterator it2(img, region); - while (!it2.IsAtEnd()) - { - TInputImage::IndexType ind = it2.GetIndex(); - SphereType::InputType point; - point[0] = ind[0]; - point[1] = ind[1]; - point[2] = ind[2]; - SphereType::OutputType output = sphere->Evaluate(point); - if (output) - it2.Set(1); - ++it2; - } //while - } //for -} - -void AirwaysTree::printUpToLevel(int level) -{ - cout << "Printing up to level: " << level <m_root->printUpToLevel(level); - cout << "Printing done" <m_root->printNodeAndChildrenIds( ); - cout << "Printing nodes and children DONE" <= 2) - { - // Print header - cout << "Level" << " " << "SonPositionX" << " " << "SonPositionY" << " " << "SonPositionZ" << " " - "ParentVectorX" << " " << "ParentVectorY" << " " << "ParentVectorZ" << " " << - "ChildVectorX" << " " << "ChildVectorY" << " " << "ChildVectorZ"<< " " << - "Qr" << " " << "Qx" << " " << "Qy" " " << "Qz" " " << "Qtheta" << " " << - "Wx" << " " << "Wy" << " " << "Wz" << " " << - "EuclDistSonParent" << " " <<"EuclDistSonGrandson" << " " << - "RadMeanSonParent" << " " << "RadMeanSonGrandson" <m_root->createQuaternionsUpToLevel(level, level); - } - else - cout << "Quaternions must be created from level 2." <m_root->getStasticsBifurcations(p); - - cout << "Bifurcations:" << endl; - for(int i = 0; i < 6; i++) - { - cout << i+1 << "->" << p[i] << endl; - } - - cout << "Statistics bifurcations done " <SetRegions( region ); - imagePointer->SetSpacing( spacing ); - imagePointer->SetOrigin( origin ); - imagePointer->Allocate(); - - //this->m_root->saveToImage(_imagePointer); - vec_nodes nodes_children_root = this->m_root->GetChildren(); - vec_nodes::const_iterator it_children = nodes_children_root.begin(); - for( ; it_children != nodes_children_root.end(); ++it_children) - { - Vec3 coords_father = (*it_children)->GetEdge()->GetSource()->GetCoords(); - Vec3 coords_child = (*it_children)->GetCoords(); - drawLineInImage(coords_father, coords_child, imagePointer); - } - - cout << "Writing ..." << endl; - typedef itk::ImageFileWriter WriterType; - WriterType::Pointer writer = WriterType::New(); - writer->SetInput(imagePointer); - writer->SetFileName(filename); - writer->Update(); - cout << "Writing ... done" << endl; -} - -void AirwaysTree::drawLineInImage(Vec3 initVoxel, Vec3 endVoxel, TInputImage::Pointer imagePointer) -{ - TInputImage::RegionType region = imagePointer->GetLargestPossibleRegion(); - - TInputImage::SpacingType spacing = imagePointer->GetSpacing(); - - TInputImage::PointType origin = imagePointer->GetOrigin(); - - TInputImage::IndexType init; - init[0]=(initVoxel[0]-origin[0])/spacing[0]; - init[1]=(initVoxel[1]-origin[1])/spacing[1]; - init[2]=(initVoxel[2]-origin[2])/spacing[2]; - - TInputImage::IndexType end; - end[0]=(endVoxel[0]-origin[0])/spacing[0]; - end[1]=(endVoxel[1]-origin[1])/spacing[1]; - end[2]=(endVoxel[2]-origin[2])/spacing[2]; - - TPixel pixel; - pixel = 1; - - itk::LineIterator it(imagePointer, init, end); - it.GoToBegin(); - while (!it.IsAtEnd()) - { - it.Set(pixel); - ++it; - } -} - -//To store the graph in a vtk -void AirwaysTree::saveAirwayAsVTK(const std::string filename, bool common) -{ - vtkSmartPointer colors = vtkSmartPointer::New(); - colors->SetNumberOfComponents(3); - colors->SetName("Colors"); - - //pointer of lines and points - vtkSmartPointer lines = vtkSmartPointer::New(); - vtkSmartPointer pts = vtkSmartPointer::New(); - - Vec3 root = this->m_root->GetCoords(); - - //UndirectedGraph - - srand(time(NULL)); - unsigned int id = 1; - - CalculateVTKLinesFromEdges(this->m_root, 0, id, pts, lines, colors, common); - - vtkSmartPointer linesPolyData = vtkSmartPointer::New(); - linesPolyData->SetPoints(pts); - linesPolyData->SetLines(lines); - - linesPolyData->GetCellData()->SetScalars(colors); - - // Write the file - vtkSmartPointer writer = vtkSmartPointer::New(); - writer->SetFileName(filename.c_str()); -#if VTK_MAJOR_VERSION <= 5 - writer->SetInput(linesPolyData); -#else - writer->SetInputData(linesPolyData); -#endif - writer->Write(); -} - -//To store the graph in a vtk -void AirwaysTree::CalculateVTKLinesFromEdges(const Node* node, const unsigned int& parentId, - unsigned int& cId, vtkSmartPointer& pts, - vtkSmartPointer& lines, - vtkSmartPointer& colors, bool common) -{ - if (node == NULL) - return; - - // Colors - unsigned char red[3] = { 255, 0, 0 }; - unsigned char green[3] = { 0, 255, 0 }; - unsigned char blue[3] = { 0, 0, 255 }; - unsigned char yellow[3] = { 255, 255, 0 }; - - const vec_nodes children = node->GetChildren(); - - for(vec_nodes::const_iterator it = children.begin(); it != children.end(); ++it) - { - if (!(*it)->IsMarked() && common) - continue; - - const Edge* edge = (*it)->GetEdge(); - //pts->InsertNextPoint(edge->GetSource()->GetCoords().GetVec3()); - //pts->InsertNextPoint(edge->GetTarget()->GetCoords().GetVec3()); - - pts->InsertNextPoint(node->GetCoords().GetVec3()); - pts->InsertNextPoint((*it)->GetCoords().GetVec3()); - - // Set color to be used - int numColor = node->GetLevel() % 4; - if(numColor == 0) - colors->InsertNextTupleValue(green); - else if(numColor == 1) - colors->InsertNextTupleValue(red); - else if(numColor == 2) - colors->InsertNextTupleValue(blue); - else - colors->InsertNextTupleValue(yellow); - - vtkSmartPointer line = vtkSmartPointer::New(); - line->GetPointIds()->SetId(0, parentId); - line->GetPointIds()->SetId(1, cId++); - lines->InsertNextCell(line); - unsigned int newParent = cId++; - CalculateVTKLinesFromEdges(*it, newParent, cId, pts, lines, colors, common); - } //for -} - - -} /* namespace airways */ - - -#endif - diff --git a/lib/Airways/AirwaysLib/airwaysTree.h b/lib/Airways/AirwaysLib/airwaysTree.h deleted file mode 100644 index 9b9775d..0000000 --- a/lib/Airways/AirwaysLib/airwaysTree.h +++ /dev/null @@ -1,372 +0,0 @@ -/* - * airwaysTree.h - * - * Created on: May 3, 2014 - * Author: caceres@creatis.insa-lyon.fr - */ - -#ifndef _AIRWAYS_TREE_H_ -#define _AIRWAYS_TREE_H_ - -#include "airwaysTreeTypeDefinition.h" - -// VTK -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// ITK -#include "itkImage.h" -#include "itkImageRegionIterator.h" -#include "itkLineIterator.h" -#include -#include - -namespace airways -{ - -// Types - -// Vector of nodes -typedef std::vector vec_nodes; - -// Pair of nodes -typedef std::pair pair_nodes; - -//Pair of a pair of nodes and a score -typedef std::pair Pair_PairNodes_Score; - -/** - * - */ -//typedef std::pair Pair_PairNodes_Score; - -/** - * Vector of pairs of a pair of nodes and a score - */ -typedef std::vector Vector_Pair_PairNodes_Score; - -/*! - * A vector stocking all the points between two nodes - */ -typedef std::vector vec_pair_posVox_rad; - -class TempAirwaysAppli_AirwaysLib_EXPORT AirwaysTree -{ -public: - - AirwaysTree(); - - AirwaysTree(TInputImage::Pointer img, TInputImage::Pointer img_sk, Node* root); - - AirwaysTree(TInputImage::Pointer image_airwaySegmentation, TInputImage::Pointer image_skeletonDM, EdgeVector& vector_edges, Edge* edge_trachea); - - - //CERON - // New constructor that doesn't update path info between nodes. - AirwaysTree(TInputImage::Pointer image, TInputImage::Pointer image_skeleton, Node* root, bool shouldUpdate); - virtual ~AirwaysTree(); - - /** - * Getters - */ - - Node* GetRoot() const; - - std::string GetImageName() const; - - std::string GetResultPath() const; - - TInputImage::Pointer GetSegmentedImage() const; - - TInputImage::Pointer GetSkeletonImage() const; - - const Node* GetNode(const Vec3 nodeCoords) const; - - /** - * Method that return the node with the specified id - * @param nId is id of the requested node - * @return the requested id, NULL if not found - */ - Node* GetNodeById(unsigned int nId); - - /** - * Method that returns the depth of the node whose id is given by parameter - * @pre the node exist in the sub-tree - * @param idNode is the search node id - * @return the depth of the node up to the actual node - */ - int GetDepthById(unsigned int nId); - - unsigned int CountMarkedNodes(Node* current = NULL) const; - - /** - * Method that returns the weight of the tree - * @return the weight of the tree which is the number of nodes in the tree. - */ - unsigned int GetWeight( ) const; - - unsigned int GetHeight(Node* current = NULL) const; - - unsigned int GetLevels(Node* current = NULL, unsigned int cLevel = 0) const; - - /** - * Method that returns the number of leafs in the tree - * @return the number of leafs in the tree - */ - unsigned int GetNumberOfLeafs() const; - - const EdgeVector& GetEdges() const; - - const vec_nodes& GetNodes() const; - - /** - * Method that returns the closest node of a given voxel. - * The closes node is the one whose path to the father has the closest point to the given point - * in real coordinates of the image. - * @param voxel_x x componente of the voxel - * @param voxel_y y componente of the voxel - * @param voxel_z z componente of the voxel - * @return the closest node to the given voxel - */ - const Node* GetClosestBrachNodeToIndex(float point_x, float point_y, float point_z) const; - - /** - * Method that returns the list of nodes that influence the given point - * @param point_x, point_y, point_z are the position of the point in real coordinates x, y, and z respectively. - * @param vec_nodes_influence vector to save the nodes - */ - void GetBrancheNodesInfluencingPoint(float point_x, float point_y, float point_z, vec_nodes& vec_nodes_influence); - - AirwaysTree& GetTreeFromMarkedNodes(Node* currentNode = NULL, AirwaysTree* tree = NULL); - - AirwaysTree& GetSubTreeFromNode(Node* node, AirwaysTree* tree = NULL); - - AirwaysTree& GetSubTreeByLevels(const int& level, Node* node = NULL, AirwaysTree* tree = NULL); - - AirwaysTree& GetSubTreeByLength(const double& length, Node* node = NULL, AirwaysTree* tree = NULL, double cLenght = 0.0); - - AirwaysTree& GetSubTreeByRadius(const double& radius, Node* node = NULL, AirwaysTree* tree = NULL, double cRadius = 0.0); - - void MarkLevels(const int& level, Node* currentNode = NULL); - - bool IsEmpty() const; - - /** - * Method that search a node inside a path. The path is defined by the starting and ending nodes - * @param idNode_starting is the id of the starting node - * @param idNode_ending is the id of the ending node - * @param idNode_searched is the of the searched node - * @return true if the searched node is inside the path, false otherwise - */ - bool IsNodeInsidePath(unsigned int idNode_starting, unsigned int idNode_ending, unsigned int idNode_searched); - - void SetRoot(Node* root); - - void SetImageName(const std::string& img_name); - - void SetResultPath(const std::string& folderPath); - - bool Insert(Edge* edge); - - void UnMarkAll(Node* currentNode = NULL); - - /** - * Method that compares two tree starting from the root node. - * @param treeB is the tree to be compared with - * @param Q is the depth to select "fathers" nodes - * @param F is the depth to select "family" nodes - * @param commonA vector to save the common nodes for this subtree - * @param commonA vector to save the common nodes for the subtree given by parameter - * @param nonCommonA vector to save the non-common nodes for this subtree - * @param nonCommonB vector to save the non-common nodes for the subtree given by parameter - */ - void CompareTreesOrkiszMorales(AirwaysTree& treeB, unsigned int Q, unsigned int F, vec_nodes& commonA, vec_nodes& commonB, vec_nodes& nonCommonA, vec_nodes& nonCommonB, std::map< unsigned int, std::vector >& map_A_to_B, std::map< unsigned int, std::vector >& map_B_to_A, std::vector< std::pair< std::pair, std::pair > >& vector_pair_edges_A_to_B); - - void MarkPathFromNodeToNode(Node* node_begin, Node* node_end); - - /** - * Method that compares the actual tree with another given by parameter - * @param treeB the tree to be compared with - */ - void CompareTrees(AirwaysTree& treeB); - - /** - * Method that finds the pair, at least one is a leaf, with the lowest score - * @param vectorPairNodesScore is the vector of pairs - * @return the pair, at least one is a leaf, with the lowest score - */ - Pair_PairNodes_Score GetBestLeaf(Vector_Pair_PairNodes_Score vectorPairNodesScore); - - /** - * Method that returns the pair of pair nodes and score for the given ids. - * @param vectorPairNodesScore vector of pair nodes and score - * @param idA is the first id if the pair nodes - * @param idB is the second id if the pair nodes - * @return the score for the given pair. - */ - double GetPairNodes_Score(Vector_Pair_PairNodes_Score vectorPairNodesScore, const unsigned int idA, const unsigned int idB); - - /** - * Method that returns a copy of the tree - * @return the copy of this tree - */ - AirwaysTree* GetCopy(); - - /** - * Method that deleted a node, all his children, from the tree - * @return true if the node was deleted (found), false otherwise - */ - bool DeleteNodeById(unsigned int nId); - - /** - * Method that removes all the pairs that contains the a given id is a given component position. - * @param vectorPairNodesScore the vector of pair nodes and score - * @param component is the component position to be analyzed - * @param nId is the searched id - * @return the number of deleted pairs - */ - unsigned int DeleteEntriesByIdNode(Vector_Pair_PairNodes_Score& vectorPairNodesScore, unsigned int component, unsigned int nId); - - /** - * Method that compares all the actual branches to all branches in the tree given by parameter - * @param treeB in the tree to be compared with - */ - Vector_Pair_PairNodes_Score CompareAllBranches(AirwaysTree& treeB); - - /** - * Method that return the composed edge from the root node to the node whose id is given by parameter - * @param idNode is the id of the node where the complex edge ends. - */ - Edge* GetComposedEdge(unsigned int idNode); - - /** - * Method that detaches a node and return a tree with a root and just the detaches node - * @param nId is the id node to be searched - * @return a tree with a root and just the detaches node - */ - AirwaysTree* GetSingleDetachedTreeNodeById(unsigned int nId); - - void UpdateLevels(unsigned int levels = 0); - - void SubIsomorphism(AirwaysTree& treeB); - - bool Isomorphism(AirwaysTree& tree); - - void ImageReconstructionFromNode(TInputImage::Pointer& result, Node* node, bool skeleton = false); - - void ImageReconstruction(TInputImage::Pointer& result, bool skeleton = false, Node* node = NULL); - - void ImageReconstructionBySpheres(TInputImage::Pointer& result, Node* node = NULL, bool useMarks = false); - - - /** - * Method that prints the airway up to a given level - * @level is the level where the printing stops - */ - void printUpToLevel(int level); - - void printNodeAndChildrenIds(); - - /** - * Method that creates the quaternions of the airways up to a given level - * @level is the level where the creation stops. - * @pre level >= 2 - */ - void createQuaternionsUpToLevel(int level); - - /** - * Method that prints the statistics of number of bifurcations in each node - */ - void getStatisticsBifurcations(); - - void saveAirwayAsVTK(const std::string filename, bool common = false); - - /** - * Method that save the airways in a image - * @param filename is the name of the image to be saved - * @param dims is the image dimensions - * @param spacing is the image spacing - * @param origin is the image origin - */ - void saveAirwayToImage(std::string filename, int dims[3], double spc[3], double origin[3]); - - /** - * Method that draws a line in an image - * @initVoxel is the initial voxel - * @endVoxel is the final voxel - * @imagePointer is the image pointer - */ - void drawLineInImage(Vec3 initVoxel, Vec3 endVoxel, TInputImage::Pointer imagePointer); - - void drawLine(int* pixelPointInit, int* pixelPointEnd, TInputImage::Pointer _imagePointer); - - -protected: - - Node* GetNode(const Vec3 nodeCoords, Node* current = NULL); - - Node* GetLeaf(Node* current = NULL); - - void UpdateEdges(Node* node = NULL); - - AirwaysTree& GetSubTreeByDetachingNode(Node* node); - - /** - * Method that adds an edge to the graph given by parameter - * @param source is the source vertex of the edge - * @param target is the target vertex of the edge - * @param graph is the graph to add the new edge - */ - DiGraph_EdgePair AddBoostEdge(const pair_posVox_rad& source, const pair_posVox_rad& target, DiGraph& graph); - - bool FindNeighborhood(DiGraph& graph, Vec3Queue& queue, Vec3List& used, const Vec3& end, ConstNeighborhoodIterator& iterator); - - /** - * Method that return the shortest* path between two nodes, begin and end. *As we are dealing with arborescent trees - * then there is just one path between two nodes! - * The path goes from the end to the begin pixel! - * @param graph containing all the nodes and edges - * @param begin is the starting node - * @param end is the ending node - * @return the shortest path between the starting and ending nodes or vertices. - */ - DiGraph GetGraphShortestPath(const DiGraph& graph, const Vec3& begin, const Vec3& end); - - vec_pair_posVox_rad GetGraphShortestPath_AMP(const DiGraph& graph, const Vec3& begin, const Vec3& end); - - vec_pair_posVox_rad GetSkeletonInfoFromEdge(const Vec3& begin, const Vec3& end); - - bool ComputeSimpleRegionGrowing(TInputImage::Pointer& img, const Vec3 seedPtn); - - void RemoveBranchFromImage(TInputImage::Pointer& img, Node* node); - - void CreateSpheres(TInputImage::Pointer& img, Node* node); - - void CalculateVTKLinesFromEdges(const Node* node, const unsigned int& parentId, - unsigned int& cId, vtkSmartPointer& pts, - vtkSmartPointer& lines, - vtkSmartPointer& colors, bool common); - void FillTree(Node* node); - -protected: - - std::string m_img_name; - std::string m_result_path; - TInputImage::Pointer m_skeleton; - TInputImage::Pointer m_img; - Node* m_root; - vec_nodes m_nodes; - EdgeVector m_edges; -}; -} /* namespace airways */ - -#endif /* AIRWAYSTREE_H_ */ diff --git a/lib/Airways/AirwaysLib/airwaysTreeTypeDefinition.h b/lib/Airways/AirwaysLib/airwaysTreeTypeDefinition.h deleted file mode 100644 index 235430a..0000000 --- a/lib/Airways/AirwaysLib/airwaysTreeTypeDefinition.h +++ /dev/null @@ -1,132 +0,0 @@ -/* - * airwaysTreeTypeDefinition.h - * - * Created on: May 19, 2014 - * Author: caceres - */ - -#ifndef AIRWAYSTREETYPEDEFINITION_H_ -#define AIRWAYSTREETYPEDEFINITION_H_ - -//std -#include -#include -#include -#include -//boost -#include -//itk -#include "itkImage.h" -#include "itkConnectedComponentImageFilter.h" -#include "itkConstNeighborhoodIterator.h" -#include "itkImageDuplicator.h" -#include "itkSphereSpatialFunction.h" -#include "itkConnectedThresholdImageFilter.h" -#include "itkSubtractImageFilter.h" -#include "itkCastImageFilter.h" -//airways -#include "../MathLib/vec3.h" -#include "airwaysNode.h" -#include "airwaysEdge.h" - -namespace airways -{ - typedef std::pair pair_posVox_rad; - typedef std::vector vec_pair_posVox_rad; - - /** - * Pair of id nodes - */ - - - /** - * Pair of a pair of nodes and a score - */ - //typedef std::pair Pair_PairNodes_Score; - - //---------------------------------------------------------------------------- - /* - * Typedef declaration - */ - /** - * @typedef Defines a graph using the Boost DiGraph library - */ - typedef boost::adjacency_list DiGraph; - //end typedef Graph - //-------------------------------------------------------------------------- - /** - * @typedef Defines boost::vertex_descriptor of DiGraph - */ - typedef boost::graph_traits::vertex_descriptor DiGraph_VertexDescriptor; - //-------------------------------------------------------------------------- - ///DiGraph edge_descriptor - typedef boost::graph_traits::edge_descriptor DiGraph_EdgeDescriptor; - //-------------------------------------------------------------------------- - ///DiGraph edge pair - typedef std::pair DiGraph_EdgePair; - //-------------------------------------------------------------------------- - ///DiGraph Vertex IndexMap - typedef boost::property_map::type DiGraph_VertexIndexMap; - //-------------------------------------------------------------------------- - ///DiGraph VertexIterator - typedef boost::graph_traits::vertex_iterator DiGraph_VertexIterator; - //-------------------------------------------------------------------------- - ///DiGraph Vertex iterator pair - typedef std::pair DiGraph_VertexIteratorPair; - //-------------------------------------------------------------------------- - ///DiGraph Edge iterator - typedef boost::graph_traits::edge_iterator DiGraph_EdgeIterator; - //-------------------------------------------------------------------------- - ///DiGraph In Edge iterator - typedef boost::graph_traits::in_edge_iterator DiGraph_InEdgeIterator; - //-------------------------------------------------------------------------- - ///DiGraph Out Edge iterator - typedef boost::graph_traits::out_edge_iterator DiGraph_OutEdgeIterator; - //-------------------------------------------------------------------------- - ///DiGraph Adjacency iterator - typedef boost::graph_traits::adjacency_iterator DiGraph_AdjacencyIterator; - //-------------------------------------------------------------------------- - ///DiGraph Vertex descriptor vector - typedef std::vector DiGraph_VertexVector; - //-------------------------------------------------------------------------- - ///DiGraph Vertex descriptor queue - typedef std::queue DiGraph_VertexQueue; - //-------------------------------------------------------------------------- - ///DiGraph Edge descriptor vector - typedef std::vector DiGraph_EdgeVector; - //---------------------------------------------------------------------------- - const unsigned int Dim = 3; - typedef double TPixel; - typedef unsigned char TPixel2; - typedef itk::Image TInputImage; - typedef itk::Image TInputImage2; - typedef itk::Image TInputImage3; - //---------------------------------------------------------------------------- - typedef itk::ImageDuplicator DuplicatorType; - //-------------------------------------------------------------------------- - typedef itk::ConstNeighborhoodIterator ConstNeighborhoodIterator; - typedef itk::ImageRegionIterator RegionIterator; - //---------------------------------------------------------------------------- - typedef itk::SphereSpatialFunction<> SphereType; - //---------------------------------------------------------------------------- - typedef itk::ConnectedThresholdImageFilter ConnectedFilterType; - //---------------------------------------------------------------------------- - typedef itk::SubtractImageFilter SubtractImageFilterType; - //---------------------------------------------------------------------------- - typedef itk::CastImageFilter CastFilterType; - typedef itk::ConnectedComponentImageFilter ConnectedComponentImageFilterType; - //---------------------------------------------------------------------------- - - //---------------------------------------------------------------------------- - typedef std::vector EdgeVector; - //---------------------------------------------------------------------------- - typedef std::queue Vec3Queue; - typedef std::vector Vec3List; -// -/* - * End of typedef declaration - */ -} - -#endif /* AIRWAYSTREETYPEDEFINITION_H_ */ diff --git a/lib/Airways/CMakeLists.txt b/lib/Airways/CMakeLists.txt deleted file mode 100644 index b609a0d..0000000 --- a/lib/Airways/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -SUBDIRS( - MathLib - AirwaysLib - ) - -## eof - $RCSfile$ diff --git a/lib/Airways/MathLib/CMakeLists.txt b/lib/Airways/MathLib/CMakeLists.txt deleted file mode 100644 index cc436e0..0000000 --- a/lib/Airways/MathLib/CMakeLists.txt +++ /dev/null @@ -1,37 +0,0 @@ -## ============================= -## = Set names and directories = -## ============================= - -SET(lib_NAME TempAirwaysAppli_MathLib) - -## =============== -## = Source code = -## =============== - -FILE(GLOB lib_HEADERS_H "${CMAKE_CURRENT_SOURCE_DIR}/*.h") -FILE(GLOB lib_HEADERS_HPP "${CMAKE_CURRENT_SOURCE_DIR}/*.hpp") -FILE(GLOB lib_HEADERS_HXX "${CMAKE_CURRENT_SOURCE_DIR}/*.hxx") -FILE(GLOB lib_SOURCES_C "${CMAKE_CURRENT_SOURCE_DIR}/*.c") -FILE(GLOB lib_SOURCES_CPP "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp") -FILE(GLOB lib_SOURCES_CXX "${CMAKE_CURRENT_SOURCE_DIR}/*.cxx") - -## ===================== -## = Compilation rules = -## ===================== - -ADD_LIBRARY( - ${lib_NAME} - SHARED - ${lib_SOURCES_C} - ${lib_SOURCES_CPP} - ${lib_SOURCES_CXX} - ) -GENERATE_EXPORT_HEADER( - ${lib_NAME} - BASE_NAME ${lib_NAME} - EXPORT_MACRO_NAME ${lib_NAME}_EXPORT - EXPORT_FILE_NAME ${CMAKE_CURRENT_BINARY_DIR}/${lib_NAME}_Export.h - STATIC_DEFINE ${lib_NAME}_BUILT_AS_STATIC - ) - -## eof - $RCSfile$ diff --git a/lib/Airways/MathLib/Quaternion.cpp b/lib/Airways/MathLib/Quaternion.cpp deleted file mode 100644 index 6beaa48..0000000 --- a/lib/Airways/MathLib/Quaternion.cpp +++ /dev/null @@ -1,168 +0,0 @@ -//---------------------------------------------------------------------------- -// Class definition include -//---------------------------------------------------------------------------- - -#include "Quaternion.h" - -//---------------------------------------------------------------------------- -// Class implementation -//---------------------------------------------------------------------------- -//---------------------------------------------------------------------------- -// Builder -//---------------------------------------------------------------------------- - -Quaternion::Quaternion( ) -{ - theta = 0.0; - w = Vec3(0,0,0); - r = cos(theta/2); - double sinHalfTheta = sin(theta/2); - im = w*sinHalfTheta; -} - -Quaternion::Quaternion(Vec3 v1, Vec3 v2) -{ - // Normalize the vectors - v1.Normalize(); - v2.Normalize(); - - // Dot product - float cosTheta = v1.Dot(v2); - theta = acos(cosTheta); - - // Cross product - w = v1.Cross(v2); - - // Normalization - w.Normalize(); - - // Build the quaternion - r = cos(theta/2); - double sinHalfTheta = sin(theta/2); - im = w*sinHalfTheta; -} - -Quaternion::Quaternion(float nTheta, Vec3 nW) -{ - theta = nTheta; - w = nW; - w.Normalize(); - - // Build the quaternion - r = cos(theta/2); - double sinHalfTheta = sin(theta/2); - im = w*sinHalfTheta; -} - -Quaternion::Quaternion(float nR, float nI, float nJ, float nK) -{ - r = nR; - im = Vec3(nI, nJ, nK); - - theta = 2*acos(r); - double sinHalfTheta = sin(theta/2); - w = im/sinHalfTheta; -} - -//---------------------------------------------------------------------------- -// Destructor -//---------------------------------------------------------------------------- - -Quaternion::~Quaternion( ) -{ - -} -//---------------------------------------------------------------------------- -// Methods -//---------------------------------------------------------------------------- - -float Quaternion::getR() -{ - return r; -} - -float Quaternion::getI() -{ - return w[0]; -} - -float Quaternion::getJ() -{ - return w[1]; -} - -float Quaternion::getK() -{ - return w[2]; -} - -Vec3 Quaternion::getW() -{ - return w; -} - -Quaternion Quaternion::conjugate( ) -{ - return Quaternion(theta, -w); -} - -Vec3 Quaternion::rotateVector(Vec3 vector) -{ - // Quaterion representing the vector - vector.Normalize(); - Quaternion qv(0,vector[0],vector[1],vector[2]); - Quaternion qthis(r,im[0],im[1],im[2]); - Quaternion qthis_conj = qthis.conjugate(); - - - cout << "Qv: [" << qv << "]" << endl; - cout << "Qthis: [" << qthis << "]" << endl; - cout << "QthisConj: [" << qthis_conj << "]" << endl; - - // Final quaternion - Quaternion Qtemp = qthis*qv; - cout << "Qtemp: [" << Qtemp << "]" << endl; - - Quaternion qf = Qtemp*qthis_conj; - - cout << "Qf: [" << qf << "]" << endl; - - return qf.im; - //return Vec3(0,0,0); -} - -//---------------------------------------------------------------------------- -// Operators -//---------------------------------------------------------------------------- - -const float& Quaternion::operator[](unsigned int i) const -{ - return (i == 0 ? r : (im)[i-1]); -} - -Quaternion Quaternion::operator*(Quaternion q) -{ - float a1 = this->r; - float b1 = this->w[0]; - float c1 = this->w[1]; - float d1 = this->w[2]; - - float a2 = q.r; - float b2 = q.w[0]; - float c2 = q.w[1]; - float d2 = q.w[2]; - - float r_n = a1*a2 - b1*b2 - c1*c2 - d1*d2; - float i_n = a1*b2 + a2*b1 + c1*d2 - c2*d1; - float j_n = a1*c2 - b1*d2 + a2*c1 + b2*d1; - float k_n = a1*d2 + b1*c2 - b2*c1 + a2*d1; - - return Quaternion(r_n, i_n, j_n, k_n); -} - -std::ostream& operator<<(std::ostream& os, const Quaternion& q) -{ - os << q[0] << " " << q[1] << " " << q[2] << " " << q[3]; - os << " " < - -//----------------- -// OWN -//----------------- -#include -#include "vec3.h" - -// Namespaces -using namespace std; - -//------------------------------------------------------------------------------ -// Class that represents a Quaterion with all its operations -//------------------------------------------------------------------------------ -class TempAirwaysAppli_MathLib_EXPORT Quaternion -{ -public: - - //------------------------------------------------------------ - //Builder - //------------------------------------------------------------ - - /* - * Class builder - */ - Quaternion( ); - - /* - * Class builder using two vectors - * @param v1 is the first vector - * @param v2 is the second vector - */ - Quaternion(Vec3 v1, Vec3 v2); - - /* - * Class builder using theta and w vector - * @param nTheta is the theta angle - * @param nW is the w vector - */ - Quaternion(float nTheta, Vec3 nW); - - /* - * Class builder using r and im - * @param nR in the real part of the quaternion - * @param nI, nJ and nK are the imaginary parts of the quaternion - */ - Quaternion(float nR, float nI, float nJ, float nK); - - //------------------------------------------------------------ - //Destructor - //------------------------------------------------------------ - - ~Quaternion(); - - //------------------------------------------------------------ - //Public methods - //------------------------------------------------------------ - - /** - * Method that returns the real (r) component - * @return the r component - */ - float getR(); - - /** - * Method that returns the i component - * @return the i component - */ - float getI(); - - /** - * Method that returns the j component - * @return the j component - */ - float getJ(); - - /** - * Method that returns the k component - * @return the k component - */ - float getK(); - - /** - * Method that returns the w vector - * @return the w vector - */ - Vec3 getW(); - - /** - * Method that returns the conjugate of the quaternion - * @return the conjugate of the quaternion - */ - Quaternion conjugate( ); - - /** - * Method that returns a vector transformed by the quaternion - * @param vector to be rotated - * @return the transformed vector - */ - Vec3 rotateVector(Vec3 vector); - - //------------------------------------------------------------ - //Operators - //------------------------------------------------------------ - - /* - * Definition of operator * - * @param is the quaternion to be multiplied with - * @return the multiplication quaternion - */ - Quaternion operator*(Quaternion q); - - /** - * Definition of operator [] - * @param Position of the quanternion to be returned. Position 0 corresponds - * to the real component and 1, 2, and 3 to the complex components. - * @param The value on the specified position is returned. - * - */ - const float& operator[](unsigned int i) const; - - /** - * Operator to print - */ - friend std::ostream& operator<<(std::ostream& os, const Quaternion& coord); - - -private: - - //------------------------------------------------------------ - //Private methods - //------------------------------------------------------------ - - - //------------------------------------------------------------ - //Atributes - //------------------------------------------------------------ - - /** - * Real part of the quaternion - */ - float r; - - /** - * Angle between vectors - */ - float theta; - - /** - * Rotation vector - */ - Vec3 w; - - /** - * Vector the quaternion - */ - Vec3 im; - -}; - -//------------------------------------------------------------------------------ -#endif diff --git a/lib/Airways/MathLib/vec3.cxx b/lib/Airways/MathLib/vec3.cxx deleted file mode 100644 index ca35977..0000000 --- a/lib/Airways/MathLib/vec3.cxx +++ /dev/null @@ -1,233 +0,0 @@ -#include "vec3.h" - - -Vec3::Vec3() : x(0.0), y(0.0), z(0.0) -{ -} - -Vec3::Vec3(const float& x, const float& y, const float& z) -{ - this->x = x; - this->y = y; - this->z = z; -} - -const float* Vec3::GetVec3() const -{ - float* ret = new float[3]; - ret[0] = this->x; - ret[1] = this->y; - ret[2] = this->z; - return ret; -} - -float* Vec3::GetVec3() -{ - float* ret = new float[3]; - ret[0] = this->x; - ret[1] = this->y; - ret[2] = this->z; - return ret; -} - -Vec3& Vec3::operator=(const Vec3& vec) -{ - this->x = vec.x; - this->y = vec.y; - this->z = vec.z; - return *this; -} - -float& Vec3::operator[](unsigned int i) -{ - return (i == 0 ? x : i == 1 ? y : z); -} - -const float& Vec3::operator[](unsigned int i) const -{ - return (i == 0 ? this->x : i == 1 ? this->y : this->z); -} - -Vec3 Vec3::operator+() const -{ - return *this; -} - -Vec3 Vec3::operator-() const -{ - return Vec3(-this->x, -this->y, -this->z); -} - -Vec3& Vec3::operator+=(const Vec3& b) - { - this->x += b.x; - this->y += b.y; - this->z += b.z; - return *this; - } - -Vec3& Vec3::operator-=(const Vec3& b) - { - this->x -= b.x; - this->y -= b.y; - this->z -= b.z; - return *this; - } - -Vec3& Vec3::operator*=(const float& k) - { - this->x *= k; - this->y *= k; - this->z *= k; - return *this; - } - -Vec3& Vec3::operator/=(const float& k) - { - this->x /= k; - this->y /= k; - this->z /= k; - return *this; - } - -Vec3 Vec3::operator+(const Vec3& b) -{ - return Vec3(this->x + b.x, this->y + b.y, this->z + b.z); -} - -Vec3 Vec3::operator-(const Vec3& b) -{ - return Vec3(this->x - b.x, this->y - b.y, this->z - b.z); -} - -Vec3 Vec3::operator*(const float& k) -{ - return Vec3(this->x * k, this->y * k, this->z * k); -} - -Vec3 Vec3::operator/(const float& k) -{ - return Vec3(this->x / k, this->y / k, this->z / k); -} - -bool Vec3::operator==(const Vec3& b) const -{ - //double epsilon = std::numeric_limits::epsilon(); - //return (fabs(this->x - b.x) <= epsilon) && (fabs(this->y - b.y) <= epsilon) - //&& (fabs(this->z - b.z) <= epsilon); - return this->x == b.x && this->y == b.y && this->z == b.z; -} - -bool Vec3::operator!=(const Vec3& b) const - { - return (!(*this == b)); - } - -bool Vec3::operator<(const Vec3& b) const -{ - if(this->x < b.x) - return true; - else if(this->x > b.x) - return false; - else - { - if(this->y < b.y) - return true; - else if(this->y > b.y) - return false; - else - { - if(this->z < b.z) - return true; - return false; - } - } -} - -bool Vec3::operator>(const Vec3& b) -{ - if(this->x > b.x) - return true; - else if(this->x < b.x) - return false; - else - { - if(this->y > b.y) - return true; - else if(this->y < b.y) - return false; - else - { - if(this->z > b.z) - return true; - return false; - } - } -} - -float Vec3::Norm() const -{ - return sqrt(this->x * this->x + this->y * this->y + this->z * this->z); -} - -void Vec3::Normalize() -{ - float norm = sqrt(this->x * this->x + this->y * this->y + this->z * this->z); - this->x = this->x / norm; - this->y = this->y / norm; - this->z = this->z / norm; -} - -void Vec3::set(const float& x, const float& y, const float& z) -{ - this->x = x; - this->y = y; - this->z = z; -} - -float Vec3::Dot(const Vec3& b) const -{ - return (this->x * b.x + this->y * b.y + this->z * b.z); -} - -Vec3 Vec3::Orthogonal(const Vec3& b) const -{ - Vec3 u = Vec3(fabs(b.x), fabs(b.y), fabs(b.z)); - int i = 0; - int j = 1; - if ((u.x > u.y) && (u.z > u.y)) - j = 2; - else - { - i = 1; - j = 2; - if (u.x > u.z) - j = 0; - } - u = Vec3(); - u[i] = b[j]; - u[j] = -b[i]; - return u; -} - -Vec3 Vec3::Cross(const Vec3& b) const -{ - return Vec3(this->y * b.z - this->z * b.y, this->z * b.x - this->x * b.z, - this->x * b.y - this->y * b.x); -} - - -float Vec3::EculideanDistance(const Vec3& b) const -{ - return sqrt( - pow(this->x - b.x, 2.0) + pow(this->y - b.y, 2.0) - + pow(this->z - b.z, 2.0)); -} - -std::ostream& -operator<<(std::ostream& os, const Vec3& coord) -{ - os << coord[0] << " " << coord[1] << " " << coord[2]; - return os; -} - diff --git a/lib/Airways/MathLib/vec3.h b/lib/Airways/MathLib/vec3.h deleted file mode 100644 index 6adbe42..0000000 --- a/lib/Airways/MathLib/vec3.h +++ /dev/null @@ -1,221 +0,0 @@ -/** - * Class that models a vector in 3D - * Author: Diego Cáceres - * Modifications by: Alfredo Morales Pinzón - * Date modifications: Octobre 7, 2014 - */ -#ifndef VEC3_H -#define VEC3_H - -#include -#include -#include -#include // std::numeric_limits - -//------------------------------------------------------------------------------ -/** - * @brief The Vec3 class that represents a vector in 3D - */ -class TempAirwaysAppli_MathLib_EXPORT Vec3 -{ -private: - float x, y, z; //!< Coordinates -public: - //---------------------------------------------------------------------------- - /** - * @brief Vec3 - */ - Vec3(); - //---------------------------------------------------------------------------- - /** - * @brief Vec3 - * @param x - * @param y - * @param z - */ - Vec3(const float& x, const float& y, const float& z); - //---------------------------------------------------------------------------- - //Getters - //---------------------------------------------------------------------------- - /** - * @brief GetVec3 - * @return - */ - const float* GetVec3() const; - //---------------------------------------------------------------------------- - /** - * @brief GetVec3 - * @return - */ - float* GetVec3(); - //---------------------------------------------------------------------------- - /** - * @brief Norm - * @return - */ - float Norm() const; - - /** - * Method that normalizes the vector. v = v/|v| - */ - void Normalize(); - - /** - * Method that sets all the values - */ - void set(const float& x, const float& y, const float& z); - - /** - * @brief Dot - * @param b - * @return - */ - float Dot(const Vec3& b) const; - //---------------------------------------------------------------------------- - /** - * @brief Orthogonal - * @param b - * @return - */ - Vec3 Orthogonal(const Vec3& b) const; - //---------------------------------------------------------------------------- - /** - * @brief Cross - * @param b - * @return - */ - Vec3 Cross(const Vec3& b) const; - //---------------------------------------------------------------------------- - /** - * @brief EculideanDistance between two points - * @param b - * @return - */ - float EculideanDistance(const Vec3& b) const; - //---------------------------------------------------------------------------- - //Operator Overloads - //---------------------------------------------------------------------------- - /** - * @brief The copy operator - * @param vec - * @return - */ - Vec3& operator=(const Vec3& vec); - //---------------------------------------------------------------------------- - /** - * @brief operator [] - * @param i - * @return - */ - float& operator[](unsigned int i); - //---------------------------------------------------------------------------- - /** - * @brief operator [] - * @param i - * @return - */ - const float& operator[](unsigned int i) const; - //---------------------------------------------------------------------------- - /** - * @brief operator + - * @return - */ - Vec3 operator+() const; - //---------------------------------------------------------------------------- - /** - * @brief operator - - * @return - */ - Vec3 operator-() const; - //---------------------------------------------------------------------------- - /** - * @brief operator += - * @param b - * @return - */ - Vec3& operator+=(const Vec3& b); - //---------------------------------------------------------------------------- - /** - * @brief operator -= - * @param b - * @return - */ - Vec3& operator-=(const Vec3& b); - //---------------------------------------------------------------------------- - /** - * @brief operator *= - * @param k - * @return - */ - Vec3& operator*=(const float& k); - //---------------------------------------------------------------------------- - /** - * @brief operator /= - * @param k - * @return - */ - Vec3& operator/=(const float& k); - //---------------------------------------------------------------------------- - /** - * @brief operator + - * @param b - * @return - */ - Vec3 operator+(const Vec3& b); - //---------------------------------------------------------------------------- - /** - * @brief operator - - * @param b - * @return - */ - Vec3 operator-(const Vec3& b); - //---------------------------------------------------------------------------- - /** - * @brief operator * - * @param k - * @return - */ - Vec3 operator*(const float& k); - //---------------------------------------------------------------------------- - /** - * @brief operator / - * @param k - * @return - */ - Vec3 operator/(const float& k); - //---------------------------------------------------------------------------- - /** - * @brief operator == - * @param b - * @return - */ - bool operator==(const Vec3& b) const; - //---------------------------------------------------------------------------- - /** - * @brief operator != - * @param b - * @return - */ - bool operator!=(const Vec3& b) const; - //---------------------------------------------------------------------------- - /** - * @brief operator < - * @param b - * @return - */ - bool operator<(const Vec3& b) const; - //---------------------------------------------------------------------------- - /** - * @brief operator > - * @param b - * @return - */ - bool operator>(const Vec3& b); - //---------------------------------------------------------------------------- - friend std::ostream& operator<<(std::ostream& os, const Vec3& coord); - //---------------------------------------------------------------------------- - -}; -//------------------------------------------------------------------------------ - -#endif // VEC3_H diff --git a/lib/Airways/fpa2Airways/Converter.h b/lib/Airways/fpa2Airways/Converter.h deleted file mode 100644 index 13e31b2..0000000 --- a/lib/Airways/fpa2Airways/Converter.h +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef __AIRWAYS__FPA2AIRWAYS__CONVERTER__H__ -#define __AIRWAYS__FPA2AIRWAYS__CONVERTER__H__ - -#include -#include - -namespace fpa2Airways -{ - /** - */ - template< class _TSkeleton, class _TAirways > - class Converter - : public itk::ProcessObject - { - public: - typedef Converter Self; - typedef itk::ProcessObject Superclass; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; - - typedef _TSkeleton TSkeleton; - typedef _TAirways TAirways; - typedef itk::SimpleDataObjectDecorator< _TAirways* > TOutput; - - public: - itkNewMacro( Self ); - itkTypeMacro( Converter, itk::ProcessObject ); - - public: - void SetInput( const TSkeleton* sk ); - TSkeleton* GetInput( ); - const TSkeleton* GetInput( ) const; - TAirways* GetOutput( ); - const TAirways* GetOutput( ) const; - - protected: - Converter( ); - virtual ~Converter( ); - - virtual void GenerateData( ) ITK_OVERRIDE; - - private: - // Purposely not implemented. - Converter( const Self& ); - Self& operator=( const Self& ); - }; - -} // ecapseman - -#ifndef ITK_MANUAL_INSTANTIATION -#include -#endif // ITK_MANUAL_INSTANTIATION - -#endif // __AIRWAYS__FPA2AIRWAYS__CONVERTER__H__ - -// eof - $RCSfile$ diff --git a/lib/Airways/fpa2Airways/Converter.hxx b/lib/Airways/fpa2Airways/Converter.hxx deleted file mode 100644 index e3a564e..0000000 --- a/lib/Airways/fpa2Airways/Converter.hxx +++ /dev/null @@ -1,84 +0,0 @@ -#ifndef __AIRWAYS__FPA2AIRWAYS__CONVERTER__HXX__ -#define __AIRWAYS__FPA2AIRWAYS__CONVERTER__HXX__ - -// ------------------------------------------------------------------------- -template< class _TSkeleton, class _TAirways > -void fpa2Airways::Converter< _TSkeleton, _TAirways >:: -SetInput( const _TSkeleton* sk ) -{ - this->itk::ProcessObject::SetNthInput( 0, const_cast< _TSkeleton* >( sk ) ); -} - -// ------------------------------------------------------------------------- -template< class _TSkeleton, class _TAirways > -_TSkeleton* fpa2Airways::Converter< _TSkeleton, _TAirways >:: -GetInput( ) -{ - return( - dynamic_cast< _TSkeleton* >( this->itk::ProcessObject::GetInput( 0 ) ) - ); -} - -// ------------------------------------------------------------------------- -template< class _TSkeleton, class _TAirways > -const _TSkeleton* fpa2Airways::Converter< _TSkeleton, _TAirways >:: -GetInput( ) const -{ - return( - dynamic_cast< const _TSkeleton* >( - this->itk::ProcessObject::GetInput( 0 ) - ) - ); -} - -// ------------------------------------------------------------------------- -template< class _TSkeleton, class _TAirways > -_TAirways* fpa2Airways::Converter< _TSkeleton, _TAirways >:: -GetOutput( ) -{ - auto o = dynamic_cast< _TAirways* >( - this->itk::ProcessObject::GetOutput( 0 ) - ); - return( o->Get( ) ); -} - -// ------------------------------------------------------------------------- -template< class _TSkeleton, class _TAirways > -const _TAirways* fpa2Airways::Converter< _TSkeleton, _TAirways >:: -GetOutput( ) const -{ - auto o = dynamic_cast< const _TAirways* >( - this->itk::ProcessObject::GetOutput( 0 ) - ); - return( o->Get( ) ); -} - -// ------------------------------------------------------------------------- -template< class _TSkeleton, class _TAirways > -fpa2Airways::Converter< _TSkeleton, _TAirways >:: -Converter( ) - : Superclass( ) -{ - this->SetNumberOfRequiredInputs( 1 ); - this->SetNumberOfRequiredOutputs( 1 ); - typename TOutput::Pointer o = TOutput::New( ); - this->itk::ProcessObject::SetNthOutput( 0, o.GetPointer( ) ); -} - -// ------------------------------------------------------------------------- -template< class _TSkeleton, class _TAirways > -fpa2Airways::Converter< _TSkeleton, _TAirways >:: -~Converter( ) -{ -} - -// ------------------------------------------------------------------------- -template< class _TSkeleton, class _TAirways > -void fpa2Airways::Converter< _TSkeleton, _TAirways >:: -GenerateData( ) -{ -} - -#endif // __AIRWAYS__FPA2AIRWAYS__CONVERTER__HXX__ - -// eof - $RCSfile$ diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt deleted file mode 100644 index 0afa2df..0000000 --- a/lib/CMakeLists.txt +++ /dev/null @@ -1,12 +0,0 @@ -IF(BUILD_TempAirwaysAppli) - SUBDIRS( - Airways - ) -ENDIF(BUILD_TempAirwaysAppli) -IF(BUILD_PLUGINS) - SUBDIRS( - fpa_Instances - ) -ENDIF(BUILD_PLUGINS) - -## eof - $RCSfile$ diff --git a/lib/fpa/Base/Algorithm.h b/lib/fpa/Base/Algorithm.h deleted file mode 100644 index 94d1ddd..0000000 --- a/lib/fpa/Base/Algorithm.h +++ /dev/null @@ -1,183 +0,0 @@ -#ifndef __FPA__BASE__ALGORITHM__H__ -#define __FPA__BASE__ALGORITHM__H__ - -#include -#include -#include -#include - -namespace fpa -{ - namespace Base - { - /** - * Base front propagation algorithm. From a series of start seeds with - * costs, a priority queue is filled and emptied updating costs. Each - * vertex could be marked as "visited", "in the front", "not yet there" - * or "freezed". - * - * @param V Vertex type. - * @param C Vertex value type. - * @param R Result value type. - * @param S Space type where vertices are. - * @param VC Vertex lexicographical compare. - * @param B Base class for this algorithm. It should be any itk-based - * filter (itk::ProcessObject). - * - */ - template< class V, class C, class R, class S, class VC, class B > - class Algorithm - : public B - { - public: - typedef Algorithm Self; - typedef B Superclass; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; - - typedef V TVertex; - typedef C TValue; - typedef R TResult; - typedef S TSpace; - typedef VC TVertexCompare; - - fpa_Base_NewEvent( TStartEvent ); - fpa_Base_NewEvent( TStartLoopEvent ); - fpa_Base_NewEvent( TStartBacktrackingEvent ); - fpa_Base_NewEvent( TEndEvent ); - fpa_Base_NewEvent( TEndLoopEvent ); - fpa_Base_NewEvent( TEndBacktrackingEvent ); - fpa_Base_NewEventWithVertex( TAliveEvent, TVertex ); - fpa_Base_NewEventWithVertex( TFrontEvent, TVertex ); - fpa_Base_NewEventWithVertex( TFreezeEvent, TVertex ); - fpa_Base_NewEventWithVertex( TBacktrackingEvent, TVertex ); - - protected: - typedef std::vector< TVertex > _TVertices; - typedef std::pair< TVertex, bool > _TCollision; - typedef std::vector< _TCollision > _TCollisionsRow; - typedef std::vector< _TCollisionsRow > _TCollisions; - - /** - */ - enum _TNodeLabel - { - FarLabel = 0, - FrontLabel, - AliveLabel - }; - - /** - */ - class _TNode - { - public: - _TNode( ); - virtual ~_TNode( ); - - public: - TVertex Parent; - TResult Result; - short FrontId; - char Label; - }; - typedef std::map< TVertex, _TNode, TVertexCompare > _TNodes; - - public: - itkTypeMacro( Algorithm, B ); - - itkBooleanMacro( ThrowEvents ); - itkBooleanMacro( StopAtOneFront ); - - itkGetConstMacro( ThrowEvents, bool ); - itkGetConstMacro( StopAtOneFront, bool ); - - itkSetMacro( ThrowEvents, bool ); - itkSetMacro( StopAtOneFront, bool ); - - public: - virtual void InvokeEvent( const itk::EventObject& e ); - virtual void InvokeEvent( const itk::EventObject& e ) const; - - void AddSeed( const TVertex& s, const TResult& r ); - const TVertex& GetSeed( const unsigned int& id ) const; - void ClearSeeds( ); - unsigned long GetNumberOfSeeds( ) const; - - protected: - Algorithm( ); - virtual ~Algorithm( ); - - // Connection with itk's pipeline - virtual void GenerateData( ) ITK_OVERRIDE; - - // Main loop algorithm - virtual void _Loop( ); - - // Supporting methods for loop - virtual void _BeforeGenerateData( ); - virtual void _AfterGenerateData( ); - virtual void _BeforeLoop( ); - virtual void _AfterLoop( ); - - // Methods to control forced stops - virtual bool _UpdateCollisions( const TVertex& a, const TVertex& b ); - virtual bool _NeedToStop( ) const; - - // Graph-related abstract methods - virtual unsigned long _NumberOfVertices( ) const = 0; - virtual const TValue& _VertexValue( const TVertex& v ) const = 0; - virtual double _Distance( - const TVertex& a, const TVertex& b - ) const = 0; - virtual bool _HasEdge( const TVertex& a, const TVertex& b ) const = 0; - virtual void _Neighborhood( - _TVertices& neighborhood, const TVertex& v - ) const = 0; - - // Results-related abstract methods - virtual bool _ComputeNeighborResult( - TResult& result, const TVertex& neighbor, const TVertex& parent - ) const = 0; - virtual void _InitResults( ) = 0; - virtual const TResult& _Result( const TVertex& v ) const = 0; - virtual void _SetResult( const TVertex& v, const _TNode& n ); - - // Marks-related abstract methods - virtual _TNode& _Node( const TVertex& v ); - virtual const _TNode& _Node( const TVertex& v ) const; - virtual void _InitMarks( ); - virtual void _Mark( const TVertex& v, const _TNode& node ); - - // Queue-related abstract methods - virtual void _InitQueue( ); - virtual bool _IsQueueEmpty( ) const = 0; - virtual void _QueuePush( const TVertex& v, const _TNode& n ) = 0; - virtual void _QueuePop( TVertex& v, _TNode& n ) = 0; - virtual void _QueueClear( ) = 0; - - private: - // Purposely not implemented - Algorithm( const Self& other ); - Self& operator=( const Self& other ); - - protected: - bool m_ThrowEvents; - bool m_StopAtOneFront; - _TNodes m_Seeds; - _TVertices m_SeedVertices; - _TNodes m_Marks; - _TCollisions m_Collisions; - }; - - } // ecapseman - -} // ecapseman - -#ifndef ITK_MANUAL_INSTANTIATION -#include -#endif // ITK_MANUAL_INSTANTIATION - -#endif // __FPA__BASE__ALGORITHM__H__ - -// eof - $RCSfile$ diff --git a/lib/fpa/Base/Algorithm.hxx b/lib/fpa/Base/Algorithm.hxx deleted file mode 100644 index 3530787..0000000 --- a/lib/fpa/Base/Algorithm.hxx +++ /dev/null @@ -1,366 +0,0 @@ -#ifndef __FPA__BASE__ALGORITHM__HXX__ -#define __FPA__BASE__ALGORITHM__HXX__ - -#include -#include - -// ------------------------------------------------------------------------- -template< class V, class C, class R, class S, class VC, class B > -fpa::Base::Algorithm< V, C, R, S, VC, B >::_TNode:: -_TNode( ) - : Result( TResult( 0 ) ), - FrontId( -1 ), - Label( Self::FarLabel ) -{ -} - -// ------------------------------------------------------------------------- -template< class V, class C, class R, class S, class VC, class B > -fpa::Base::Algorithm< V, C, R, S, VC, B >::_TNode:: -~_TNode( ) -{ -} - -// ------------------------------------------------------------------------- -template< class V, class C, class R, class S, class VC, class B > -void fpa::Base::Algorithm< V, C, R, S, VC, B >:: -InvokeEvent( const itk::EventObject& e ) -{ - if( this->m_ThrowEvents ) - this->Superclass::InvokeEvent( e ); -} - -// ------------------------------------------------------------------------- -template< class V, class C, class R, class S, class VC, class B > -void fpa::Base::Algorithm< V, C, R, S, VC, B >:: -InvokeEvent( const itk::EventObject& e ) const -{ - if( this->m_ThrowEvents ) - this->Superclass::InvokeEvent( e ); -} - -// ------------------------------------------------------------------------- -template< class V, class C, class R, class S, class VC, class B > -void fpa::Base::Algorithm< V, C, R, S, VC, B >:: -AddSeed( const TVertex& s, const TResult& r ) -{ - _TNode ns; - ns.Parent = s; - ns.Result = r; - ns.FrontId = this->m_SeedVertices.size( ); - ns.Label = Self::FrontLabel; - this->m_Seeds[ s ] = ns; - this->m_SeedVertices.push_back( s ); - this->Modified( ); -} - -// ------------------------------------------------------------------------- -template< class V, class C, class R, class S, class VC, class B > -const typename fpa::Base::Algorithm< V, C, R, S, VC, B >:: -TVertex& fpa::Base::Algorithm< V, C, R, S, VC, B >:: -GetSeed( const unsigned int& id ) const -{ - return( this->m_SeedVertices[ id ] ); -} - -// ------------------------------------------------------------------------- -template< class V, class C, class R, class S, class VC, class B > -void fpa::Base::Algorithm< V, C, R, S, VC, B >:: -ClearSeeds( ) -{ - this->m_Seeds.clear( ); - this->m_SeedVertices.clear( ); - this->Modified( ); -} - -// ------------------------------------------------------------------------- -template< class V, class C, class R, class S, class VC, class B > -unsigned long fpa::Base::Algorithm< V, C, R, S, VC, B >:: -GetNumberOfSeeds( ) const -{ - return( this->m_Seeds.size( ) ); -} - -// ------------------------------------------------------------------------- -template< class V, class C, class R, class S, class VC, class B > -fpa::Base::Algorithm< V, C, R, S, VC, B >:: -Algorithm( ) - : Superclass( ), - m_ThrowEvents( false ), - m_StopAtOneFront( false ) -{ -} - -// ------------------------------------------------------------------------- -template< class V, class C, class R, class S, class VC, class B > -fpa::Base::Algorithm< V, C, R, S, VC, B >:: -~Algorithm( ) -{ -} - -// ------------------------------------------------------------------------- -template< class V, class C, class R, class S, class VC, class B > -void fpa::Base::Algorithm< V, C, R, S, VC, B >:: -GenerateData( ) -{ - unsigned long N = this->m_Seeds.size( ); - if( N == 0 ) - return; - - this->InvokeEvent( TStartEvent( ) ); - this->_BeforeGenerateData( ); - - this->m_Collisions.clear( ); - this->m_Collisions. - resize( N, _TCollisionsRow( N, _TCollision( TVertex( ), false ) ) ); - this->_InitResults( ); - this->_InitMarks( ); - this->_InitQueue( ); - this->_Loop( ); - this->_AfterGenerateData( ); - this->InvokeEvent( TEndEvent( ) ); -} - -// ------------------------------------------------------------------------- -template< class V, class C, class R, class S, class VC, class B > -void fpa::Base::Algorithm< V, C, R, S, VC, B >:: -_Loop( ) -{ - this->InvokeEvent( TStartLoopEvent( ) ); - this->_BeforeLoop( ); - while( !( this->_IsQueueEmpty( ) ) ) - { - // Get next candidate - TVertex vertex; - _TNode node; - this->_QueuePop( vertex, node ); - if( this->_Node( vertex ).Label == Self::AliveLabel ) - continue; - - // Mark it as "Alive" and update final result - node.Label = Self::AliveLabel; - this->_Mark( vertex, node ); - this->_SetResult( vertex, node ); - this->InvokeEvent( TAliveEvent( vertex, node.FrontId ) ); - - // Check if a forced stop condition arises - if( !( this->_NeedToStop( ) ) ) - { - // Compute neighborhood - _TVertices neighborhood; - this->_Neighborhood( neighborhood, vertex ); - - // Iterate over neighbors - typename _TVertices::iterator nIt = neighborhood.begin( ); - while( nIt != neighborhood.end( ) ) - { - _TNode neighbor = this->_Node( *nIt ); - if( neighbor.Label == Self::AliveLabel ) - { - // Update collisions - if( this->_UpdateCollisions( vertex, *nIt ) ) - { - this->_QueueClear( ); - nIt = neighborhood.end( ); - continue; - - } // fi - } - else - { - // Add new candidate to queue - if( this->_ComputeNeighborResult( neighbor.Result, *nIt, vertex ) ) - { - neighbor.FrontId = node.FrontId; - neighbor.Parent = vertex; - neighbor.Label = Self::FrontLabel; - this->_QueuePush( *nIt, neighbor ); - this->_Mark( *nIt, neighbor ); - this->InvokeEvent( TFrontEvent( *nIt, node.FrontId ) ); - } - else - this->InvokeEvent( TFreezeEvent( *nIt, node.FrontId ) ); - - } // fi - ++nIt; - - } // elihw - } - else - this->_QueueClear( ); - - } // elihw - this->_AfterLoop( ); - this->InvokeEvent( TEndLoopEvent( ) ); -} - -// ------------------------------------------------------------------------- -template< class V, class C, class R, class S, class VC, class B > -void fpa::Base::Algorithm< V, C, R, S, VC, B >:: -_BeforeGenerateData( ) -{ -} - -// ------------------------------------------------------------------------- -template< class V, class C, class R, class S, class VC, class B > -void fpa::Base::Algorithm< V, C, R, S, VC, B >:: -_AfterGenerateData( ) -{ -} - -// ------------------------------------------------------------------------- -template< class V, class C, class R, class S, class VC, class B > -void fpa::Base::Algorithm< V, C, R, S, VC, B >:: -_BeforeLoop( ) -{ -} - -// ------------------------------------------------------------------------- -template< class V, class C, class R, class S, class VC, class B > -void fpa::Base::Algorithm< V, C, R, S, VC, B >:: -_AfterLoop( ) -{ -} - -// ------------------------------------------------------------------------- -template< class V, class C, class R, class S, class VC, class B > -bool fpa::Base::Algorithm< V, C, R, S, VC, B >:: -_UpdateCollisions( const TVertex& a, const TVertex& b ) -{ - bool ret = false; - _TNode na = this->_Node( a ); - _TNode nb = this->_Node( b ); - long fa = na.FrontId; - long fb = nb.FrontId; - - if( fa != fb ) - { - // Mark collision, if it is new - bool exists = this->m_Collisions[ fa ][ fb ].second; - exists &= this->m_Collisions[ fb ][ fa ].second; - - if( !exists ) - { - this->m_Collisions[ fa ][ fb ].first = a; - this->m_Collisions[ fa ][ fb ].second = true; - this->m_Collisions[ fb ][ fa ].first = b; - this->m_Collisions[ fb ][ fa ].second = true; - - // Stop if one front is desired - if( this->m_StopAtOneFront ) - { - // Perform a depth-first iteration on front graph - unsigned long N = this->GetNumberOfSeeds( ); - unsigned long count = 0; - std::vector< bool > m( N, false ); - std::queue< unsigned long > q; - q.push( 0 ); - while( !q.empty( ) ) - { - unsigned long f = q.front( ); - q.pop( ); - - if( m[ f ] ) - continue; - m[ f ] = true; - count++; - - for( unsigned int n = 0; n < N; ++n ) - if( this->m_Collisions[ f ][ n ].second && !m[ n ] ) - q.push( n ); - - } // elihw - ret = ( count == N ); - - } // fi - - } // fi - - } // fi - return( ret ); -} - -// ------------------------------------------------------------------------- -template< class V, class C, class R, class S, class VC, class B > -bool fpa::Base::Algorithm< V, C, R, S, VC, B >:: -_NeedToStop( ) const -{ - return( false ); -} - -// ------------------------------------------------------------------------- -template< class V, class C, class R, class S, class VC, class B > -typename fpa::Base::Algorithm< V, C, R, S, VC, B >:: -_TNode& fpa::Base::Algorithm< V, C, R, S, VC, B >:: -_Node( const TVertex& v ) -{ - typename _TNodes::iterator vIt = this->m_Marks.find( v ); - if( vIt == this->m_Marks.end( ) ) - { - _TNode new_node; - new_node.Parent = v; - new_node.Result = TResult( 0 ); - new_node.FrontId = -1; - new_node.Label = Self::FarLabel; - this->m_Marks[ v ] = new_node; - vIt = this->m_Marks.find( v ); - - } // fi - return( vIt->second ); -} - -// ------------------------------------------------------------------------- -template< class V, class C, class R, class S, class VC, class B > -void fpa::Base::Algorithm< V, C, R, S, VC, B >:: -_SetResult( const TVertex& v, const _TNode& n ) -{ - // Do nothing at this hierarchy level -} - -// ------------------------------------------------------------------------- -template< class V, class C, class R, class S, class VC, class B > -const typename fpa::Base::Algorithm< V, C, R, S, VC, B >:: -_TNode& fpa::Base::Algorithm< V, C, R, S, VC, B >:: -_Node( const TVertex& v ) const -{ - typename _TNodes::const_iterator vIt = this->m_Marks.find( v ); - return( vIt->second ); -} - -// ------------------------------------------------------------------------- -template< class V, class C, class R, class S, class VC, class B > -void fpa::Base::Algorithm< V, C, R, S, VC, B >:: -_InitMarks( ) -{ - this->m_Marks.clear( ); -} - -// ------------------------------------------------------------------------- -template< class V, class C, class R, class S, class VC, class B > -void fpa::Base::Algorithm< V, C, R, S, VC, B >:: -_Mark( const TVertex& v, const _TNode& node ) -{ - this->m_Marks[ v ] = node; -} - -// ------------------------------------------------------------------------- -template< class V, class C, class R, class S, class VC, class B > -void fpa::Base::Algorithm< V, C, R, S, VC, B >:: -_InitQueue( ) -{ - this->_QueueClear( ); - for( - typename _TNodes::const_iterator sIt = this->m_Seeds.begin( ); - sIt != this->m_Seeds.end( ); - sIt++ - ) - { - this->_QueuePush( sIt->first, sIt->second ); - this->_Mark( sIt->first, sIt->second ); - - } // rof -} - -#endif // __FPA__BASE__ALGORITHM__HXX__ - -// eof - $RCSfile$ diff --git a/lib/fpa/Base/Dijkstra.h b/lib/fpa/Base/Dijkstra.h deleted file mode 100644 index 115447b..0000000 --- a/lib/fpa/Base/Dijkstra.h +++ /dev/null @@ -1,130 +0,0 @@ -#ifndef __FPA__BASE__DIJKSTRA__H__ -#define __FPA__BASE__DIJKSTRA__H__ - -#include -#include -#include - -namespace fpa -{ - namespace Base - { - /** - * Dijkstra is a front propagation algorithm that minimizes costs - * - * @param V Vertex type. - * @param C Vertex value type. - * @param R Result value type. - * @param S Space type where vertices are. - * @param VC Vertex lexicographical compare. - * @param MST Minimum spanning tree type. - * @param B Base class for this algorithm. It should be any itk-based - * filter (itk::ProcessObject). - * - */ - template< class V, class C, class R, class S, class VC, class MST, class B > - class Dijkstra - : public Algorithm< V, C, R, S, VC, B > - { - public: - typedef Dijkstra Self; - typedef Algorithm< V, C, R, S, VC, B > Superclass; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; - - typedef MST TMinimumSpanningTree; - typedef typename Superclass::TVertex TVertex; - typedef typename Superclass::TValue TValue; - typedef typename Superclass::TResult TResult; - typedef typename Superclass::TSpace TSpace; - typedef typename Superclass::TVertexCompare TVertexCompare; - - typedef typename Superclass::TStartEvent TStartEvent; - typedef typename Superclass::TStartLoopEvent TStartLoopEvent; - typedef typename Superclass::TEndEvent TEndEvent; - typedef typename Superclass::TEndLoopEvent TEndLoopEvent; - typedef typename Superclass::TAliveEvent TAliveEvent; - typedef typename Superclass::TFrontEvent TFrontEvent; - typedef typename Superclass::TFreezeEvent TFreezeEvent; - - typedef typename Superclass::TStartBacktrackingEvent TStartBacktrackingEvent; - typedef typename Superclass::TEndBacktrackingEvent TEndBacktrackingEvent; - typedef typename Superclass::TBacktrackingEvent TBacktrackingEvent; - - protected: - typedef typename Superclass::_TVertices _TVertices; - typedef typename Superclass::_TCollision _TCollision; - typedef typename Superclass::_TCollisionsRow _TCollisionsRow; - typedef typename Superclass::_TCollisions _TCollisions; - typedef typename Superclass::_TNode _TNode; - typedef typename Superclass::_TNodes _TNodes; - - struct _TQueueNode - { - TVertex Vertex; - _TNode Node; - - // Make the min-heap behave as a max-heap - bool operator<( const _TQueueNode& other ) const - { return( other.Node.Result < this->Node.Result ); } - }; - typedef std::vector< _TQueueNode > _TQueue; - - public: - itkTypeMacro( Dijkstra, Algorithm ); - - itkBooleanMacro( LocalCosts ); - itkBooleanMacro( FillNodeQueue ); - itkGetConstMacro( LocalCosts, bool ); - itkGetConstMacro( FillNodeQueue, bool ); - itkSetMacro( LocalCosts, bool ); - itkSetMacro( FillNodeQueue, bool ); - - public: - TMinimumSpanningTree* GetMinimumSpanningTree( ); - const TMinimumSpanningTree* GetMinimumSpanningTree( ) const; - void GraftMinimumSpanningTree( itk::DataObject* obj ); - - protected: - Dijkstra( ); - virtual ~Dijkstra( ); - - virtual TResult _Cost( const TVertex& v, const TVertex& p ) const = 0; - - virtual void _BeforeGenerateData( ) ITK_OVERRIDE; - - // Results-related abstract methods - virtual bool _ComputeNeighborResult( - TResult& result, const TVertex& neighbor, const TVertex& parent - ) const ITK_OVERRIDE; - virtual void _SetResult( const TVertex& v, const _TNode& n ) ITK_OVERRIDE; - - // Queue-related abstract methods - virtual bool _IsQueueEmpty( ) const ITK_OVERRIDE; - virtual void _QueuePush( const TVertex& v, const _TNode& n ) ITK_OVERRIDE; - virtual void _QueuePop( TVertex& v, _TNode& n ) ITK_OVERRIDE; - virtual void _QueueClear( ) ITK_OVERRIDE; - - private: - // Purposely not implemented - Dijkstra( const Self& other ); - Self& operator=( const Self& other ); - - protected: - bool m_LocalCosts; - bool m_FillNodeQueue; - _TQueue m_Queue; - unsigned int m_MSTIdx; - }; - - } // ecapseman - -} // ecapseman - -#ifndef ITK_MANUAL_INSTANTIATION -#include -#endif // ITK_MANUAL_INSTANTIATION - -#endif // __FPA__BASE__DIJKSTRA__H__ - -// eof - $RCSfile$ diff --git a/lib/fpa/Base/Dijkstra.hxx b/lib/fpa/Base/Dijkstra.hxx deleted file mode 100644 index bad348b..0000000 --- a/lib/fpa/Base/Dijkstra.hxx +++ /dev/null @@ -1,145 +0,0 @@ -#ifndef __FPA__BASE__DIJKSTRA__HXX__ -#define __FPA__BASE__DIJKSTRA__HXX__ - -#include - -// ------------------------------------------------------------------------- -template< class V, class C, class R, class S, class VC, class MST, class B > -typename fpa::Base::Dijkstra< V, C, R, S, VC, MST, B >:: -TMinimumSpanningTree* fpa::Base::Dijkstra< V, C, R, S, VC, MST, B >:: -GetMinimumSpanningTree( ) -{ - return( - dynamic_cast< TMinimumSpanningTree* >( - this->itk::ProcessObject::GetOutput( this->m_MSTIdx ) - ) - ); -} - -// ------------------------------------------------------------------------- -template< class V, class C, class R, class S, class VC, class MST, class B > -const typename fpa::Base::Dijkstra< V, C, R, S, VC, MST, B >:: -TMinimumSpanningTree* fpa::Base::Dijkstra< V, C, R, S, VC, MST, B >:: -GetMinimumSpanningTree( ) const -{ - return( - dynamic_cast< const TMinimumSpanningTree* >( - this->itk::ProcessObject::GetOutput( this->m_MSTIdx ) - ) - ); -} - -// ------------------------------------------------------------------------- -template< class V, class C, class R, class S, class VC, class MST, class B > -void fpa::Base::Dijkstra< V, C, R, S, VC, MST, B >:: -GraftMinimumSpanningTree( itk::DataObject* obj ) -{ - TMinimumSpanningTree* mst = dynamic_cast< TMinimumSpanningTree* >( obj ); - if( mst != NULL ) - this->GraftNthOutput( this->m_MSTIdx, mst ); -} - -// ------------------------------------------------------------------------- -template< class V, class C, class R, class S, class VC, class MST, class B > -fpa::Base::Dijkstra< V, C, R, S, VC, MST, B >:: -Dijkstra( ) - : Superclass( ), - m_LocalCosts( false ), - m_FillNodeQueue( false ) -{ - this->m_MSTIdx = this->GetNumberOfRequiredOutputs( ); - this->SetNumberOfRequiredOutputs( this->m_MSTIdx + 1 ); - this->itk::ProcessObject::SetNthOutput( - this->m_MSTIdx, TMinimumSpanningTree::New( ) - ); -} - -// ------------------------------------------------------------------------- -template< class V, class C, class R, class S, class VC, class MST, class B > -fpa::Base::Dijkstra< V, C, R, S, VC, MST, B >:: -~Dijkstra( ) -{ -} - -// ------------------------------------------------------------------------- -template< class V, class C, class R, class S, class VC, class MST, class B > -void fpa::Base::Dijkstra< V, C, R, S, VC, MST, B >:: -_BeforeGenerateData( ) -{ - this->Superclass::_BeforeGenerateData( ); - this->GetMinimumSpanningTree( )->SetFillNodeQueue( this->m_FillNodeQueue ); -} - -// ------------------------------------------------------------------------- -template< class V, class C, class R, class S, class VC, class MST, class B > -bool fpa::Base::Dijkstra< V, C, R, S, VC, MST, B >:: -_ComputeNeighborResult( - TResult& result, const TVertex& neighbor, const TVertex& parent - ) const -{ - result = this->_Cost( neighbor, parent ); - result *= TResult( this->_Distance( neighbor, parent ) ); - - // WARNING: Dijkstra does not work on negative values! - if( result >= TResult( 0 ) ) - { - _TNode pn = this->_Node( parent ); - if( pn.Label == Self::AliveLabel && !this->m_LocalCosts ) - result += pn.Result; - return( true ); - } - else - return( false ); -} - -// ------------------------------------------------------------------------- -template< class V, class C, class R, class S, class VC, class MST, class B > -void fpa::Base::Dijkstra< V, C, R, S, VC, MST, B >:: -_SetResult( const TVertex& v, const _TNode& n ) -{ - this->GetMinimumSpanningTree( )->SetNode( v, n.Parent, n.FrontId, n.Result ); -} - -// ------------------------------------------------------------------------- -template< class V, class C, class R, class S, class VC, class MST, class B > -bool fpa::Base::Dijkstra< V, C, R, S, VC, MST, B >:: -_IsQueueEmpty( ) const -{ - return( this->m_Queue.empty( ) ); -} - -// ------------------------------------------------------------------------- -template< class V, class C, class R, class S, class VC, class MST, class B > -void fpa::Base::Dijkstra< V, C, R, S, VC, MST, B >:: -_QueuePush( const TVertex& v, const _TNode& n ) -{ - _TQueueNode qn; - qn.Vertex = v; - qn.Node = n; - this->m_Queue.push_back( qn ); - std::push_heap( this->m_Queue.begin( ), this->m_Queue.end( ) ); -} - -// ------------------------------------------------------------------------- -template< class V, class C, class R, class S, class VC, class MST, class B > -void fpa::Base::Dijkstra< V, C, R, S, VC, MST, B >:: -_QueuePop( TVertex& v, _TNode& n ) -{ - _TQueueNode qn = this->m_Queue.front( ); - std::pop_heap( this->m_Queue.begin( ), this->m_Queue.end( ) ); - this->m_Queue.pop_back( ); - v = qn.Vertex; - n = qn.Node; -} - -// ------------------------------------------------------------------------- -template< class V, class C, class R, class S, class VC, class MST, class B > -void fpa::Base::Dijkstra< V, C, R, S, VC, MST, B >:: -_QueueClear( ) -{ - this->m_Queue.clear( ); -} - -#endif // __FPA__BASE__DIJKSTRA__HXX__ - -// eof - $RCSfile$ diff --git a/lib/fpa/Base/Events.h b/lib/fpa/Base/Events.h deleted file mode 100644 index 09f0637..0000000 --- a/lib/fpa/Base/Events.h +++ /dev/null @@ -1,103 +0,0 @@ -#ifndef __FPA__BASE__EVENTS__H__ -#define __FPA__BASE__EVENTS__H__ - -#include -#include - -// ------------------------------------------------------------------------- -#define fpa_Base_NewEvent( name ) \ - class name \ - : public BaseEvent \ - { \ - public: \ - name( ) : BaseEvent( ) { } \ - virtual ~name( ) { } \ - const char* GetEventName( ) const \ - { return( "fpa::Base::##name" ); } \ - bool CheckEvent( const itk::EventObject* e ) const \ - { return( dynamic_cast< const name* >( e ) != NULL ); } \ - itk::EventObject* MakeObject( ) const \ - { return( new name( ) ); } \ - }; - -// ------------------------------------------------------------------------- -#define fpa_Base_NewEventWithVertex( name, type ) \ - class name \ - : public BaseEventWithVertex< type > \ - { \ - public: \ - name( ) : BaseEventWithVertex< type >( ) { } \ - name( const type& v, long fid ) \ - : BaseEventWithVertex< type >( v, fid ) { } \ - virtual ~name( ) { } \ - const char* GetEventName( ) const \ - { return( "fpa::Base::##name" ); } \ - bool CheckEvent( const itk::EventObject* e ) const \ - { return( dynamic_cast< const name* >( e ) != NULL ); } \ - itk::EventObject* MakeObject( ) const \ - { return( new name( ) ); } \ - }; - -namespace fpa -{ - namespace Base - { - /** - */ - class BaseEvent - : public itk::AnyEvent - { - public: - BaseEvent( ) - : itk::AnyEvent( ) - { } - virtual ~BaseEvent( ) - { } - const char* GetEventName( ) const - { return( "fpa::Base::BaseEvent" ); } - bool CheckEvent( const itk::EventObject* e ) const - { return( dynamic_cast< const BaseEvent* >( e ) != NULL ); } - itk::EventObject* MakeObject( ) const - { return( new BaseEvent( ) ); } - }; - - /** - */ - template< class V > - class BaseEventWithVertex - : public BaseEvent - { - public: - BaseEventWithVertex( ) - : BaseEvent( ) - { } - BaseEventWithVertex( const V& v, long fid ) - : BaseEvent( ), - Vertex( v ), - FrontId( fid ) - { } - virtual ~BaseEventWithVertex( ) - { } - const char* GetEventName( ) const - { return( "fpa::Base::BaseEventWithVertex" ); } - bool CheckEvent( const itk::EventObject* e ) const - { - return( - dynamic_cast< const BaseEventWithVertex< V >* >( e ) != NULL - ); - } - itk::EventObject* MakeObject( ) const - { return( new BaseEventWithVertex< V >( ) ); } - - public: - V Vertex; - long FrontId; - }; - - } // ecapseman - -} // ecapseman - -#endif // __FPA__BASE__EVENTS__H__ - -// eof - $RCSfile$ diff --git a/lib/fpa/Base/ExtractEndPointsAndBifurcationsFromMinimumSpanningTree.h b/lib/fpa/Base/ExtractEndPointsAndBifurcationsFromMinimumSpanningTree.h deleted file mode 100644 index 9a12904..0000000 --- a/lib/fpa/Base/ExtractEndPointsAndBifurcationsFromMinimumSpanningTree.h +++ /dev/null @@ -1,93 +0,0 @@ -#ifndef __FPA__BASE__EXTRACTENDPOINTSANDBIFURCATIONSFROMMINIMUMSPANNINGTREE__H__ -#define __FPA__BASE__EXTRACTENDPOINTSANDBIFURCATIONSFROMMINIMUMSPANNINGTREE__H__ - -#include -#include -#include -#include -#include - -namespace fpa -{ - namespace Base - { - /** - */ - template< class _TMST > - class ExtractEndPointsAndBifurcationsFromMinimumSpanningTree - : public itk::ProcessObject - { - public: - typedef ExtractEndPointsAndBifurcationsFromMinimumSpanningTree Self; - typedef itk::ProcessObject Superclass; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; - - typedef _TMST TMinimumSpanningTree; - typedef typename _TMST::TVertex TVertex; - typedef std::pair< TVertex, TVertex > TBranch; - typedef std::vector< TBranch > TBranches; - - typedef - cpExtensions::DataStructures::ImageIndexesContainer< TVertex::Dimension > - TVertices; - - public: - itkTypeMacro( - ExtractEndPointsAndBifurcationsFromMinimumSpanningTree, - itk::ProcessObject - ); - - public: - const TMinimumSpanningTree* GetMinimumSpanningTree( ); - void SetMinimumSpanningTree( TMinimumSpanningTree* mst ); - - TVertices* GetEndPoints( ); - TVertices* GetBifurcations( ); - TVertices* GetCollisions( ); - - virtual void Update( ) ITK_OVERRIDE - { - this->GenerateData( ); - } - - protected: - ExtractEndPointsAndBifurcationsFromMinimumSpanningTree( ); - virtual ~ExtractEndPointsAndBifurcationsFromMinimumSpanningTree( ); - - virtual void GenerateData( ) ITK_OVERRIDE; - - virtual void _MarkSkeleton( - const TVertex& v, const unsigned long& l - ) = 0; - virtual void _MarkSphere( - const TVertex& v, - const double& r, - const unsigned long& l - ) = 0; - virtual unsigned long _Mark( const TVertex& v ) = 0; - virtual unsigned long _SkeletonMark( const TVertex& v ) = 0; - virtual double _Radius( const TVertex& v ) = 0; - - virtual void _Tmp( ) = 0; - - private: - // Purposely not implemented - ExtractEndPointsAndBifurcationsFromMinimumSpanningTree( const Self& other ); - Self& operator=( const Self& other ); - - protected: - TBranches m_Branches; - }; - - } // ecapseman - -} // ecapseman - -#ifndef ITK_MANUAL_INSTANTIATION -#include -#endif // ITK_MANUAL_INSTANTIATION - -#endif // __FPA__BASE__EXTRACTENDPOINTSANDBIFURCATIONSFROMMINIMUMSPANNINGTREE__H__ - -// eof - $RCSfile$ diff --git a/lib/fpa/Base/ExtractEndPointsAndBifurcationsFromMinimumSpanningTree.hxx b/lib/fpa/Base/ExtractEndPointsAndBifurcationsFromMinimumSpanningTree.hxx deleted file mode 100644 index 82debb4..0000000 --- a/lib/fpa/Base/ExtractEndPointsAndBifurcationsFromMinimumSpanningTree.hxx +++ /dev/null @@ -1,222 +0,0 @@ -#ifndef __FPA__BASE__EXTRACTENDPOINTSANDBIFURCATIONSFROMMINIMUMSPANNINGTREE__HXX__ -#define __FPA__BASE__EXTRACTENDPOINTSANDBIFURCATIONSFROMMINIMUMSPANNINGTREE__HXX__ - -#include -#include - -// ------------------------------------------------------------------------- -template< class _TMST > -const typename -fpa::Base::ExtractEndPointsAndBifurcationsFromMinimumSpanningTree< _TMST >:: -TMinimumSpanningTree* -fpa::Base::ExtractEndPointsAndBifurcationsFromMinimumSpanningTree< _TMST >:: -GetMinimumSpanningTree( ) -{ - return( - dynamic_cast< const _TMST* >( this->itk::ProcessObject::GetInput( 0 ) ) - ); -} - -// ------------------------------------------------------------------------- -template< class _TMST > -void -fpa::Base::ExtractEndPointsAndBifurcationsFromMinimumSpanningTree< _TMST >:: -SetMinimumSpanningTree( TMinimumSpanningTree* mst ) -{ - this->itk::ProcessObject::SetNthInput( 0, const_cast< _TMST* >( mst ) ); -} - -// ------------------------------------------------------------------------- -template< class _TMST > -typename -fpa::Base::ExtractEndPointsAndBifurcationsFromMinimumSpanningTree< _TMST >:: -TVertices* -fpa::Base::ExtractEndPointsAndBifurcationsFromMinimumSpanningTree< _TMST >:: -GetEndPoints( ) -{ - return( - dynamic_cast< TVertices* >( this->itk::ProcessObject::GetOutput( 0 ) ) - ); -} - -// ------------------------------------------------------------------------- -template< class _TMST > -typename -fpa::Base::ExtractEndPointsAndBifurcationsFromMinimumSpanningTree< _TMST >:: -TVertices* -fpa::Base::ExtractEndPointsAndBifurcationsFromMinimumSpanningTree< _TMST >:: -GetBifurcations( ) -{ - return( - dynamic_cast< TVertices* >( this->itk::ProcessObject::GetOutput( 1 ) ) - ); -} - -// ------------------------------------------------------------------------- -template< class _TMST > -typename -fpa::Base::ExtractEndPointsAndBifurcationsFromMinimumSpanningTree< _TMST >:: -TVertices* -fpa::Base::ExtractEndPointsAndBifurcationsFromMinimumSpanningTree< _TMST >:: -GetCollisions( ) -{ - return( - dynamic_cast< TVertices* >( this->itk::ProcessObject::GetOutput( 2 ) ) - ); -} - -// ------------------------------------------------------------------------- -template< class _TMST > -fpa::Base::ExtractEndPointsAndBifurcationsFromMinimumSpanningTree< _TMST >:: -ExtractEndPointsAndBifurcationsFromMinimumSpanningTree( ) - : Superclass( ) -{ - this->SetNumberOfRequiredInputs( 1 ); - this->SetNumberOfRequiredOutputs( 4 ); - typename TVertices::Pointer ep = TVertices::New( ); - typename TVertices::Pointer bf = TVertices::New( ); - typename TVertices::Pointer co = TVertices::New( ); - this->itk::ProcessObject::SetNthOutput( 0, ep.GetPointer( ) ); - this->itk::ProcessObject::SetNthOutput( 1, bf.GetPointer( ) ); - this->itk::ProcessObject::SetNthOutput( 2, co.GetPointer( ) ); -} - -// ------------------------------------------------------------------------- -template< class _TMST > -fpa::Base::ExtractEndPointsAndBifurcationsFromMinimumSpanningTree< _TMST >:: -~ExtractEndPointsAndBifurcationsFromMinimumSpanningTree( ) -{ -} - -// ------------------------------------------------------------------------- -template< class _TMST > -void -fpa::Base::ExtractEndPointsAndBifurcationsFromMinimumSpanningTree< _TMST >:: -GenerateData( ) -{ - typedef std::multimap< double, TVertex > _TQueue; - typedef std::pair< TVertex, TVertex > _TBranch; - typedef std::vector< _TBranch > _TBranches; - typedef typename _TQueue::value_type _TQueueValue; - - // 0. Useful objects and values - auto mst = this->GetMinimumSpanningTree( ); - auto endpoints = this->GetEndPoints( ); - auto bifurcations = this->GetBifurcations( ); - auto collisions = this->GetCollisions( ); - endpoints->Get( ).clear( ); - bifurcations->Get( ).clear( ); - collisions->Get( ).clear( ); - this->m_Branches.clear( ); - - // 1. Get priority queue - auto& q = mst->GetNodeQueue( ); - - // 2. Main loop: iterate in inverse order (max-priority) - unsigned long label = 0; - for( auto qIt = q.rbegin( ); qIt != q.rend( ); ++qIt ) - { - auto gCost = qIt->first; - auto vertex = qIt->second; - - // 2.1. Check if the vertex has already been visited - if( this->_Mark( vertex ) > 0 || this->_SkeletonMark( vertex ) > 0 ) - continue; - - // 2.2. Get path from front seed - auto path = mst->GetPath( vertex ); - - // 2.3. Prepare new branch data and prepare new end-point - label++; - this->m_Branches.push_back( _TBranch( vertex, vertex ) ); - endpoints->Get( ).push_back( vertex ); - - // 2.4. Backtracking - auto pIt = path.begin( ); - TVertex last_collision; - bool inCollision = false; - while( pIt != path.end( ) ) - { - auto mark = this->_SkeletonMark( *pIt ); - if( mark > 0 && mark != label ) - { - // 2.4.1. A bifurcation has been reached - bifurcations->Get( ).push_back( *pIt ); - - // Reorder labels - auto coll_branch = this->m_Branches[ mark - 1 ]; - this->m_Branches[ mark - 1 ] = _TBranch( coll_branch.first, *pIt ); - this->m_Branches[ label - 1 ] = _TBranch( qIt->second, *pIt ); - this->m_Branches.push_back( _TBranch( *pIt, coll_branch.second ) ); - - // Mark skeleton (b,coll_branch_second) with the new label - label++; - while( *pIt != coll_branch.second && pIt != path.end( ) ) - { - this->_MarkSkeleton( *pIt, label ); - pIt++; - - } // elihw - if( pIt != path.end( ) ) - this->_MarkSkeleton( *pIt, label ); - - // Force inner loop termination - pIt = path.end( ); - } - else - { - if( !inCollision ) - { - mark = this->_Mark( *pIt ); - if( mark > 0 && mark != label ) - { - // 2.4.2. A collision has been reached - last_collision = *pIt; - collisions->Get( ).push_back( *pIt ); - inCollision = true; - } - else - { - // 2.4.3. Just mark sphere and skeleton - double r = this->_Radius( *pIt ); - this->_MarkSkeleton( *pIt, label ); - this->_MarkSphere( *pIt, r, label ); - this->m_Branches[ label - 1 ].second = *pIt; - - // 2.4.4. Is this a seed? -> add it to endpoints - auto sIt = pIt; - sIt++; - if( sIt == path.end( ) ) - endpoints->Get( ).push_back( *pIt ); - - } // fi - - } // fi - pIt++; - - } // fi - - } // elihw - - } // rof - - // Remove illegal branches - auto dIt = this->m_Branches.begin( ); - while( dIt != this->m_Branches.end( ) ) - { - if( dIt->first == dIt->second ) - dIt = this->m_Branches.erase( dIt ); - else - dIt++; - - } // fi - - // Finish - endpoints->SetReferenceImage( mst ); - bifurcations->SetReferenceImage( mst ); - collisions->SetReferenceImage( mst ); -} - -#endif // __FPA__BASE__EXTRACTENDPOINTSANDBIFURCATIONSFROMMINIMUMSPANNINGTREE__HXX__ - -// eof - $RCSfile$ diff --git a/lib/fpa/Base/ExtractPathFromMinimumSpanningTree.h b/lib/fpa/Base/ExtractPathFromMinimumSpanningTree.h deleted file mode 100644 index 2b65112..0000000 --- a/lib/fpa/Base/ExtractPathFromMinimumSpanningTree.h +++ /dev/null @@ -1,74 +0,0 @@ -#ifndef __FPA__BASE__EXTRACTPATHFROMMINIMUMSPANNINGTREE__H__ -#define __FPA__BASE__EXTRACTPATHFROMMINIMUMSPANNINGTREE__H__ - -#include -#include -#include - -namespace fpa -{ - namespace Base - { - /** - */ - template< class T > - class ExtractPathFromMinimumSpanningTree - : public itk::ProcessObject - { - public: - typedef ExtractPathFromMinimumSpanningTree Self; - typedef itk::ProcessObject Superclass; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; - - typedef T TMinimumSpanningTree; - typedef typename T::TVertex TVertex; - typedef - cpExtensions::DataStructures::PolyLineParametricPath< TVertex::Dimension > - TPath; - typedef std::pair< TVertex, TVertex > _TBranch; - typedef std::vector< _TBranch > _TBranches; - - public: - itkNewMacro( Self ); - itkTypeMacro( ExtractPathFromMinimumSpanningTree, itk::ProcessObject ); - - itkGetConstMacro( Vertex0, TVertex ); - itkGetConstMacro( Vertex1, TVertex ); - - itkSetMacro( Vertex0, TVertex ); - itkSetMacro( Vertex1, TVertex ); - - public: - const T* GetInput( ) const; - void SetInput( const T* tree ); - - TPath* GetOutput( ); - - protected: - ExtractPathFromMinimumSpanningTree( ); - virtual ~ExtractPathFromMinimumSpanningTree( ); - - virtual void GenerateData( ) ITK_OVERRIDE; - - private: - // Purposely not implemented - ExtractPathFromMinimumSpanningTree( const Self& other ); - Self& operator=( const Self& other ); - - protected: - TVertex m_Vertex0; - TVertex m_Vertex1; - }; - - } // ecapseman - -} // ecapseman - -#ifndef ITK_MANUAL_INSTANTIATION -#include -#endif // ITK_MANUAL_INSTANTIATION - -#endif // __FPA__BASE__EXTRACTPATHFROMMINIMUMSPANNINGTREE__H__ - -// eof - $RCSfile$ diff --git a/lib/fpa/Base/ExtractPathFromMinimumSpanningTree.hxx b/lib/fpa/Base/ExtractPathFromMinimumSpanningTree.hxx deleted file mode 100644 index 400642c..0000000 --- a/lib/fpa/Base/ExtractPathFromMinimumSpanningTree.hxx +++ /dev/null @@ -1,70 +0,0 @@ -#ifndef __FPA__BASE__EXTRACTPATHFROMMINIMUMSPANNINGTREE__HXX__ -#define __FPA__BASE__EXTRACTPATHFROMMINIMUMSPANNINGTREE__HXX__ - -// ------------------------------------------------------------------------- -template< class T > -const T* fpa::Base::ExtractPathFromMinimumSpanningTree< T >:: -GetInput( ) const -{ - return( - dynamic_cast< const T* >( this->itk::ProcessObject::GetInput( 0 ) ) - ); -} - -// ------------------------------------------------------------------------- -template< class T > -void fpa::Base::ExtractPathFromMinimumSpanningTree< T >:: -SetInput( const T* tree ) -{ - this->itk::ProcessObject::SetNthInput( 0, const_cast< T* >( tree ) ); -} - -// ------------------------------------------------------------------------- -template< class T > -typename fpa::Base::ExtractPathFromMinimumSpanningTree< T >:: -TPath* fpa::Base::ExtractPathFromMinimumSpanningTree< T >:: -GetOutput( ) -{ - return( - itkDynamicCastInDebugMode< TPath* >( this->GetPrimaryOutput( ) ) - ); -} - -// ------------------------------------------------------------------------- -template< class T > -fpa::Base::ExtractPathFromMinimumSpanningTree< T >:: -ExtractPathFromMinimumSpanningTree( ) - : Superclass( ) -{ - this->itk::ProcessObject::SetNumberOfRequiredInputs( 1 ); - - typename TPath::Pointer out = TPath::New( ); - this->itk::ProcessObject::SetNumberOfRequiredOutputs( 1 ); - this->itk::ProcessObject::SetNthOutput( 0, out.GetPointer( ) ); -} - -// ------------------------------------------------------------------------- -template< class T > -fpa::Base::ExtractPathFromMinimumSpanningTree< T >:: -~ExtractPathFromMinimumSpanningTree( ) -{ -} - -// ------------------------------------------------------------------------- -template< class T > -void fpa::Base::ExtractPathFromMinimumSpanningTree< T >:: -GenerateData( ) -{ - auto tree = this->GetInput( ); - auto path = this->GetOutput( ); - - auto lst = tree->GetPath( this->m_Vertex0, this->m_Vertex1 ); - path->Initialize( ); - for( auto i = lst.begin( ); i != lst.end( ); ++i ) - path->AddVertex( *i ); - path->SetReferenceImage( tree ); -} - -#endif // __FPA__BASE__EXTRACTPATHFROMMINIMUMSPANNINGTREE__HXX__ - -// eof - $RCSfile$ diff --git a/lib/fpa/Base/FastMarching.h b/lib/fpa/Base/FastMarching.h deleted file mode 100644 index b615f8e..0000000 --- a/lib/fpa/Base/FastMarching.h +++ /dev/null @@ -1,78 +0,0 @@ -#ifndef __FPA__BASE__FASTMARCHING__H__ -#define __FPA__BASE__FASTMARCHING__H__ - -#include - -namespace fpa -{ - namespace Base - { - /** - */ - template< class V, class C, class VV, class VC, class B > - class FastMarching - : public Dijkstra< V, C, VV, VC, B > - { - public: - // Templated types - typedef V TVertex; - typedef C TCost; - typedef VV TVertexValue; - typedef B TBaseFilter; - - // Standard class typdedefs - typedef FastMarching Self; - typedef Dijkstra< V, C, VV, VC, B > Superclass; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; - - typedef typename Superclass::TResult TResult; - typedef typename Superclass::TTraits TTraits; - - protected: - typedef typename Superclass::_TFrontId _TFrontId; - typedef typename Superclass::_TNode _TNode; - typedef typename Superclass::_TNodes _TNodes; - struct _TNodeEikonalSort - { - bool operator()( const _TNode& a, const _TNode& b ) const - { return( a.Result < b.Result ); } - }; - - public: - itkTypeMacro( FastMarching, Dijkstra ); - - protected: - FastMarching( ); - virtual ~FastMarching( ); - - virtual bool _UpdateNeigh( _TNode& nn, const _TNode& n ); - - /** - * Eikonal solution method - * - * This method returns the computed time and a flag indicating if the - * determinant was valid. - */ - bool _SolveEikonal( double& re, const _TNode& n, const double& F ); - - private: - // Purposely not implemented - FastMarching( const Self& ); - void operator=( const Self& ); - - protected: - static const double LargestValue; - }; - - } // ecapseman - -} // ecapseman - -#ifndef ITK_MANUAL_INSTANTIATION -#include -#endif // ITK_MANUAL_INSTANTIATION - -#endif // __FPA__BASE__FASTMARCHING__H__ - -// eof - $RCSfile$ diff --git a/lib/fpa/Base/FastMarching.hxx b/lib/fpa/Base/FastMarching.hxx deleted file mode 100644 index ef1f634..0000000 --- a/lib/fpa/Base/FastMarching.hxx +++ /dev/null @@ -1,121 +0,0 @@ -#ifndef __FPA__BASE__FASTMARCHING__HXX__ -#define __FPA__BASE__FASTMARCHING__HXX__ - -#include -#include - -#include - -// --------------------------------------------------------------------- -template< class V, class C, class VV, class VC, class B > -const double fpa::Base::FastMarching< V, C, VV, VC, B >:: -LargestValue = std::numeric_limits< double >::max( ); - -// ------------------------------------------------------------------------- -template< class V, class C, class VV, class VC, class B > -fpa::Base::FastMarching< V, C, VV, VC, B >:: -FastMarching( ) - : Superclass( ) -{ -} - -// ------------------------------------------------------------------------- -template< class V, class C, class VV, class VC, class B > -fpa::Base::FastMarching< V, C, VV, VC, B >:: -~FastMarching( ) -{ -} - -// ------------------------------------------------------------------------- -template< class V, class C, class VV, class VC, class B > -bool fpa::Base::FastMarching< V, C, VV, VC, B >:: -_UpdateNeigh( _TNode& nn, const _TNode& n ) -{ - bool r = true; - if( !( this->_IsMarked( nn.Vertex ) ) ) - { - double re; - double F = double( this->_Value( nn.Vertex ) ); - r = this->_SolveEikonal( re, nn, F ); - if( r ) - { - nn.Result = TResult( re ); - nn.Cost = TCost( re ); - - } // fi - - } // fi - return( r ); -} - -// ------------------------------------------------------------------------- -template< class V, class C, class VV, class VC, class B > -bool fpa::Base::FastMarching< V, C, VV, VC, B >:: -_SolveEikonal( double& re, const _TNode& n, const double& F ) -{ - _TNodes neighs; - this->_Neighs( n, neighs ); - - // Compute interest nodes (i.e. the smallest valued in each dimension) - _TNodes minNodes; - unsigned int i = 0; - while( i < neighs.size( ) ) - { - V nm = neighs[ i++ ].Vertex; - V np = neighs[ i++ ].Vertex; - bool mm = this->_IsMarked( nm ); - bool mp = this->_IsMarked( np ); - TResult rm = this->_Result( nm ); - TResult rp = this->_Result( np ); - - _TNode Ti; - if( mm && mp ) - minNodes.push_back( - ( rm < rp )? - _TNode( nm, rm, n.FrontId ): - _TNode( np, rp, n.FrontId ) - ); - else if( !mm && mp ) - minNodes.push_back( _TNode( np, rp, n.FrontId ) ); - else if( mm && !mp ) - minNodes.push_back( _TNode( nm, rm, n.FrontId ) ); - - } // elihw - std::sort( minNodes.begin( ), minNodes.end( ), _TNodeEikonalSort( ) ); - - // Compute solution - double al = double( 0 ); - double be = double( 0 ); - double ga = double( -1 ) / ( F * F ); - re = Self::LargestValue; - - typename _TNodes::const_iterator nIt = minNodes.begin( ); - bool valid = true; - while( nIt != minNodes.end( ) && valid ) - { - if( !( re < double( nIt->Result ) ) ) - { - double d = this->_Norm( n.Vertex, nIt->Vertex ); - double s = double( 1 ) / ( d * d ); - double v = double( nIt->Result ); - - al += s; - be += v * s; - ga += v * v * s; - - double de = ( be * be ) - ( al * ga ); - valid = !( de < double( 0 ) ); - if( valid ) - re = ( be + std::sqrt( de ) ) / al; - nIt++; - } - else - nIt = minNodes.end( ); - - } // elihw - return( valid ); -} - -#endif // __FPA__BASE__FASTMARCHING__HXX__ - -// eof - $RCSfile$ diff --git a/lib/fpa/Base/Functors/InvertCostFunction.h b/lib/fpa/Base/Functors/InvertCostFunction.h deleted file mode 100644 index 22644ad..0000000 --- a/lib/fpa/Base/Functors/InvertCostFunction.h +++ /dev/null @@ -1,73 +0,0 @@ -#ifndef __FPA__BASE__FUNCTORS__INVERTCOSTFUNCTION__H__ -#define __FPA__BASE__FUNCTORS__INVERTCOSTFUNCTION__H__ - -#include -#include - -namespace fpa -{ - namespace Base - { - namespace Functors - { - /** - */ - template< class C > - class InvertCostFunction - : public itk::FunctionBase< C, C > - { - public: - /// Type-related and pointers - typedef InvertCostFunction Self; - typedef itk::FunctionBase< C, C > Superclass; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; - - public: - itkNewMacro( Self ); - itkTypeMacro( InvertCostFunction, itkFunctionBase ); - - itkGetConstMacro( Alpha, C ); - itkGetConstMacro( Beta, C ); - - itkSetMacro( Alpha, C ); - itkSetMacro( Beta, C ); - - public: - virtual C Evaluate( const C& input ) const ITK_OVERRIDE - { - C a = std::pow( input, this->m_Alpha ); - if( input >= C( 0 ) ) - return( std::pow( C( 1 ) / ( C( 1 ) + a ), this->m_Beta ) ); - else - return( std::pow( C( -1 ) / ( C( 1 ) - a ), this->m_Beta ) ); - } - - protected: - InvertCostFunction( ) - : Superclass( ), - m_Alpha( C( 1 ) ), - m_Beta( C( 1 ) ) - { } - virtual ~InvertCostFunction( ) - { } - - private: - // Purposely not implemented - InvertCostFunction( const Self& ); - void operator=( const Self& ); - - protected: - C m_Alpha; - C m_Beta; - }; - - } // ecapseman - - } // ecapseman - -} // ecapseman - -#endif // __FPA__BASE__FUNCTORS__INVERTCOSTFUNCTION__H__ - -// eof - $RCSfile$ diff --git a/lib/fpa/Base/Functors/TautologyFunction.h b/lib/fpa/Base/Functors/TautologyFunction.h deleted file mode 100644 index 82498d0..0000000 --- a/lib/fpa/Base/Functors/TautologyFunction.h +++ /dev/null @@ -1,62 +0,0 @@ -#ifndef __FPA__BASE__FUNCTORS__TAUTOLOGYFUNCTION__H__ -#define __FPA__BASE__FUNCTORS__TAUTOLOGYFUNCTION__H__ - -#include - -namespace fpa -{ - namespace Base - { - namespace Functors - { - /** - */ - template< class S, class V > - class TautologyFunction - : public itk::FunctionBase< V, bool > - { - public: - typedef TautologyFunction Self; - typedef itk::FunctionBase< V, bool > Superclass; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; - - typedef S TSpace; - typedef V TVertex; - - public: - itkNewMacro( Self ); - itkTypeMacro( TautologyFunction, itkFunctionBase ); - - itkGetConstObjectMacro( Space, TSpace ); - itkSetConstObjectMacro( Space, TSpace ); - - public: - virtual bool Evaluate( const TVertex& input ) const ITK_OVERRIDE - { return( true ); } - - protected: - TautologyFunction( ) - : Superclass( ) - { } - virtual ~TautologyFunction( ) - { } - - private: - // Purposely not implemented - TautologyFunction( const Self& ); - void operator=( const Self& ); - - protected: - typename TSpace::ConstPointer m_Space; - }; - - } // ecapseman - - } // ecapseman - -} // ecapseman - -#endif // __FPA__BASE__FUNCTORS__TAUTOLOGYFUNCTION__H__ - -// eof - $RCSfile$ diff --git a/lib/fpa/Base/ImageSkeleton.h b/lib/fpa/Base/ImageSkeleton.h deleted file mode 100644 index d7ca832..0000000 --- a/lib/fpa/Base/ImageSkeleton.h +++ /dev/null @@ -1,70 +0,0 @@ -#ifndef __FPA__BASE__IMAGESKELETON__H__ -#define __FPA__BASE__IMAGESKELETON__H__ - -#include -#include - -namespace fpa -{ - namespace Base - { - /** - */ - template< class _TMST > - class ImageSkeleton - : public itk::SimpleDataObjectDecorator< std::map< typename _TMST::TVertex, std::map< typename _TMST::TVertex, typename cpExtensions::DataStructures::PolyLineParametricPath< _TMST::TVertex::Dimension >::Pointer, typename _TMST::TVertex::LexicographicCompare >, typename _TMST::TVertex::LexicographicCompare > > - { - public: - // Base types - typedef _TMST TMinimumSpanningTree; - typedef typename _TMST::TVertex TVertex; - typedef typename TVertex::LexicographicCompare TVertexCmp; - typedef - cpExtensions::DataStructures::PolyLineParametricPath< TVertex::Dimension > - TPath; - typedef - std::map< TVertex, typename TPath::Pointer, TVertexCmp > - TSkeletonRow; - typedef std::map< TVertex, TSkeletonRow, TVertexCmp > TSkeleton; - - // ITK-related types - typedef ImageSkeleton Self; - typedef itk::SimpleDataObjectDecorator< TSkeleton > Superclass; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; - - public: - itkNewMacro( Self ); - itkTypeMacro( ImageSkeleton, itk::SimpleDataObjectDecorator ); - - itkGetConstObjectMacro( MinimumSpanningTree, _TMST ); - itkSetConstObjectMacro( MinimumSpanningTree, _TMST ); - - public: - void AddBranch( const TVertex& a, const TVertex& b ); - const TPath* GetBranch( const TVertex& a, const TVertex& b ) const; - - protected: - ImageSkeleton( ); - virtual ~ImageSkeleton( ); - - private: - // Purposely not implemented - ImageSkeleton( const Self& other ); - Self& operator=( const Self& other ); - - protected: - typename _TMST::ConstPointer m_MinimumSpanningTree; - }; - - } // ecapseman - -} // ecapseman - -#ifndef ITK_MANUAL_INSTANTIATION -#include -#endif // ITK_MANUAL_INSTANTIATION - -#endif // __FPA__BASE__IMAGESKELETON__H__ - -// eof - $RCSfile$ diff --git a/lib/fpa/Base/ImageSkeleton.hxx b/lib/fpa/Base/ImageSkeleton.hxx deleted file mode 100644 index 747d9de..0000000 --- a/lib/fpa/Base/ImageSkeleton.hxx +++ /dev/null @@ -1,84 +0,0 @@ -#ifndef __FPA__BASE__IMAGESKELETON__HXX__ -#define __FPA__BASE__IMAGESKELETON__HXX__ - -// ------------------------------------------------------------------------- -template< class _TMST > -void fpa::Base::ImageSkeleton< _TMST >:: -AddBranch( const TVertex& a, const TVertex& b ) -{ - if( this->m_MinimumSpanningTree.IsNull( ) ) - return; - - // Check if the branch already exists - bool found = false; - auto aIt = this->Get( ).find( a ); - if( aIt != this->Get( ).end( ) ) - found = ( aIt->second.find( b ) != aIt->second.end( ) ); - if( found ) - return; - - // Create path - auto vertices = this->m_MinimumSpanningTree->GetPath( a, b ); - typename TPath::Pointer path = TPath::New( ); - for( auto vIt = vertices.begin( ); vIt != vertices.end( ); ++vIt ) - path->AddVertex( *vIt ); - - // Assign path vertices - path->SetReferenceImage( this->m_MinimumSpanningTree ); - - typedef typename TSkeleton::value_type _T1; - typedef typename TSkeletonRow::value_type _T2; - - TSkeleton& sk = this->Get( ); - auto sIt = sk.find( a ); - if( sIt == sk.end( ) ) - { - sIt = sk.insert( _T1( a, TSkeletonRow( ) ) ).first; - this->Modified( ); - - } // fi - if( sIt->second.find( b ) == sIt->second.end( ) ) - { - sIt->second.insert( _T2( b, path ) ); - this->Modified( ); - - } // fi -} - -// ------------------------------------------------------------------------- -template< class _TMST > -const typename fpa::Base::ImageSkeleton< _TMST >:: -TPath* fpa::Base::ImageSkeleton< _TMST >:: -GetBranch( const TVertex& a, const TVertex& b ) const -{ - auto aIt = this->Get( ).find( a ); - if( aIt != this->Get( ).end( ) ) - { - auto bIt = aIt->second.find( b ); - if( bIt != aIt->second.end( ) ) - return( bIt->second.GetPointer( ) ); - else - return( NULL ); - } - else - return( NULL ); -} - -// ------------------------------------------------------------------------- -template< class _TMST > -fpa::Base::ImageSkeleton< _TMST >:: -ImageSkeleton( ) - : Superclass( ) -{ -} - -// ------------------------------------------------------------------------- -template< class _TMST > -fpa::Base::ImageSkeleton< _TMST >:: -~ImageSkeleton( ) -{ -} - -#endif // __FPA__BASE__IMAGESKELETON__HXX__ - -// eof - $RCSfile$ diff --git a/lib/fpa/Base/IncrementalRegionGrow.h b/lib/fpa/Base/IncrementalRegionGrow.h deleted file mode 100644 index 7104777..0000000 --- a/lib/fpa/Base/IncrementalRegionGrow.h +++ /dev/null @@ -1,87 +0,0 @@ -#ifndef __FPA__BASE__INCREMENTALREGIONGROW__H__ -#define __FPA__BASE__INCREMENTALREGIONGROW__H__ - -#include -#include -#include - -namespace fpa -{ - namespace Base - { - /** - * Region grow is a front propagation with no costs. - */ - template< class V, class R, class VV, class VC, class B > - class IncrementalRegionGrow - : public RegionGrow< V, R, VV, VC, B > - { - public: - /// Standard class typdedefs - typedef IncrementalRegionGrow Self; - typedef RegionGrow< V, R, VV, VC, B > Superclass; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; - - typedef typename Superclass::TVertex TVertex; - typedef typename Superclass::TValue TValue; - typedef typename Superclass::TResult TResult; - typedef typename Superclass::TVertexCompare TVertexCompare; - typedef typename Superclass::TGrowingFunction TGrowingFunction; - - typedef std::vector< typename TGrowingFunction::Pointer > TFunctions; - typedef std::vector< unsigned long > TVolumes; - - protected: - typedef typename Superclass::_TVertices _TVertices; - typedef typename Superclass::_TCollision _TCollision; - typedef typename Superclass::_TCollisionsRow _TCollisionsRow; - typedef typename Superclass::_TCollisions _TCollisions; - typedef typename Superclass::_TNode _TNode; - typedef typename Superclass::_TNodes _TNodes; - typedef typename Superclass::_TQueue _TQueue; - - public: - itkTypeMacro( IncrementalRegionGrow, RegionGrow ); - - public: - TGrowingFunction* GetGrowingFunction( unsigned int i ); - const TGrowingFunction* GetGrowingFunction( unsigned int i ) const; - unsigned long GetGrowingFunctionVolume( unsigned int i ) const; - unsigned int GetNumberOfGrowingFunctions( ) const; - void ClearGrowingFunctions( ); - unsigned int AddGrowingFunction( TGrowingFunction* function ); - - protected: - IncrementalRegionGrow( ); - virtual ~IncrementalRegionGrow( ); - - virtual void _BeforeGenerateData( ); - virtual void _AfterLoop( ); - virtual void _Loop( ); - virtual bool _CheckMembership( const TVertex& v ) const; - - private: - // Purposely not implemented. - IncrementalRegionGrow( const Self& ); - void operator=( const Self& ); - - protected: - mutable _TQueue m_AuxiliaryQueue; - - TFunctions m_Functions; - TVolumes m_Volumes; - unsigned int m_ActualFunction; - }; - - } // ecapseman - -} // ecapseman - -#ifndef ITK_MANUAL_INSTANTIATION -#include -#endif // ITK_MANUAL_INSTANTIATION - -#endif // __FPA__BASE__INCREMENTALREGIONGROW__H__ - -// eof - $RCSfile$ diff --git a/lib/fpa/Base/IncrementalRegionGrow.hxx b/lib/fpa/Base/IncrementalRegionGrow.hxx deleted file mode 100644 index d5d9447..0000000 --- a/lib/fpa/Base/IncrementalRegionGrow.hxx +++ /dev/null @@ -1,154 +0,0 @@ -#ifndef __FPA__BASE__INCREMENTALREGIONGROW__HXX__ -#define __FPA__BASE__INCREMENTALREGIONGROW__HXX__ - -// ------------------------------------------------------------------------- -template< class V, class R, class VV, class VC, class B > -typename fpa::Base::IncrementalRegionGrow< V, R, VV, VC, B >:: -TGrowingFunction* fpa::Base::IncrementalRegionGrow< V, R, VV, VC, B >:: -GetGrowingFunction( unsigned int i ) -{ - if( i < this->m_Functions.size( ) ) - return( this->m_Functions[ i ] ); - else - return( NULL ); -} - -// ------------------------------------------------------------------------- -template< class V, class R, class VV, class VC, class B > -const typename fpa::Base::IncrementalRegionGrow< V, R, VV, VC, B >:: -TGrowingFunction* fpa::Base::IncrementalRegionGrow< V, R, VV, VC, B >:: -GetGrowingFunction( unsigned int i ) const -{ - if( i < this->m_Functions.size( ) ) - return( this->m_Functions[ i ] ); - else - return( NULL ); -} - -// ------------------------------------------------------------------------- -template< class V, class R, class VV, class VC, class B > -unsigned long fpa::Base::IncrementalRegionGrow< V, R, VV, VC, B >:: -GetGrowingFunctionVolume( unsigned int i ) const -{ - if( i < this->m_Volumes.size( ) ) - return( this->m_Volumes[ i ] ); - else - return( NULL ); -} - -// ------------------------------------------------------------------------- -template< class V, class R, class VV, class VC, class B > -unsigned int fpa::Base::IncrementalRegionGrow< V, R, VV, VC, B >:: -GetNumberOfGrowingFunctions( ) const -{ - return( this->m_Functions.size( ) ); -} - -// ------------------------------------------------------------------------- -template< class V, class R, class VV, class VC, class B > -void fpa::Base::IncrementalRegionGrow< V, R, VV, VC, B >:: -ClearGrowingFunctions( ) -{ - this->m_Functions.clear( ); - this->m_Volumes.clear( ); - this->Modified( ); -} - -// ------------------------------------------------------------------------- -template< class V, class R, class VV, class VC, class B > -unsigned int fpa::Base::IncrementalRegionGrow< V, R, VV, VC, B >:: -AddGrowingFunction( TGrowingFunction* function ) -{ - this->m_Functions.push_back( function ); - this->m_Volumes.push_back( 0 ); - this->Modified( ); -} - -// ------------------------------------------------------------------------- -template< class V, class R, class VV, class VC, class B > -fpa::Base::IncrementalRegionGrow< V, R, VV, VC, B >:: -IncrementalRegionGrow( ) - : Superclass( ) -{ -} - -// ------------------------------------------------------------------------- -template< class V, class R, class VV, class VC, class B > -fpa::Base::IncrementalRegionGrow< V, R, VV, VC, B >:: -~IncrementalRegionGrow( ) -{ -} - -// ------------------------------------------------------------------------- -template< class V, class R, class VV, class VC, class B > -void fpa::Base::IncrementalRegionGrow< V, R, VV, VC, B >:: -_BeforeGenerateData( ) -{ - this->Superclass::_BeforeGenerateData( ); - this->m_ActualFunction = 0; -} - -// ------------------------------------------------------------------------- -template< class V, class R, class VV, class VC, class B > -void fpa::Base::IncrementalRegionGrow< V, R, VV, VC, B >:: -_AfterLoop( ) -{ - /* TODO - this->Superclass::_AfterLoop( ); - - // Replace queue - this->_QueueClear( ); - while( !( this->m_AuxiliaryQueue.empty( ) ) ) - { - // Get node - _TNode node = this->m_AuxiliaryQueue.front( ); - this->m_AuxiliaryQueue.pop( ); - this->_QueuePush( node ); - - // Unmark it - typename _TMarks::iterator mIt = this->m_Marks.find( node.Vertex ); - if( mIt != this->m_Marks.end( ) ) - this->m_Marks.erase( mIt ); - - } // elihw - - // Move to next function - this->m_ActualFunction++; - */ -} - -// ------------------------------------------------------------------------- -template< class V, class R, class VV, class VC, class B > -void fpa::Base::IncrementalRegionGrow< V, R, VV, VC, B >:: -_Loop( ) -{ - while( this->m_ActualFunction < this->m_Functions.size( ) ) - this->Superclass::_Loop( ); -} - -// ------------------------------------------------------------------------- -template< class V, class R, class VV, class VC, class B > -bool fpa::Base::IncrementalRegionGrow< V, R, VV, VC, B >:: -_CheckMembership( const TVertex& v ) const -{ - /* TODO - - if( this->m_ActualFunction < this->m_Functions.size( ) ) - { - bool ret = - this->m_Functions[ this->m_ActualFunction ]->Evaluate( v ); - if( !ret ) - this->m_AuxiliaryQueue.push( n ); - else - this->m_Volumes[ this->m_ActualFunction ]++; - return( ret ); - } - else - return( false ); -*/ - return( false ); -} - -#endif // __FPA__BASE__INCREMENTALREGIONGROW__HXX__ - -// eof - $RCSfile$ diff --git a/lib/fpa/Base/MinimumSpanningTree.h b/lib/fpa/Base/MinimumSpanningTree.h deleted file mode 100644 index bc9ce93..0000000 --- a/lib/fpa/Base/MinimumSpanningTree.h +++ /dev/null @@ -1,102 +0,0 @@ -#ifndef __FPA__BASE__MINIMUMSPANNINGTREE__H__ -#define __FPA__BASE__MINIMUMSPANNINGTREE__H__ - -#include -#include -#include -#include -#include - -namespace fpa -{ - namespace Base - { - /** - */ - template< class _TSuperclass, class _TVertex > - class MinimumSpanningTree - : public _TSuperclass - { - public: - typedef MinimumSpanningTree Self; - typedef _TSuperclass Superclass; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; - - typedef _TVertex TVertex; - typedef std::vector< TVertex > TVertices; - typedef std::pair< TVertex, bool > TCollision; - typedef std::vector< TCollision > TCollisionsRow; - typedef std::vector< TCollisionsRow > TCollisions; - - typedef itk::Point< double, TVertex::Dimension > TPoint; - typedef std::vector< TPoint > TPoints; - typedef std::multimap< double, TVertex > TNodeQueue; - - protected: - typedef std::vector< unsigned long > _TRow; - typedef std::vector< _TRow > _TMatrix; - - public: - itkTypeMacro( MinimumSpanningTree, _TSuperclass ); - - itkBooleanMacro( FillNodeQueue ); - - itkGetConstReferenceMacro( Collisions, TCollisions ); - itkGetConstReferenceMacro( NodeQueue, TNodeQueue ); - itkGetConstMacro( FillNodeQueue, bool ); - - itkSetMacro( FillNodeQueue, bool ); - - public: - void SetCollisions( const TCollisions& collisions ); - TVertices GetPath( const TVertex& a ) const; - TVertices GetPath( const TVertex& a, const TVertex& b ) const; - - virtual TPoints GetEuclideanPath( const TVertex& a ) const; - virtual TPoints GetEuclideanPath( - const TVertex& a, const TVertex& b - ) const; - virtual bool IsDefinedInEuclideanSpace( ) const; - - virtual void SetNode( - const TVertex& v, - const TVertex& p, - const short& fid, - const double& cost - ); - virtual void Clear( ); - - protected: - MinimumSpanningTree( ); - virtual ~MinimumSpanningTree( ); - - virtual bool _HasVertex( const TVertex& a ) const = 0; - virtual short _FrontId( const TVertex& a ) const = 0; - virtual void _Path( TVertices& path, const TVertex& a ) const = 0; - - private: - // Purposely not implemented - MinimumSpanningTree( const Self& other ); - Self& operator=( const Self& other ); - - protected: - TCollisions m_Collisions; - _TMatrix m_FrontPaths; - TNodeQueue m_NodeQueue; - bool m_FillNodeQueue; - - static const unsigned long INF_VALUE; - }; - - } // ecapseman - -} // ecapseman - -#ifndef ITK_MANUAL_INSTANTIATION -#include -#endif // ITK_MANUAL_INSTANTIATION - -#endif // __FPA__BASE__MINIMUMSPANNINGTREE__H__ - -// eof - $RCSfile$ diff --git a/lib/fpa/Base/MinimumSpanningTree.hxx b/lib/fpa/Base/MinimumSpanningTree.hxx deleted file mode 100644 index c53a071..0000000 --- a/lib/fpa/Base/MinimumSpanningTree.hxx +++ /dev/null @@ -1,236 +0,0 @@ -#ifndef __FPA__BASE__MINIMUMSPANNINGTREE__HXX__ -#define __FPA__BASE__MINIMUMSPANNINGTREE__HXX__ - -#include - -// ------------------------------------------------------------------------- -template< class _TSuperclass, class _TVertex > -const unsigned long fpa::Base:: -MinimumSpanningTree< _TSuperclass, _TVertex >::INF_VALUE = - std::numeric_limits< unsigned long >::max( ); - -// ------------------------------------------------------------------------- -template< class _TSuperclass, class _TVertex > -void fpa::Base::MinimumSpanningTree< _TSuperclass, _TVertex >:: -SetCollisions( const TCollisions& collisions ) -{ - // Prepare a front graph - this->m_Collisions = collisions; - unsigned long nSeeds = this->m_Collisions.size( ); - _TMatrix dist( nSeeds, _TRow( nSeeds, Self::INF_VALUE ) ); - this->m_FrontPaths = dist; - for( unsigned long i = 0; i < nSeeds; ++i ) - { - for( unsigned long j = 0; j < nSeeds; ++j ) - { - if( this->m_Collisions[ i ][ j ].second ) - { - dist[ i ][ j ] = 1; - dist[ j ][ i ] = 1; - this->m_FrontPaths[ i ][ j ] = j; - this->m_FrontPaths[ j ][ i ] = i; - - } // fi - - } // rof - dist[ i ][ i ] = 0; - this->m_FrontPaths[ i ][ i ] = i; - - } // rof - - // Use Floyd-Warshall to compute all possible paths - for( unsigned long k = 0; k < nSeeds; ++k ) - { - for( unsigned long i = 0; i < nSeeds; ++i ) - { - for( unsigned long j = 0; j < nSeeds; ++j ) - { - if( ( dist[ i ][ k ] + dist[ k ][ j ] ) < dist[ i ][ j ] ) - { - dist[ i ][ j ] = dist[ i ][ k ] + dist[ k ][ j ]; - this->m_FrontPaths[ i ][ j ] = this->m_FrontPaths[ i ][ k ]; - - } // fi - - } // rof - - } // rof - - } // rof - this->Modified( ); -} - -// ------------------------------------------------------------------------- -template< class _TSuperclass, class _TVertex > -typename fpa::Base::MinimumSpanningTree< _TSuperclass, _TVertex >:: -TVertices fpa::Base::MinimumSpanningTree< _TSuperclass, _TVertex >:: -GetPath( const TVertex& a ) const -{ - TVertices path; - if( this->_HasVertex( a ) ) - this->_Path( path, a ); - return( path ); -} - -// ------------------------------------------------------------------------- -template< class _TSuperclass, class _TVertex > -typename fpa::Base::MinimumSpanningTree< _TSuperclass, _TVertex >:: -TVertices fpa::Base::MinimumSpanningTree< _TSuperclass, _TVertex >:: -GetPath( const TVertex& a, const TVertex& b ) const -{ - TVertices path; - - // Check existence - if( !this->_HasVertex( a ) || !this->_HasVertex( b ) ) - return( path ); - - // Get front ids - short fa = this->_FrontId( a ); - short fb = this->_FrontId( b ); - - if( fa == fb ) - { - // Get paths - TVertices ap, bp; - this->_Path( ap, a ); - this->_Path( bp, b ); - - // Ignore common part: find common ancestor - auto raIt = ap.rbegin( ); - auto rbIt = bp.rbegin( ); - while( *raIt == *rbIt && raIt != ap.rend( ) && rbIt != bp.rend( ) ) - { - ++raIt; - ++rbIt; - - } // elihw - if( raIt != ap.rbegin( ) ) --raIt; - if( rbIt != bp.rbegin( ) ) --rbIt; - - // Add part from a - for( auto iaIt = ap.begin( ); iaIt != ap.end( ) && *iaIt != *raIt; ++iaIt ) - path.push_back( *iaIt ); - - // Add part from b - for( ; rbIt != bp.rend( ); ++rbIt ) - path.push_back( *rbIt ); - } - else - { - // Use this->m_FrontPaths from Floyd-Warshall - if( this->m_FrontPaths[ fa ][ fb ] < Self::INF_VALUE ) - { - // Compute front path - std::vector< long > fpath; - fpath.push_back( fa ); - while( fa != fb ) - { - fa = this->m_FrontPaths[ fa ][ fb ]; - fpath.push_back( fa ); - - } // elihw - - // Continue only if both fronts are connected - unsigned int N = fpath.size( ); - if( N > 0 ) - { - // First path: from start vertex to first collision - path = this->GetPath( - a, this->m_Collisions[ fpath[ 0 ] ][ fpath[ 1 ] ].first - ); - - // Intermediary paths - for( unsigned int i = 1; i < N - 1; ++i ) - { - TVertices ipath = - this->GetPath( - this->m_Collisions[ fpath[ i ] ][ fpath[ i - 1 ] ].first, - this->m_Collisions[ fpath[ i ] ][ fpath[ i + 1 ] ].first - ); - path.insert( path.end( ), ipath.begin( ), ipath.end( ) ); - - } // rof - - // Final path: from last collision to end point - TVertices lpath = - this->GetPath( - this->m_Collisions[ fpath[ N - 1 ] ][ fpath[ N - 2 ] ].first, b - ); - path.insert( path.end( ), lpath.begin( ), lpath.end( ) ); - - } // fi - - } // fi - - } // fi - return( path ); -} - -// ------------------------------------------------------------------------- -template< class _TSuperclass, class _TVertex > -typename fpa::Base::MinimumSpanningTree< _TSuperclass, _TVertex >:: -TPoints fpa::Base::MinimumSpanningTree< _TSuperclass, _TVertex >:: -GetEuclideanPath( const TVertex& a ) const -{ - TPoints points; - return( points ); -} - -// ------------------------------------------------------------------------- -template< class _TSuperclass, class _TVertex > -typename fpa::Base::MinimumSpanningTree< _TSuperclass, _TVertex >:: -TPoints fpa::Base::MinimumSpanningTree< _TSuperclass, _TVertex >:: -GetEuclideanPath( const TVertex& a, const TVertex& b ) const -{ - TPoints points; - return( points ); -} - -// ------------------------------------------------------------------------- -template< class _TSuperclass, class _TVertex > -bool fpa::Base::MinimumSpanningTree< _TSuperclass, _TVertex >:: -IsDefinedInEuclideanSpace( ) const -{ - return( false ); -} - -// ------------------------------------------------------------------------- -template< class _TSuperclass, class _TVertex > -void fpa::Base::MinimumSpanningTree< _TSuperclass, _TVertex >:: -SetNode( - const TVertex& v, const TVertex& p, - const short& fid, const double& cost - ) -{ - typedef typename TNodeQueue::value_type _TNodeQueueValue; - if( this->m_FillNodeQueue ) - this->m_NodeQueue.insert( _TNodeQueueValue( cost, v ) ); -} - -// ------------------------------------------------------------------------- -template< class _TSuperclass, class _TVertex > -void fpa::Base::MinimumSpanningTree< _TSuperclass, _TVertex >:: -Clear( ) -{ - this->m_NodeQueue.clear( ); -} - -// ------------------------------------------------------------------------- -template< class _TSuperclass, class _TVertex > -fpa::Base::MinimumSpanningTree< _TSuperclass, _TVertex >:: -MinimumSpanningTree( ) - : Superclass( ), - m_FillNodeQueue( false ) -{ -} - -// ------------------------------------------------------------------------- -template< class _TSuperclass, class _TVertex > -fpa::Base::MinimumSpanningTree< _TSuperclass, _TVertex >:: -~MinimumSpanningTree( ) -{ -} - -#endif // __FPA__BASE__MINIMUMSPANNINGTREE__HXX__ - -// eof - $RCSfile$ diff --git a/lib/fpa/Base/RegionGrow.h b/lib/fpa/Base/RegionGrow.h deleted file mode 100644 index 8bc2776..0000000 --- a/lib/fpa/Base/RegionGrow.h +++ /dev/null @@ -1,105 +0,0 @@ -#ifndef __FPA__BASE__REGIONGROW__H__ -#define __FPA__BASE__REGIONGROW__H__ - -#include -#include -#include -#include - -namespace fpa -{ - namespace Base - { - /** - * Region grow is a front propagation with no costs. - * - * @param V Vertex type. - * @param C Vertex value type. - * @param R Result value type. - * @param S Space type where vertices are. - * @param VC Vertex lexicographical compare. - * @param B Base class for this algorithm. It should be any itk-based - * filter (itk::ProcessObject). - * - */ - template< class V, class C, class R, class S, class VC, class B > - class RegionGrow - : public Algorithm< V, C, R, S, VC, B > - { - public: - typedef RegionGrow Self; - typedef Algorithm< V, C, R, S, VC, B > Superclass; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; - - typedef typename Superclass::TVertex TVertex; - typedef typename Superclass::TValue TValue; - typedef typename Superclass::TResult TResult; - typedef typename Superclass::TSpace TSpace; - typedef typename Superclass::TVertexCompare TVertexCompare; - - typedef fpa::Base::Functors::TautologyFunction< S, V > TGrowingFunction; - - protected: - typedef typename Superclass::_TVertices _TVertices; - typedef typename Superclass::_TCollision _TCollision; - typedef typename Superclass::_TCollisionsRow _TCollisionsRow; - typedef typename Superclass::_TCollisions _TCollisions; - typedef typename Superclass::_TNode _TNode; - typedef typename Superclass::_TNodes _TNodes; - - typedef std::queue< std::pair< TVertex, _TNode > > _TQueue; - - public: - itkTypeMacro( RegionGrow, Algorithm ); - - itkGetConstMacro( InsideValue, TResult ); - itkGetConstMacro( OutsideValue, TResult ); - itkGetObjectMacro( GrowingFunction, TGrowingFunction ); - itkGetConstObjectMacro( GrowingFunction, TGrowingFunction ); - - itkSetMacro( InsideValue, TResult ); - itkSetMacro( OutsideValue, TResult ); - itkSetObjectMacro( GrowingFunction, TGrowingFunction ); - - protected: - RegionGrow( ); - virtual ~RegionGrow( ); - - virtual bool _CheckMembership( const TVertex& v ) const; - - // Results-related abstract methods - virtual bool _ComputeNeighborResult( - TResult& result, const TVertex& neighbor, const TVertex& parent - ) const ITK_OVERRIDE; - - // Queue-related abstract methods - virtual bool _IsQueueEmpty( ) const ITK_OVERRIDE; - virtual void _QueuePush( const TVertex& v, const _TNode& n ) ITK_OVERRIDE; - virtual void _QueuePop( TVertex& v, _TNode& n ) ITK_OVERRIDE; - virtual void _QueueClear( ) ITK_OVERRIDE; - - private: - // Purposely not implemented - RegionGrow( const Self& other ); - Self& operator=( const Self& other ); - - protected: - TResult m_InsideValue; - TResult m_OutsideValue; - _TQueue m_Queue; - - typename TGrowingFunction::Pointer m_GrowingFunction; - }; - - } // ecapseman - -} // ecapseman - -#ifndef ITK_MANUAL_INSTANTIATION -#include -#endif // ITK_MANUAL_INSTANTIATION - -#endif // __FPA__BASE__REGIONGROW__H__ - -// eof - $RCSfile$ diff --git a/lib/fpa/Base/RegionGrow.hxx b/lib/fpa/Base/RegionGrow.hxx deleted file mode 100644 index 8542f30..0000000 --- a/lib/fpa/Base/RegionGrow.hxx +++ /dev/null @@ -1,89 +0,0 @@ -#ifndef __FPA__BASE__REGIONGROWING__HXX__ -#define __FPA__BASE__REGIONGROWING__HXX__ - -// ------------------------------------------------------------------------- -template< class V, class C, class R, class S, class VC, class B > -fpa::Base::RegionGrow< V, C, R, S, VC, B >:: -RegionGrow( ) - : Superclass( ), - m_InsideValue( TResult( 1 ) ), - m_OutsideValue( TResult( 0 ) ) -{ -} - -// ------------------------------------------------------------------------- -template< class V, class C, class R, class S, class VC, class B > -fpa::Base::RegionGrow< V, C, R, S, VC, B >:: -~RegionGrow( ) -{ -} - -// ------------------------------------------------------------------------- -template< class V, class C, class R, class S, class VC, class B > -bool fpa::Base::RegionGrow< V, C, R, S, VC, B >:: -_CheckMembership( const TVertex& v ) const -{ - if( this->m_GrowingFunction.IsNotNull( ) ) - return( this->m_GrowingFunction->Evaluate( v ) ); - else - return( true ); -} - -// ------------------------------------------------------------------------- -template< class V, class C, class R, class S, class VC, class B > -bool fpa::Base::RegionGrow< V, C, R, S, VC, B >:: -_ComputeNeighborResult( - TResult& result, const TVertex& neighbor, const TVertex& parent - ) const -{ - if( this->_CheckMembership( neighbor ) ) - { - result = this->m_InsideValue; - return( true ); - } - else - { - result = this->m_OutsideValue; - return( false ); - - } // fi -} - -// ------------------------------------------------------------------------- -template< class V, class C, class R, class S, class VC, class B > -bool fpa::Base::RegionGrow< V, C, R, S, VC, B >:: -_IsQueueEmpty( ) const -{ - return( this->m_Queue.empty( ) ); -} - -// ------------------------------------------------------------------------- -template< class V, class C, class R, class S, class VC, class B > -void fpa::Base::RegionGrow< V, C, R, S, VC, B >:: -_QueuePush( const TVertex& v, const _TNode& n ) -{ - this->m_Queue.push( std::pair< TVertex, _TNode >( v, n ) ); -} - -// ------------------------------------------------------------------------- -template< class V, class C, class R, class S, class VC, class B > -void fpa::Base::RegionGrow< V, C, R, S, VC, B >:: -_QueuePop( TVertex& v, _TNode& n ) -{ - v = this->m_Queue.front( ).first; - n = this->m_Queue.front( ).second; - this->m_Queue.pop( ); -} - -// ------------------------------------------------------------------------- -template< class V, class C, class R, class S, class VC, class B > -void fpa::Base::RegionGrow< V, C, R, S, VC, B >:: -_QueueClear( ) -{ - while( this->m_Queue.size( ) > 0 ) - this->m_Queue.pop( ); -} - -#endif // __FPA__BASE__REGIONGROWING__HXX__ - -// eof - $RCSfile$ diff --git a/lib/fpa/Base/RegionGrowWithMultipleCriteria.h b/lib/fpa/Base/RegionGrowWithMultipleCriteria.h deleted file mode 100644 index cce7dbf..0000000 --- a/lib/fpa/Base/RegionGrowWithMultipleCriteria.h +++ /dev/null @@ -1,83 +0,0 @@ -#ifndef __FPA__BASE__REGIONGROWWITHMULTIPLECRITERIA__H__ -#define __FPA__BASE__REGIONGROWWITHMULTIPLECRITERIA__H__ - -#include -#include -#include - -namespace fpa -{ - namespace Base - { - /** - * Region grow is a front propagation with no costs. - */ - template< class V, class R, class VV, class VC, class B > - class RegionGrowWithMultipleCriteria - : public RegionGrow< V, R, VV, VC, B > - { - public: - typedef V TVertex; - typedef R TResult; - typedef VV TVertexValue; - typedef B TBaseFilter; - - /// Standard class typdedefs - typedef RegionGrowWithMultipleCriteria Self; - typedef RegionGrow< V, R, VV, VC, B > Superclass; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; - - typedef typename Superclass::TTraits TTraits; - typedef typename Superclass::TCost TCost; - typedef itk::FunctionBase< V, TCost > TMembershipFunction; - typedef - typename TMembershipFunction::Pointer - TMembershipFunctionPointer; - typedef std::vector< TMembershipFunctionPointer > TFunctions; - - protected: - typedef typename Superclass::_TFrontId _TFrontId; - typedef typename Superclass::_TNode _TNode; - typedef typename Superclass::_TNodes _TNodes; - typedef typename Superclass::_TQueue _TQueue; - typedef typename Superclass::_TMarks _TMarks; - - public: - itkTypeMacro( RegionGrowWithMultipleCriteria, RegionGrow ); - - public: - unsigned int GetNumberOfMembershipFunctions( ) const; - void ClearMembershipFunctions( ); - void AddMembershipFunction( TMembershipFunction* function ); - - protected: - RegionGrowWithMultipleCriteria( ); - virtual ~RegionGrowWithMultipleCriteria( ); - - virtual void _BeforeMainLoop( ); - virtual void _AfterLoop( ); - virtual void _Loop( ); - virtual bool _CheckMembership( const _TNode& n ) const; - - private: - RegionGrowWithMultipleCriteria( const Self& ); // Not impl. - void operator=( const Self& ); // Not impl. - - protected: - mutable _TQueue m_AuxiliaryQueue; - TFunctions m_Functions; - typename TFunctions::iterator m_ActualFunction; - }; - - } // ecapseman - -} // ecapseman - -#ifndef ITK_MANUAL_INSTANTIATION -#include -#endif // ITK_MANUAL_INSTANTIATION - -#endif // __FPA__BASE__REGIONGROWWITHMULTIPLECRITERIA__H__ - -// eof - $RCSfile$ diff --git a/lib/fpa/Base/RegionGrowWithMultipleCriteria.hxx b/lib/fpa/Base/RegionGrowWithMultipleCriteria.hxx deleted file mode 100644 index 0fd4378..0000000 --- a/lib/fpa/Base/RegionGrowWithMultipleCriteria.hxx +++ /dev/null @@ -1,108 +0,0 @@ -#ifndef __FPA__BASE__REGIONGROWWITHMULTIPLECRITERIA__HXX__ -#define __FPA__BASE__REGIONGROWWITHMULTIPLECRITERIA__HXX__ - -// ------------------------------------------------------------------------- -template< class V, class R, class VV, class VC, class B > -unsigned int fpa::Base::RegionGrowWithMultipleCriteria< V, R, VV, VC, B >:: -GetNumberOfMembershipFunctions( ) const -{ - return( this->m_Functions.size( ) ); -} - -// ------------------------------------------------------------------------- -template< class V, class R, class VV, class VC, class B > -void fpa::Base::RegionGrowWithMultipleCriteria< V, R, VV, VC, B >:: -ClearMembershipFunctions( ) -{ - this->m_Functions.clear( ); - this->Modified( ); -} - -// ------------------------------------------------------------------------- -template< class V, class R, class VV, class VC, class B > -void fpa::Base::RegionGrowWithMultipleCriteria< V, R, VV, VC, B >:: -AddMembershipFunction( TMembershipFunction* function ) -{ - this->m_Functions.push_back( function ); - this->Modified( ); -} - -// ------------------------------------------------------------------------- -template< class V, class R, class VV, class VC, class B > -fpa::Base::RegionGrowWithMultipleCriteria< V, R, VV, VC, B >:: -RegionGrowWithMultipleCriteria( ) - : Superclass( ) -{ -} - -// ------------------------------------------------------------------------- -template< class V, class R, class VV, class VC, class B > -fpa::Base::RegionGrowWithMultipleCriteria< V, R, VV, VC, B >:: -~RegionGrowWithMultipleCriteria( ) -{ -} - -// ------------------------------------------------------------------------- -template< class V, class R, class VV, class VC, class B > -void fpa::Base::RegionGrowWithMultipleCriteria< V, R, VV, VC, B >:: -_BeforeMainLoop( ) -{ - this->Superclass::_BeforeMainLoop( ); - this->m_ActualFunction = this->m_Functions.begin( ); -} - -// ------------------------------------------------------------------------- -template< class V, class R, class VV, class VC, class B > -void fpa::Base::RegionGrowWithMultipleCriteria< V, R, VV, VC, B >:: -_AfterLoop( ) -{ - this->Superclass::_AfterLoop( ); - - // Replace queue - this->_QueueClear( ); - while( !( this->m_AuxiliaryQueue.empty( ) ) ) - { - // Get node - _TNode node = this->m_AuxiliaryQueue.front( ); - this->m_AuxiliaryQueue.pop( ); - this->_QueuePush( node ); - - // Unmark it - typename _TMarks::iterator mIt = this->m_Marks.find( node.Vertex ); - if( mIt != this->m_Marks.end( ) ) - this->m_Marks.erase( mIt ); - - } // elihw - - // Move to next function - this->m_ActualFunction++; -} - -// ------------------------------------------------------------------------- -template< class V, class R, class VV, class VC, class B > -void fpa::Base::RegionGrowWithMultipleCriteria< V, R, VV, VC, B >:: -_Loop( ) -{ - while( this->m_ActualFunction != this->m_Functions.end( ) ) - this->Superclass::_Loop( ); -} - -// ------------------------------------------------------------------------- -template< class V, class R, class VV, class VC, class B > -bool fpa::Base::RegionGrowWithMultipleCriteria< V, R, VV, VC, B >:: -_CheckMembership( const _TNode& n ) const -{ - if( this->m_ActualFunction != this->m_Functions.end( ) ) - { - bool ret = ( *( this->m_ActualFunction ) )->Evaluate( n.Vertex ); - if( !ret ) - this->m_AuxiliaryQueue.push( n ); - return( ret ); - } - else - return( false ); -} - -#endif // __FPA__BASE__REGIONGROWWITHMULTIPLECRITERIA__HXX__ - -// eof - $RCSfile$ diff --git a/lib/fpa/Common.cxx.in b/lib/fpa/Common.cxx.in deleted file mode 100644 index 2b1a193..0000000 --- a/lib/fpa/Common.cxx.in +++ /dev/null @@ -1,9 +0,0 @@ -#include - -// ------------------------------------------------------------------------- -std::string fpa::GetVersion( ) -{ - return( "@VERSION_STRING@" ); -} - -// eof - $RCSfile$ diff --git a/lib/fpa/Common.h b/lib/fpa/Common.h deleted file mode 100644 index c46ae57..0000000 --- a/lib/fpa/Common.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef __FPA__COMMON__H__ -#define __FPA__COMMON__H__ - -#include -#include - -namespace fpa -{ - std::string fpa_EXPORT GetVersion( ); - -} // ecapseman - -#endif // __FPA__COMMON__H__ - -// eof - $RCSfile$ diff --git a/lib/fpa/IO/MinimumSpanningTreeReader.h b/lib/fpa/IO/MinimumSpanningTreeReader.h deleted file mode 100644 index 0430ad9..0000000 --- a/lib/fpa/IO/MinimumSpanningTreeReader.h +++ /dev/null @@ -1,61 +0,0 @@ -#ifndef __FPA__IO__MINIMUMSPANNINGTREEREADER__H__ -#define __FPA__IO__MINIMUMSPANNINGTREEREADER__H__ - -#include -#include - -namespace fpa -{ - namespace IO - { - /** - */ - template< class _TTree > - class MinimumSpanningTreeReader - : public itk::ProcessObject - { - public: - typedef MinimumSpanningTreeReader Self; - typedef itk::ProcessObject Superclass; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; - - typedef _TTree TTree; - - public: - itkNewMacro( Self ); - itkTypeMacro( MinimumSpanningTreeReader, itkProcessObject ); - - itkGetConstMacro( FileName, std::string ); - itkSetMacro( FileName, std::string ); - - public: - _TTree* GetOutput( ); - virtual void Update( ) ITK_OVERRIDE; - - protected: - MinimumSpanningTreeReader( ); - virtual ~MinimumSpanningTreeReader( ); - - virtual void GenerateData( ) ITK_OVERRIDE; - - private: - // Purposely not implemented - MinimumSpanningTreeReader( const Self& other ); - Self& operator=( const Self& other ); - - protected: - std::string m_FileName; - }; - - } // ecapseman - -} // ecapseman - -#ifndef ITK_MANUAL_INSTANTIATION -#include -#endif // ITK_MANUAL_INSTANTIATION - -#endif // __FPA__IO__MINIMUMSPANNINGTREEREADER__H__ - -// eof - $RCSfile$ diff --git a/lib/fpa/IO/MinimumSpanningTreeReader.hxx b/lib/fpa/IO/MinimumSpanningTreeReader.hxx deleted file mode 100644 index 72eecc2..0000000 --- a/lib/fpa/IO/MinimumSpanningTreeReader.hxx +++ /dev/null @@ -1,187 +0,0 @@ -#ifndef __FPA__IO__MINIMUMSPANNINGTREEREADER__HXX__ -#define __FPA__IO__MINIMUMSPANNINGTREEREADER__HXX__ - -#include -#include -#include -#include - -// ------------------------------------------------------------------------- -template< class _TTree > -_TTree* fpa::IO::MinimumSpanningTreeReader< _TTree >:: -GetOutput( ) -{ - return( - dynamic_cast< _TTree* >( this->itk::ProcessObject::GetOutput( 0 ) ) - ); -} - -// ------------------------------------------------------------------------- -template< class _TTree > -void fpa::IO::MinimumSpanningTreeReader< _TTree >:: -Update( ) -{ - this->GenerateData( ); -} - -// ------------------------------------------------------------------------- -template< class _TTree > -fpa::IO::MinimumSpanningTreeReader< _TTree >:: -MinimumSpanningTreeReader( ) - : Superclass( ), - m_FileName( "" ) -{ - this->SetNumberOfRequiredInputs( 0 ); - this->SetNumberOfRequiredOutputs( 0 ); - typename _TTree::Pointer out = _TTree::New( ); - this->itk::ProcessObject::SetNthOutput( 0, out.GetPointer( ) ); -} - -// ------------------------------------------------------------------------- -template< class _TTree > -fpa::IO::MinimumSpanningTreeReader< _TTree >:: -~MinimumSpanningTreeReader( ) -{ -} - -// ------------------------------------------------------------------------- -template< class _TTree > -void fpa::IO::MinimumSpanningTreeReader< _TTree >:: -GenerateData( ) -{ - _TTree* tree = this->GetOutput( ); - - char* buff = NULL; - std::ifstream file( - this->m_FileName.c_str( ), - std::ios::in | std::ios::binary | std::ios::ate - ); - if( !file ) - { - itkExceptionMacro( - << "Error opening file to read a minimum spanning tree: \"" - << this->m_FileName - << "\"" - ); - return; - - } // fi - - // Put all file into a memory buffer - auto size = file.tellg( ); - buff = new char[ size ]; - file.seekg( 0, std::ios::beg ); - file.read ( buff, size ); - file.close( ); - std::istringstream in( buff ); - - // Read basic data - unsigned int dim, fill_queue; - in >> dim >> fill_queue; - tree->SetFillNodeQueue( fill_queue == 1 ); - - // Read regions - typename _TTree::IndexType li, ri, bi; - typename _TTree::SizeType ls, rs, bs; - li.Fill( 0 ); - ri = bi = li; - ls.Fill( 0 ); - rs = bs = ls; - for( unsigned int d = 0; d < dim; ++d ) - if( d < _TTree::ImageDimension ) - in >> li[ d ] >> ls[ d ]; - for( unsigned int d = 0; d < dim; ++d ) - if( d < _TTree::ImageDimension ) - in >> ri[ d ] >> rs[ d ]; - for( unsigned int d = 0; d < dim; ++d ) - if( d < _TTree::ImageDimension ) - in >> bi[ d ] >> bs[ d ]; - typename _TTree::RegionType lr, rr, br; - lr.SetIndex( li ); lr.SetSize( ls ); - rr.SetIndex( ri ); rr.SetSize( rs ); - br.SetIndex( bi ); br.SetSize( bs ); - - // Read spatial information - typename _TTree::SpacingType spc; - typename _TTree::PointType ori; - typename _TTree::DirectionType dir; - for( unsigned int d = 0; d < dim; ++d ) - if( d < _TTree::ImageDimension ) - in >> ori[ d ]; - for( unsigned int d = 0; d < dim; ++d ) - if( d < _TTree::ImageDimension ) - in >> spc[ d ]; - for( unsigned int d = 0; d < dim; ++d ) - { - if( d < _TTree::ImageDimension ) - { - for( unsigned int e = 0; e < dim; ++e ) - if( e < _TTree::ImageDimension ) - in >> dir[ d ][ e ]; - - } // fi - - } // rof - - // Allocate memory and prepare it - tree->SetLargestPossibleRegion( lr ); - tree->SetRequestedRegion( rr ); - tree->SetBufferedRegion( br ); - tree->SetOrigin( ori ); - tree->SetSpacing( spc ); - tree->SetDirection( dir ); - tree->Allocate( ); - tree->Clear( ); - - // Read collisions - typedef typename _TTree::TCollision _TCollision; - typedef typename _TTree::TCollisionsRow _TCollisionsRow; - typename _TTree::TCollisions coll; - unsigned long coll_size; - in >> coll_size; - for( unsigned long i = 0; i < coll_size; ++i ) - { - coll.push_back( _TCollisionsRow( ) ); - - unsigned long row_size; - in >> row_size; - for( unsigned long j = 0; j < row_size; ++j ) - { - typename _TTree::IndexType v; - for( unsigned int d = 0; d < dim; ++d ) - if( d < _TTree::ImageDimension ) - in >> v[ d ]; - unsigned int b; - in >> b; - coll[ i ].push_back( _TCollision( v, b == 1 ) ); - - } // rof - - } // rof - tree->SetCollisions( coll ); - - // Read vertices - while( !in.eof( ) ) - { - short fid; - double cost; - typename _TTree::IndexType v; - typename _TTree::IndexType::OffsetType p; - in >> fid >> cost; - for( unsigned int d = 0; d < dim; ++d ) - if( d < _TTree::ImageDimension ) - in >> v[ d ]; - for( unsigned int d = 0; d < dim; ++d ) - if( d < _TTree::ImageDimension ) - in >> p[ d ]; - tree->SetNode( v, v + p, fid, cost ); - - } // elihw - - // Free buffer - delete [] buff; -} - -#endif // __FPA__IO__MINIMUMSPANNINGTREEREADER__HXX__ - -// eof - $RCSfile$ diff --git a/lib/fpa/IO/MinimumSpanningTreeWriter.h b/lib/fpa/IO/MinimumSpanningTreeWriter.h deleted file mode 100644 index 0b384fc..0000000 --- a/lib/fpa/IO/MinimumSpanningTreeWriter.h +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef __FPA__IO__MINIMUMSPANNINGTREEWRITER__H__ -#define __FPA__IO__MINIMUMSPANNINGTREEWRITER__H__ - -#include -#include - -namespace fpa -{ - namespace IO - { - /** - */ - template< class _TTree > - class MinimumSpanningTreeWriter - : public itk::ProcessObject - { - public: - typedef MinimumSpanningTreeWriter Self; - typedef itk::ProcessObject Superclass; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; - - typedef _TTree TTree; - - public: - itkNewMacro( Self ); - itkTypeMacro( MinimumSpanningTreeWriter, itkProcessObject ); - - itkGetConstMacro( FileName, std::string ); - itkSetMacro( FileName, std::string ); - - public: - void SetInput( const _TTree* input ); - _TTree* GetInput( ); - const _TTree* GetInput( ) const; - virtual void Update( ) ITK_OVERRIDE; - - protected: - MinimumSpanningTreeWriter( ); - virtual ~MinimumSpanningTreeWriter( ); - - virtual void GenerateData( ) ITK_OVERRIDE; - - private: - // Purposely not implemented - MinimumSpanningTreeWriter( const Self& other ); - Self& operator=( const Self& other ); - - protected: - std::string m_FileName; - }; - - } // ecapseman - -} // ecapseman - -#ifndef ITK_MANUAL_INSTANTIATION -#include -#endif // ITK_MANUAL_INSTANTIATION - -#endif // __FPA__IO__MINIMUMSPANNINGTREEWRITER__H__ - -// eof - $RCSfile$ diff --git a/lib/fpa/IO/MinimumSpanningTreeWriter.hxx b/lib/fpa/IO/MinimumSpanningTreeWriter.hxx deleted file mode 100644 index d4b1f12..0000000 --- a/lib/fpa/IO/MinimumSpanningTreeWriter.hxx +++ /dev/null @@ -1,183 +0,0 @@ -#ifndef __FPA__IO__MINIMUMSPANNINGTREEWRITER__HXX__ -#define __FPA__IO__MINIMUMSPANNINGTREEWRITER__HXX__ - -#include -#include -#include -#include -#include - -// ------------------------------------------------------------------------- -template< class _TTree > -void fpa::IO::MinimumSpanningTreeWriter< _TTree >:: -SetInput( const _TTree* input ) -{ - this->itk::ProcessObject::SetNthInput( 0, const_cast< _TTree* >( input ) ); -} - -// ------------------------------------------------------------------------- -template< class _TTree > -_TTree* fpa::IO::MinimumSpanningTreeWriter< _TTree >:: -GetInput( ) -{ - return( - dynamic_cast< _TTree* >( this->itk::ProcessObject::GetInput( 0 ) ) - ); -} - -// ------------------------------------------------------------------------- -template< class _TTree > -const _TTree* fpa::IO::MinimumSpanningTreeWriter< _TTree >:: -GetInput( ) const -{ - return( - dynamic_cast< const _TTree* >( this->itk::ProcessObject::GetInput( 0 ) ) - ); -} - -// ------------------------------------------------------------------------- -template< class _TTree > -void fpa::IO::MinimumSpanningTreeWriter< _TTree >:: -Update( ) -{ - _TTree* input = this->GetInput( ); - if( input != NULL ) - { - input->UpdateOutputInformation( ); - input->UpdateOutputData( ); - this->GenerateData( ); - this->ReleaseInputs( ); - - } // fi -} - -// ------------------------------------------------------------------------- -template< class _TTree > -fpa::IO::MinimumSpanningTreeWriter< _TTree >:: -MinimumSpanningTreeWriter( ) - : Superclass( ), - m_FileName( "" ) -{ - this->SetNumberOfRequiredInputs( 1 ); -} - -// ------------------------------------------------------------------------- -template< class _TTree > -fpa::IO::MinimumSpanningTreeWriter< _TTree >:: -~MinimumSpanningTreeWriter( ) -{ -} - -// ------------------------------------------------------------------------- -template< class _TTree > -void fpa::IO::MinimumSpanningTreeWriter< _TTree >:: -GenerateData( ) -{ - typedef itk::Offset< _TTree::ImageDimension > _TOffset; - _TOffset zero_off; - zero_off.Fill( 0 ); - const _TTree* input = this->GetInput( ); - - // Create buffer - std::stringstream out; - - // Get tree properties - unsigned int dim = _TTree::ImageDimension; - auto lr = input->GetLargestPossibleRegion( ); - auto rr = input->GetRequestedRegion( ); - auto br = input->GetBufferedRegion( ); - auto ori = input->GetOrigin( ); - auto spc = input->GetSpacing( ); - auto dir = input->GetDirection( ); - - // Write tree dimension - out << dim << std::endl; - out << ( ( input->GetFillNodeQueue( ) )? 1: 0 ) << std::endl; - - // Write tree regions - out << lr.GetIndex( )[ 0 ] << " " << lr.GetSize( )[ 0 ]; - for( unsigned int d = 1; d < dim; ++d ) - out << " " << lr.GetIndex( )[ d ] << " " << lr.GetSize( )[ d ]; - out << std::endl; - out << rr.GetIndex( )[ 0 ] << " " << rr.GetSize( )[ 0 ]; - for( unsigned int d = 1; d < dim; ++d ) - out << " " << rr.GetIndex( )[ d ] << " " << rr.GetSize( )[ d ]; - out << std::endl; - out << br.GetIndex( )[ 0 ] << " " << br.GetSize( )[ 0 ]; - for( unsigned int d = 1; d < dim; ++d ) - out << " " << br.GetIndex( )[ d ] << " " << br.GetSize( )[ d ]; - out << std::endl; - - // Write spatial properties - out << ori[ 0 ]; - for( unsigned int d = 1; d < dim; ++d ) - out << " " << ori[ d ]; - out << std::endl; - out << spc[ 0 ]; - for( unsigned int d = 1; d < dim; ++d ) - out << " " << spc[ d ]; - out << std::endl; - out << dir[ 0 ][ 0 ]; - for( unsigned int d = 0; d < dim; ++d ) - for( unsigned int e = 0; e < dim; ++e ) - if( d != 0 || e != 0 ) - out << " " << dir[ d ][ e ]; - out << std::endl; - - // Write collisions - auto& coll = input->GetCollisions( ); - out << coll.size( ) << std::endl; - for( unsigned long i = 0; i < coll.size( ); ++i ) - { - out << coll[ i ].size( ); - for( unsigned long j = 0; j < coll[ i ].size( ); ++j ) - { - for( unsigned int d = 0; d < dim; ++d ) - out << " " << coll[ i ][ j ].first[ d ]; - out << " " << coll[ i ][ j ].second << std::endl; - - } // rof - - } // rof - - // Write vertices - itk::ImageRegionConstIteratorWithIndex< _TTree > vIt( input, rr ); - for( vIt.GoToBegin( ); !vIt.IsAtEnd( ); ++vIt ) - { - if( - vIt.Get( ).Parent != zero_off || - vIt.Get( ).GlobalCost > double( 0 ) - ) - { - out << vIt.Get( ).FrontId << " " << vIt.Get( ).GlobalCost; - for( unsigned int d = 0; d < dim; ++d ) - out << " " << vIt.GetIndex( )[ d ]; - for( unsigned int d = 0; d < dim; ++d ) - out << " " << vIt.Get( ).Parent[ d ]; - out << std::endl; - - } // fi - - } // rof - - // Real file write - std::ofstream file( - this->m_FileName.c_str( ), std::ios::binary | std::ios::trunc - ); - if( !file ) - { - itkExceptionMacro( - << "Error opening file to write a minimum spanning tree: \"" - << this->m_FileName - << "\"" - ); - return; - - } // fi - file.write( out.str( ).c_str( ), out.str( ).size( ) ); - file.close( ); -} - -#endif // __FPA__IO__MINIMUMSPANNINGTREEWRITER__HXX__ - -// eof - $RCSfile$ diff --git a/lib/fpa/Image/Algorithm.h b/lib/fpa/Image/Algorithm.h deleted file mode 100644 index 6d68bb5..0000000 --- a/lib/fpa/Image/Algorithm.h +++ /dev/null @@ -1,94 +0,0 @@ -#ifndef __FPA__IMAGE__ALGORITHM__H__ -#define __FPA__IMAGE__ALGORITHM__H__ - -#include - -namespace fpa -{ - namespace Image - { - /** - * A generic front propagation algorithm were vertices are image pixels. - * - * @param I Input image type - * @param O Output image type - * @param A Base algorithm (RegionGrow, Dijkstra or FastMarching) - */ - template< class I, class O, class A > - class Algorithm - : public A - { - public: - /// Standard class typdedefs - typedef Algorithm Self; - typedef A Superclass; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; - - /// Template input values - typedef I TInputImage; - typedef O TOutputImage; - - typedef typename Superclass::TVertex TVertex; - typedef typename Superclass::TValue TValue; - typedef typename Superclass::TResult TResult; - typedef typename Superclass::TSpace TSpace; - typedef typename Superclass::TVertexCompare TVertexCompare; - - protected: - typedef typename Superclass::_TVertices _TVertices; - typedef typename Superclass::_TCollision _TCollision; - typedef typename Superclass::_TCollisionsRow _TCollisionsRow; - typedef typename Superclass::_TCollisions _TCollisions; - typedef typename Superclass::_TNode _TNode; - typedef typename Superclass::_TNodes _TNodes; - - public: - itkTypeMacro( Algorithm, TAlgorithm ); - - /// Set/Get - itkGetConstMacro( NeighborhoodOrder, unsigned int ); - itkSetMacro( NeighborhoodOrder, unsigned int ); - - protected: - Algorithm( ); - virtual ~Algorithm( ); - - virtual void _BeforeGenerateData( ) ITK_OVERRIDE; - - // Graph-related abstract methods - virtual unsigned long _NumberOfVertices( ) const ITK_OVERRIDE; - virtual const TValue& _VertexValue( const TVertex& v ) const ITK_OVERRIDE; - virtual double _Distance( - const TVertex& a, const TVertex& b - ) const ITK_OVERRIDE; - virtual bool _HasEdge( const TVertex& a, const TVertex& b ) const ITK_OVERRIDE; - virtual void _Neighborhood( - _TVertices& neighborhood, const TVertex& v - ) const ITK_OVERRIDE; - - // Results-related abstract methods - virtual void _InitResults( ) ITK_OVERRIDE; - virtual const TResult& _Result( const TVertex& v ) const ITK_OVERRIDE; - virtual void _SetResult( const TVertex& v, const _TNode& n ) ITK_OVERRIDE; - - private: - // Purposely not implemented - Algorithm( const Self& other ); - Self& operator=( const Self& other ); - - protected: - unsigned int m_NeighborhoodOrder; - }; - - } // ecapseman - -} // ecapseman - -#ifndef ITK_MANUAL_INSTANTIATION -#include -#endif // ITK_MANUAL_INSTANTIATION - -#endif // __FPA__IMAGE__ALGORITHM__H__ - -// eof - $RCSfile$ diff --git a/lib/fpa/Image/Algorithm.hxx b/lib/fpa/Image/Algorithm.hxx deleted file mode 100644 index 2eda502..0000000 --- a/lib/fpa/Image/Algorithm.hxx +++ /dev/null @@ -1,145 +0,0 @@ -#ifndef __FPA__IMAGE__ALGORITHM__HXX__ -#define __FPA__IMAGE__ALGORITHM__HXX__ - -#include -#include - -// ------------------------------------------------------------------------- -template< class I, class O, class A > -fpa::Image::Algorithm< I, O, A >:: -Algorithm( ) - : Superclass( ), - m_NeighborhoodOrder( 1 ) -{ -} - -// ------------------------------------------------------------------------- -template< class I, class O, class A > -fpa::Image::Algorithm< I, O, A >:: -~Algorithm( ) -{ -} - -// ------------------------------------------------------------------------- -template< class I, class O, class A > -void fpa::Image::Algorithm< I, O, A >:: -_BeforeGenerateData( ) -{ - this->Superclass::_BeforeGenerateData( ); - this->AllocateOutputs( ); -} - -// ------------------------------------------------------------------------- -template< class I, class O, class A > -unsigned long fpa::Image::Algorithm< I, O, A >:: -_NumberOfVertices( ) const -{ - return( this->GetInput( )->GetRequestedRegion( ).GetNumberOfPixels( ) ); -} - -// ------------------------------------------------------------------------- -template< class I, class O, class A > -const typename fpa::Image::Algorithm< I, O, A >:: -TValue& fpa::Image::Algorithm< I, O, A >:: -_VertexValue( const TVertex& v ) const -{ - return( this->GetInput( )->GetPixel( v ) ); -} - -// ------------------------------------------------------------------------- -template< class I, class O, class A > -double fpa::Image::Algorithm< I, O, A >:: -_Distance( const TVertex& a, const TVertex& b ) const -{ - typename I::PointType pa, pb; - this->GetInput( )->TransformIndexToPhysicalPoint( a, pa ); - this->GetInput( )->TransformIndexToPhysicalPoint( b, pb ); - return( double( pa.EuclideanDistanceTo( pb ) ) ); -} - -// ------------------------------------------------------------------------- -template< class I, class O, class A > -bool fpa::Image::Algorithm< I, O, A >:: -_HasEdge( const TVertex& a, const TVertex& b ) const -{ - unsigned long dist = 0; - for( unsigned int d = 0; d < I::ImageDimension; d++ ) - dist += std::abs( long( a[ d ] ) - long( b[ d ] ) ); - if( this->m_NeighborhoodOrder == 1 ) - return( dist <= 1 ); - else - return( dist <= I::ImageDimension ); -} - -// ------------------------------------------------------------------------- -template< class I, class O, class A > -void fpa::Image::Algorithm< I, O, A >:: -_Neighborhood( _TVertices& neighborhood, const TVertex& v ) const -{ - typename I::RegionType reg = this->GetInput( )->GetRequestedRegion( ); - - neighborhood.clear( ); - if( this->m_NeighborhoodOrder == 1 ) - { - for( unsigned int d = 0; d < I::ImageDimension; d++ ) - { - for( int i = -1; i <= 1; i += 2 ) - { - TVertex n = v; - n[ d ] += i; - if( reg.IsInside( n ) ) - neighborhood.push_back( n ); - - } // rof - - } // rof - } - else - { - typedef itk::ConstNeighborhoodIterator< I > TNeighIt; - typename I::SizeType nSize; - nSize.Fill( 1 ); - - TNeighIt nIt( nSize, this->GetInput( ), reg ); - nIt.SetLocation( v ); - for( unsigned int i = 0; i < nIt.Size( ); i++ ) - { - TVertex n = nIt.GetIndex( i ); - if( n == v ) - continue; - if( reg.IsInside( n ) ) - neighborhood.push_back( n ); - - } // rof - - } // fi -} - -// ------------------------------------------------------------------------- -template< class I, class O, class A > -void fpa::Image::Algorithm< I, O, A >:: -_InitResults( ) -{ -} - -// ------------------------------------------------------------------------- -template< class I, class O, class A > -const typename fpa::Image::Algorithm< I, O, A >:: -TResult& fpa::Image::Algorithm< I, O, A >:: -_Result( const TVertex& v ) const -{ - return( this->GetOutput( )->GetPixel( v ) ); -} - -// ------------------------------------------------------------------------- -template< class I, class O, class A > -void fpa::Image::Algorithm< I, O, A >:: -_SetResult( const TVertex& v, const _TNode& n ) -{ - this->Superclass::_SetResult( v, n ); - this->GetOutput( )->SetPixel( v, n.Result ); -} - -#endif // __FPA__IMAGE__ALGORITHM__HXX__ - -// eof - $RCSfile$ diff --git a/lib/fpa/Image/Dijkstra.h b/lib/fpa/Image/Dijkstra.h deleted file mode 100644 index f4da123..0000000 --- a/lib/fpa/Image/Dijkstra.h +++ /dev/null @@ -1,105 +0,0 @@ -#ifndef __FPA__IMAGE__DIJKSTRA__H__ -#define __FPA__IMAGE__DIJKSTRA__H__ - -#include -#include -#include -#include -#include -#include - -namespace fpa -{ - namespace Image - { - /** - * @param I Input image type - * @param O Output image type - */ - template< class I, class O = I > - class Dijkstra - : public Algorithm< I, O, fpa::Base::Dijkstra< typename I::IndexType, typename I::PixelType, typename O::PixelType, I, itk::Functor::IndexLexicographicCompare< I::ImageDimension >, fpa::Image::MinimumSpanningTree< I::ImageDimension >, itk::ImageToImageFilter< I, O > > > - { - public: - typedef fpa::Base::Dijkstra< typename I::IndexType, typename I::PixelType, typename O::PixelType, I, itk::Functor::IndexLexicographicCompare< I::ImageDimension >, fpa::Image::MinimumSpanningTree< I::ImageDimension >, itk::ImageToImageFilter< I, O > > TBaseAlgorithm; - typedef Dijkstra Self; - typedef Algorithm< I, O, TBaseAlgorithm > Superclass; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; - - typedef typename Superclass::TInputImage TInputImage; - typedef typename Superclass::TOutputImage TOutputImage; - typedef typename Superclass::TVertex TVertex; - typedef typename Superclass::TValue TValue; - typedef typename Superclass::TResult TResult; - typedef typename Superclass::TSpace TSpace; - - typedef typename Superclass::TStartEvent TStartEvent; - typedef typename Superclass::TStartLoopEvent TStartLoopEvent; - typedef typename Superclass::TEndEvent TEndEvent; - typedef typename Superclass::TEndLoopEvent TEndLoopEvent; - typedef typename Superclass::TAliveEvent TAliveEvent; - typedef typename Superclass::TFrontEvent TFrontEvent; - typedef typename Superclass::TFreezeEvent TFreezeEvent; - - typedef typename Superclass::TStartBacktrackingEvent TStartBacktrackingEvent; - typedef typename Superclass::TEndBacktrackingEvent TEndBacktrackingEvent; - typedef typename Superclass::TBacktrackingEvent TBacktrackingEvent; - - typedef typename TBaseAlgorithm::TMinimumSpanningTree TMinimumSpanningTree; - - typedef fpa::Image::Functors::ImageCostFunction< TInputImage, TResult > TCostFunction; - typedef itk::FunctionBase< TResult, TResult > TConversionFunction; - - protected: - typedef typename Superclass::_TVertices _TVertices; - typedef typename Superclass::_TCollision _TCollision; - typedef typename Superclass::_TCollisionsRow _TCollisionsRow; - typedef typename Superclass::_TCollisions _TCollisions; - typedef typename Superclass::_TNode _TNode; - typedef typename Superclass::_TNodes _TNodes; - - public: - itkNewMacro( Self ); - itkTypeMacro( Dijkstra, Algorithm ); - - itkGetObjectMacro( CostFunction, TCostFunction ); - itkGetObjectMacro( ConversionFunction, TConversionFunction ); - - itkGetConstObjectMacro( CostFunction, TCostFunction ); - itkGetConstObjectMacro( ConversionFunction, TConversionFunction ); - - itkSetObjectMacro( CostFunction, TCostFunction ); - itkSetObjectMacro( ConversionFunction, TConversionFunction ); - - protected: - Dijkstra( ); - virtual ~Dijkstra( ); - - virtual TResult _Cost( const TVertex& v, const TVertex& p ) const ITK_OVERRIDE; - - virtual void _BeforeGenerateData( ) ITK_OVERRIDE; - virtual void _AfterGenerateData( ) ITK_OVERRIDE; - virtual void _InitResults( ) ITK_OVERRIDE; - - private: - // Purposely not implemented - Dijkstra( const Self& other ); - Self& operator=( const Self& other ); - - protected: - typename TCostFunction::Pointer m_CostFunction; - typename TConversionFunction::Pointer m_ConversionFunction; - }; - - } // ecapseman - -} // ecapseman - -#ifndef ITK_MANUAL_INSTANTIATION -#include -#endif // ITK_MANUAL_INSTANTIATION - -#endif // __FPA__IMAGE__DIJKSTRA__H__ - -// eof - $RCSfile$ diff --git a/lib/fpa/Image/Dijkstra.hxx b/lib/fpa/Image/Dijkstra.hxx deleted file mode 100644 index 76df258..0000000 --- a/lib/fpa/Image/Dijkstra.hxx +++ /dev/null @@ -1,68 +0,0 @@ -#ifndef __FPA__IMAGE__DIJKSTRA__HXX__ -#define __FPA__IMAGE__DIJKSTRA__HXX__ - -#include - -// ------------------------------------------------------------------------- -template< class I, class O > -fpa::Image::Dijkstra< I, O >:: -Dijkstra( ) - : Superclass( ) -{ - this->m_CostFunction = TCostFunction::New( ); -} - -// ------------------------------------------------------------------------- -template< class I, class O > -fpa::Image::Dijkstra< I, O >:: -~Dijkstra( ) -{ -} - -// ------------------------------------------------------------------------- -template< class I, class O > -typename fpa::Image::Dijkstra< I, O >:: -TResult fpa::Image::Dijkstra< I, O >:: -_Cost( const TVertex& v, const TVertex& p ) const -{ - if( this->_HasEdge( v, p ) ) - { - TResult c = this->m_CostFunction->Evaluate( v, p ); - if( this->m_ConversionFunction.IsNotNull( ) ) - c = this->m_ConversionFunction->Evaluate( c ); - return( c ); - } - else - return( std::numeric_limits< TResult >::max( ) ); -} - -// ------------------------------------------------------------------------- -template< class I, class O > -void fpa::Image::Dijkstra< I, O >:: -_BeforeGenerateData( ) -{ - this->Superclass::_BeforeGenerateData( ); - this->m_CostFunction->SetInputImage( this->GetInput( ) ); -} - -// ------------------------------------------------------------------------- -template< class I, class O > -void fpa::Image::Dijkstra< I, O >:: -_AfterGenerateData( ) -{ - this->Superclass::_AfterGenerateData( ); - this->GetMinimumSpanningTree( )->SetCollisions( this->m_Collisions ); -} - -// ------------------------------------------------------------------------- -template< class I, class O > -void fpa::Image::Dijkstra< I, O >:: -_InitResults( ) -{ - this->Superclass::_InitResults( ); - this->GetOutput( )->FillBuffer( TResult( 0 ) ); -} - -#endif // __FPA__IMAGE__DIJKSTRA__HXX__ - -// eof - $RCSfile$ diff --git a/lib/fpa/Image/DijkstraWithEndPointDetection.h b/lib/fpa/Image/DijkstraWithEndPointDetection.h deleted file mode 100644 index 2158f16..0000000 --- a/lib/fpa/Image/DijkstraWithEndPointDetection.h +++ /dev/null @@ -1,160 +0,0 @@ -#ifndef __FPA__IMAGE__DIJKSTRAWITHENDPOINTDETECTION__H__ -#define __FPA__IMAGE__DIJKSTRAWITHENDPOINTDETECTION__H__ - -#include -#include -#include -#include -#include - -namespace fpa -{ - namespace Image - { - /** - * @param I Input image type - * @param O Output image type - */ - template< class I, class O > - class DijkstraWithEndPointDetection - : public Dijkstra< I, O > - { - public: - typedef DijkstraWithEndPointDetection Self; - typedef Dijkstra< I, O > Superclass; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; - - typedef typename Superclass::TInputImage TInputImage; - typedef typename Superclass::TOutputImage TOutputImage; - typedef typename Superclass::TVertex TVertex; - typedef typename Superclass::TVertexCompare TVertexCompare; - typedef typename Superclass::TValue TValue; - typedef typename Superclass::TResult TResult; - typedef typename Superclass::TSpace TSpace; - typedef typename Superclass::TMinimumSpanningTree TMinimumSpanningTree; - typedef typename Superclass::TCostFunction TCostFunction; - typedef typename Superclass::TConversionFunction TConversionFunction; - typedef typename Superclass::_TVertices TVertices; - - typedef typename Superclass::TStartEvent TStartEvent; - typedef typename Superclass::TStartLoopEvent TStartLoopEvent; - typedef typename Superclass::TEndEvent TEndEvent; - typedef typename Superclass::TEndLoopEvent TEndLoopEvent; - typedef typename Superclass::TAliveEvent TAliveEvent; - typedef typename Superclass::TFrontEvent TFrontEvent; - typedef typename Superclass::TFreezeEvent TFreezeEvent; - - typedef typename - Superclass::TStartBacktrackingEvent TStartBacktrackingEvent; - typedef typename - Superclass::TEndBacktrackingEvent TEndBacktrackingEvent; - typedef typename - Superclass::TBacktrackingEvent TBacktrackingEvent; - - typedef unsigned short TLabel; - typedef itk::Image< TLabel, I::ImageDimension > TLabelImage; - - typedef fpa::Base:: - UniqueValuesContainer< TVertex, TVertexCompare > TUniqueVertices; - typedef fpa::Base:: - MatrixValuesContainer< TVertex, TLabel, TVertexCompare > TBranches; - - protected: - typedef typename Superclass::_TVertices _TVertices; - typedef typename Superclass::_TCollision _TCollision; - typedef typename Superclass::_TCollisionsRow _TCollisionsRow; - typedef typename Superclass::_TCollisions _TCollisions; - typedef typename Superclass::_TNode _TNode; - typedef typename Superclass::_TNodes _TNodes; - - typedef typename I::PixelType _TPixel; - typedef typename I::RegionType _TRegion; - typedef typename I::SizeType _TSize; - - typedef std::pair< TResult, TVertex > _TCandidate; - typedef std::multimap< TResult, TVertex > _TCandidates; - - public: - itkNewMacro( Self ); - itkTypeMacro( DijkstraWithEndPointDetection, Dijkstra ); - - itkBooleanMacro( CorrectSeeds ); - itkBooleanMacro( CorrectEndPoints ); - - itkGetConstMacro( CorrectSeeds, bool ); - itkGetConstMacro( CorrectEndPoints, bool ); - itkGetConstMacro( SafetyNeighborhoodSize, unsigned int ); - - itkGetConstMacro( NumberOfBranches, unsigned long ); - - itkSetMacro( CorrectSeeds, bool ); - itkSetMacro( CorrectEndPoints, bool ); - itkSetMacro( SafetyNeighborhoodSize, unsigned int ); - - public: - TLabelImage* GetLabelImage( ); - const TLabelImage* GetLabelImage( ) const; - void GraftLabelImage( itk::DataObject* obj ); - - TUniqueVertices* GetEndPoints( ); - const TUniqueVertices* GetEndPoints( ) const; - void GraftEndPoints( itk::DataObject* obj ); - - TUniqueVertices* GetBifurcations( ); - const TUniqueVertices* GetBifurcations( ) const; - void GraftBifurcations( itk::DataObject* obj ); - - TBranches* GetBranches( ); - const TBranches* GetBranches( ) const; - void GraftBranches( itk::DataObject* obj ); - - protected: - DijkstraWithEndPointDetection( ); - virtual ~DijkstraWithEndPointDetection( ); - - virtual void _BeforeGenerateData( ); - virtual void _AfterGenerateData( ); - virtual void _SetResult( const TVertex& v, const _TNode& n ); - - void _EndPointsAndBifurcations( ); - void _FindBranches( ); - void _LabelAll( ); - - _TRegion _Region( const TVertex& c, const double& r ); - - template< class _T > - TVertex _MaxInRegion( - const _T* image, const TVertex& v, const double& r - ); - - private: - // Purposely not implemented - DijkstraWithEndPointDetection( const Self& other ); - Self& operator=( const Self& other ); - - protected: - unsigned int m_LabelImageIndex; - unsigned int m_BifurcationsIndex; - unsigned int m_EndPointsIndex; - unsigned int m_BranchesIndex; - - bool m_CorrectSeeds; - bool m_CorrectEndPoints; - unsigned int m_SafetyNeighborhoodSize; - - _TCandidates m_Candidates; - unsigned long m_NumberOfBranches; - }; - - } // ecapseman - -} // ecapseman - -#ifndef ITK_MANUAL_INSTANTIATION -#include -#endif // ITK_MANUAL_INSTANTIATION - -#endif // __FPA__IMAGE__DIJKSTRAWITHENDPOINTDETECTION__H__ - -// eof - $RCSfile$ diff --git a/lib/fpa/Image/DijkstraWithEndPointDetection.hxx b/lib/fpa/Image/DijkstraWithEndPointDetection.hxx deleted file mode 100644 index 3bbf8c5..0000000 --- a/lib/fpa/Image/DijkstraWithEndPointDetection.hxx +++ /dev/null @@ -1,561 +0,0 @@ -#ifndef __FPA__IMAGE__DIJKSTRAWITHENDPOINTDETECTION__HXX__ -#define __FPA__IMAGE__DIJKSTRAWITHENDPOINTDETECTION__HXX__ - -#include -#include -#include -#include - -// ------------------------------------------------------------------------- -template< class I, class O > -typename fpa::Image::DijkstraWithEndPointDetection< I, O >:: -TLabelImage* fpa::Image::DijkstraWithEndPointDetection< I, O >:: -GetLabelImage( ) -{ - return( - dynamic_cast< TLabelImage* >( - this->itk::ProcessObject::GetOutput( this->m_LabelImageIndex ) - ) - ); -} - -// ------------------------------------------------------------------------- -template< class I, class O > -const typename fpa::Image::DijkstraWithEndPointDetection< I, O >:: -TLabelImage* fpa::Image::DijkstraWithEndPointDetection< I, O >:: -GetLabelImage( ) const -{ - return( - dynamic_cast< const TLabelImage* >( - this->itk::ProcessObject::GetOutput( this->m_LabelImageIndex ) - ) - ); -} - -// ------------------------------------------------------------------------- -template< class I, class O > -void fpa::Image::DijkstraWithEndPointDetection< I, O >:: -GraftLabelImage( itk::DataObject* obj ) -{ - TLabelImage* lbl = - dynamic_cast< TLabelImage* >( - this->itk::ProcessObject::GetOutput( this->m_LabelImageIndex ) - ); - if( lbl != NULL ) - this->GraftNthOutput( this->m_LabelImageIndex, lbl ); -} - -// ------------------------------------------------------------------------- -template< class I, class O > -typename fpa::Image::DijkstraWithEndPointDetection< I, O >:: -TUniqueVertices* fpa::Image::DijkstraWithEndPointDetection< I, O >:: -GetEndPoints( ) -{ - return( - dynamic_cast< TUniqueVertices* >( - this->itk::ProcessObject::GetOutput( this->m_EndPointsIndex ) - ) - ); -} - -// ------------------------------------------------------------------------- -template< class I, class O > -const typename fpa::Image::DijkstraWithEndPointDetection< I, O >:: -TUniqueVertices* fpa::Image::DijkstraWithEndPointDetection< I, O >:: -GetEndPoints( ) const -{ - return( - dynamic_cast< const TUniqueVertices* >( - this->itk::ProcessObject::GetOutput( this->m_EndPointsIndex ) - ) - ); -} - -// ------------------------------------------------------------------------- -template< class I, class O > -void fpa::Image::DijkstraWithEndPointDetection< I, O >:: -GraftEndPoints( itk::DataObject* obj ) -{ - TUniqueVertices* lbl = - dynamic_cast< TUniqueVertices* >( - this->itk::ProcessObject::GetOutput( this->m_EndPointsIndex ) - ); - if( lbl != NULL ) - this->GraftNthOutput( this->m_EndPointsIndex, lbl ); -} - -// ------------------------------------------------------------------------- -template< class I, class O > -typename fpa::Image::DijkstraWithEndPointDetection< I, O >:: -TUniqueVertices* fpa::Image::DijkstraWithEndPointDetection< I, O >:: -GetBifurcations( ) -{ - return( - dynamic_cast< TUniqueVertices* >( - this->itk::ProcessObject::GetOutput( this->m_BifurcationsIndex ) - ) - ); -} - -// ------------------------------------------------------------------------- -template< class I, class O > -const typename fpa::Image::DijkstraWithEndPointDetection< I, O >:: -TUniqueVertices* fpa::Image::DijkstraWithEndPointDetection< I, O >:: -GetBifurcations( ) const -{ - return( - dynamic_cast< const TUniqueVertices* >( - this->itk::ProcessObject::GetOutput( this->m_BifurcationsIndex ) - ) - ); -} - -// ------------------------------------------------------------------------- -template< class I, class O > -void fpa::Image::DijkstraWithEndPointDetection< I, O >:: -GraftBifurcations( itk::DataObject* obj ) -{ - TUniqueVertices* lbl = - dynamic_cast< TUniqueVertices* >( - this->itk::ProcessObject::GetOutput( this->m_BifurcationsIndex ) - ); - if( lbl != NULL ) - this->GraftNthOutput( this->m_BifurcationsIndex, lbl ); -} - - -// ------------------------------------------------------------------------- -template< class I, class O > -typename fpa::Image::DijkstraWithEndPointDetection< I, O >:: -TBranches* fpa::Image::DijkstraWithEndPointDetection< I, O >:: -GetBranches( ) -{ - return( - dynamic_cast< TBranches* >( - this->itk::ProcessObject::GetOutput( this->m_BranchesIndex ) - ) - ); -} - -// ------------------------------------------------------------------------- -template< class I, class O > -const typename fpa::Image::DijkstraWithEndPointDetection< I, O >:: -TBranches* fpa::Image::DijkstraWithEndPointDetection< I, O >:: -GetBranches( ) const -{ - return( - dynamic_cast< const TBranches* >( - this->itk::ProcessObject::GetOutput( this->m_BranchesIndex ) - ) - ); -} - -// ------------------------------------------------------------------------- -template< class I, class O > -void fpa::Image::DijkstraWithEndPointDetection< I, O >:: -GraftBranches( itk::DataObject* obj ) -{ - TBranches* lbl = - dynamic_cast< TBranches* >( - this->itk::ProcessObject::GetOutput( this->m_BranchesIndex ) - ); - if( lbl != NULL ) - this->GraftNthOutput( this->m_BranchesIndex, lbl ); -} - -// ------------------------------------------------------------------------- -template< class I, class O > -fpa::Image::DijkstraWithEndPointDetection< I, O >:: -DijkstraWithEndPointDetection( ) - : Superclass( ), - m_CorrectSeeds( true ), - m_CorrectEndPoints( true ), - m_SafetyNeighborhoodSize( 3 ) -{ - this->m_LabelImageIndex = this->GetNumberOfRequiredOutputs( ); - this->m_EndPointsIndex = this->m_LabelImageIndex + 1; - this->m_BifurcationsIndex = this->m_LabelImageIndex + 2; - this->m_BranchesIndex = this->m_LabelImageIndex + 3; - this->SetNumberOfRequiredOutputs( this->m_LabelImageIndex + 4 ); - this->itk::ProcessObject::SetNthOutput( - this->m_LabelImageIndex, TLabelImage::New( ) - ); - this->itk::ProcessObject::SetNthOutput( - this->m_EndPointsIndex, TUniqueVertices::New( ) - ); - this->itk::ProcessObject::SetNthOutput( - this->m_BifurcationsIndex, TUniqueVertices::New( ) - ); - this->itk::ProcessObject::SetNthOutput( - this->m_BranchesIndex, TBranches::New( ) - ); -} - -// ------------------------------------------------------------------------- -template< class I, class O > -fpa::Image::DijkstraWithEndPointDetection< I, O >:: -~DijkstraWithEndPointDetection( ) -{ -} - -// ------------------------------------------------------------------------- -template< class I, class O > -void fpa::Image::DijkstraWithEndPointDetection< I, O >:: -_BeforeGenerateData( ) -{ - if( this->m_CorrectSeeds ) - { - const I* input = this->GetInput( ); - typename I::SpacingType spac = input->GetSpacing( ); - double max_spac = double( spac[ 0 ] ); - for( unsigned int d = 1; d < I::ImageDimension; ++d ) - max_spac = - ( double( spac[ d ] ) > max_spac )? double( spac[ d ] ): max_spac; - max_spac *= double( 3 ); - - // Correct seeds - for( unsigned int s = 0; s < this->m_SeedVertices.size( ); ++s ) - { - TVertex seed = this->m_SeedVertices[ s ]; - _TNode n = this->m_Seeds[ seed ]; - _TRegion region = this->_Region( seed, max_spac ); - itk::ImageRegionConstIteratorWithIndex< I > iIt( input, region ); - - iIt.GoToBegin( ); - _TPixel max_value = iIt.Get( ); - for( ++iIt; !iIt.IsAtEnd( ); ++iIt ) - { - if( iIt.Get( ) > max_value ) - { - this->m_SeedVertices[ s ] = iIt.GetIndex( ); - max_value = iIt.Get( ); - - } // fi - - } // rof - this->m_Seeds.erase( seed ); - n.Parent = this->m_SeedVertices[ s ]; - this->m_Seeds[ this->m_SeedVertices[ s ] ] = n; - - } // rof - - } // fi - - // End initialization - this->Superclass::_BeforeGenerateData( ); - this->m_Candidates.clear( ); -} - -// ------------------------------------------------------------------------- -template< class I, class O > -void fpa::Image::DijkstraWithEndPointDetection< I, O >:: -_AfterGenerateData( ) -{ - // Finish base algorithm - this->Superclass::_AfterGenerateData( ); - - // Check if backtracking has any sense - if( this->m_Candidates.size( ) == 0 ) - return; - this->InvokeEvent( TEndEvent( ) ); - this->InvokeEvent( TStartBacktrackingEvent( ) ); - - // Detect endpoints and bifurcations - this->_EndPointsAndBifurcations( ); - - // Find branches - this->_FindBranches( ); - - // Label pixels and branches - this->_LabelAll( ); -} - -// ------------------------------------------------------------------------- -template< class I, class O > -void fpa::Image::DijkstraWithEndPointDetection< I, O >:: -_SetResult( const TVertex& v, const _TNode& n ) -{ - this->Superclass::_SetResult( v, n ); - this->m_Candidates.insert( _TCandidate( n.Result, v ) ); -} - -// ------------------------------------------------------------------------- -template< class I, class O > -void fpa::Image::DijkstraWithEndPointDetection< I, O >:: -_EndPointsAndBifurcations( ) -{ - // Prepare backtracking objects - TUniqueVertices* endpoints = this->GetEndPoints( ); - TUniqueVertices* bifurcations = this->GetBifurcations( ); - endpoints->Clear( ); - bifurcations->Clear( ); - - // Get some input values - TVertex seed = this->GetSeed( 0 ); - const I* input = this->GetInput( ); - const TMinimumSpanningTree* mst = this->GetMinimumSpanningTree( ); - - // Prepare a pixel marks structure - typedef std::map< TVertex, bool, TVertexCompare > _TPixelMarks; - _TPixelMarks pixel_marks; - - // Object to hold tree-nodes marks - typedef std::set< TVertex, TVertexCompare > _TTreeMarks; - _TTreeMarks tree_marks; - - // Iterate over the candidates, starting from the candidates that - // are near thin branches (high accumulated cost) - typename _TCandidates::const_reverse_iterator cIt = - this->m_Candidates.rbegin( ); - for( ; cIt != this->m_Candidates.rend( ); ++cIt ) - { - // If pixel has already been visited, pass - TVertex v = cIt->second; - if( pixel_marks[ v ] ) - continue; - - // Correct it to nearest start candidate (high distance value) - double vr = std::sqrt( double( input->GetPixel( v ) ) ); - if( this->m_CorrectEndPoints ) - v = this->_MaxInRegion( input, v, vr * double( 1.5 ) ); - - // Now, check for real marking conditions - // 1. Has it been visited by dijkstra? - if( this->_Node( v ).Label == Self::FarLabel ) - continue; - // 2. Is it already marked? - if( pixel_marks[ v ] ) - continue; - // 3. Is it already an endpoint? - if( endpoints->Find( v ) ) - continue; - // 4. Ok, it is completely new! - endpoints->Insert( v ); - - // Get the path all the way to global seed - TVertices path = mst->GetPath( v, seed ); - - // Backtracking to find endpoints and bifurcations - bool adding_new_points = true; - typename TVertices::const_iterator pIt = path.begin( ); - for( ; pIt != path.end( ) && adding_new_points; ++pIt ) - { - this->InvokeEvent( TBacktrackingEvent( *pIt, 1 ) ); - if( tree_marks.find( *pIt ) == tree_marks.end( ) ) - { - // Mark current point as a tree point - tree_marks.insert( *pIt ); - - // Mark a region around current point as visited - vr = std::sqrt( double( input->GetPixel( *pIt ) ) ); - _TRegion region = this->_Region( *pIt, vr ); - if( region.GetNumberOfPixels( ) > 0 ) - { - itk::ImageRegionConstIteratorWithIndex< I > iIt( input, region ); - for( iIt.GoToBegin( ); !iIt.IsAtEnd( ); ++iIt ) - pixel_marks[ iIt.GetIndex( ) ] = true; - } - else - pixel_marks[ *pIt ] = true; - } - else - { - // A bifurcation point has been reached! - if( *pIt != seed ) - { - bifurcations->Insert( *pIt ); - adding_new_points = false; - - } // fi - - } // fi - - } // rof - this->InvokeEvent( TEndBacktrackingEvent( ) ); - - } // rof -} - -// ------------------------------------------------------------------------- -template< class I, class O > -void fpa::Image::DijkstraWithEndPointDetection< I, O >:: -_FindBranches( ) -{ - // Configure and obtain inputs - TVertex seed = this->GetSeed( 0 ); - const TMinimumSpanningTree* mst = this->GetMinimumSpanningTree( ); - const TUniqueVertices* endpoints = this->GetEndPoints( ); - const TUniqueVertices* bifurcations = this->GetBifurcations( ); - TBranches* branches = this->GetBranches( ); - branches->Clear( ); - - // Reconstruct pixels - typename TUniqueVertices::ConstIterator eIt = endpoints->Begin( ); - for( ; eIt != endpoints->End( ); ++eIt ) - { - // Get the path all the way to global seed - TVertices path = mst->GetPath( *eIt, seed ); - - TVertex start_vertex = *eIt; - typename TVertices::const_iterator pIt = path.begin( ); - for( ; pIt != path.end( ); ++pIt ) - { - if( bifurcations->Find( *pIt ) ) - { - branches->SetValue( start_vertex, *pIt, 1 ); - start_vertex = *pIt; - - } // fi - - } // rof - - // Finish with branches to global seed - branches->SetValue( start_vertex, seed, 1 ); - - } // rof -} - -// ------------------------------------------------------------------------- -template< class I, class O > -void fpa::Image::DijkstraWithEndPointDetection< I, O >:: -_LabelAll( ) -{ - // Configure and obtain inputs - const I* input = this->GetInput( ); - const TMinimumSpanningTree* mst = this->GetMinimumSpanningTree( ); - const TUniqueVertices* bifurcations = this->GetBifurcations( ); - TBranches* branches = this->GetBranches( ); - TLabelImage* label = this->GetLabelImage( ); - label->FillBuffer( 0 ); - - // Label branches - typename TBranches::Iterator bIt = branches->Begin( ); - TLabel actual_label = 0; - for( ; bIt != branches->End( ); ++bIt ) - { - typename TBranches::RowIterator brIt = branches->Begin( bIt ); - for( ; brIt != branches->End( bIt ); ++brIt ) - { - actual_label++; - brIt->second = actual_label; - - TVertices path = mst->GetPath( bIt->first, brIt->first ); - typename TVertices::const_iterator pIt = path.begin( ); - for( ; pIt != path.end( ); ++pIt ) - { - double d = std::sqrt( double( input->GetPixel( *pIt ) ) ); - _TRegion region = this->_Region( *pIt, d ); - itk::ImageRegionConstIteratorWithIndex< I > iIt( input, region ); - itk::ImageRegionIteratorWithIndex< TLabelImage > lIt( label, region ); - iIt.GoToBegin( ); - lIt.GoToBegin( ); - for( ; !iIt.IsAtEnd( ); ++iIt, ++lIt ) - { - // Mask real input image - if( - !( iIt.Get( ) < ( typename I::PixelType )( 0 ) ) && - lIt.Get( ) == TLabel( 0 ) - ) - lIt.Set( actual_label ); - - } // rof - - } // rof - - } // rof - - } // rof - this->m_NumberOfBranches = actual_label; - - // Label bifurcations - typename TUniqueVertices::ConstIterator bifIt = - bifurcations->Begin( ); - for( ; bifIt != bifurcations->End( ); ++bifIt ) - { - actual_label++; - double d = std::sqrt( double( input->GetPixel( *bifIt ) ) ); - _TRegion region = this->_Region( *bifIt, d * 1.5 ); - itk::ImageRegionConstIteratorWithIndex< I > iIt( input, region ); - itk::ImageRegionIteratorWithIndex< TLabelImage > lIt( label, region ); - iIt.GoToBegin( ); - lIt.GoToBegin( ); - for( ; !iIt.IsAtEnd( ); ++iIt, ++lIt ) - { - // Mask real input image - if( !( iIt.Get( ) < ( typename I::PixelType )( 0 ) ) ) - lIt.Set( actual_label ); - - } // rof - - } // rof -} - -// ------------------------------------------------------------------------- -template< class I, class O > -typename fpa::Image::DijkstraWithEndPointDetection< I, O >:: -_TRegion fpa::Image::DijkstraWithEndPointDetection< I, O >:: -_Region( const TVertex& c, const double& r ) -{ - typename I::ConstPointer input = this->GetInput( ); - typename I::SpacingType spac = input->GetSpacing( ); - _TRegion region = input->GetLargestPossibleRegion( ); - typename I::IndexType idx0 = region.GetIndex( ); - typename I::IndexType idx1 = idx0 + region.GetSize( ); - - // Compute region size and index - typename I::IndexType i0, i1; - _TSize size; - for( unsigned int d = 0; d < I::ImageDimension; ++d ) - { - // NOTE: 3 is a minimum neighborhood size - long s = - long( std::ceil( r / double( spac[ d ] ) ) ) + - long( this->m_SafetyNeighborhoodSize ); - i0[ d ] = c[ d ] - s; - i1[ d ] = c[ d ] + s; - - if( i0[ d ] < idx0[ d ] ) i0[ d ] = idx0[ d ]; - if( i1[ d ] < idx0[ d ] ) i1[ d ] = idx0[ d ]; - if( i0[ d ] > idx1[ d ] ) i0[ d ] = idx1[ d ]; - if( i1[ d ] > idx1[ d ] ) i1[ d ] = idx1[ d ]; - size[ d ] = i1[ d ] - i0[ d ]; - - } // rof - - // Prepare region and return it - region.SetIndex( i0 ); - region.SetSize( size ); - - return( region ); -} - -// ------------------------------------------------------------------------- -template< class I, class O > -template< class _T > -typename fpa::Image::DijkstraWithEndPointDetection< I, O >:: -TVertex fpa::Image::DijkstraWithEndPointDetection< I, O >:: -_MaxInRegion( const _T* image, const TVertex& v, const double& r ) -{ - typedef itk::ImageRegionConstIteratorWithIndex< _T > _TIt; - - _TIt iIt( image, this->_Region( v, r ) ); - iIt.GoToBegin( ); - TVertex max_vertex = iIt.GetIndex( ); - typename _T::PixelType max_value = iIt.Get( ); - for( ++iIt; !iIt.IsAtEnd( ); ++iIt ) - { - typename _T::PixelType value = iIt.Get( ); - if( value > max_value ) - { - max_value = value; - max_vertex = iIt.GetIndex( ); - - } // fi - - } // rof - return( max_vertex ); -} - -#endif // __FPA__IMAGE__DIJKSTRAWITHENDPOINTDETECTION__HXX__ - -// eof - $RCSfile$ diff --git a/lib/fpa/Image/ExtractEndPointsAndBifurcationsFromMinimumSpanningTree.h b/lib/fpa/Image/ExtractEndPointsAndBifurcationsFromMinimumSpanningTree.h deleted file mode 100644 index 002afb4..0000000 --- a/lib/fpa/Image/ExtractEndPointsAndBifurcationsFromMinimumSpanningTree.h +++ /dev/null @@ -1,93 +0,0 @@ -#ifndef __FPA__IMAGE__EXTRACTENDPOINTSANDBIFURCATIONSFROMMINIMUMSPANNINGTREE__H__ -#define __FPA__IMAGE__EXTRACTENDPOINTSANDBIFURCATIONSFROMMINIMUMSPANNINGTREE__H__ - -#include -#include - -namespace fpa -{ - namespace Image - { - /** - */ - template< class _TImage, class _TMST > - class ExtractEndPointsAndBifurcationsFromMinimumSpanningTree - : public fpa::Base::ExtractEndPointsAndBifurcationsFromMinimumSpanningTree< _TMST > - { - public: - typedef - fpa::Base::ExtractEndPointsAndBifurcationsFromMinimumSpanningTree< _TMST > - Superclass; - typedef ExtractEndPointsAndBifurcationsFromMinimumSpanningTree Self; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; - - typedef _TImage TImage; - typedef typename Superclass::TMinimumSpanningTree TMinimumSpanningTree; - typedef typename Superclass::TVertex TVertex; - - typedef itk::Image< unsigned short, TImage::ImageDimension > TMarkImage; - typedef fpa::Base::ImageSkeleton< _TMST > TSkeleton; - - public: - itkNewMacro( Self ); - itkTypeMacro( - ExtractEndPointsAndBifurcationsFromMinimumSpanningTree, - fpa::Base::ExtractEndPointsAndBifurcationsFromMinimumSpanningTree - ); - - itkBooleanMacro( SquaredDistanceMap ); - itkGetConstMacro( SquaredDistanceMap, bool ); - itkSetMacro( SquaredDistanceMap, bool ); - - public: - const TImage* GetCostsImage( ); - const TImage* GetDistanceMap( ); - TSkeleton* GetSkeleton( ); - void SetCostsImage( TImage* image ); - void SetDistanceMap( TImage* image ); - - protected: - ExtractEndPointsAndBifurcationsFromMinimumSpanningTree( ); - virtual ~ExtractEndPointsAndBifurcationsFromMinimumSpanningTree( ); - - virtual void GenerateData( ) ITK_OVERRIDE; - - virtual void _MarkSkeleton( - const TVertex& v, const unsigned long& l - ) ITK_OVERRIDE; - virtual void _MarkSphere( - const TVertex& v, - const double& r, - const unsigned long& l - ) ITK_OVERRIDE; - virtual unsigned long _Mark( const TVertex& v ) ITK_OVERRIDE; - virtual unsigned long _SkeletonMark( const TVertex& v ) ITK_OVERRIDE; - virtual double _Radius( const TVertex& v ) ITK_OVERRIDE; - - virtual void _Tmp( ) ITK_OVERRIDE - { - } - - private: - // Purposely not implemented - ExtractEndPointsAndBifurcationsFromMinimumSpanningTree( const Self& other ); - Self& operator=( const Self& other ); - - protected: - typename TMarkImage::Pointer m_MarkImage; - typename TMarkImage::Pointer m_SkeletonImage; - bool m_SquaredDistanceMap; - }; - - } // ecapseman - -} // ecapseman - -#ifndef ITK_MANUAL_INSTANTIATION -#include -#endif // ITK_MANUAL_INSTANTIATION - -#endif // __FPA__IMAGE__EXTRACTENDPOINTSANDBIFURCATIONSFROMMINIMUMSPANNINGTREE__H__ - -// eof - $RCSfile$ diff --git a/lib/fpa/Image/ExtractEndPointsAndBifurcationsFromMinimumSpanningTree.hxx b/lib/fpa/Image/ExtractEndPointsAndBifurcationsFromMinimumSpanningTree.hxx deleted file mode 100644 index cdc34fb..0000000 --- a/lib/fpa/Image/ExtractEndPointsAndBifurcationsFromMinimumSpanningTree.hxx +++ /dev/null @@ -1,235 +0,0 @@ -#ifndef __FPA__IMAGE__EXTRACTENDPOINTSANDBIFURCATIONSFROMMINIMUMSPANNINGTREE__HXX__ -#define __FPA__IMAGE__EXTRACTENDPOINTSANDBIFURCATIONSFROMMINIMUMSPANNINGTREE__HXX__ - -#include -#include - -// ------------------------------------------------------------------------- -template< class _TImage, class _TMST > -const typename -fpa::Image::ExtractEndPointsAndBifurcationsFromMinimumSpanningTree< _TImage, _TMST >:: -TImage* -fpa::Image::ExtractEndPointsAndBifurcationsFromMinimumSpanningTree< _TImage, _TMST >:: -GetCostsImage( ) -{ - return( - dynamic_cast< const _TImage* >( this->itk::ProcessObject::GetInput( 1 ) ) - ); -} - -// ------------------------------------------------------------------------- -template< class _TImage, class _TMST > -const typename -fpa::Image::ExtractEndPointsAndBifurcationsFromMinimumSpanningTree< _TImage, _TMST >:: -TImage* -fpa::Image::ExtractEndPointsAndBifurcationsFromMinimumSpanningTree< _TImage, _TMST >:: -GetDistanceMap( ) -{ - return( - dynamic_cast< const _TImage* >( this->itk::ProcessObject::GetInput( 2 ) ) - ); -} - -// ------------------------------------------------------------------------- -template< class _TImage, class _TMST > -typename -fpa::Image::ExtractEndPointsAndBifurcationsFromMinimumSpanningTree< _TImage, _TMST >:: -TSkeleton* -fpa::Image::ExtractEndPointsAndBifurcationsFromMinimumSpanningTree< _TImage, _TMST >:: -GetSkeleton( ) -{ - return( - dynamic_cast< TSkeleton* >( - this->itk::ProcessObject::GetOutput( - this->GetNumberOfRequiredOutputs( ) - 1 - ) - ) - ); -} - -// ------------------------------------------------------------------------- -template< class _TImage, class _TMST > -void -fpa::Image::ExtractEndPointsAndBifurcationsFromMinimumSpanningTree< _TImage, _TMST >:: -SetCostsImage( TImage* image ) -{ - this->itk::ProcessObject::SetNthInput( 1, const_cast< _TImage* >( image ) ); -} - -// ------------------------------------------------------------------------- -template< class _TImage, class _TMST > -void -fpa::Image::ExtractEndPointsAndBifurcationsFromMinimumSpanningTree< _TImage, _TMST >:: -SetDistanceMap( TImage* image ) -{ - this->itk::ProcessObject::SetNthInput( 2, const_cast< _TImage* >( image ) ); -} - -// ------------------------------------------------------------------------- -template< class _TImage, class _TMST > -fpa::Image::ExtractEndPointsAndBifurcationsFromMinimumSpanningTree< _TImage, _TMST >:: -ExtractEndPointsAndBifurcationsFromMinimumSpanningTree( ) - : Superclass( ), - m_SquaredDistanceMap( false ) -{ - this->SetNumberOfRequiredInputs( 3 ); - unsigned int nOuts = this->GetNumberOfRequiredOutputs( ); - this->SetNumberOfRequiredOutputs( nOuts + 1 ); - typename TSkeleton::Pointer sk = TSkeleton::New( ); - this->itk::ProcessObject::SetNthOutput( nOuts, sk.GetPointer( ) ); -} - -// ------------------------------------------------------------------------- -template< class _TImage, class _TMST > -fpa::Image::ExtractEndPointsAndBifurcationsFromMinimumSpanningTree< _TImage, _TMST >:: -~ExtractEndPointsAndBifurcationsFromMinimumSpanningTree( ) -{ -} - -// ------------------------------------------------------------------------- -template< class _TImage, class _TMST > -void -fpa::Image::ExtractEndPointsAndBifurcationsFromMinimumSpanningTree< _TImage, _TMST >:: -GenerateData( ) -{ - // Create auxiliary objects - auto image = this->GetCostsImage( ); - this->m_MarkImage = TMarkImage::New( ); - this->m_MarkImage->SetLargestPossibleRegion( image->GetLargestPossibleRegion( ) ); - this->m_MarkImage->SetRequestedRegion( image->GetRequestedRegion( ) ); - this->m_MarkImage->SetBufferedRegion( image->GetBufferedRegion( ) ); - this->m_MarkImage->SetDirection( image->GetDirection( ) ); - this->m_MarkImage->SetOrigin( image->GetOrigin( ) ); - this->m_MarkImage->SetSpacing( image->GetSpacing( ) ); - this->m_MarkImage->Allocate( ); - this->m_MarkImage->FillBuffer( 0 ); - this->m_SkeletonImage = TMarkImage::New( ); - this->m_SkeletonImage->SetLargestPossibleRegion( image->GetLargestPossibleRegion( ) ); - this->m_SkeletonImage->SetRequestedRegion( image->GetRequestedRegion( ) ); - this->m_SkeletonImage->SetBufferedRegion( image->GetBufferedRegion( ) ); - this->m_SkeletonImage->SetDirection( image->GetDirection( ) ); - this->m_SkeletonImage->SetOrigin( image->GetOrigin( ) ); - this->m_SkeletonImage->SetSpacing( image->GetSpacing( ) ); - this->m_SkeletonImage->Allocate( ); - this->m_SkeletonImage->FillBuffer( 0 ); - - // Real execution - this->Superclass::GenerateData( ); - - // Build skeleton - auto sk = this->GetSkeleton( ); - sk->SetMinimumSpanningTree( this->GetMinimumSpanningTree( ) ); - auto bIt = this->m_Branches.begin( ); - for( ; bIt != this->m_Branches.end( ); ++bIt ) - sk->AddBranch( bIt->second, bIt->first ); -} - -// ------------------------------------------------------------------------- -template< class _TImage, class _TMST > -void -fpa::Image::ExtractEndPointsAndBifurcationsFromMinimumSpanningTree< _TImage, _TMST >:: -_MarkSkeleton( const TVertex& v, const unsigned long& l ) -{ - if( this->m_SkeletonImage->GetRequestedRegion( ).IsInside( v ) ) - this->m_SkeletonImage->SetPixel( v, l ); -} - -// ------------------------------------------------------------------------- -template< class _TImage, class _TMST > -void -fpa::Image::ExtractEndPointsAndBifurcationsFromMinimumSpanningTree< _TImage, _TMST >:: -_MarkSphere( - const TVertex& v, - const double& r, - const unsigned long& l - ) -{ - double rr = r * double( 1.1 ); - - // Get marking region - auto rreg = this->m_MarkImage->GetRequestedRegion( ); - auto spac = this->m_MarkImage->GetSpacing( ); - TVertex ireg = rreg.GetIndex( ); - TVertex jreg = ireg + rreg.GetSize( ); - TVertex idx, jdx; - typename _TImage::SizeType size; - bool all = false; - for( unsigned int d = 0; d < _TImage::ImageDimension; ++d ) - { - unsigned long s = std::ceil( rr / double( spac[ d ] ) ); - if( s < 3 ) - { - s = 3; - all = true; - - } // fi - s += 3; - idx[ d ] = v[ d ] - s; - jdx[ d ] = v[ d ] + s; - - jreg[ d ]--; - if( idx[ d ] < ireg[ d ] ) idx[ d ] = ireg[ d ]; - if( idx[ d ] > jreg[ d ] ) idx[ d ] = jreg[ d ]; - if( jdx[ d ] < ireg[ d ] ) jdx[ d ] = ireg[ d ]; - if( jdx[ d ] > jreg[ d ] ) jdx[ d ] = jreg[ d ]; - size[ d ] = jdx[ d ] - idx[ d ] + 1; - - } // rof - typename _TImage::RegionType region; - region.SetIndex( idx ); - region.SetSize( size ); - - // Mark region - typename _TImage::PointType c; - this->m_MarkImage->TransformIndexToPhysicalPoint( v, c ); - itk::ImageRegionIteratorWithIndex< TMarkImage > - spIt( this->m_MarkImage, region ); - for( spIt.GoToBegin( ); !spIt.IsAtEnd( ); ++spIt ) - { - typename _TImage::PointType pnt; - this->m_MarkImage->TransformIndexToPhysicalPoint( spIt.GetIndex( ), pnt ); - /* - if( double( pnt.EuclideanDistanceTo( c ) ) <= rr || all ) - if( spIt.Get( ) == 0 ) - */ - spIt.Set( l ); - - } // rof -} - -// ------------------------------------------------------------------------- -template< class _TImage, class _TMST > -unsigned long -fpa::Image::ExtractEndPointsAndBifurcationsFromMinimumSpanningTree< _TImage, _TMST >:: -_Mark( const TVertex& v ) -{ - return( this->m_MarkImage->GetPixel( v ) ); -} - -// ------------------------------------------------------------------------- -template< class _TImage, class _TMST > -unsigned long fpa::Image::ExtractEndPointsAndBifurcationsFromMinimumSpanningTree< _TImage, _TMST >:: -_SkeletonMark( const TVertex& v ) -{ - return( this->m_SkeletonImage->GetPixel( v ) ); -} - -// ------------------------------------------------------------------------- -template< class _TImage, class _TMST > -double -fpa::Image::ExtractEndPointsAndBifurcationsFromMinimumSpanningTree< _TImage, _TMST >:: -_Radius( const TVertex& v ) -{ - double d = double( this->GetDistanceMap( )->GetPixel( v ) ); - double s = std::fabs( d ); - if( s > double( 0 ) ) - s /= d; - if( this->m_SquaredDistanceMap ) - return( s * std::sqrt( std::fabs( d ) ) ); - else - return( d ); -} - -#endif // __FPA__IMAGE__EXTRACTENDPOINTSANDBIFURCATIONSFROMMINIMUMSPANNINGTREE__HXX__ - -// eof - $RCSfile$ diff --git a/lib/fpa/Image/FastMarching.h b/lib/fpa/Image/FastMarching.h deleted file mode 100644 index d86d99d..0000000 --- a/lib/fpa/Image/FastMarching.h +++ /dev/null @@ -1,58 +0,0 @@ -#ifndef __FPA__IMAGE__FASTMARCHING__H__ -#define __FPA__IMAGE__FASTMARCHING__H__ - -#include -#include -#include -#include -#include -#include - -namespace fpa -{ - namespace Image - { - /** - * @param I Input image type - */ - template< class I, class C > - class FastMarching - : public Algorithm< I, fpa::Base::FastMarching< typename I::IndexType, C, typename I::PixelType, itk::Functor::IndexLexicographicCompare< I::ImageDimension >, itk::ImageToImageFilter< I, itk::Image< C, I::ImageDimension > > > > - { - public: - // Standard class typdedefs - typedef typename I::IndexType TVertex; - typedef typename I::PixelType TVertexValue; - typedef itk::Image< C, I::ImageDimension > TCostImage; - typedef itk::ImageToImageFilter< I, TCostImage > TBaseFilter; - typedef fpa::Base::FastMarching< TVertex, C, TVertexValue, itk::Functor::IndexLexicographicCompare< I::ImageDimension >, TBaseFilter > TBaseAlgorithm; - - typedef FastMarching Self; - typedef Algorithm< I, TBaseAlgorithm > Superclass; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; - - public: - itkNewMacro( Self ); - itkTypeMacro( FastMarching, fpaBaseFastMarching ); - - protected: - FastMarching( ) - : Superclass( ) - { } - virtual ~FastMarching( ) - { } - - private: - // Purposely not implemented - FastMarching( const Self& ); - void operator=( const Self& ); - }; - - } // ecapseman - -} // ecapseman - -#endif // __FPA__IMAGE__FASTMARCHING__H__ - -// eof - $RCSfile$ diff --git a/lib/fpa/Image/Functors/FluxMedialness.h b/lib/fpa/Image/Functors/FluxMedialness.h deleted file mode 100644 index 4aa7e8a..0000000 --- a/lib/fpa/Image/Functors/FluxMedialness.h +++ /dev/null @@ -1,78 +0,0 @@ -#ifndef __FPA__IMAGE__FUNCTORS__FLUXMEDIALNESS__H__ -#define __FPA__IMAGE__FUNCTORS__FLUXMEDIALNESS__H__ - -#include - -namespace fpa -{ - namespace Image - { - namespace Functors - { - /** - */ - template< class _TGradient > - class FluxMedialness - : public GradientImageFunctionBase< _TGradient > - { - public: - typedef FluxMedialness Self; - typedef GradientImageFunctionBase< _TGradient > Superclass; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; - - itkStaticConstMacro( Dimension, unsigned int, Superclass::Dimension ); - - typedef typename Superclass::TOutput TOutput; - typedef typename Superclass::TScalar TScalar; - typedef typename Superclass::TIndex TIndex; - typedef typename Superclass::TVector TVector; - typedef typename Superclass::TPoint TPoint; - - typedef std::vector< double > TRCandidates; - - public: - itkNewMacro( Self ); - itkTypeMacro( FluxMedialness, GradientImageFunctionBase ); - - itkGetConstMacro( RadiusStep, double ); - itkGetConstMacro( MinRadius, double ); - itkGetConstMacro( MaxRadius, double ); - itkGetConstMacro( RadialSampling, unsigned int ); - - itkSetMacro( RadiusStep, double ); - itkSetMacro( MinRadius, double ); - itkSetMacro( MaxRadius, double ); - itkSetMacro( RadialSampling, unsigned int ); - - protected: - FluxMedialness( ); - virtual ~FluxMedialness( ); - - virtual TOutput _Evaluate( const TIndex& i ) const ITK_OVERRIDE; - - private: - // Purposely not implemented. - FluxMedialness( const Self& ); - void operator=( const Self& ); - - protected: - double m_MinRadius; - double m_MaxRadius; - unsigned int m_RadialSampling; - double m_RadiusStep; - }; - - } // ecapseman - - } // ecapseman - -} // ecapseman - -#ifndef ITK_MANUAL_INSTANTIATION -#include -#endif // ITK_MANUAL_INSTANTIATION - -#endif // __FPA__IMAGE__FUNCTORS__FLUXMEDIALNESS__H__ - -// eof - $RCSfile$ diff --git a/lib/fpa/Image/Functors/FluxMedialness.hxx b/lib/fpa/Image/Functors/FluxMedialness.hxx deleted file mode 100644 index 8f8651b..0000000 --- a/lib/fpa/Image/Functors/FluxMedialness.hxx +++ /dev/null @@ -1,108 +0,0 @@ -#ifndef __FPA__IMAGE__FUNCTORS__FLUXMEDIALNESS__HXX__ -#define __FPA__IMAGE__FUNCTORS__FLUXMEDIALNESS__HXX__ - -#include -#include -#include - -// ------------------------------------------------------------------------- -template< class _TGradient > -fpa::Image::Functors::FluxMedialness< _TGradient >:: -FluxMedialness( ) - : Superclass( ), - m_MinRadius( double( 0 ) ), - m_MaxRadius( double( 1 ) ), - m_RadialSampling( 4 ), - m_RadiusStep( double( 1 ) ) -{ -} - -// ------------------------------------------------------------------------- -template< class _TGradient > -fpa::Image::Functors::FluxMedialness< _TGradient >:: -~FluxMedialness( ) -{ -} - -// ------------------------------------------------------------------------- -template< class _TGradient > -typename fpa::Image::Functors::FluxMedialness< _TGradient >:: -TOutput fpa::Image::Functors::FluxMedialness< _TGradient >:: -_Evaluate( const TIndex& i ) const -{ - itk::Object::GlobalWarningDisplayOff( ); - - double pi2n = double( 2 ) * double( vnl_math::pi ); - pi2n /= int( this->m_RadialSampling ); - const _TGradient* img = this->GetInputImage( ); - // Gradient in central pixel - //TVector grad_idx = img->GetPixel( i ); - - double Flux1 = 0; - double Flux = 0; - - TRCandidates FluxFinal; - TRCandidates radiusGenerated; - double dR = double( 0 ); - double optR = double( 0 ); - TPoint center; - img->TransformIndexToPhysicalPoint( i, center ); - double radius = double(0); - - for( unsigned int cx = 0; cx < Self::Dimension - 1; cx++ ) - { - for( unsigned int cy = cx + 1; cy < Self::Dimension; cy++ ) - { - dR = double( 0 ); - FluxFinal.clear(); - radiusGenerated.clear(); - radius = this->m_MinRadius; - while( radius <= this->m_MaxRadius ) - { - Flux = 0; - for( unsigned int I_radial = 0; I_radial < this->m_RadialSampling ; I_radial++ ) - { - Flux1 = 0; - - // Direction of first profile - typename TPoint::VectorType dir1; - dir1.Fill( double( 0 ) ); - dir1[ cx ] = std::cos( pi2n * double( I_radial ) ); - dir1[ cy ] = std::sin( pi2n * double( I_radial ) ); - dir1 *= (radius); - TIndex rIdx; - if (img->TransformPhysicalPointToIndex( center + dir1, rIdx )) - { - TVector grad_rIdx = img->GetPixel( rIdx ); - TVector u_i1; - u_i1.SetVnlVector( ( center - ( center + dir1 ) ).GetVnlVector( ) ); - u_i1.Normalize( ); - // dot product - Flux1 = grad_rIdx * u_i1; - } - - Flux += Flux1; - - } // rof - //std::cout<<" radius:"<m_RadialSampling; - FluxFinal.push_back(Flux); - radiusGenerated.push_back(radius); - radius += this->m_RadiusStep; - - } //elihw - - dR= *( std::max_element( FluxFinal.begin(), FluxFinal.end() ) ); - optR= (dR>optR)? dR:optR; - - } // rof - - } // rof - return( TScalar(optR) ); -} - -#endif // __FPA__IMAGE__FUNCTORS__FLUXMEDIALNESS__HXX__ - -// eof - $RCSfile$ diff --git a/lib/fpa/Image/Functors/GaussianModelEstimatorFunction.h b/lib/fpa/Image/Functors/GaussianModelEstimatorFunction.h deleted file mode 100644 index 0b7727d..0000000 --- a/lib/fpa/Image/Functors/GaussianModelEstimatorFunction.h +++ /dev/null @@ -1,74 +0,0 @@ -#ifndef __FPA__IMAGE__FUNCTORS__GAUSSIANMODELESTIMATORFUNCTION__H__ -#define __FPA__IMAGE__FUNCTORS__GAUSSIANMODELESTIMATORFUNCTION__H__ - -#include -#include -#include - -namespace fpa -{ - namespace Image - { - namespace Functors - { - /** - */ - template< class I, class S > - class GaussianModelEstimatorFunction - : public itk::FunctionBase< typename I::PixelType, bool > - { - public: - // Type-related and pointers - typedef GaussianModelEstimatorFunction Self; - typedef itk::FunctionBase< typename I::PixelType, bool > Superclass; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; - - // Superclass' types - typedef cpPlugins::Extensions::Algorithms::IterativeGaussianModelEstimator< S, 3 > TEstimator; - typedef cpPlugins::Extensions::Algorithms::RGBToYPbPrFunction< S > TYPbPrFunction; - - public: - itkNewMacro( Self ); - itkTypeMacro( GaussianModelEstimatorFunction, itkFunctionBase ); - - itkGetConstMacro( ModelSupport, unsigned long ); - - public: - bool SaveModelToFile( const std::string& filename ) const; - bool LoadModelFromFile( const std::string& filename ); - - virtual void SetModelSupport( const unsigned long& s ); - virtual bool Evaluate( const typename I::PixelType& rgb ) const; - - protected: - GaussianModelEstimatorFunction( ); - virtual ~GaussianModelEstimatorFunction( ); - - private: - // Purposely not implemented - GaussianModelEstimatorFunction( const Self& ); - void operator=( const Self& ); - - protected: - typename TEstimator::Pointer m_Estimator; - TYPbPrFunction m_YPbPrFunction; - - unsigned long m_ModelSupport; - unsigned long m_RealModelSupport; - mutable bool m_Estimating; - }; - - } // ecapseman - - } // ecapseman - -} // ecapseman - -#ifndef ITK_MANUAL_INSTANTIATION -#include -#endif // ITK_MANUAL_INSTANTIATION - -#endif // __FPA__IMAGE__FUNCTORS__GAUSSIANMODELESTIMATORFUNCTION__H__ - -// eof - $RCSfile$ diff --git a/lib/fpa/Image/Functors/GaussianModelEstimatorFunction.hxx b/lib/fpa/Image/Functors/GaussianModelEstimatorFunction.hxx deleted file mode 100644 index accfb27..0000000 --- a/lib/fpa/Image/Functors/GaussianModelEstimatorFunction.hxx +++ /dev/null @@ -1,76 +0,0 @@ -#ifndef __FPA__IMAGE__FUNCTORS__GAUSSIANMODELESTIMATORFUNCTION__HXX__ -#define __FPA__IMAGE__FUNCTORS__GAUSSIANMODELESTIMATORFUNCTION__HXX__ - -// ------------------------------------------------------------------------- -template< class I, class S > -bool fpa::Image::Functors::GaussianModelEstimatorFunction< I, S >:: -SaveModelToFile( const std::string& filename ) const -{ - this->m_Estimator->SaveModelToFile( filename ); -} - -// ------------------------------------------------------------------------- -template< class I, class S > -bool fpa::Image::Functors::GaussianModelEstimatorFunction< I, S >:: -LoadModelFromFile( const std::string& filename ) -{ - this->m_Estimator->LoadModelFromFile( filename ); - this->m_RealModelSupport = - this->m_ModelSupport + this->m_Estimator->GetNumberOfSamples( ); - this->m_Estimating = false; - this->Modified( ); -} - -// ------------------------------------------------------------------------- -template< class I, class S > -void fpa::Image::Functors::GaussianModelEstimatorFunction< I, S >:: -SetModelSupport( const unsigned long& s ) -{ - this->m_ModelSupport = s; - this->m_RealModelSupport = s; - this->Modified( ); -} - -// ------------------------------------------------------------------------- -template< class I, class S > -bool fpa::Image::Functors::GaussianModelEstimatorFunction< I, S >:: -Evaluate( const typename I::PixelType& rgb ) const -{ - if( !this->m_Estimating && this->m_ModelSupport > 0 ) - { - this->m_Estimator->AddSample( this->m_YPbPrFunction( rgb ) ); - if( this->m_Estimator->GetNumberOfSamples( ) == this->m_RealModelSupport ) - this->m_Estimating = true; - return( true ); - } - else - { - S p = this->m_Estimator->Probability( this->m_YPbPrFunction( rgb ) ); - return( p >= 0.3 ); - - } // fi -} - -// ------------------------------------------------------------------------- -template< class I, class S > -fpa::Image::Functors::GaussianModelEstimatorFunction< I, S >:: -GaussianModelEstimatorFunction( ) - : Superclass( ), - m_ModelSupport( 10 ), - m_RealModelSupport( 10 ) -{ - this->m_Estimator = TEstimator::New( ); - this->m_Estimator->Clear( ); - this->m_Estimating = false; -} - -// ------------------------------------------------------------------------- -template< class I, class S > -fpa::Image::Functors::GaussianModelEstimatorFunction< I, S >:: -~GaussianModelEstimatorFunction( ) -{ -} - -#endif // __FPA__IMAGE__FUNCTORS__GAUSSIANMODELESTIMATORFUNCTION__HXX__ - -// eof - $RCSfile$ diff --git a/lib/fpa/Image/Functors/GradientImageFunctionBase.h b/lib/fpa/Image/Functors/GradientImageFunctionBase.h deleted file mode 100644 index fa93034..0000000 --- a/lib/fpa/Image/Functors/GradientImageFunctionBase.h +++ /dev/null @@ -1,73 +0,0 @@ -#ifndef __FPA__IMAGE__FUNCTORS__GRADIENTIMAGEFUNCTIONBASE__H__ -#define __FPA__IMAGE__FUNCTORS__GRADIENTIMAGEFUNCTIONBASE__H__ - -#include - -namespace fpa -{ - namespace Image - { - namespace Functors - { - /** - * Base class to compute values based on image gradients (vector). - * It allows incremental computation of the gradient. - */ - template< class _TGradient > - class GradientImageFunctionBase - : public itk::ImageFunction< _TGradient, typename _TGradient::PixelType::ValueType, typename _TGradient::PixelType::ValueType > - { - public: - // Types from input arguments - typedef _TGradient TGradient; - typedef typename _TGradient::PixelType TVector; - typedef typename TVector::ValueType TScalar; - itkStaticConstMacro( Dimension, unsigned int, _TGradient::ImageDimension ); - - // Standard itk types - typedef GradientImageFunctionBase Self; - typedef itk::ImageFunction< _TGradient, TScalar, TScalar > Superclass; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; - - // Types from base itk::ImageFunction - typedef typename Superclass::InputType TInput; - typedef typename Superclass::OutputType TOutput; - typedef typename Superclass::PointType TPoint; - typedef typename Superclass::ContinuousIndexType TContIndex; - typedef typename Superclass::IndexType TIndex; - - public: - itkTypeMacro( GradientImageFunctionBase, itkImageFunction ); - - public: - virtual void Prepare( ) const; - virtual TOutput Evaluate( const TPoint& p ) const ITK_OVERRIDE; - virtual TOutput EvaluateAtIndex( const TIndex& i ) const ITK_OVERRIDE; - virtual TOutput EvaluateAtContinuousIndex( const TContIndex& i ) const ITK_OVERRIDE; - - protected: - GradientImageFunctionBase( ); - virtual ~GradientImageFunctionBase( ); - - virtual TOutput _Evaluate( const TIndex& i ) const = 0; - - private: - // Purposely not implemented. - GradientImageFunctionBase( const Self& ); - void operator=( const Self& ); - }; - - } // ecapseman - - } // ecapseman - -} // ecapseman - -#ifndef ITK_MANUAL_INSTANTIATION -#include -#endif // ITK_MANUAL_INSTANTIATION - -#endif // __FPA__IMAGE__FUNCTORS__GRADIENTIMAGEFUNCTIONBASE__H__ - -// eof - $RCSfile$ diff --git a/lib/fpa/Image/Functors/GradientImageFunctionBase.hxx b/lib/fpa/Image/Functors/GradientImageFunctionBase.hxx deleted file mode 100644 index 34acf1c..0000000 --- a/lib/fpa/Image/Functors/GradientImageFunctionBase.hxx +++ /dev/null @@ -1,59 +0,0 @@ -#ifndef __FPA__IMAGE__FUNCTORS__GRADIENTIMAGEFUNCTIONBASE__HXX__ -#define __FPA__IMAGE__FUNCTORS__GRADIENTIMAGEFUNCTIONBASE__HXX__ - -// ------------------------------------------------------------------------- -template< class _TGradient > -void fpa::Image::Functors::GradientImageFunctionBase< _TGradient >:: -Prepare( ) const -{ -} - -// ------------------------------------------------------------------------- -template< class _TGradient > -typename fpa::Image::Functors::GradientImageFunctionBase< _TGradient >:: -TOutput fpa::Image::Functors::GradientImageFunctionBase< _TGradient >:: -Evaluate( const TPoint& p ) const -{ - TIndex i; - this->GetInputImage( )->TransformPhysicalPointToIndex( p, i ); - return( this->EvaluateAtIndex( i ) ); -} - -// ------------------------------------------------------------------------- -template< class _TGradient > -typename fpa::Image::Functors::GradientImageFunctionBase< _TGradient >:: -TOutput fpa::Image::Functors::GradientImageFunctionBase< _TGradient >:: -EvaluateAtIndex( const TIndex& i ) const -{ - return( this->_Evaluate( i ) ); -} - -// ------------------------------------------------------------------------- -template< class _TGradient > -typename fpa::Image::Functors::GradientImageFunctionBase< _TGradient >:: -TOutput fpa::Image::Functors::GradientImageFunctionBase< _TGradient >:: -EvaluateAtContinuousIndex( const TContIndex& i ) const -{ - TPoint p; - this->GetInputImage( )->TransformContinuousIndexToPhysicalPoint( i, p ); - return( this->Evaluate( p ) ); -} - -// ------------------------------------------------------------------------- -template< class _TGradient > -fpa::Image::Functors::GradientImageFunctionBase< _TGradient >:: -GradientImageFunctionBase( ) - : Superclass( ) -{ -} - -// ------------------------------------------------------------------------- -template< class _TGradient > -fpa::Image::Functors::GradientImageFunctionBase< _TGradient >:: -~GradientImageFunctionBase( ) -{ -} - -#endif // __FPA__IMAGE__FUNCTORS__GRADIENTIMAGEFUNCTIONBASE__HXX__ - -// eof - $RCSfile$ diff --git a/lib/fpa/Image/Functors/GulsunTekMedialness.h b/lib/fpa/Image/Functors/GulsunTekMedialness.h deleted file mode 100644 index 4a26aab..0000000 --- a/lib/fpa/Image/Functors/GulsunTekMedialness.h +++ /dev/null @@ -1,80 +0,0 @@ -#ifndef __FPA__IMAGE__FUNCTORS__GULSUNTEKMEDIALNESS__H__ -#define __FPA__IMAGE__FUNCTORS__GULSUNTEKMEDIALNESS__H__ - -#include - -namespace fpa -{ - namespace Image - { - namespace Functors - { - /** - */ - template< class _TGradient > - class GulsunTekMedialness - : public GradientImageFunctionBase< _TGradient > - { - public: - typedef GulsunTekMedialness Self; - typedef GradientImageFunctionBase< _TGradient > Superclass; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; - - itkStaticConstMacro( Dimension, unsigned int, Superclass::Dimension ); - - typedef typename Superclass::TOutput TOutput; - typedef typename Superclass::TScalar TScalar; - typedef typename Superclass::TIndex TIndex; - typedef typename Superclass::TVector TVector; - typedef typename Superclass::TPoint TPoint; - typedef typename TIndex::OffsetType TOffset; - - typedef std::vector< double > TProfile; - typedef std::vector< TOffset > TOffsets; - - public: - itkNewMacro( Self ); - itkTypeMacro( GulsunTekMedialness, GradientImageFunctionBase ); - - itkGetConstMacro( MinRadius, double ); - itkGetConstMacro( MaxRadius, double ); - itkGetConstMacro( ProfileSampling, unsigned int ); - itkGetConstMacro( RadialSampling, unsigned int ); - - itkSetMacro( MinRadius, double ); - itkSetMacro( MaxRadius, double ); - itkSetMacro( ProfileSampling, unsigned int ); - itkSetMacro( RadialSampling, unsigned int ); - - protected: - GulsunTekMedialness( ); - virtual ~GulsunTekMedialness( ); - - virtual TOutput _Evaluate( const TIndex& i ) const ITK_OVERRIDE; - - private: - // Purposely not implemented. - GulsunTekMedialness( const Self& ); - void operator=( const Self& ); - - protected: - double m_MinRadius; - double m_MaxRadius; - unsigned int m_ProfileSampling; - unsigned int m_RadialSampling; - }; - - } // ecapseman - - } // ecapseman - -} // ecapseman - -#ifndef ITK_MANUAL_INSTANTIATION -#include -#endif // ITK_MANUAL_INSTANTIATION - -#endif // __FPA__IMAGE__FUNCTORS__GULSUNTEKMEDIALNESS__H__ - -// eof - $RCSfile$ diff --git a/lib/fpa/Image/Functors/GulsunTekMedialness.hxx b/lib/fpa/Image/Functors/GulsunTekMedialness.hxx deleted file mode 100644 index 9cf48c9..0000000 --- a/lib/fpa/Image/Functors/GulsunTekMedialness.hxx +++ /dev/null @@ -1,114 +0,0 @@ -#ifndef __FPA__IMAGE__FUNCTORS__GULSUNTEKMEDIALNESS__HXX__ -#define __FPA__IMAGE__FUNCTORS__GULSUNTEKMEDIALNESS__HXX__ - -#include -#include -#include - -// ------------------------------------------------------------------------- -template< class _TGradient > -fpa::Image::Functors::GulsunTekMedialness< _TGradient >:: -GulsunTekMedialness( ) - : Superclass( ), - m_MinRadius( double( 0 ) ), - m_MaxRadius( double( 1 ) ), - m_ProfileSampling( 4 ), - m_RadialSampling( 10 ) -{ -} - -// ------------------------------------------------------------------------- -template< class _TGradient > -fpa::Image::Functors::GulsunTekMedialness< _TGradient >:: -~GulsunTekMedialness( ) -{ -} - -// ------------------------------------------------------------------------- -template< class _TGradient > -typename fpa::Image::Functors::GulsunTekMedialness< _TGradient >:: -TOutput fpa::Image::Functors::GulsunTekMedialness< _TGradient >:: -_Evaluate( const TIndex& i ) const -{ - itk::Object::GlobalWarningDisplayOff( ); - - // Various values - const _TGradient* in = this->GetInputImage( ); - double pi2n = - double( 2 ) * double( vnl_math::pi ) / - double( this->m_ProfileSampling ); - double rOff = this->m_MaxRadius / double( this->m_RadialSampling - 1 ); - double optR = double( 0 ); - TPoint pnt; - in->TransformIndexToPhysicalPoint( i, pnt ); - - // Main loop - for( unsigned int cx = 0; cx < Self::Dimension - 1; cx++ ) - { - for( unsigned int cy = cx + 1; cy < Self::Dimension; cy++ ) - { - TProfile maxProfile( this->m_RadialSampling, double( 0 ) ); - for( unsigned int p = 0; p < this->m_ProfileSampling; p++ ) - { - double a = pi2n * double( p ); - - // Direction of this profile - TVector dir; - dir.Fill( TScalar( 0 ) ); - dir[ cx ] = TScalar( std::cos( a ) ); - dir[ cy ] = TScalar( std::sin( a ) ); - - double maxrise = double( 0 ); - double maxfall = double( -1 ); - TProfile profile; - for( unsigned int r = 0; r < this->m_RadialSampling; r++ ) - { - double radius = double( r ) * rOff; - TIndex idx; - typename TPoint::VectorType aux; - aux.SetVnlVector( dir.GetVnlVector( ) ); - if( - in->TransformPhysicalPointToIndex( pnt + ( aux * radius ), idx ) - ) - { - TVector g = in->GetPixel( idx ); - double b = double( g.GetNorm( ) ); - if( double( g * dir ) < double( 0 ) ) - b *= double( -1 ); - maxrise = ( b > maxrise )? b: maxrise; - if( radius >= this->m_MinRadius ) - maxfall = ( b < maxfall )? b: maxfall; - profile.push_back( -b - maxrise ); - } - else - profile.push_back( double( 0 ) ); - - } // rof - - for( unsigned int r = 0; r < this->m_RadialSampling; r++ ) - { - double E = profile[ r ] / -maxfall; - E = ( E < double( 0 ) )? double( 0 ): E; - E = ( E > double( 1 ) )? double( 1 ): E; - maxProfile[ r ] += E; - - } // rof - - } // rof - - for( unsigned int r = 0; r < this->m_RadialSampling; r++ ) - { - double E = maxProfile[ r ] / double( this->m_RadialSampling ); - optR = ( E > optR )? E: optR; - - } // rof - - } // rof - - } // rof - return( TScalar( optR ) ); -} - -#endif // __FPA__IMAGE__FUNCTORS__GULSUNTEKMEDIALNESS__HXX__ - -// eof - $RCSfile$ diff --git a/lib/fpa/Image/Functors/ImageAbsoluteDifferenceCostFunction.h b/lib/fpa/Image/Functors/ImageAbsoluteDifferenceCostFunction.h deleted file mode 100644 index 6171f26..0000000 --- a/lib/fpa/Image/Functors/ImageAbsoluteDifferenceCostFunction.h +++ /dev/null @@ -1,87 +0,0 @@ -#ifndef __FPA__IMAGE__FUNCTORS__IMAGEABSOLUTEDIFFERENCECOSTFUNCTION__H__ -#define __FPA__IMAGE__FUNCTORS__IMAGEABSOLUTEDIFFERENCECOSTFUNCTION__H__ - -#include - -namespace fpa -{ - namespace Image - { - namespace Functors - { - /** - */ - template< class I, class R > - class ImageAbsoluteDifferenceCostFunction - : public fpa::Image::Functors::ImageCostFunction< I, R > - { - public: - /// Type-related and pointers - typedef ImageAbsoluteDifferenceCostFunction Self; - typedef fpa::Image::Functors::ImageCostFunction< I, R > Superclass; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; - - typedef typename Superclass::TInputImage TInputImage; - typedef typename Superclass::TResult TResult; - typedef typename Superclass::TIndex TIndex; - - public: - itkNewMacro( Self ); - itkTypeMacro( ImageAbsoluteDifferenceCostFunction, itkObject ); - - public: - virtual R Evaluate( const TIndex& v, const TIndex& p ) const - { - typedef typename I::PixelType _TPixel; - typedef typename itk::NumericTraits< _TPixel > _TTraits; - typedef typename _TTraits::MeasurementVectorType _TVector; - typedef typename _TTraits::ValueType _TValue; - - if( this->m_InputImage.IsNotNull( ) ) - { - _TPixel pix = this->m_InputImage->GetPixel( v ); - pix -= this->m_InputImage->GetPixel( p ); - if( typeid( _TPixel ) != typeid( _TValue ) ) - { - _TVector* a = reinterpret_cast< _TVector* >( &pix ); - unsigned int n = - this->m_InputImage->GetNumberOfComponentsPerPixel( ); - double sum = double( 0 ); - for( unsigned int i = 0; i < n; ++i ) - sum += ( double( ( *a )[ i ] ) * double( ( *a )[ i ] ) ); - return( R( std::sqrt( sum ) ) ); - } - else - { - double pix_val = - double( *( reinterpret_cast< _TValue* >( &pix ) ) ); - return( R( std::fabs( pix_val ) ) ); - } - } - else - return( std::numeric_limits< R >::max( ) ); - } - - protected: - ImageAbsoluteDifferenceCostFunction( ) - : Superclass( ) - { } - virtual ~ImageAbsoluteDifferenceCostFunction( ) - { } - - private: - // Purposely not implemented - ImageAbsoluteDifferenceCostFunction( const Self& ); - void operator=( const Self& ); - }; - - } // ecapseman - - } // ecapseman - -} // ecapseman - -#endif // __FPA__IMAGE__FUNCTORS__IMAGEABSOLUTEDIFFERENCECOSTFUNCTION__H__ - -// eof - $RCSfile$ diff --git a/lib/fpa/Image/Functors/ImageCostFunction.h b/lib/fpa/Image/Functors/ImageCostFunction.h deleted file mode 100644 index 533b64b..0000000 --- a/lib/fpa/Image/Functors/ImageCostFunction.h +++ /dev/null @@ -1,90 +0,0 @@ -#ifndef __FPA__IMAGE__FUNCTORS__IMAGECOSTFUNCTION__H__ -#define __FPA__IMAGE__FUNCTORS__IMAGECOSTFUNCTION__H__ - -#include -#include -#include - -namespace fpa -{ - namespace Image - { - namespace Functors - { - /** - */ - template< class I, class R > - class ImageCostFunction - : public itk::Object - { - public: - /// Type-related and pointers - typedef ImageCostFunction Self; - typedef itk::Object Superclass; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; - - typedef I TInputImage; - typedef R TResult; - typedef typename I::IndexType TIndex; - - public: - itkNewMacro( Self ); - itkTypeMacro( ImageCostFunction, itkObject ); - - itkGetConstObjectMacro( InputImage, I ); - itkSetConstObjectMacro( InputImage, I ); - - public: - virtual R Evaluate( const TIndex& v, const TIndex& p ) const - { - typedef typename I::PixelType _TPixel; - typedef typename itk::NumericTraits< _TPixel > _TTraits; - typedef typename _TTraits::MeasurementVectorType _TVector; - typedef typename _TTraits::ValueType _TValue; - - if( this->m_InputImage.IsNotNull( ) ) - { - _TPixel pix = this->m_InputImage->GetPixel( v ); - if( typeid( _TPixel ) != typeid( _TValue ) ) - { - _TVector* array = reinterpret_cast< _TVector* >( &pix ); - unsigned int n = - this->m_InputImage->GetNumberOfComponentsPerPixel( ); - R sum = R( 0 ); - for( unsigned int i = 0; i < n; ++i ) - sum += R( ( *array )[ i ] ); - return( sum / R( n ) ); - } - else - return( R( *( reinterpret_cast< _TValue* >( &pix ) ) ) ); - } - else - return( std::numeric_limits< R >::max( ) ); - } - - protected: - ImageCostFunction( ) - : Superclass( ) - { } - virtual ~ImageCostFunction( ) - { } - - private: - // Purposely not implemented - ImageCostFunction( const Self& ); - void operator=( const Self& ); - - protected: - typename I::ConstPointer m_InputImage; - }; - - } // ecapseman - - } // ecapseman - -} // ecapseman - -#endif // __FPA__IMAGE__FUNCTORS__IMAGECOSTFUNCTION__H__ - -// eof - $RCSfile$ diff --git a/lib/fpa/Image/Functors/MFluxMedialness.h b/lib/fpa/Image/Functors/MFluxMedialness.h deleted file mode 100644 index d109ea8..0000000 --- a/lib/fpa/Image/Functors/MFluxMedialness.h +++ /dev/null @@ -1,78 +0,0 @@ -#ifndef __FPA__IMAGE__FUNCTORS__MFLUXMEDIALNESS__H__ -#define __FPA__IMAGE__FUNCTORS__MFLUXMEDIALNESS__H__ - -#include - -namespace fpa -{ - namespace Image - { - namespace Functors - { - /** - */ - template< class _TGradient > - class MFluxMedialness - : public GradientImageFunctionBase< _TGradient > - { - public: - typedef MFluxMedialness Self; - typedef GradientImageFunctionBase< _TGradient > Superclass; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; - - itkStaticConstMacro( Dimension, unsigned int, Superclass::Dimension ); - - typedef typename Superclass::TOutput TOutput; - typedef typename Superclass::TScalar TScalar; - typedef typename Superclass::TIndex TIndex; - typedef typename Superclass::TVector TVector; - typedef typename Superclass::TPoint TPoint; - - typedef std::vector< double > TRCandidates; - - public: - itkNewMacro( Self ); - itkTypeMacro( MFluxMedialness, GradientImageFunctionBase ); - - itkGetConstMacro( RadiusStep, double ); - itkGetConstMacro( MinRadius, double ); - itkGetConstMacro( MaxRadius, double ); - itkGetConstMacro( RadialSampling, unsigned int ); - - itkSetMacro( RadiusStep, double ); - itkSetMacro( MinRadius, double ); - itkSetMacro( MaxRadius, double ); - itkSetMacro( RadialSampling, unsigned int ); - - protected: - MFluxMedialness( ); - virtual ~MFluxMedialness( ); - - virtual TOutput _Evaluate( const TIndex& i ) const ITK_OVERRIDE; - - private: - // Purposely not implemented. - MFluxMedialness( const Self& ); - void operator=( const Self& ); - - protected: - double m_MinRadius; - double m_MaxRadius; - unsigned int m_RadialSampling; - double m_RadiusStep; - }; - - } // ecapseman - - } // ecapseman - -} // ecapseman - -#ifndef ITK_MANUAL_INSTANTIATION -#include -#endif // ITK_MANUAL_INSTANTIATION - -#endif // __FPA__IMAGE__FUNCTORS__MFLUXMEDIALNESS__H__ - -// eof - $RCSfile$ diff --git a/lib/fpa/Image/Functors/MFluxMedialness.hxx b/lib/fpa/Image/Functors/MFluxMedialness.hxx deleted file mode 100644 index 5e902e5..0000000 --- a/lib/fpa/Image/Functors/MFluxMedialness.hxx +++ /dev/null @@ -1,159 +0,0 @@ -#ifndef __FPA__IMAGE__FUNCTORS__MFLUXMEDIALNESS__HXX__ -#define __FPA__IMAGE__FUNCTORS__MFLUXMEDIALNESS__HXX__ - -#include -#include -#include - -// ------------------------------------------------------------------------- -template< class _TGradient > -fpa::Image::Functors::MFluxMedialness< _TGradient >:: -MFluxMedialness( ) - : Superclass( ), - m_MinRadius( double( 0 ) ), - m_MaxRadius( double( 1 ) ), - m_RadialSampling( 4 ), - m_RadiusStep( double( 1 ) ) -{ -} - -// ------------------------------------------------------------------------- -template< class _TGradient > -fpa::Image::Functors::MFluxMedialness< _TGradient >:: -~MFluxMedialness( ) -{ -} - -// ------------------------------------------------------------------------- -template< class _TGradient > -typename fpa::Image::Functors::MFluxMedialness< _TGradient >:: -TOutput fpa::Image::Functors::MFluxMedialness< _TGradient >:: -_Evaluate( const TIndex& i ) const -{ - itk::Object::GlobalWarningDisplayOff( ); - - double pi2n = double( 2 ) * double( vnl_math::pi ); - pi2n /= int( this->m_RadialSampling ); - const _TGradient* img = this->GetInputImage( ); - //const itk::Image::SpacingType& input_spacing = img->GetSpacing( ); - - double Flux1 = 0; - double Flux2 = 0; - double MFlux = 0; - - TRCandidates FluxFinal; - TRCandidates radiusGenerated; - double dR = double( 0 ); - double optR = double( 0 ); - TPoint center; - img->TransformIndexToPhysicalPoint( i, center ); - double radius; - - for( unsigned int cx = 0; cx < Self::Dimension - 1; cx++ ) - { - for( unsigned int cy = cx + 1; cy < Self::Dimension; cy++ ) - { - dR = double( 0 ); - FluxFinal.clear(); - radiusGenerated.clear(); - radius = this->m_MinRadius; - while( radius <= this->m_MaxRadius ) - { - MFlux = 0; - for( unsigned int I_radial = 0; I_radial < this->m_RadialSampling / 2; I_radial++ ) - { - Flux1 = 0; - Flux2 = 0; - - // Direction of first profile - typename TPoint::VectorType dir1; - dir1.Fill( double( 0 ) ); - dir1[ cx ] = std::cos( pi2n * double( I_radial ) ); - dir1[ cy ] = std::sin( pi2n * double( I_radial ) ); - //dir1 *= (radius); - - TIndex rIdx; - - if ( img->TransformPhysicalPointToIndex( center + (dir1*radius), rIdx ) ) - { - TVector grad_rIdx = img->GetPixel( rIdx ); - TVector u_i1; - u_i1.SetVnlVector( ( center - ( center + dir1 ) ).GetVnlVector( ) ); - u_i1.Normalize( ); - // dot product - Flux1 = grad_rIdx * u_i1; - } - else - { - //if (Self::Dimension==3) - //{ - //std::cout<<"Point Edge x:"<TransformPhysicalPointToIndex( center + (dir2*radius), rIdx2 ) ) - { - TVector grad_rIdx2 = img->GetPixel( rIdx2 ); - TVector u_i2; - u_i2.SetVnlVector( ( center - ( center + dir2 ) ).GetVnlVector( ) ); - u_i2.Normalize( ); - - Flux2 = grad_rIdx2 * u_i2; - } - else - { - //if (Self::Dimension==3) - //{ - //std::cout<<"Point Edge x:"<m_RadialSampling; - FluxFinal.push_back(MFlux); - radiusGenerated.push_back(radius); - - radius += this->m_RadiusStep; - - } //elihw - - dR= *( std::max_element( FluxFinal.begin(), FluxFinal.end() ) ); - optR= (dR>optR)? dR:optR; - - } // rof - - } // rof - return( TScalar(optR) ); -} - -#endif // __FPA__IMAGE__FUNCTORS__MFLUXMEDIALNESS__HXX__ - -// eof - $RCSfile$ diff --git a/lib/fpa/Image/Functors/RegionGrowAllBelongsFunction.h b/lib/fpa/Image/Functors/RegionGrowAllBelongsFunction.h deleted file mode 100644 index 8aef295..0000000 --- a/lib/fpa/Image/Functors/RegionGrowAllBelongsFunction.h +++ /dev/null @@ -1,60 +0,0 @@ -#ifndef __FPA__IMAGE__FUNCTORS__REGIONGROWALLBELONGSFUNCTION__H__ -#define __FPA__IMAGE__FUNCTORS__REGIONGROWALLBELONGSFUNCTION__H__ - -#include - -namespace fpa -{ - namespace Image - { - namespace Functors - { - /** - */ - template< class I > - class RegionGrowAllBelongsFunction - : public fpa::Base::Functors::TautologyFunction< I, typename I::IndexType > - { - public: - /// Type-related and pointers - typedef RegionGrowAllBelongsFunction Self; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; - typedef fpa::Base::Functors:: - TautologyFunction< I, typename I::IndexType > - Superclass; - - // Superclass' types - typedef I TInputImage; - typedef typename I::IndexType TIndex; - - public: - itkNewMacro( Self ); - itkTypeMacro( RegionGrowAllBelongsFunction, itkImageFunction ); - - public: - virtual bool Evaluate( const TIndex& v ) const ITK_OVERRIDE - { return( true ); } - - protected: - RegionGrowAllBelongsFunction( ) - : Superclass( ) - { } - virtual ~RegionGrowAllBelongsFunction( ) - { } - - private: - // Purposely not implemented - RegionGrowAllBelongsFunction( const Self& ); - void operator=( const Self& ); - }; - - } // ecapseman - - } // ecapseman - -} // ecapseman - -#endif // __FPA__IMAGE__FUNCTORS__REGIONGROWALLBELONGSFUNCTION__H__ - -// eof - $RCSfile$ diff --git a/lib/fpa/Image/Functors/RegionGrowThresholdFunction.h b/lib/fpa/Image/Functors/RegionGrowThresholdFunction.h deleted file mode 100644 index 4ec4bbf..0000000 --- a/lib/fpa/Image/Functors/RegionGrowThresholdFunction.h +++ /dev/null @@ -1,88 +0,0 @@ -#ifndef __FPA__IMAGE__FUNCTORS__REGIONGROWTHRESHOLDFUNCTION__H__ -#define __FPA__IMAGE__FUNCTORS__REGIONGROWTHRESHOLDFUNCTION__H__ - -#include -#include - -namespace fpa -{ - namespace Image - { - namespace Functors - { - /** - */ - template< class I > - class RegionGrowThresholdFunction - : public RegionGrowAllBelongsFunction< I > - { - public: - /// Type-related and pointers - typedef RegionGrowThresholdFunction Self; - typedef RegionGrowAllBelongsFunction< I > Superclass; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; - - // Superclass' types - typedef I TInputImage; - typedef typename I::IndexType TIndex; - typedef typename I::PixelType TPixel; - - public: - itkNewMacro( Self ); - itkTypeMacro( - RegionGrowThresholdFunction, - RegionGrowAllBelongsFunction - ); - - itkGetConstMacro( LowerThreshold, TPixel ); - itkGetConstMacro( UpperThreshold, TPixel ); - - itkSetMacro( LowerThreshold, TPixel ); - itkSetMacro( UpperThreshold, TPixel ); - - public: - virtual bool Evaluate( const TIndex& idx ) const ITK_OVERRIDE - { - const I* img = this->GetSpace( ); - - if( img != NULL ) - { - TPixel v = img->GetPixel( idx ); - return( - !( v < this->m_LowerThreshold || this->m_UpperThreshold < v ) - ); - - } // fi - return( false ); - } - - protected: - RegionGrowThresholdFunction( ) - : Superclass( ) - { - itk::NumericTraits< TPixel >::min( this->m_LowerThreshold ); - itk::NumericTraits< TPixel >::max( this->m_UpperThreshold ); - } - virtual ~RegionGrowThresholdFunction( ) - { } - - private: - // Purposely not implemented - RegionGrowThresholdFunction( const Self& ); - void operator=( const Self& ); - - protected: - TPixel m_LowerThreshold; - TPixel m_UpperThreshold; - }; - - } // ecapseman - - } // ecapseman - -} // ecapseman - -#endif // __FPA__IMAGE__FUNCTORS__REGIONGROWTHRESHOLDFUNCTION__H__ - -// eof - $RCSfile$ diff --git a/lib/fpa/Image/IncrementalRegionGrow.h b/lib/fpa/Image/IncrementalRegionGrow.h deleted file mode 100644 index 70d13c8..0000000 --- a/lib/fpa/Image/IncrementalRegionGrow.h +++ /dev/null @@ -1,71 +0,0 @@ -#ifndef __FPA__IMAGE__INCREMENTALREGIONGROW__H__ -#define __FPA__IMAGE__INCREMENTALREGIONGROW__H__ - -#include -#include -#include -#include -#include - -namespace fpa -{ - namespace Image - { - /** - * @param I Input image type - * @param O Output image type - */ - template< class I, class O > - class IncrementalRegionGrow - : public Algorithm< I, O, fpa::Base::IncrementalRegionGrow< typename I::IndexType, typename I::PixelType, typename O::PixelType, itk::Functor::IndexLexicographicCompare< I::ImageDimension >, itk::ImageToImageFilter< I, O > > > - { - public: - typedef fpa::Base::IncrementalRegionGrow< typename I::IndexType, typename I::PixelType, typename O::PixelType, itk::Functor::IndexLexicographicCompare< I::ImageDimension >, itk::ImageToImageFilter< I, O > > TBaseAlgorithm; - - typedef IncrementalRegionGrow Self; - typedef Algorithm< I, O, TBaseAlgorithm > Superclass; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; - - typedef typename Superclass::TInputImage TInputImage; - typedef typename Superclass::TOutputImage TOutputImage; - typedef typename Superclass::TVertex TVertex; - typedef typename Superclass::TValue TValue; - typedef typename Superclass::TResult TResult; - typedef typename Superclass::TGrowingFunction TGrowingFunction; - - protected: - typedef typename Superclass::_TVertices _TVertices; - typedef typename Superclass::_TCollision _TCollision; - typedef typename Superclass::_TCollisionsRow _TCollisionsRow; - typedef typename Superclass::_TCollisions _TCollisions; - typedef typename Superclass::_TNode _TNode; - typedef typename Superclass::_TNodes _TNodes; - - public: - itkNewMacro( Self ); - itkTypeMacro( IncrementalRegionGrow, Algorithm ); - - protected: - IncrementalRegionGrow( ); - virtual ~IncrementalRegionGrow( ); - - virtual void _InitResults( ); - - private: - // Purposely not implemented - IncrementalRegionGrow( const Self& other ); - Self& operator=( const Self& other ); - }; - - } // ecapseman - -} // ecapseman - -#ifndef ITK_MANUAL_INSTANTIATION -#include -#endif // ITK_MANUAL_INSTANTIATION - -#endif // __FPA__IMAGE__INCREMENTALREGIONGROW__H__ - -// eof - $RCSfile$ diff --git a/lib/fpa/Image/IncrementalRegionGrow.hxx b/lib/fpa/Image/IncrementalRegionGrow.hxx deleted file mode 100644 index 740b2f8..0000000 --- a/lib/fpa/Image/IncrementalRegionGrow.hxx +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef __FPA__IMAGE__INCREMENTALREGIONGROW__HXX__ -#define __FPA__IMAGE__INCREMENTALREGIONGROW__HXX__ - -// ------------------------------------------------------------------------- -template< class I, class O > -fpa::Image::IncrementalRegionGrow< I, O >:: -IncrementalRegionGrow( ) - : Superclass( ) -{ -} - -// ------------------------------------------------------------------------- -template< class I, class O > -fpa::Image::IncrementalRegionGrow< I, O >:: -~IncrementalRegionGrow( ) -{ -} - -// ------------------------------------------------------------------------- -template< class I, class O > -void fpa::Image::IncrementalRegionGrow< I, O >:: -_InitResults( ) -{ - this->Superclass::_InitResults( ); - this->GetOutput( )->FillBuffer( this->m_OutsideValue ); -} - -#endif // __FPA__IMAGE__INCREMENTALREGIONGROW__HXX__ - -// eof - $RCSfile$ diff --git a/lib/fpa/Image/MinimumSpanningTree.h b/lib/fpa/Image/MinimumSpanningTree.h deleted file mode 100644 index 0d26c20..0000000 --- a/lib/fpa/Image/MinimumSpanningTree.h +++ /dev/null @@ -1,85 +0,0 @@ -#ifndef __FPA__IMAGE__MINIMUMSPANNINGTREE__H__ -#define __FPA__IMAGE__MINIMUMSPANNINGTREE__H__ - -#include -#include -#include - -namespace fpa -{ - namespace Image - { - template< unsigned int _NDim > - struct MinimumSpanningTreeData - { - typedef itk::Offset< _NDim > TOffset; - TOffset Parent; - short FrontId; - double GlobalCost; - }; - - /** - */ - template< unsigned int _NDim > - class MinimumSpanningTree - : public fpa::Base::MinimumSpanningTree< itk::Image< MinimumSpanningTreeData< _NDim >, _NDim >, itk::Index< _NDim > > - { - public: - typedef MinimumSpanningTreeData< _NDim > TInfo; - typedef itk::Image< TInfo, _NDim > TBase; - typedef itk::Index< _NDim > TVertex; - typedef fpa::Base::MinimumSpanningTree< TBase, TVertex > Superclass; - typedef MinimumSpanningTree Self; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; - - typedef typename Superclass::TVertices TVertices; - typedef typename Superclass::TPoint TPoint; - typedef typename Superclass::TPoints TPoints; - itkStaticConstMacro( Dimension, unsigned int, _NDim ); - - public: - itkNewMacro( Self ); - itkTypeMacro( MinimumSpanningTree, _TSuperclass ); - - public: - void CopyMetaData( itk::ImageBase< _NDim >* infoImage ); - virtual void SetNode( - const TVertex& v, - const TVertex& p, - const short& fid, - const double& cost - ) override; - virtual void Clear( ) override; - - virtual TPoints GetEuclideanPath( const TVertex& a ) const override; - virtual TPoints GetEuclideanPath( - const TVertex& a, const TVertex& b - ) const override; - virtual bool IsDefinedInEuclideanSpace( ) const override; - - protected: - MinimumSpanningTree( ); - virtual ~MinimumSpanningTree( ); - - virtual bool _HasVertex( const TVertex& a ) const override; - virtual short _FrontId( const TVertex& a ) const override; - virtual void _Path( TVertices& path, const TVertex& a ) const override; - - private: - // Purposely not implemented - MinimumSpanningTree( const Self& other ); - Self& operator=( const Self& other ); - }; - - } // ecapseman - -} // ecapseman - -#ifndef ITK_MANUAL_INSTANTIATION -#include -#endif // ITK_MANUAL_INSTANTIATION - -#endif // __FPA__IMAGE__MINIMUMSPANNINGTREE__H__ - -// eof - $RCSfile$ diff --git a/lib/fpa/Image/MinimumSpanningTree.hxx b/lib/fpa/Image/MinimumSpanningTree.hxx deleted file mode 100644 index 616365e..0000000 --- a/lib/fpa/Image/MinimumSpanningTree.hxx +++ /dev/null @@ -1,152 +0,0 @@ -#ifndef __FPA__IMAGE__MINIMUMSPANNINGTREE__HXX__ -#define __FPA__IMAGE__MINIMUMSPANNINGTREE__HXX__ - -#include - -// ------------------------------------------------------------------------- -template< unsigned int _NDim > -void fpa::Image::MinimumSpanningTree< _NDim >:: -CopyMetaData( itk::ImageBase< _NDim >* infoImage ) -{ - this->SetLargestPossibleRegion( infoImage->GetLargestPossibleRegion( ) ); - this->SetRequestedRegion( infoImage->GetRequestedRegion( ) ); - this->SetBufferedRegion( infoImage->GetBufferedRegion( ) ); - this->SetDirection( infoImage->GetDirection( ) ); - this->SetOrigin( infoImage->GetOrigin( ) ); - this->SetSpacing( infoImage->GetSpacing( ) ); - this->Allocate( ); - this->Clear( ); -} - -// ------------------------------------------------------------------------- -template< unsigned int _NDim > -void fpa::Image::MinimumSpanningTree< _NDim >:: -SetNode( - const TVertex& v, const TVertex& p, - const short& fid, const double& cost - ) -{ - this->Superclass::SetNode( v, p, fid, cost ); - TInfo info; - info.Parent = p - v; - info.FrontId = fid; - info.GlobalCost = cost; - this->SetPixel( v, info ); -} - -// ------------------------------------------------------------------------- -template< unsigned int _NDim > -void fpa::Image::MinimumSpanningTree< _NDim >:: -Clear( ) -{ - this->Superclass::Clear( ); - TInfo info; - info.Parent.Fill( 0 ); - info.FrontId = std::numeric_limits< short >::max( ); - info.GlobalCost = double( 0 ); - this->FillBuffer( info ); -} - -// ------------------------------------------------------------------------- -template< unsigned int _NDim > -typename fpa::Image::MinimumSpanningTree< _NDim >:: -TPoints fpa::Image::MinimumSpanningTree< _NDim >:: -GetEuclideanPath( const TVertex& a ) const -{ - TPoints path; - auto vertices = this->GetPath( a ); - for( auto vIt = vertices.begin( ); vIt != vertices.end( ); ++vIt ) - { - TPoint pnt; - this->TransformIndexToPhysicalPoint( *vIt, pnt ); - path.push_back( pnt ); - - } // rof - return( path ); -} - -// ------------------------------------------------------------------------- -template< unsigned int _NDim > -typename fpa::Image::MinimumSpanningTree< _NDim >:: -TPoints fpa::Image::MinimumSpanningTree< _NDim >:: -GetEuclideanPath( const TVertex& a, const TVertex& b ) const -{ - TPoints path; - auto vertices = this->GetPath( a, b ); - for( auto vIt = vertices.begin( ); vIt != vertices.end( ); ++vIt ) - { - TPoint pnt; - this->TransformIndexToPhysicalPoint( *vIt, pnt ); - path.push_back( pnt ); - - } // rof - return( path ); -} - -// ------------------------------------------------------------------------- -template< unsigned int _NDim > -bool fpa::Image::MinimumSpanningTree< _NDim >:: -IsDefinedInEuclideanSpace( ) const -{ - return( true ); -} - -// ------------------------------------------------------------------------- -template< unsigned int _NDim > -fpa::Image::MinimumSpanningTree< _NDim >:: -MinimumSpanningTree( ) - : Superclass( ) -{ -} - -// ------------------------------------------------------------------------- -template< unsigned int _NDim > -fpa::Image::MinimumSpanningTree< _NDim >:: -~MinimumSpanningTree( ) -{ -} - -// ------------------------------------------------------------------------- -template< unsigned int _NDim > -bool fpa::Image::MinimumSpanningTree< _NDim >:: -_HasVertex( const TVertex& a ) const -{ - return( this->_FrontId( a ) < std::numeric_limits< short >::max( ) ); -} - -// ------------------------------------------------------------------------- -template< unsigned int _NDim > -short fpa::Image::MinimumSpanningTree< _NDim >:: -_FrontId( const TVertex& a ) const -{ - static const short MAX_ID = std::numeric_limits< short >::max( ); - if( this->GetRequestedRegion( ).IsInside( a ) ) - return( this->GetPixel( a ).FrontId ); - else - return( MAX_ID ); -} - -// ------------------------------------------------------------------------- -template< unsigned int _NDim > -void fpa::Image::MinimumSpanningTree< _NDim >:: -_Path( TVertices& path, const TVertex& a ) const -{ - if( this->_HasVertex( a ) ) - { - typename TVertex::OffsetType zero; - zero.Fill( 0 ); - auto it = a; - do - { - path.push_back( it ); - it += this->GetPixel( it ).Parent; - - } while( this->GetPixel( it ).Parent != zero ); - path.push_back( it ); - - } // fi -} - -#endif // __FPA__IMAGE__MINIMUMSPANNINGTREE__HXX__ - -// eof - $RCSfile$ diff --git a/lib/fpa/Image/RegionGrow.h b/lib/fpa/Image/RegionGrow.h deleted file mode 100644 index 59e97da..0000000 --- a/lib/fpa/Image/RegionGrow.h +++ /dev/null @@ -1,72 +0,0 @@ -#ifndef __FPA__IMAGE__REGIONGROW__H__ -#define __FPA__IMAGE__REGIONGROW__H__ - -#include -#include -#include -#include -#include - -namespace fpa -{ - namespace Image - { - /** - * @param I Input image type - * @param O Output image type - */ - template< class I, class O = I > - class RegionGrow - : public Algorithm< I, O, fpa::Base::RegionGrow< typename I::IndexType, typename I::PixelType, typename O::PixelType, I, itk::Functor::IndexLexicographicCompare< I::ImageDimension >, itk::ImageToImageFilter< I, O > > > - { - public: - typedef fpa::Base::RegionGrow< typename I::IndexType, typename I::PixelType, typename O::PixelType, I, itk::Functor::IndexLexicographicCompare< I::ImageDimension >, itk::ImageToImageFilter< I, O > > TBaseAlgorithm; - - typedef RegionGrow Self; - typedef Algorithm< I, O, TBaseAlgorithm > Superclass; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; - - typedef typename Superclass::TInputImage TInputImage; - typedef typename Superclass::TOutputImage TOutputImage; - typedef typename Superclass::TVertex TVertex; - typedef typename Superclass::TValue TValue; - typedef typename Superclass::TResult TResult; - typedef typename Superclass::TSpace TSpace; - typedef typename Superclass::TGrowingFunction TGrowingFunction; - - protected: - typedef typename Superclass::_TVertices _TVertices; - typedef typename Superclass::_TCollision _TCollision; - typedef typename Superclass::_TCollisionsRow _TCollisionsRow; - typedef typename Superclass::_TCollisions _TCollisions; - typedef typename Superclass::_TNode _TNode; - typedef typename Superclass::_TNodes _TNodes; - - public: - itkNewMacro( Self ); - itkTypeMacro( RegionGrow, Algorithm ); - - protected: - RegionGrow( ); - virtual ~RegionGrow( ); - - virtual void _InitResults( ) ITK_OVERRIDE; - - private: - // Purposely not implemented - RegionGrow( const Self& other ); - Self& operator=( const Self& other ); - }; - - } // ecapseman - -} // ecapseman - -#ifndef ITK_MANUAL_INSTANTIATION -#include -#endif // ITK_MANUAL_INSTANTIATION - -#endif // __FPA__IMAGE__REGIONGROW__H__ - -// eof - $RCSfile$ diff --git a/lib/fpa/Image/RegionGrow.hxx b/lib/fpa/Image/RegionGrow.hxx deleted file mode 100644 index a56c919..0000000 --- a/lib/fpa/Image/RegionGrow.hxx +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef __FPA__IMAGE__REGIONGROW__HXX__ -#define __FPA__IMAGE__REGIONGROW__HXX__ - -// ------------------------------------------------------------------------- -template< class I, class O > -fpa::Image::RegionGrow< I, O >:: -RegionGrow( ) - : Superclass( ) -{ -} - -// ------------------------------------------------------------------------- -template< class I, class O > -fpa::Image::RegionGrow< I, O >:: -~RegionGrow( ) -{ -} - -// ------------------------------------------------------------------------- -template< class I, class O > -void fpa::Image::RegionGrow< I, O >:: -_InitResults( ) -{ - this->Superclass::_InitResults( ); - if( this->m_GrowingFunction.IsNotNull( ) ) - this->m_GrowingFunction->SetSpace( this->GetInput( ) ); - this->GetOutput( )->FillBuffer( this->m_OutsideValue ); -} - -#endif // __FPA__IMAGE__REGIONGROW__HXX__ - -// eof - $RCSfile$ diff --git a/lib/fpa/Image/RegionGrowWithMultipleCriteria.h b/lib/fpa/Image/RegionGrowWithMultipleCriteria.h deleted file mode 100644 index 2b06837..0000000 --- a/lib/fpa/Image/RegionGrowWithMultipleCriteria.h +++ /dev/null @@ -1,65 +0,0 @@ -#ifndef __FPA__IMAGE__REGIONGROWWITHMULTIPLECRITERIA__H__ -#define __FPA__IMAGE__REGIONGROWWITHMULTIPLECRITERIA__H__ - -#include -#include -#include -#include -#include - -namespace fpa -{ - namespace Image - { - /** - * @param I Input image type - */ - template< class I > - class RegionGrowWithMultipleCriteria - : public Algorithm< I, fpa::Base::RegionGrowWithMultipleCriteria< typename I::IndexType, typename I::PixelType, typename I::PixelType, itk::Functor::IndexLexicographicCompare< I::ImageDimension >, itk::ImageToImageFilter< I, I > > > - { - public: - // Standard class typdedefs - typedef typename I::IndexType TVertex; - typedef typename I::PixelType TResult; - typedef typename I::PixelType TVertexValue; - typedef itk::ImageToImageFilter< I, I > TBaseFilter; - typedef fpa::Base::RegionGrowWithMultipleCriteria< TVertex, TResult, TVertexValue, itk::Functor::IndexLexicographicCompare< I::ImageDimension >, TBaseFilter > TBaseAlgorithm; - - typedef RegionGrowWithMultipleCriteria Self; - typedef Algorithm< I, TBaseAlgorithm > Superclass; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; - - typedef - fpa::Image::Functors::ImageFunction< I, bool > - TMembershipFunction; - typedef typename Superclass::TFunctions TFunctions; - - public: - itkNewMacro( Self ); - itkTypeMacro( - RegionGrowWithMultipleCriteria, - fpaBaseRegionGrowWithMultipleCriteria - ); - - protected: - RegionGrowWithMultipleCriteria( ) - : Superclass( ) - { } - virtual ~RegionGrowWithMultipleCriteria( ) - { } - - private: - // Purposely not implemented - RegionGrowWithMultipleCriteria( const Self& ); - void operator=( const Self& ); - }; - - } // ecapseman - -} // ecapseman - -#endif // __FPA__IMAGE__REGIONGROWWITHMULTIPLECRITERIA__H__ - -// eof - $RCSfile$ diff --git a/lib/fpa/Image/RegionGrowWithMultipleThresholds.h b/lib/fpa/Image/RegionGrowWithMultipleThresholds.h deleted file mode 100644 index f538e7b..0000000 --- a/lib/fpa/Image/RegionGrowWithMultipleThresholds.h +++ /dev/null @@ -1,96 +0,0 @@ -#ifndef __FPA__IMAGE__REGIONGROWWITHMULTIPLETHRESHOLDS__H__ -#define __FPA__IMAGE__REGIONGROWWITHMULTIPLETHRESHOLDS__H__ - -#include -#include -#include -#include - -namespace fpa -{ - namespace Image - { - /** - * @param I Input image type - */ - template< class I > - class RegionGrowWithMultipleThresholds - : public RegionGrowWithMultipleCriteria< I > - { - public: - typedef RegionGrowWithMultipleThresholds Self; - typedef RegionGrowWithMultipleCriteria< I > Superclass; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; - - typedef typename I::PixelType TPixel; - - typedef std::map< TPixel, unsigned long > THistogram; - typedef typename Superclass::TBaseAlgorithm TBaseAlgorithm; - typedef typename Superclass::TMembershipFunction TMembershipFunction; - typedef typename Superclass::TFunctions TFunctions; - - typedef std::set< TPixel > TThresholds; - typedef fpa::Image::Functors::RegionGrowThresholdFunction< I > TFunction; - - protected: - typedef typename TBaseAlgorithm::_TNode _TNode; - - public: - itkNewMacro( Self ); - itkTypeMacro( RegionGrowWithMultipleThresholds, RegionGrow ); - - itkGetConstMacro( InsideValue, TPixel ); - itkGetConstMacro( OutsideValue, TPixel ); - itkGetConstMacro( DifferenceThreshold, double ); - - itkSetMacro( InsideValue, TPixel ); - itkSetMacro( OutsideValue, TPixel ); - itkSetMacro( DifferenceThreshold, double ); - - public: - void AddThreshold( const TPixel& v ); - void AddThresholds( - const TPixel& t0, - const TPixel& t1, - const unsigned int& s - ); - - protected: - RegionGrowWithMultipleThresholds( ); - virtual ~RegionGrowWithMultipleThresholds( ); - - virtual void _BeforeMainLoop( ); - virtual void _AfterMainLoop( ); - virtual void _AfterLoop( ); - virtual bool _UpdateResult( _TNode& n ); - virtual void _Mark( const _TNode& n ); - virtual bool _CheckStopCondition( ); - - private: - RegionGrowWithMultipleThresholds( const Self& ); // Not impl. - void operator=( const Self& ); // Not impl. - - protected: - TThresholds m_Thresholds; - TPixel m_InsideValue; - TPixel m_OutsideValue; - double m_DifferenceThreshold; - THistogram m_Histogram; - unsigned long m_TotalCount; - double m_LastDiff; - bool m_StopForced; - TPixel m_StopThreshold; - }; - - } // ecapseman - -} // ecapseman - -#ifndef ITK_MANUAL_INSTANTIATION -#include -#endif // ITK_MANUAL_INSTANTIATION - -#endif // __FPA__IMAGE__REGIONGROWWITHMULTIPLETHRESHOLDS__H__ - -// eof - $RCSfile$ diff --git a/lib/fpa/Image/RegionGrowWithMultipleThresholds.hxx b/lib/fpa/Image/RegionGrowWithMultipleThresholds.hxx deleted file mode 100644 index 4725c54..0000000 --- a/lib/fpa/Image/RegionGrowWithMultipleThresholds.hxx +++ /dev/null @@ -1,256 +0,0 @@ -#ifndef __FPA__IMAGE__REGIONGROWWITHMULTIPLETHRESHOLDS__HXX__ -#define __FPA__IMAGE__REGIONGROWWITHMULTIPLETHRESHOLDS__HXX__ - -#include -#include -#include - -// ------------------------------------------------------------------------- -template< class I > -void fpa::Image::RegionGrowWithMultipleThresholds< I >:: -AddThreshold( const TPixel& v ) -{ - this->m_Thresholds.insert( v ); - this->Modified( ); -} - -// ------------------------------------------------------------------------- -template< class I > -void fpa::Image::RegionGrowWithMultipleThresholds< I >:: -AddThresholds( const TPixel& t0, const TPixel& t1, const unsigned int& s ) -{ - for( TPixel t = t0; t <= t1; t += TPixel( s ) ) - this->AddThreshold( t ); -} - -// ------------------------------------------------------------------------- -template< class I > -fpa::Image::RegionGrowWithMultipleThresholds< I >:: -RegionGrowWithMultipleThresholds( ) - : Superclass( ), - m_InsideValue( TPixel( 1 ) ), - m_OutsideValue( TPixel( 0 ) ), - m_DifferenceThreshold( double( 3 ) ), - m_TotalCount( 0 ), - m_LastDiff( double( 0 ) ), - m_StopForced( false ), - m_StopThreshold( TPixel( 0 ) ) -{ -} - -// ------------------------------------------------------------------------- -template< class I > -fpa::Image::RegionGrowWithMultipleThresholds< I >:: -~RegionGrowWithMultipleThresholds( ) -{ -} - -// ------------------------------------------------------------------------- -template< class I > -void fpa::Image::RegionGrowWithMultipleThresholds< I >:: -_BeforeMainLoop( ) -{ - const I* img = this->GetInput( ); - - // Clear all states - this->ClearMembershipFunctions( ); - this->m_Histogram.clear( ); - this->m_TotalCount = img->GetLargestPossibleRegion( ).GetNumberOfPixels( ); - this->m_LastDiff = double( -1 ); - this->m_StopForced = false; - - // Initialize thresholding functors - typename TThresholds::const_iterator tIt = this->m_Thresholds.begin( ); - TPixel min_thr = std::numeric_limits< TPixel >::min( ); - for( ; tIt != this->m_Thresholds.end( ); ++tIt ) - { - typename TFunction::Pointer function = TFunction::New( ); - function->SetInputImage( img ); - function->SetLowerThreshold( min_thr ); - function->SetUpperThreshold( *tIt ); - this->AddMembershipFunction( function ); - - } // rof - - // Correct seeds - typename I::SizeType radius; - radius.Fill( 3 ); - itk::ConstNeighborhoodIterator< I > it( - radius, img, img->GetRequestedRegion( ) - ); - for( unsigned int s = 0; s < this->m_Seeds.size( ); ++s ) - { - _TNode seed = this->m_Seeds[ s ]; - it.SetLocation( seed.Vertex ); - - typename I::SizeType size = it.GetSize( ); - unsigned int nN = 1; - for( unsigned int d = 0; d < I::ImageDimension; ++d ) - nN *= size[ d ]; - TPixel min_value = img->GetPixel( seed.Vertex ); - for( unsigned int i = 0; i < nN; ++i ) - { - if( it.GetPixel( i ) < min_value ) - { - seed.Vertex = it.GetIndex( i ); - seed.Parent = seed.Vertex; - min_value = it.GetPixel( i ); - - } // fi - - } // rof - this->m_Seeds[ s ] = seed; - - } // rof - - // Continue all initializations - this->Superclass::_BeforeMainLoop( ); -} - -// ------------------------------------------------------------------------- -template< class I > -void fpa::Image::RegionGrowWithMultipleThresholds< I >:: -_AfterMainLoop( ) -{ - typedef itk::BinaryThresholdImageFilter< I, I > _TBinFilter; - - // Binarize, inplace, the grown region - if( this->m_Histogram.size( ) > 1 ) - { - typename _TBinFilter::Pointer bin = _TBinFilter::New( ); - bin->SetInput( this->GetOutput( ) ); - bin->SetInsideValue( this->m_InsideValue ); - bin->SetOutsideValue( this->m_OutsideValue ); - bin->InPlaceOn( ); - if( this->m_StopForced ) - bin->SetUpperThreshold( this->m_StopThreshold ); - else - bin->SetUpperThreshold( this->m_Histogram.rbegin( )->first ); - bin->GraftOutput( this->GetOutput( ) ); - bin->Update( ); - this->GraftOutput( bin->GetOutput( ) ); - - } // fi - - this->Superclass::_AfterMainLoop( ); -} - -// ------------------------------------------------------------------------- -template< class I > -void fpa::Image::RegionGrowWithMultipleThresholds< I >:: -_AfterLoop( ) -{ - if( this->m_ActualFunction != this->m_Functions.end( ) ) - { - TFunction* f = - dynamic_cast< TFunction* >( this->m_ActualFunction->GetPointer( ) ); - this->m_Histogram[ f->GetUpperThreshold( ) ] = this->m_Marks.size( ); - - /* TODO: code to print the signal for demo purposes - std::cout - << f->GetUpperThreshold( ) << " " - << this->m_Marks.size( ) - << std::endl; - */ - - // Get the two last complete count, if any, and compute last - // finite difference - if( this->m_Histogram.size( ) > 1 ) - { - typename THistogram::const_reverse_iterator hIt = - this->m_Histogram.rbegin( ); - typename THistogram::const_reverse_iterator gIt = hIt; - gIt++; - - this->m_LastDiff = double( hIt->second ) - double( gIt->second ); - this->m_LastDiff /= double( hIt->first ) - double( gIt->first ); - this->m_LastDiff *= m_DifferenceThreshold; - } - else - this->m_LastDiff = double( -1 ); - - } // fi - this->Superclass::_AfterLoop( ); -} - -// ------------------------------------------------------------------------- -template< class I > -bool fpa::Image::RegionGrowWithMultipleThresholds< I >:: -_UpdateResult( _TNode& n ) -{ - // Here, the output is changed to the threshold used to compute the - // growing condition of the actual vertex n - bool ret = this->Superclass::_UpdateResult( n ); - if( this->m_ActualFunction != this->m_Functions.end( ) ) - { - TFunction* f = - dynamic_cast< TFunction* >( this->m_ActualFunction->GetPointer( ) ); - if( f != NULL ) - this->GetOutput( )->SetPixel( n.Vertex, f->GetUpperThreshold( ) ); - - } // fi - return( ret ); -} - -// ------------------------------------------------------------------------- -template< class I > -void fpa::Image::RegionGrowWithMultipleThresholds< I >:: -_Mark( const _TNode& n ) -{ - this->Superclass::_Mark( n ); - - // Check if the histogram's support is enough - if( this->m_Histogram.size( ) < 2 ) - return; - typename THistogram::const_reverse_iterator hIt = - this->m_Histogram.rbegin( ); - - // Get the actual function - TFunction* f = - dynamic_cast< TFunction* >( this->m_ActualFunction->GetPointer( ) ); - if( f == NULL ) - return; - - // Previous pixel count - unsigned long prev_aCount = hIt->second; - double prev_p = double( prev_aCount ) / double( this->m_TotalCount ); - - // Actual pixel count - unsigned long aCount = this->m_Marks.size( ); - double p = double( aCount ) / double( this->m_TotalCount ); - - // Loop over, at least, 0.1% of the total number of pixels before - // performing stop analysis - if( double( 1e-3 ) < p && double( 1e-3 ) < prev_p ) - { - // Does the difference is worthy to be analyzed? - if( aCount > hIt->second ) - { - // Compute finite difference and compare it to the previous one - double diff = double( aCount ) - double( hIt->second ); - diff /= double( f->GetUpperThreshold( ) ) - double( hIt->first ); - if( diff > this->m_LastDiff ) - { - /* TODO: comment this for demo purposes - */ - this->m_StopForced = true; - this->m_StopThreshold = hIt->first; - - } // fi - - } // fi - - } // fi -} - -// ------------------------------------------------------------------------- -template< class I > -bool fpa::Image::RegionGrowWithMultipleThresholds< I >:: -_CheckStopCondition( ) -{ - return( this->m_StopForced ); -} - -#endif // __FPA__IMAGE__REGIONGROWWITHMULTIPLETHRESHOLDS__HXX__ - -// eof - $RCSfile$ diff --git a/lib/fpa/VTK/Image/ImageSkeletonToPolyData.h b/lib/fpa/VTK/Image/ImageSkeletonToPolyData.h deleted file mode 100644 index 3c19b7b..0000000 --- a/lib/fpa/VTK/Image/ImageSkeletonToPolyData.h +++ /dev/null @@ -1,67 +0,0 @@ -#ifndef __FPA__VTK__IMAGESKELETONTOPOLYDATA__H__ -#define __FPA__VTK__IMAGESKELETONTOPOLYDATA__H__ - -#include - -namespace fpa -{ - namespace VTK - { - namespace Image - { - /** - */ - template< class _TSkeleton > - class ImageSkeletonToPolyData - : public vtkPolyDataAlgorithm - { - public: - typedef ImageSkeletonToPolyData Self; - typedef _TSkeleton TSkeleton; - - public: - vtkTypeMacro( ImageSkeletonToPolyData, vtkPolyDataAlgorithm ); - - public: - static Self* New( ); - - const TSkeleton* GetInput( ) const; - void SetInput( const TSkeleton* sk ); - - protected: - ImageSkeletonToPolyData( ); - virtual ~ImageSkeletonToPolyData( ); - - int RequestData( - vtkInformation* information, - vtkInformationVector** input, - vtkInformationVector* output - ); - int RequestInformation( - vtkInformation* information, - vtkInformationVector** input, - vtkInformationVector* output - ); - - private: - // Purposely not implemented - ImageSkeletonToPolyData( const Self& ); - void operator=( const Self& ); - - protected: - const TSkeleton* m_Skeleton; - }; - - } // ecapseman - - } // ecapseman - -} // ecapseman - -#ifndef ITK_MANUAL_INSTANTIATION -#include -#endif // ITK_MANUAL_INSTANTIATION - -#endif // __FPA__VTK__IMAGESKELETONTOPOLYDATA__H__ - -// eof - $RCSfile$ diff --git a/lib/fpa/VTK/Image/ImageSkeletonToPolyData.hxx b/lib/fpa/VTK/Image/ImageSkeletonToPolyData.hxx deleted file mode 100644 index 5e41358..0000000 --- a/lib/fpa/VTK/Image/ImageSkeletonToPolyData.hxx +++ /dev/null @@ -1,176 +0,0 @@ -#ifndef __FPA__VTK__IMAGESKELETONTOPOLYDATA__HXX__ -#define __FPA__VTK__IMAGESKELETONTOPOLYDATA__HXX__ - -#include -#include -#include - -// ------------------------------------------------------------------------- -template< class _TSkeleton > -typename fpa::VTK::Image::ImageSkeletonToPolyData< _TSkeleton >:: -Self* fpa::VTK::Image::ImageSkeletonToPolyData< _TSkeleton >:: -New( ) -{ - return( new Self( ) ); -} - -// ------------------------------------------------------------------------- -template< class _TSkeleton > -const _TSkeleton* fpa::VTK::Image::ImageSkeletonToPolyData< _TSkeleton >:: -GetInput( ) const -{ - return( this->m_Skeleton ); -} - -// ------------------------------------------------------------------------- -template< class _TSkeleton > -void fpa::VTK::Image::ImageSkeletonToPolyData< _TSkeleton >:: -SetInput( const _TSkeleton* sk ) -{ - if( this->m_Skeleton != sk ) - { - this->m_Skeleton = sk; - this->Modified( ); - - } // fi -} - -// ------------------------------------------------------------------------- -template< class _TSkeleton > -fpa::VTK::Image::ImageSkeletonToPolyData< _TSkeleton >:: -ImageSkeletonToPolyData( ) - : vtkPolyDataAlgorithm( ), - m_Skeleton( NULL ) -{ - this->SetNumberOfInputPorts( 0 ); -} - -// ------------------------------------------------------------------------- -template< class _TSkeleton > -fpa::VTK::Image::ImageSkeletonToPolyData< _TSkeleton >:: -~ImageSkeletonToPolyData( ) -{ -} - -// ------------------------------------------------------------------------- -template< class _TSkeleton > -int fpa::VTK::Image::ImageSkeletonToPolyData< _TSkeleton >:: -RequestData( - vtkInformation* information, - vtkInformationVector** input, - vtkInformationVector* output - ) -{ - typedef typename _TSkeleton::TVertex _TVertex; - typedef typename _TSkeleton::TVertexCmp _TCmp; - typedef itk::Point< double, _TVertex::Dimension > _TPoint; - typedef - std::map< _TVertex, std::map< _TVertex, bool, _TCmp >, _TCmp > - _TMarks; - static const unsigned int dim = _TVertex::Dimension; - - if( this->m_Skeleton == NULL ) - return( 0 ); - - // Get output - vtkInformation* info = output->GetInformationObject( 0 ); - vtkPolyData* out = vtkPolyData::SafeDownCast( - info->Get( vtkDataObject::DATA_OBJECT( ) ) - ); - - // Prepare points and cells - vtkSmartPointer< vtkPoints > points = - vtkSmartPointer< vtkPoints >::New( ); - vtkSmartPointer< vtkCellArray > lines = - vtkSmartPointer< vtkCellArray >::New( ); - - // Iterator over input data - auto& sk = this->m_Skeleton->Get( ); - auto mst = this->m_Skeleton->GetMinimumSpanningTree( ); - _TMarks marks; - for( auto i = sk.begin( ); i != sk.end( ); ++i ) - { - for( auto j = i->second.begin( ); j != i->second.end( ); ++j ) - { - if( !marks[ i->first ][ j->first ] ) - { - auto path = j->second.GetPointer( ); - if( path != NULL ) - { - auto vertices = path->GetVertexList( ); - for( unsigned int v = 0; v < vertices->Size( ); ++v ) - { - auto idx = vertices->GetElement( v ); - _TPoint pnt; - mst->TransformContinuousIndexToPhysicalPoint( idx, pnt ); - if( dim == 1 ) - points->InsertNextPoint( pnt[ 0 ], 0, 0 ); - else if( dim == 2 ) - points->InsertNextPoint( pnt[ 0 ], pnt[ 1 ], 0 ); - else - points->InsertNextPoint( pnt[ 0 ], pnt[ 1 ], pnt[ 2 ] ); - if( v > 0 ) - { - lines->InsertNextCell( 2 ); - lines->InsertCellPoint( points->GetNumberOfPoints( ) - 2 ); - lines->InsertCellPoint( points->GetNumberOfPoints( ) - 1 ); - - } // fi - - } // rof - - } // fi - - // Mark path and its symmetric as visited - marks[ i->first ][ j->first ] = true; - marks[ j->first ][ i->first ] = true; - - } // fi - - } // rof - - } // rof - out->SetPoints( points ); - out->SetLines( lines ); - return( 1 ); -} - -// ------------------------------------------------------------------------- -template< class _TSkeleton > -int fpa::VTK::Image::ImageSkeletonToPolyData< _TSkeleton >:: -RequestInformation( - vtkInformation* information, - vtkInformationVector** input, - vtkInformationVector* output - ) -{ - vtkInformation* info = output->GetInformationObject( 0 ); - /* TODO - info->Set( - vtkStreamingDemandDrivenPipeline::MAXIMUM_NUMBER_OF_PIECES( ), -1 - ); - */ - - if( this->m_Skeleton != NULL ) - { - /* TODO - typename C::TScalar len = this->m_RGC->GetTotalLength( ); - typename C::TScalar s0 = this->m_RGC->Gets0( ); - typename C::TPoint p0 = this->m_RGC->Axis( s0 ); - typename C::TPoint p1 = this->m_RGC->Axis( s0 + len ); - - info->Set( - vtkStreamingDemandDrivenPipeline::WHOLE_BOUNDING_BOX( ), - double( p0[ 0 ] ), double( p1[ 0 ] ), - double( p0[ 1 ] ), double( p1[ 1 ] ), - double( p0[ 2 ] ), double( p1[ 2 ] ) - ); - */ - - } // fi - return( 1 ); -} - -#endif // __FPA__VTK__IMAGESKELETONTOPOLYDATA__HXX__ - -// eof - $RCSfile$ diff --git a/lib/fpa/VTK/Image/Observer2D.h b/lib/fpa/VTK/Image/Observer2D.h deleted file mode 100644 index 8abbecf..0000000 --- a/lib/fpa/VTK/Image/Observer2D.h +++ /dev/null @@ -1,88 +0,0 @@ -#ifndef __FPA__VTK__IMAGE__OBSERVER2D__H__ -#define __FPA__VTK__IMAGE__OBSERVER2D__H__ - -#include -#include -#include -#include -#include -#include -#include - -namespace fpa -{ - namespace VTK - { - namespace Image - { - /** - */ - template< class F, class R > - class Observer2D - : public itk::Command - { - public: - typedef Observer2D Self; - typedef itk::Command Superclass; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; - - typedef F TFilter; - typedef R TRenderWindow; - typedef typename TFilter::TInputImage TImage; - typedef typename TFilter::TVertex TVertex; - - typedef std::set< TVertex > TVertices; - - public: - itkNewMacro( Self ); - itkTypeMacro( Observer2D, itkCommand ); - - itkGetConstMacro( RenderPercentage, double ); - itkSetMacro( RenderPercentage, double ); - - public: - void SetRenderWindow( R* rw ); - void SetPixel( - typename TImage::IndexType idx, - unsigned char red, - unsigned char green, - unsigned char blue, - unsigned char alpha - ); - void Render( ); - void Execute( itk::Object* c, const itk::EventObject& e ) ITK_OVERRIDE - { this->Execute( ( const itk::Object* )( c ), e ); } - void Execute( const itk::Object* c, const itk::EventObject& e ) ITK_OVERRIDE; - - protected: - Observer2D( ); - virtual ~Observer2D( ); - - private: - Observer2D( const Self& ); // Not impl. - void operator=( const Self& ); // Not impl. - - protected: - vtkSmartPointer< vtkImageData > m_Stencil; - vtkSmartPointer< vtkImageActor > m_StencilActor; - - R* m_RenderWindow; - unsigned long m_Count; - unsigned long m_RenderCount; - double m_RenderPercentage; - }; - - } // ecapseman - - } // ecapseman - -} // ecapseman - -#ifndef ITK_MANUAL_INSTANTIATION -#include -#endif // ITK_MANUAL_INSTANTIATION - -#endif // __FPA__VTK__IMAGE__OBSERVER2D__H__ - -// eof - $RCSfile$ diff --git a/lib/fpa/VTK/Image/Observer2D.hxx b/lib/fpa/VTK/Image/Observer2D.hxx deleted file mode 100644 index da4c7bf..0000000 --- a/lib/fpa/VTK/Image/Observer2D.hxx +++ /dev/null @@ -1,226 +0,0 @@ -#ifndef __FPA__VTK__IMAGE__OBSERVER2D__HXX__ -#define __FPA__VTK__IMAGE__OBSERVER2D__HXX__ - -#include -#include -#include -#include -#include -#include -#include - -// ------------------------------------------------------------------------- -template< class F, class R > -void fpa::VTK::Image::Observer2D< F, R >:: -SetRenderWindow( R* rw ) -{ - this->m_RenderWindow = rw; -} - -// ------------------------------------------------------------------------- -template< class F, class R > -void fpa::VTK::Image::Observer2D< F, R >:: -SetPixel( - typename TImage::IndexType idx, - unsigned char red, - unsigned char green, - unsigned char blue, - unsigned char alpha - ) -{ - this->m_Stencil->SetScalarComponentFromDouble - ( idx[ 0 ], idx[ 1 ], 0, 0, red ); - this->m_Stencil->SetScalarComponentFromDouble - ( idx[ 0 ], idx[ 1 ], 0, 1, green ); - this->m_Stencil->SetScalarComponentFromDouble - ( idx[ 0 ], idx[ 1 ], 0, 2, blue ); - this->m_Stencil->SetScalarComponentFromDouble - ( idx[ 0 ], idx[ 1 ], 0, 3, alpha ); - this->m_Stencil->Modified( ); - this->m_StencilActor->Modified( ); -} - -// ------------------------------------------------------------------------- -template< class F, class R > -void fpa::VTK::Image::Observer2D< F, R >:: -Render( ) -{ - if( this->m_RenderWindow != NULL ) - this->m_RenderWindow->Render( ); -} - -// ------------------------------------------------------------------------- -template< class F, class R > -void fpa::VTK::Image::Observer2D< F, R >:: -Execute( const itk::Object* c, const itk::EventObject& e ) -{ - typedef typename F::TStartEvent _TStartEvent; - typedef typename F::TStartLoopEvent _TStartLoopEvent; - typedef typename F::TEndEvent _TEndEvent; - typedef typename F::TEndLoopEvent _TEndLoopEvent; - typedef typename F::TAliveEvent _TAliveEvent; - typedef typename F::TFrontEvent _TFrontEvent; - typedef typename F::TFreezeEvent _TFreezeEvent; - - typedef typename F::TStartBacktrackingEvent _TStartBacktrackingEvent; - typedef typename F::TEndBacktrackingEvent _TEndBacktrackingEvent; - typedef typename F::TBacktrackingEvent _TBacktrackingEvent; - - static unsigned char Colors[][4] = - { - { 0, 0, 127, 127 }, - { 0, 127, 127, 127 }, - { 127, 0, 127, 127 }, - { 127, 127, 0, 127 }, - { 0, 0, 63, 127 }, - { 0, 63, 63, 127 }, - { 63, 0, 63, 127 }, - { 63, 63, 0, 127 }, - { 63, 63, 127, 127 }, - { 63, 127, 127, 127 }, - { 127, 63, 127, 127 }, - { 127, 127, 63, 127 }, - { 127, 127, 63, 127 }, - { 127, 63, 63, 127 }, - { 63, 127, 63, 127 }, - { 63, 63, 127, 127 } - }; - - const F* filter = dynamic_cast< const F* >( c ); - if( this->m_RenderWindow == NULL || filter == NULL ) - return; - - const _TStartEvent* startEvt = dynamic_cast< const _TStartEvent* >( &e ); - const _TStartBacktrackingEvent* startBackEvt = - dynamic_cast< const _TStartBacktrackingEvent* >( &e ); - if( startEvt != NULL || startBackEvt != NULL ) - { - const typename F::TInputImage* img = filter->GetInput( ); - unsigned int minD = F::TInputImage::ImageDimension; - minD = ( minD < 3 )? minD: 3; - - int e[ 6 ] = { 0 }; - typename F::TInputImage::RegionType reg = img->GetRequestedRegion( ); - for( unsigned int i = 0; i < minD; i++ ) - { - e[ ( i << 1 ) + 0 ] = reg.GetIndex( )[ i ]; - e[ ( i << 1 ) + 1 ] = reg.GetIndex( )[ i ] + reg.GetSize( )[ i ] - 1; - - } // rof - - typename F::TInputImage::SpacingType spac = img->GetSpacing( ); - double s[ 3 ] = { 1, 1, 1 }; - for( unsigned int i = 0; i < minD; i++ ) - s[ i ] = double( spac[ i ] ); - - typename F::TInputImage::PointType orig = img->GetOrigin( ); - double o[ 3 ] = { 0 }; - for( unsigned int i = 0; i < minD; i++ ) - o[ i ] = double( orig[ i ] ); - - this->m_Stencil->SetExtent( e ); - this->m_Stencil->SetSpacing( s ); - this->m_Stencil->SetOrigin( o ); - this->m_Stencil->AllocateScalars( VTK_UNSIGNED_CHAR, 4 ); - for( unsigned int i = 0; i < 3; i++ ) - this->m_Stencil->GetPointData( )-> - GetScalars( )->FillComponent( i, 255 ); - this->m_Stencil->GetPointData( )->GetScalars( )->FillComponent( 3, 0 ); - - this->m_StencilActor->SetInputData( this->m_Stencil ); - this->m_StencilActor->InterpolateOff( ); - - this->m_Count = 0; - this->m_RenderCount = reg.GetNumberOfPixels( ); - - vtkRenderer* ren = - this->m_RenderWindow->GetRenderers( )->GetFirstRenderer( ); - ren->AddActor( this->m_StencilActor ); - return; - - } // fi - - const _TAliveEvent* aliveEvt = dynamic_cast< const _TAliveEvent* >( &e ); - const _TFrontEvent* frontEvt = dynamic_cast< const _TFrontEvent* >( &e ); - if( aliveEvt != NULL || frontEvt != NULL ) - { - if( aliveEvt != NULL ) - this->SetPixel( - aliveEvt->Vertex, - Colors[ aliveEvt->FrontId ][ 0 ], - Colors[ aliveEvt->FrontId ][ 1 ], - Colors[ aliveEvt->FrontId ][ 2 ], - Colors[ aliveEvt->FrontId ][ 3 ] - ); - else if( frontEvt != NULL ) - this->SetPixel( frontEvt->Vertex, 255, 0, 0, 255 ); - this->m_Count++; - - // Render visual debug - double per = double( this->m_RenderCount ) * this->m_RenderPercentage; - if( double( this->m_Count ) >= per ) - this->Render( ); - if( double( this->m_Count ) >= per ) - this->m_Count = 0; - - return; - - } // fi - - const _TEndEvent* endEvt = dynamic_cast< const _TEndEvent* >( &e ); - if( endEvt != NULL ) - { - vtkRenderer* ren = - this->m_RenderWindow->GetRenderers( )->GetFirstRenderer( ); - ren->RemoveActor( this->m_StencilActor ); - this->Render( ); - return; - - } // fi - - const _TBacktrackingEvent* backEvt = - dynamic_cast< const _TBacktrackingEvent* >( &e ); - const _TEndBacktrackingEvent* endBackEvt = - dynamic_cast< const _TEndBacktrackingEvent* >( &e ); - if( backEvt != NULL ) - { - this->SetPixel( backEvt->Vertex, 0, 0, 255, 255 ); - return; - - } // fi - - if( endBackEvt != NULL ) - { - this->m_RenderWindow->Render( ); - /* TODO: DEBUG - std::cout << "Press enter: " << std::ends; - int aux; - std::cin >> aux; - */ - return; - - } // fi -} - -// ------------------------------------------------------------------------- -template< class F, class R > -fpa::VTK::Image::Observer2D< F, R >:: -Observer2D( ) - : Superclass( ), - m_RenderWindow( NULL ), - m_RenderPercentage( double( 0.01 ) ) -{ - this->m_Stencil = vtkSmartPointer< vtkImageData >::New( ); - this->m_StencilActor = vtkSmartPointer< vtkImageActor >::New( ); -} - -// ------------------------------------------------------------------------- -template< class F, class R > -fpa::VTK::Image::Observer2D< F, R >:: -~Observer2D( ) -{ -} - -#endif // __FPA__VTK__IMAGE__OBSERVER2D__HXX__ - -// eof - $RCSfile$ diff --git a/lib/fpa/VTK/Image/Observer3D.h b/lib/fpa/VTK/Image/Observer3D.h deleted file mode 100644 index ce3c053..0000000 --- a/lib/fpa/VTK/Image/Observer3D.h +++ /dev/null @@ -1,86 +0,0 @@ -#ifndef __FPA__VTK__IMAGE__OBSERVER3D__H__ -#define __FPA__VTK__IMAGE__OBSERVER3D__H__ - -#include - -#include - -#include -#include -#include -#include - -namespace fpa -{ - namespace VTK - { - namespace Image - { - /** - */ - template< class F, class R > - class Observer3D - : public itk::Command - { - public: - typedef Observer3D Self; - typedef itk::Command Superclass; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; - - typedef F TFilter; - typedef R TRenderWindow; - typedef typename TFilter::TInputImage TImage; - typedef typename TFilter::TVertex TVertex; - typedef typename TFilter::TVertexCompare TVertexCompare; - - typedef std::set< TVertex > TVertices; - - public: - itkNewMacro( Self ); - itkTypeMacro( Observer3D, itkCommand ); - - itkGetConstMacro( RenderPercentage, double ); - itkSetMacro( RenderPercentage, double ); - - public: - void SetRenderWindow( R* rw ); - void Render( ); - void Execute( itk::Object* c, const itk::EventObject& e ) ITK_OVERRIDE - { this->Execute( ( const itk::Object* )( c ), e ); } - void Execute( const itk::Object* c, const itk::EventObject& e ) ITK_OVERRIDE; - - protected: - Observer3D( ); - virtual ~Observer3D( ); - - private: - Observer3D( const Self& ); // Not impl. - void operator=( const Self& ); // Not impl. - - protected: - vtkSmartPointer< vtkPolyData > m_PolyData; - vtkSmartPointer< vtkPolyDataMapper > m_PolyDataMapper; - vtkSmartPointer< vtkActor > m_PolyDataActor; - std::map< TVertex, unsigned long, TVertexCompare > m_PointsToReplace; - std::map< TVertex, unsigned long, TVertexCompare > m_PointsInFront; - - R* m_RenderWindow; - unsigned long m_Count; - unsigned long m_RenderCount; - double m_RenderPercentage; - }; - - } // ecapseman - - } // ecapseman - -} // ecapseman - -#ifndef ITK_MANUAL_INSTANTIATION -#include -#endif // ITK_MANUAL_INSTANTIATION - -#endif // __FPA__VTK__IMAGE__OBSERVER3D__H__ - -// eof - $RCSfile$ diff --git a/lib/fpa/VTK/Image/Observer3D.hxx b/lib/fpa/VTK/Image/Observer3D.hxx deleted file mode 100644 index 871142b..0000000 --- a/lib/fpa/VTK/Image/Observer3D.hxx +++ /dev/null @@ -1,211 +0,0 @@ -#ifndef __FPA__VTK__IMAGE__OBSERVER3D__HXX__ -#define __FPA__VTK__IMAGE__OBSERVER3D__HXX__ - -#include -#include -#include -#include -#include -#include -#include - -// ------------------------------------------------------------------------- -template< class F, class R > -void fpa::VTK::Image::Observer3D< F, R >:: -SetRenderWindow( R* rw ) -{ - this->m_RenderWindow = rw; -} - -// ------------------------------------------------------------------------- -template< class F, class R > -void fpa::VTK::Image::Observer3D< F, R >:: -Render( ) -{ - if( this->m_RenderWindow != NULL ) - this->m_RenderWindow->Render( ); -} - -// ------------------------------------------------------------------------- -template< class F, class R > -void fpa::VTK::Image::Observer3D< F, R >:: -Execute( const itk::Object* c, const itk::EventObject& e ) -{ - typedef typename F::TStartEvent _TStartEvent; - typedef typename F::TStartLoopEvent _TStartLoopEvent; - typedef typename F::TEndEvent _TEndEvent; - typedef typename F::TEndLoopEvent _TEndLoopEvent; - typedef typename F::TAliveEvent _TAliveEvent; - typedef typename F::TFrontEvent _TFrontEvent; - typedef typename F::TFreezeEvent _TFreezeEvent; - - typedef typename F::TStartBacktrackingEvent _TStartBacktrackingEvent; - typedef typename F::TEndBacktrackingEvent _TEndBacktrackingEvent; - typedef typename F::TBacktrackingEvent _TBacktrackingEvent; - - static unsigned char Colors[][4] = - { - { 0, 0, 127, 127 }, - { 0, 127, 127, 127 }, - { 127, 0, 127, 127 }, - { 127, 127, 0, 127 }, - { 0, 0, 63, 127 }, - { 0, 63, 63, 127 }, - { 63, 0, 63, 127 }, - { 63, 63, 0, 127 }, - { 63, 63, 127, 127 }, - { 63, 127, 127, 127 }, - { 127, 63, 127, 127 }, - { 127, 127, 63, 127 }, - { 127, 127, 63, 127 }, - { 127, 63, 63, 127 }, - { 63, 127, 63, 127 }, - { 63, 63, 127, 127 } - }; - - const F* filter = dynamic_cast< const F* >( c ); - if( this->m_RenderWindow == NULL || filter == NULL ) - return; - auto image = filter->GetInput( ); - if( image == NULL ) - return; - - const _TStartEvent* startEvt = dynamic_cast< const _TStartEvent* >( &e ); - const _TStartBacktrackingEvent* startBackEvt = - dynamic_cast< const _TStartBacktrackingEvent* >( &e ); - if( startEvt != NULL || startBackEvt != NULL ) - { - this->m_Count = 0; - this->m_RenderCount = - image->GetLargestPossibleRegion( ).GetNumberOfPixels( ); - this->m_PointsToReplace.clear( ); - this->m_PointsInFront.clear( ); - - vtkRenderer* ren = - this->m_RenderWindow->GetRenderers( )->GetFirstRenderer( ); - ren->AddActor( this->m_PolyDataActor ); - return; - - } // fi - - const _TFrontEvent* frontEvt = dynamic_cast< const _TFrontEvent* >( &e ); - if( frontEvt != NULL ) - { - typename F::TInputImage::PointType pnt; - image->TransformIndexToPhysicalPoint( frontEvt->Vertex, pnt ); - if( this->m_PointsToReplace.empty( ) ) - { - unsigned long nPoints = this->m_PolyData->GetNumberOfPoints( ); - this->m_PolyData->GetPoints( )-> - InsertNextPoint( pnt[ 0 ], pnt[ 1 ], pnt[ 2 ] ); - this->m_PolyData->GetVerts( )->InsertNextCell( 1 ); - this->m_PolyData->GetVerts( )->InsertCellPoint( nPoints ); - this->m_PointsInFront[ frontEvt->Vertex ] = nPoints; - } - else - { - auto pIt = this->m_PointsToReplace.begin( ); - this->m_PolyData->GetPoints( )-> - SetPoint( pIt->second, pnt[ 0 ], pnt[ 1 ], pnt[ 2 ] ); - this->m_PointsToReplace.erase( pIt ); - - } // fi - this->m_PolyData->Modified( ); - this->m_PolyDataMapper->Modified( ); - this->m_PolyDataActor->Modified( ); - - // Render visual debug - this->m_Count++; - double per = double( this->m_RenderCount ) * this->m_RenderPercentage; - if( double( this->m_Count ) >= per ) - this->Render( ); - if( double( this->m_Count ) >= per ) - this->m_Count = 0; - - return; - - } // fi - - const _TAliveEvent* aliveEvt = dynamic_cast< const _TAliveEvent* >( &e ); - if( aliveEvt != NULL ) - { - auto pIt = this->m_PointsInFront.find( aliveEvt->Vertex ); - if( pIt != this->m_PointsInFront.end( ) ) - { - this->m_PointsToReplace[ pIt->first ] = pIt->second; - this->m_PointsInFront.erase( pIt ); - - } // fi - return; - - } // fi - - const _TEndEvent* endEvt = dynamic_cast< const _TEndEvent* >( &e ); - if( endEvt != NULL ) - { - vtkRenderer* ren = - this->m_RenderWindow->GetRenderers( )->GetFirstRenderer( ); - ren->RemoveActor( this->m_PolyDataActor ); - this->Render( ); - return; - - } // fi - - const _TBacktrackingEvent* backEvt = - dynamic_cast< const _TBacktrackingEvent* >( &e ); - const _TEndBacktrackingEvent* endBackEvt = - dynamic_cast< const _TEndBacktrackingEvent* >( &e ); - if( backEvt != NULL ) - { - // TODO: - return; - - } // fi - - if( endBackEvt != NULL ) - { - this->m_RenderWindow->Render( ); - - /* TODO: DEBUG - std::cout << "Press enter: " << std::ends; - int aux; - std::cin >> aux; - */ - return; - - } // fi -} - -// ------------------------------------------------------------------------- -template< class F, class R > -fpa::VTK::Image::Observer3D< F, R >:: -Observer3D( ) - : Superclass( ), - m_RenderWindow( NULL ), - m_RenderPercentage( double( 0.001 ) ) -{ - this->m_PolyData = vtkSmartPointer< vtkPolyData >::New( ); - this->m_PolyDataMapper = vtkSmartPointer< vtkPolyDataMapper >::New( ); - this->m_PolyDataActor =vtkSmartPointer< vtkActor >::New( ); - - vtkSmartPointer< vtkPoints > points = - vtkSmartPointer< vtkPoints >::New( ); - vtkSmartPointer< vtkCellArray > verts = - vtkSmartPointer< vtkCellArray >::New( ); - this->m_PolyData->SetPoints( points ); - this->m_PolyData->SetVerts( verts ); - this->m_PolyDataMapper->SetInputData( this->m_PolyData ); - this->m_PolyDataActor->SetMapper( this->m_PolyDataMapper ); - this->m_PolyDataActor->GetProperty( )->SetColor( 0, 1, 0 ); -} - -// ------------------------------------------------------------------------- -template< class F, class R > -fpa::VTK::Image::Observer3D< F, R >:: -~Observer3D( ) -{ -} - -#endif // __FPA__VTK__IMAGE__OBSERVER3D__HXX__ - -// eof - $RCSfile$ diff --git a/lib/fpa_Instances/Backtracking.i b/lib/fpa_Instances/Backtracking.i deleted file mode 100644 index dd5916a..0000000 --- a/lib/fpa_Instances/Backtracking.i +++ /dev/null @@ -1,21 +0,0 @@ -d #dims=2;3 -d #floats=float;double -d #mst=fpa::Image::MinimumSpanningTree -d #path=ExtractPathFromMinimumSpanningTree -d #ebc=ExtractEndPointsAndBifurcationsFromMinimumSpanningTree - -f fpa_Instances/Instances.h - -i utility -i vector -t fpa/Base/#path.h -t fpa/Base/#ebc.h -t fpa/Image/#ebc.h -t itkSimpleDataObjectDecorator.h - -c itk::SimpleDataObjectDecorator< std::vector< std::pair< itk::Index< #dims >, itk::Index< #dims > > > > -c fpa::Base::#path< #mst< #dims > > -c fpa::Base::#ebc< #mst< #dims > > -c fpa::Image::#ebc< itk::Image< #floats, #dims >, #mst< #dims > > - -* eof - $RCSfile$ diff --git a/lib/fpa_Instances/CMakeLists.txt b/lib/fpa_Instances/CMakeLists.txt deleted file mode 100644 index 536b61c..0000000 --- a/lib/fpa_Instances/CMakeLists.txt +++ /dev/null @@ -1,24 +0,0 @@ -## ================================= -## == Compile instances libraries == -## ================================= - -SET(pfx "fpa_") -SET(arg ${pfx} ${prj_VER} ${prj_sVER}) - -cpPlugins_WrapInstances(Instances ${arg} ${cpPlugins_LIBRARIES} ${ITK_LIBRARIES} ${VTK_LIBRARIES}) -cpPlugins_WrapInstances(Functors ${arg} ${pfx}Instances) -cpPlugins_WrapInstances(Filters ${arg} ${pfx}Instances) -cpPlugins_WrapInstances(Backtracking ${arg} ${pfx}Instances) -cpPlugins_WrapInstances(Observers ${arg} ${pfx}Filters ${VTK_LIBRARIES}) - -SET( - fpa_LIBRARIES - ${pfx}Instances - ${pfx}Functors - ${pfx}Filters - ${pfx}Backtracking - ${pfx}Observers - CACHE INTERNAL "All valid instances." FORCE - ) - -## eof - $RCSfile$ diff --git a/lib/fpa_Instances/Filters.i b/lib/fpa_Instances/Filters.i deleted file mode 100644 index d4269e9..0000000 --- a/lib/fpa_Instances/Filters.i +++ /dev/null @@ -1,43 +0,0 @@ -f fpa_Instances/Instances.h - -t fpa/Base/Algorithm.h -t fpa/Base/RegionGrow.h -t fpa/Base/Dijkstra.h - -t fpa/Image/Algorithm.h -t fpa/Image/RegionGrow.h -t fpa/Image/Dijkstra.h - -d #dims=2;3 -d #int=char;short;int;long -d #uint=unsigned #int -d #float=float;double -d #pixels=#int;#uint;#float -d #b=fpa::Base -d #i=fpa::Image -d #mst=MinimumSpanningTree -d #rg_ins=#pixels -d #rg_outs=unsigned short;unsigned char -d #d_ins=#pixels -d #d_outs=#float -d #inputs=#pixels -d #outputs=#pixels - -* ===================== -* == Base algorithms == -* ===================== - -c #b::Algorithm< itk::Index< #dims >, #inputs, #outputs, itk::Image< #inputs, #dims >, itk::Functor::IndexLexicographicCompare< #dims >, itk::ImageToImageFilter< itk::Image< #inputs, #dims >, itk::Image< #outputs, #dims > > > - -c #i::Algorithm< itk::Image< #rg_ins, #dims >, itk::Image< #rg_outs, #dims >, fpa::Base::RegionGrow< itk::Index< #dims >, #rg_ins, #rg_outs, itk::Image< #rg_ins, #dims >, itk::Functor::IndexLexicographicCompare< #dims >, itk::ImageToImageFilter< itk::Image< #rg_ins, #dims >, itk::Image< #rg_outs, #dims > > > > - -c #b::Dijkstra< itk::Index< #dims >, #d_ins, #d_outs, itk::Image< #d_ins, #dims >, itk::Functor::IndexLexicographicCompare< #dims >, #i::MinimumSpanningTree< #dims >, itk::ImageToImageFilter< itk::Image< #d_ins, #dims >, itk::Image< #d_outs, #dims > > > - -* ====================== -* == Image algorithms == -* ====================== - -c #i::RegionGrow< itk::Image< #rg_ins, #dims >, itk::Image< #rg_outs, #dims > > -c #i::Dijkstra< itk::Image< #d_ins, #dims >, itk::Image< #d_outs, #dims > > - -* eof - $RCSfile$ diff --git a/lib/fpa_Instances/Functors.i b/lib/fpa_Instances/Functors.i deleted file mode 100644 index 0bb83ff..0000000 --- a/lib/fpa_Instances/Functors.i +++ /dev/null @@ -1,31 +0,0 @@ -d #functors=GulsunTekMedialness;FluxMedialness;MFluxMedialness -d #filter=cpExtensions::Algorithms::ImageFunctionFilter -d #vectors=itk::CovariantVector -d #k=itk::Image - -f fpa_Instances/Instances.h - -t itkImageFunction.h -t fpa/Image/Functors/#functors.h -t fpa/Image/Functors/GradientImageFunctionBase.h -t cpExtensions/Algorithms/ImageFunctionFilter.h - -d #dims=2;3 -d #int=char;short;int;long -d #uint=unsigned #int -d #float=float;double -d #pixels=#int;#uint;#float -d #b=fpa::Base -d #i=fpa::Image -d #mst=MinimumSpanningTree -d #rg_ins=#pixels -d #rg_outs=unsigned short;unsigned char -d #d_ins=#pixels -d #d_outs=#float -d #inputs=#pixels -d #outputs=#pixels - -c #i::Functors::#functors< #k< #vectors< #float, #dims >, #dims > > -c #filter< #k< #vectors< #float, #dims >, #dims >, #k< #float, #dims >, #i::Functors::#functors< #k< #vectors< #float, #dims >, #dims > > > - -* eof - $RCSfile$ diff --git a/lib/fpa_Instances/Instances.i b/lib/fpa_Instances/Instances.i deleted file mode 100644 index 9c8d6d7..0000000 --- a/lib/fpa_Instances/Instances.i +++ /dev/null @@ -1,51 +0,0 @@ -f cpPlugins_Instances/ScalarImagesBaseFilters.h - -t fpa/Base/MinimumSpanningTree.h -t fpa/Image/MinimumSpanningTree.h -t fpa/IO/MinimumSpanningTreeReader.h -t fpa/IO/MinimumSpanningTreeWriter.h -t fpa/Base/ImageSkeleton.h -t fpa/VTK/Image/ImageSkeletonToPolyData.h - -t itkImage.h -t itkImportImageContainer.h -t itkImageRegionConstIteratorWithIndex.h -t itkImageConstIteratorWithIndex.h -t itkSimpleDataObjectDecorator.h - -d #dims=2;3 -d #int=char;short;int;long -d #uint=unsigned #int -d #float=float;double -d #pixels=#int;#uint;#float -d #b=fpa::Base -d #i=fpa::Image -d #mst=MinimumSpanningTree -d #rg_ins=#pixels -d #rg_outs=unsigned short;unsigned char -d #d_ins=#pixels -d #d_outs=#float -d #inputs=#pixels -d #outputs=#pixels - -* ================ -* == Base types == -* ================ - -c itk::ImportImageContainer< unsigned long, #i::{#mst}Data< #dims > > -c itk::Image< #i::{#mst}Data< #dims >, #dims > -c #b::#mst< itk::Image< #i::{#mst}Data< #dims >, #dims >, itk::Index< #dims > > -c #i::#mst@{Data;{}}< #dims > -c #b::ImageSkeleton< #i::#mst< #dims > > - -c itk::ImageConstIteratorWithIndex< #i::#mst< #dims > > -c itk::ImageRegionConstIteratorWithIndex< #i::#mst< #dims > > -c fpa::IO::MinimumSpanningTree@{Reader;Writer}< #i::#mst< #dims > > - -* ======================== -* == Conversion filters == -* ======================== - -c fpa::VTK::Image::ImageSkeletonToPolyData< #b::ImageSkeleton< #i::#mst< #dims > > > - -* eof - $RCSfile$ diff --git a/lib/fpa_Instances/Observers.i b/lib/fpa_Instances/Observers.i deleted file mode 100644 index 247788b..0000000 --- a/lib/fpa_Instances/Observers.i +++ /dev/null @@ -1,24 +0,0 @@ -d #dims=2;3 -d #int=char;short;int;long -d #uint=unsigned #int -d #float=float;double -d #pixels=#int;#uint;#float -d #rg_ins=#pixels -d #rg_outs=unsigned short;unsigned char -d #d_ins=#pixels -d #d_outs=#float -d #cls=fpa::VTK::Image::Observer -d #i=fpa::Image -d #k=itk::Image - -f fpa_Instances/Filters.h - -i vtkRenderWindow.h - -t fpa/VTK/Image/Observer2D.h -t fpa/VTK/Image/Observer3D.h - -c {#cls}{#dims}D< #i::RegionGrow< #k< #rg_ins, #dims >, #k< #rg_outs, #dims > >, vtkRenderWindow > -c {#cls}{#dims}D< #i::Dijkstra< #k< #d_ins, #dims >, #k< #d_outs, #dims > >, vtkRenderWindow > - -* eof - $RCSfile$ diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt deleted file mode 100644 index fd17844..0000000 --- a/plugins/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -IF(BUILD_PLUGINS) - SUBDIRS( - fpa - ) -ENDIF(BUILD_PLUGINS) - -## eof - $RCSfile$ diff --git a/plugins/fpa/BaseImageFilter.cxx b/plugins/fpa/BaseImageFilter.cxx deleted file mode 100644 index 88e80f3..0000000 --- a/plugins/fpa/BaseImageFilter.cxx +++ /dev/null @@ -1,49 +0,0 @@ -#include "BaseImageFilter.h" -#include - -// ------------------------------------------------------------------------- -bool fpaPlugins::BaseImageFilter:: -IsInteractive( ) -{ - return( true ); -} - -// ------------------------------------------------------------------------- -void fpaPlugins::BaseImageFilter:: -SetInteractionObjects( const std::vector< void* >& objs ) -{ - if( objs.size( ) > 0 ) - this->m_SingleInteractor = - reinterpret_cast< vtkRenderWindowInteractor* >( objs[ 0 ] ); - if( objs.size( ) > 1 ) - this->m_MPRViewer = reinterpret_cast< TMPRWidget* >( objs[ 1 ] ); -} - -// ------------------------------------------------------------------------- -fpaPlugins::BaseImageFilter:: -BaseImageFilter( ) - : Superclass( ) -{ - this->_AddInput( "Input" ); - this->_AddInput( "Seeds" ); - this->_AddOutput< cpPlugins::Image >( "Output" ); - - this->m_Parameters.ConfigureAsBool( "VisualDebug" ); - this->m_Parameters.ConfigureAsBool( "StopAtOneFront" ); - this->m_Parameters.SetBool( "VisualDebug", false ); - this->m_Parameters.SetBool( "StopAtOneFront", false ); - - std::vector< std::string > orders; - orders.push_back( "1" ); - orders.push_back( "2" ); - this->m_Parameters.ConfigureAsChoices( "NeighborhoodOrder", orders ); - this->m_Parameters.SetSelectedChoice( "NeighborhoodOrder", "1" ); -} - -// ------------------------------------------------------------------------- -fpaPlugins::BaseImageFilter:: -~BaseImageFilter( ) -{ -} - -// eof - $RCSfile$ diff --git a/plugins/fpa/BaseImageFilter.h b/plugins/fpa/BaseImageFilter.h deleted file mode 100644 index 3069f49..0000000 --- a/plugins/fpa/BaseImageFilter.h +++ /dev/null @@ -1,68 +0,0 @@ -#ifndef __FPAPLUGINS__BASEIMAGEFILTER__H__ -#define __FPAPLUGINS__BASEIMAGEFILTER__H__ - -#include -#include - -#include -#include - -namespace fpaPlugins -{ - /** - */ - class fpaPlugins_EXPORT BaseImageFilter - : public cpPlugins::ProcessObject - { - public: - typedef BaseImageFilter Self; - typedef cpPlugins::ProcessObject Superclass; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; - - typedef cpExtensions::QT::SimpleMPRWidget TMPRWidget; - - public: - itkTypeMacro( BaseImageFilter, cpPlugins::ProcessObject ); - cpPlugins_Id_Macro( BaseImageFilter, fpaImageAlgorithm ); - - public: - virtual bool IsInteractive( ) override; - virtual void SetInteractionObjects( - const std::vector< void* >& objs - ) override; - - protected: - BaseImageFilter( ); - virtual ~BaseImageFilter( ); - - 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 ); - - protected: - TMPRWidget* m_MPRViewer; - vtkRenderWindowInteractor* m_SingleInteractor; - std::set< unsigned long > m_Observers; - }; - -} // ecapseman - -#include "BaseImageFilter.hxx" - -#endif // __FPAPLUGINS__BASEIMAGEFILTER__H__ - -// eof - $RCSfile$ diff --git a/plugins/fpa/BaseImageFilter.hxx b/plugins/fpa/BaseImageFilter.hxx deleted file mode 100644 index 965514f..0000000 --- a/plugins/fpa/BaseImageFilter.hxx +++ /dev/null @@ -1,150 +0,0 @@ -#ifndef __FPAPLUGINS__BASEIMAGEFILTER__HXX__ -#define __FPAPLUGINS__BASEIMAGEFILTER__HXX__ - -#include -#include - -// ------------------------------------------------------------------------- -template< class _TFilter > -_TFilter* fpaPlugins::BaseImageFilter:: -_ConfigureFilter( ) -{ - typedef typename _TFilter::TInputImage _TImage; - static const unsigned int Dim = _TImage::ImageDimension; - - auto image = this->GetInputData< _TImage >( "Input" ); - if( image == NULL ) - return( NULL ); - auto seeds = this->GetInputData< vtkPoints >( "Seeds" ); - - // Create filter and connect input - auto filter = this->_CreateITK< _TFilter >( ); - filter->SetInput( image ); - - // Set numeric parameters - filter->SetNeighborhoodOrder( - this->m_Parameters.GetSelectedChoice( "NeighborhoodOrder" )[ 0 ] - '0' - ); - filter->SetStopAtOneFront( this->m_Parameters.GetBool( "StopAtOneFront" ) ); - - // Assign seeds - filter->ClearSeeds( ); - if( seeds != NULL ) - { - typename _TImage::PointType pnt; - typename _TImage::IndexType idx; - unsigned int dim = - ( _TImage::ImageDimension < 3 )? _TImage::ImageDimension: 3; - for( unsigned 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 - - // Ok! - return( filter ); -} - -// ------------------------------------------------------------------------- -template< class _TFilter > -void fpaPlugins::BaseImageFilter:: -_ExecuteFilter( _TFilter* filter ) -{ - // Go!!! - this->_ConfigureDebugger( filter ); - filter->Update( ); - this->_DeconfigureDebugger( filter ); - - // Connect output - this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) ); -} - -// ------------------------------------------------------------------------- -template< class _TFilter > -void fpaPlugins::BaseImageFilter:: -_ConfigureDebugger( _TFilter* filter ) -{ - typedef typename _TFilter::TInputImage _TImage; - typedef fpa::VTK::Image::Observer2D< _TFilter, vtkRenderWindow > _2D; - typedef fpa::VTK::Image::Observer3D< _TFilter, vtkRenderWindow > _3D; - - this->m_Observers.clear( ); - if( this->m_Parameters.GetBool( "VisualDebug" ) ) - { - if( this->m_MPRViewer != NULL ) - { - if( _TImage::ImageDimension == 2 ) - { - auto iren = this->m_MPRViewer->GetInteractor( 2 ); - if( iren != NULL ) - { - typename _2D::Pointer debugger = _2D::New( ); - debugger->SetRenderWindow( iren->GetRenderWindow( ) ); - debugger->SetRenderPercentage( 0.01 ); - this->m_Observers.insert( - filter->AddObserver( itk::AnyEvent( ), debugger ) - ); - filter->ThrowEventsOn( ); - - } // fi - } - else if( _TImage::ImageDimension == 3 ) - { - auto iren = this->m_MPRViewer->GetInteractor( 3 ); - if( iren != NULL ) - { - typename _3D::Pointer debugger = _3D::New( ); - debugger->SetRenderWindow( iren->GetRenderWindow( ) ); - debugger->SetRenderPercentage( 0.001 ); - this->m_Observers.insert( - filter->AddObserver( itk::AnyEvent( ), debugger ) - ); - filter->ThrowEventsOn( ); - - } // fi - - } // fi - - } // fi - - if( this->m_SingleInteractor != NULL ) - { - if( _TImage::ImageDimension == 2 ) - { - } - else if( _TImage::ImageDimension == 3 ) - { - } // fi - - } // fi - - } // fi -} - -// ------------------------------------------------------------------------- -template< class F > -void fpaPlugins::BaseImageFilter:: -_DeconfigureDebugger( F* filter ) -{ - if( filter != NULL ) - { - auto oIt = this->m_Observers.begin( ); - for( ; oIt != this->m_Observers.end( ); ++oIt ) - filter->RemoveObserver( *oIt ); - - } // fi - this->m_Observers.clear( ); -} - -#endif // __FPAPLUGINS__BASEIMAGEFILTER__HXX__ - -// eof - $RCSfile$ diff --git a/plugins/fpa/CMakeLists.txt b/plugins/fpa/CMakeLists.txt deleted file mode 100644 index 84f58c3..0000000 --- a/plugins/fpa/CMakeLists.txt +++ /dev/null @@ -1,59 +0,0 @@ -SET(lib_NAME fpaPlugins) -SET( - lib_HEADERS - ${CMAKE_CURRENT_SOURCE_DIR}/GradientBaseImageFunctionSource.h - ${CMAKE_CURRENT_SOURCE_DIR}/ImageRegionGrow.h - ${CMAKE_CURRENT_SOURCE_DIR}/ImageDijkstra.h - ${CMAKE_CURRENT_SOURCE_DIR}/MinimumSpanningTreeReader.h - ${CMAKE_CURRENT_SOURCE_DIR}/MinimumSpanningTreeWriter.h - ${CMAKE_CURRENT_SOURCE_DIR}/RegionGrowThresholdFunction.h - ${CMAKE_CURRENT_SOURCE_DIR}/InvertCostFunction.h - ${CMAKE_CURRENT_SOURCE_DIR}/ExtractPathFromMinimumSpanningTree.h - ${CMAKE_CURRENT_SOURCE_DIR}/ExtractEndPointsAndBifurcationsFromMinimumSpanningTree.h - ) -SET( - lib_SOURCES - ${CMAKE_CURRENT_SOURCE_DIR}/GradientBaseImageFunctionSource.cxx - ${CMAKE_CURRENT_SOURCE_DIR}/ImageRegionGrow.cxx - ${CMAKE_CURRENT_SOURCE_DIR}/ImageDijkstra.cxx - ${CMAKE_CURRENT_SOURCE_DIR}/MinimumSpanningTreeReader.cxx - ${CMAKE_CURRENT_SOURCE_DIR}/MinimumSpanningTreeWriter.cxx - ${CMAKE_CURRENT_SOURCE_DIR}/RegionGrowThresholdFunction.cxx - ${CMAKE_CURRENT_SOURCE_DIR}/InvertCostFunction.cxx - ${CMAKE_CURRENT_SOURCE_DIR}/ExtractPathFromMinimumSpanningTree.cxx - ${CMAKE_CURRENT_SOURCE_DIR}/ExtractEndPointsAndBifurcationsFromMinimumSpanningTree.cxx - ) -SET( - lib_OTHER_SOURCES - ${CMAKE_CURRENT_SOURCE_DIR}/BaseImageFilter.h - ${CMAKE_CURRENT_SOURCE_DIR}/BaseImageFilter.hxx - ${CMAKE_CURRENT_SOURCE_DIR}/BaseImageFilter.cxx - ${CMAKE_CURRENT_SOURCE_DIR}/MinimumSpanningTree.h - ${CMAKE_CURRENT_SOURCE_DIR}/MinimumSpanningTree.cxx - ${CMAKE_CURRENT_SOURCE_DIR}/ImageSkeleton.h - ${CMAKE_CURRENT_SOURCE_DIR}/ImageSkeleton.cxx - ) -SET(lib_QT4_HEADERS "") - -cpPlugins_WrapPlugins( - ${lib_NAME} ${prj_VER} ${prj_sVER} - "${lib_HEADERS}" - "${lib_SOURCES}" - "${lib_OTHER_SOURCES}" - "${lib_QT4_HEADERS}" - ${cpExtensions_LIBRARY} - ${fpa_LIBRARIES} - ) - -## ======================== -## -- Installation rules -- -## ======================== - -#INSTALL( -# TARGETS ${lib_NAME} -# RUNTIME DESTINATION bin -# LIBRARY DESTINATION lib -# ARCHIVE DESTINATION lib/static -# ) - -## eof - $RCSfile$ diff --git a/plugins/fpa/ExtractEndPointsAndBifurcationsFromMinimumSpanningTree.cxx b/plugins/fpa/ExtractEndPointsAndBifurcationsFromMinimumSpanningTree.cxx deleted file mode 100644 index ea2c37a..0000000 --- a/plugins/fpa/ExtractEndPointsAndBifurcationsFromMinimumSpanningTree.cxx +++ /dev/null @@ -1,73 +0,0 @@ -#include "ExtractEndPointsAndBifurcationsFromMinimumSpanningTree.h" - -#include -#include -#include -#include - -// ------------------------------------------------------------------------- -fpaPlugins::ExtractEndPointsAndBifurcationsFromMinimumSpanningTree:: -ExtractEndPointsAndBifurcationsFromMinimumSpanningTree( ) - : Superclass( ) -{ - this->_AddInput( "CostsImage" ); - this->_AddInput( "DistanceMap" ); - this->_AddInput( "MST" ); - this->_AddOutput< cpPlugins::ImageIndexesContainer >( "EndPoints" ); - this->_AddOutput< cpPlugins::ImageIndexesContainer >( "Bifurcations" ); - this->_AddOutput< cpPlugins::ImageIndexesContainer >( "Collisions" ); - this->_AddOutput< fpaPlugins::ImageSkeleton >( "Skeleton" ); - - this->m_Parameters.ConfigureAsBool( "SquaredDistanceMap" ); - this->m_Parameters.SetBool( "SquaredDistanceMap", false ); -} - -// ------------------------------------------------------------------------- -fpaPlugins::ExtractEndPointsAndBifurcationsFromMinimumSpanningTree:: -~ExtractEndPointsAndBifurcationsFromMinimumSpanningTree( ) -{ -} - -// ------------------------------------------------------------------------- -void fpaPlugins::ExtractEndPointsAndBifurcationsFromMinimumSpanningTree:: -_GenerateData( ) -{ - auto image = this->GetInputData< itk::DataObject >( "CostsImage" ); - cpPlugins_Image_Demangle_Pixel_AllFloats ( _GD0, image, 2 ); - else cpPlugins_Image_Demangle_Pixel_AllFloats( _GD0, image, 3 ); - else this->_Error( "Invalid input costs." ); -} - -// ------------------------------------------------------------------------- -template< class _TImage > -void fpaPlugins::ExtractEndPointsAndBifurcationsFromMinimumSpanningTree:: -_GD0( _TImage* image ) -{ - typedef fpa::Image::MinimumSpanningTree< _TImage::ImageDimension > _TMST; - typedef fpa::Image::ExtractEndPointsAndBifurcationsFromMinimumSpanningTree< _TImage, _TMST > _TFilter; - - // Check input objects' integrity - auto dmap = this->GetInputData< _TImage >( "DistanceMap" ); - if( dmap == NULL ) - this->_Error( "Distance map does not have the same type as the costs image." ); - auto mst = this->GetInputData< _TMST >( "MST" ); - if( mst == NULL ) - this->_Error( "No valid input tree." ); - - // Create filter and connect inputs - _TFilter* filter = this->_CreateITK< _TFilter >( ); - filter->SetCostsImage( image ); - filter->SetDistanceMap( dmap ); - filter->SetMinimumSpanningTree( mst ); - filter->SetSquaredDistanceMap( - this->m_Parameters.GetBool( "SquaredDistanceMap" ) - ); - filter->Update( ); - - this->GetOutput( "EndPoints" )->SetITK( filter->GetEndPoints( ) ); - this->GetOutput( "Bifurcations" )->SetITK( filter->GetBifurcations( ) ); - this->GetOutput( "Collisions" )->SetITK( filter->GetCollisions( ) ); - this->GetOutput( "Skeleton" )->SetITK( filter->GetSkeleton( ) ); -} - -// eof - $RCSfile$ diff --git a/plugins/fpa/ExtractEndPointsAndBifurcationsFromMinimumSpanningTree.h b/plugins/fpa/ExtractEndPointsAndBifurcationsFromMinimumSpanningTree.h deleted file mode 100644 index 27b0efc..0000000 --- a/plugins/fpa/ExtractEndPointsAndBifurcationsFromMinimumSpanningTree.h +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef __FPAPLUGINS__EXTRACTENDPOINTSANDBIFURCATIONSFROMMINIMUMSPANNINGTREE__H__ -#define __FPAPLUGINS__EXTRACTENDPOINTSANDBIFURCATIONSFROMMINIMUMSPANNINGTREE__H__ - -#include -#include - -namespace fpaPlugins -{ - /** - */ - class fpaPlugins_EXPORT ExtractEndPointsAndBifurcationsFromMinimumSpanningTree - : public cpPlugins::ProcessObject - { - public: - typedef ExtractEndPointsAndBifurcationsFromMinimumSpanningTree Self; - typedef cpPlugins::ProcessObject Superclass; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; - - public: - itkNewMacro( Self ); - itkTypeMacro( - ExtractEndPointsAndBifurcationsFromMinimumSpanningTree, - cpPlugins::ProcessObject - ); - cpPlugins_Id_Macro( - ExtractEndPointsAndBifurcationsFromMinimumSpanningTree, - fpaImageAlgorithm - ); - - protected: - ExtractEndPointsAndBifurcationsFromMinimumSpanningTree( ); - virtual ~ExtractEndPointsAndBifurcationsFromMinimumSpanningTree( ); - - virtual void _GenerateData( ) ITK_OVERRIDE; - - template< class _TImage > - inline void _GD0( _TImage* image ); - - private: - // Purposely not implemented. - ExtractEndPointsAndBifurcationsFromMinimumSpanningTree( const Self& other ); - Self& operator=( const Self& other ); - }; - -} // ecapseman - -#endif // __FPAPLUGINS__EXTRACTENDPOINTSANDBIFURCATIONSFROMMINIMUMSPANNINGTREE__H__ - -// eof - $RCSfile$ diff --git a/plugins/fpa/ExtractPathFromMinimumSpanningTree.cxx b/plugins/fpa/ExtractPathFromMinimumSpanningTree.cxx deleted file mode 100644 index 0f717ab..0000000 --- a/plugins/fpa/ExtractPathFromMinimumSpanningTree.cxx +++ /dev/null @@ -1,81 +0,0 @@ -#include "ExtractPathFromMinimumSpanningTree.h" -#include -#include -#include - -// ------------------------------------------------------------------------- -fpaPlugins::ExtractPathFromMinimumSpanningTree:: -ExtractPathFromMinimumSpanningTree( ) - : Superclass( ) -{ - this->_AddInput( "MST" ); - this->_AddInput( "Seeds" ); - this->_AddOutput< cpPlugins::Path >( "Output" ); - - this->m_Parameters.ConfigureAsUint( "Vertex0" ); - this->m_Parameters.ConfigureAsUint( "Vertex1" ); - this->m_Parameters.SetUint( "Vertex0", 0 ); - this->m_Parameters.SetUint( "Vertex1", 1 ); -} - -// ------------------------------------------------------------------------- -fpaPlugins::ExtractPathFromMinimumSpanningTree:: -~ExtractPathFromMinimumSpanningTree( ) -{ -} - -// ------------------------------------------------------------------------- -void fpaPlugins::ExtractPathFromMinimumSpanningTree:: -_GenerateData( ) -{ - typedef fpa::Image::MinimumSpanningTree< 2 > _2DMST; - typedef fpa::Image::MinimumSpanningTree< 3 > _3DMST; - - auto mst = this->GetInputData< itk::DataObject >( "MST" ); - auto mst2 = dynamic_cast< _2DMST* >( mst ); - auto mst3 = dynamic_cast< _3DMST* >( mst ); - if ( mst2 != NULL ) this->_GD0( mst2 ); - else if( mst3 != NULL ) this->_GD0( mst3 ); - else this->_Error( "Invalid input MST." ); -} - -// ------------------------------------------------------------------------- -template< class _TMST > -void fpaPlugins::ExtractPathFromMinimumSpanningTree:: -_GD0( _TMST* mst ) -{ - typedef fpa::Base::ExtractPathFromMinimumSpanningTree< _TMST > _TFilter; - auto vertices = this->GetInputData< vtkPoints >( "Seeds" ); - if( vertices == NULL ) - this->_Error( "No valid vertices." ); - if( vertices->GetNumberOfPoints( ) < 2 ) - this->_Error( "Not enough vertices." ); - - double b0[ 3 ], b1[ 3 ]; - vertices->GetPoint( this->m_Parameters.GetUint( "Vertex0" ), b0 ); - vertices->GetPoint( this->m_Parameters.GetUint( "Vertex1" ), b1 ); - - typename _TMST::PointType p0, p1; - unsigned int dim = ( _TMST::ImageDimension < 3 )? _TMST::ImageDimension: 3; - for( unsigned int d = 0; d < dim; ++d ) - { - p0[ d ] = b0[ d ]; - p1[ d ] = b1[ d ]; - - } // rof - typename _TMST::TVertex v0, v1; - mst->TransformPhysicalPointToIndex( p0, v0 ); - mst->TransformPhysicalPointToIndex( p1, v1 ); - - // Create filter and connect input - _TFilter* filter = this->_CreateITK< _TFilter >( ); - filter->SetInput( mst ); - filter->SetVertex0( v0 ); - filter->SetVertex1( v1 ); - filter->Update( ); - - // Connect output and finish - this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) ); -} - -// eof - $RCSfile$ diff --git a/plugins/fpa/ExtractPathFromMinimumSpanningTree.h b/plugins/fpa/ExtractPathFromMinimumSpanningTree.h deleted file mode 100644 index fd445bd..0000000 --- a/plugins/fpa/ExtractPathFromMinimumSpanningTree.h +++ /dev/null @@ -1,48 +0,0 @@ -#ifndef __FPAPLUGINS__EXTRACTPATHFROMMINIMUMSPANNINGTREE__H__ -#define __FPAPLUGINS__EXTRACTPATHFROMMINIMUMSPANNINGTREE__H__ - -#include -#include - -namespace fpaPlugins -{ - /** - */ - class fpaPlugins_EXPORT ExtractPathFromMinimumSpanningTree - : public cpPlugins::ProcessObject - { - public: - typedef ExtractPathFromMinimumSpanningTree Self; - typedef cpPlugins::ProcessObject Superclass; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; - - public: - itkNewMacro( Self ); - itkTypeMacro( - ExtractPathFromMinimumSpanningTree, cpPlugins::ProcessObject - ); - cpPlugins_Id_Macro( - ExtractPathFromMinimumSpanningTree, fpaBaseAlgorithm - ); - - protected: - ExtractPathFromMinimumSpanningTree( ); - virtual ~ExtractPathFromMinimumSpanningTree( ); - - virtual void _GenerateData( ) ITK_OVERRIDE; - - template< class _TMST > - inline void _GD0( _TMST* mst ); - - private: - // Purposely not implemented. - ExtractPathFromMinimumSpanningTree( const Self& other ); - Self& operator=( const Self& other ); - }; - -} // ecapseman - -#endif // __FPAPLUGINS__EXTRACTPATHFROMMINIMUMSPANNINGTREE__H__ - -// eof - $RCSfile$ diff --git a/plugins/fpa/GradientBaseImageFunctionSource.cxx b/plugins/fpa/GradientBaseImageFunctionSource.cxx deleted file mode 100644 index 85a79ce..0000000 --- a/plugins/fpa/GradientBaseImageFunctionSource.cxx +++ /dev/null @@ -1,93 +0,0 @@ -#include "GradientBaseImageFunctionSource.h" - -#include -#include - -// ------------------------------------------------------------------------- -fpaPlugins::GradientBaseImageFunctionSource:: -GradientBaseImageFunctionSource( ) - : Superclass( ) -{ - this->_AddInput( "Input" ); - this->_AddOutput< cpPlugins::Image >( "Output" ); - - std::vector< std::string > choices; - choices.push_back( "Gulsun&Tek" ); - choices.push_back( "Flux" ); - choices.push_back( "MFlux" ); - this->m_Parameters.ConfigureAsChoices( "FunctionType", choices ); - this->m_Parameters.SetSelectedChoice( "FunctionType", "Gulsun&Tek" ); - - 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 ); -} - -// ------------------------------------------------------------------------- -fpaPlugins::GradientBaseImageFunctionSource:: -~GradientBaseImageFunctionSource( ) -{ -} - -// ------------------------------------------------------------------------- -void fpaPlugins::GradientBaseImageFunctionSource:: -_GenerateData( ) -{ - auto image = this->GetInputData< itk::DataObject >( "Input" ); - cpPlugins_Image_Demangle_VectorPixel_AllFloats ( _GD0, image, CovariantVector, 2 ); - else cpPlugins_Image_Demangle_VectorPixel_AllFloats( _GD0, image, CovariantVector, 3 ); - else this->_Error( "Invalid input image." ); -} - -// ------------------------------------------------------------------------- -template< class _TImage > -void fpaPlugins::GradientBaseImageFunctionSource:: -_GD0( _TImage* image ) -{ - typedef fpa::Image::Functors::GulsunTekMedialness< _TImage > _TGT; - typedef fpa::Image::Functors::FluxMedialness< _TImage > _TFl; - typedef fpa::Image::Functors::MFluxMedialness< _TImage > _TMFl; - - auto ft = this->m_Parameters.GetSelectedChoice( "FunctionType" ); - if ( ft == "Gulsun&Tek" ) this->_GD1< _TImage, _TGT >( image ); - else if( ft == "Flux" ) this->_GD1< _TImage, _TFl >( image ); - else if( ft == "MFlux" ) this->_GD1< _TImage, _TMFl >( image ); - else this->_Error( "Invalid function type." ); -} - -// ------------------------------------------------------------------------- -template< class _TImage, class _TFunction > -void fpaPlugins::GradientBaseImageFunctionSource:: -_GD1( _TImage* image ) -{ - typedef itk::Image< typename _TFunction::TOutput, _TImage::ImageDimension > _TOutImage; - typedef cpExtensions::Algorithms::ImageFunctionFilter< _TImage, _TOutImage, _TFunction > _TFilter; - - _TFilter* filter = this->_CreateITK< _TFilter >( ); - filter->SetInput( image ); - _TFunction* 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->Update( ); - - // Connect output and finish - this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) ); -} - -// eof - $RCSfile$ diff --git a/plugins/fpa/GradientBaseImageFunctionSource.h b/plugins/fpa/GradientBaseImageFunctionSource.h deleted file mode 100644 index feae730..0000000 --- a/plugins/fpa/GradientBaseImageFunctionSource.h +++ /dev/null @@ -1,51 +0,0 @@ -#ifndef __FPAPLUGINS__GRADIENTBASEIMAGEFUNCTIONSOURCE__H__ -#define __FPAPLUGINS__GRADIENTBASEIMAGEFUNCTIONSOURCE__H__ - -#include -#include - -namespace fpaPlugins -{ - /** - */ - class fpaPlugins_EXPORT GradientBaseImageFunctionSource - : public cpPlugins::ProcessObject - { - public: - typedef GradientBaseImageFunctionSource Self; - typedef cpPlugins::ProcessObject Superclass; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; - - public: - itkNewMacro( Self ); - itkTypeMacro( - GradientBaseImageFunctionSource, cpPlugins::ProcessObject - ); - cpPlugins_Id_Macro( - GradientBaseImageFunctionSource, fpaImageAlgorithmFunctors - ); - - protected: - GradientBaseImageFunctionSource( ); - virtual ~GradientBaseImageFunctionSource( ); - - virtual void _GenerateData( ) ITK_OVERRIDE; - - template< class _TImage > - inline void _GD0( _TImage* image ); - - template< class _TImage, class _TFunction > - inline void _GD1( _TImage* image ); - - private: - // Purposely not implemented. - GradientBaseImageFunctionSource( const Self& other ); - Self& operator=( const Self& other ); - }; - -} // ecapseman - -#endif // __FPAPLUGINS__GRADIENTBASEIMAGEFUNCTIONSOURCE__H__ - -// eof - $RCSfile$ diff --git a/plugins/fpa/ImageDijkstra.cxx b/plugins/fpa/ImageDijkstra.cxx deleted file mode 100644 index ef86917..0000000 --- a/plugins/fpa/ImageDijkstra.cxx +++ /dev/null @@ -1,69 +0,0 @@ -#include "ImageDijkstra.h" -#include "MinimumSpanningTree.h" - -#include -#include - -// ------------------------------------------------------------------------- -fpaPlugins::ImageDijkstra:: -ImageDijkstra( ) - : Superclass( ) -{ - this->_AddInput( "CostFunctor", false ); - this->_AddOutput< fpaPlugins::MinimumSpanningTree >( "MST" ); - this->m_Parameters.ConfigureAsBool( "FillNodeQueue" ); - this->m_Parameters.SetBool( "FillNodeQueue", false ); -} - -// ------------------------------------------------------------------------- -fpaPlugins::ImageDijkstra:: -~ImageDijkstra( ) -{ -} - -// ------------------------------------------------------------------------- -void fpaPlugins::ImageDijkstra:: -_GenerateData( ) -{ - auto image = this->GetInputData< itk::DataObject >( "Input" ); - cpPlugins_Image_Demangle_Pixel_AllScalars ( _GD0, image, 2 ); - else cpPlugins_Image_Demangle_Pixel_AllScalars( _GD0, image, 3 ); - else this->_Error( "No valid input image." ); -} - -// ------------------------------------------------------------------------- -template< class _TImage > -void fpaPlugins::ImageDijkstra:: -_GD0( _TImage* image ) -{ - typedef float _TPixel; - typedef itk::Image< _TPixel, _TImage::ImageDimension > _TOutImage; - typedef fpa::Image::Dijkstra< _TImage, _TOutImage > _TFilter; - typedef typename _TFilter::TResult _TCost; - typedef itk::FunctionBase< _TCost, _TCost > _TCostFunctor; - typedef typename _TFilter::TMinimumSpanningTree _TMST; - - auto base_functor = - this->GetInputData< itk::LightObject >( "CostFunctor" ); - _TCostFunctor* functor = NULL; - if( base_functor != NULL ) - { - functor = dynamic_cast< _TCostFunctor* >( base_functor ); - if( functor == NULL ) - this->_Error( "Given cost functor is invalid." ); - - } // fi - - // Create filter - _TFilter* filter = this->_ConfigureFilter< _TFilter >( ); - filter->SetFillNodeQueue( this->m_Parameters.GetBool( "FillNodeQueue" ) ); - filter->SetConversionFunction( functor ); - - // Go!!! - this->_ExecuteFilter( filter ); - - // Connect remaining output - this->GetOutput( "MST" )->SetITK( filter->GetMinimumSpanningTree( ) ); -} - -// eof - $RCSfile$ diff --git a/plugins/fpa/ImageDijkstra.h b/plugins/fpa/ImageDijkstra.h deleted file mode 100644 index e4cb3de..0000000 --- a/plugins/fpa/ImageDijkstra.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef __FPAPLUGINS__IMAGEDIJKSTRA__H__ -#define __FPAPLUGINS__IMAGEDIJKSTRA__H__ - -#include "BaseImageFilter.h" - -namespace fpaPlugins -{ - /** - */ - class fpaPlugins_EXPORT ImageDijkstra - : public BaseImageFilter - { - public: - typedef ImageDijkstra Self; - typedef BaseImageFilter Superclass; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; - - public: - itkNewMacro( Self ); - itkTypeMacro( ImageDijkstra, BaseImageFilter ); - cpPlugins_Id_Macro( ImageDijkstra, fpaImageAlgorithm ); - - protected: - ImageDijkstra( ); - virtual ~ImageDijkstra( ); - - virtual void _GenerateData( ) ITK_OVERRIDE; - - template< class _TImage > - inline void _GD0( _TImage* image ); - - private: - // Purposely not implemented. - ImageDijkstra( const Self& other ); - Self& operator=( const Self& other ); - }; - -} // ecapseman - -#endif // __FPAPLUGINS__IMAGEDIJKSTRA__H__ - -// eof - $RCSfile$ diff --git a/plugins/fpa/ImageRegionGrow.cxx b/plugins/fpa/ImageRegionGrow.cxx deleted file mode 100644 index 333c708..0000000 --- a/plugins/fpa/ImageRegionGrow.cxx +++ /dev/null @@ -1,65 +0,0 @@ -#include "ImageRegionGrow.h" - -#include -#include - -// ------------------------------------------------------------------------- -fpaPlugins::ImageRegionGrow:: -ImageRegionGrow( ) - : Superclass( ) -{ - this->_AddInput( "GrowFunctor", false ); - this->m_Parameters.ConfigureAsUint( "InsideValue" ); - this->m_Parameters.ConfigureAsUint( "OutsideValue" ); - this->m_Parameters.SetUint( "InsideValue", 1 ); - this->m_Parameters.SetUint( "OutsideValue", 0 ); -} - -// ------------------------------------------------------------------------- -fpaPlugins::ImageRegionGrow:: -~ImageRegionGrow( ) -{ -} - -// ------------------------------------------------------------------------- -void fpaPlugins::ImageRegionGrow:: -_GenerateData( ) -{ - auto image = this->GetInputData< itk::DataObject >( "Input" ); - cpPlugins_Image_Demangle_Pixel_AllScalars ( _GD0, image, 2 ); - else cpPlugins_Image_Demangle_Pixel_AllScalars( _GD0, image, 3 ); - else this->_Error( "No valid input image." ); -} - -// ------------------------------------------------------------------------- -template< class _TImage > -void fpaPlugins::ImageRegionGrow:: -_GD0( _TImage* image ) -{ - typedef unsigned short _TPixel; - typedef itk::Image< _TPixel, _TImage::ImageDimension > _TOutImage; - typedef fpa::Image::RegionGrow< _TImage, _TOutImage > _TFilter; - typedef typename _TFilter::TGrowingFunction _TGrowFunctor; - typedef typename _TFilter::TResult _TResult; - - // Create filter - _TFilter* filter = this->_ConfigureFilter< _TFilter >( ); - - typename _TGrowFunctor::Pointer functor; - auto wrap_functor = this->GetInput( "GrowFunctor" ); - if( wrap_functor != NULL ) - functor = wrap_functor->GetITK< _TGrowFunctor >( ); - if( functor.IsNull( ) ) - filter->SetGrowingFunction( functor ); - filter->SetInsideValue( - _TResult( this->m_Parameters.GetUint( "InsideValue" ) ) - ); - filter->SetOutsideValue( - _TResult( this->m_Parameters.GetUint( "OutsideValue" ) ) - ); - - // Go!!! - this->_ExecuteFilter( filter ); -} - -// eof - $RCSfile$ diff --git a/plugins/fpa/ImageRegionGrow.h b/plugins/fpa/ImageRegionGrow.h deleted file mode 100644 index ce6a82e..0000000 --- a/plugins/fpa/ImageRegionGrow.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef __FPAPLUGINS__IMAGEREGIONGROW__H__ -#define __FPAPLUGINS__IMAGEREGIONGROW__H__ - -#include "BaseImageFilter.h" - -namespace fpaPlugins -{ - /** - */ - class fpaPlugins_EXPORT ImageRegionGrow - : public BaseImageFilter - { - public: - typedef ImageRegionGrow Self; - typedef BaseImageFilter Superclass; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; - - public: - itkNewMacro( Self ); - itkTypeMacro( ImageRegionGrow, BaseImageFilter ); - cpPlugins_Id_Macro( ImageRegionGrow, fpaImageAlgorithm ); - - protected: - ImageRegionGrow( ); - virtual ~ImageRegionGrow( ); - - virtual void _GenerateData( ) ITK_OVERRIDE; - - template< class _TImage > - inline void _GD0( _TImage* image ); - - private: - // Purposely not implemented. - ImageRegionGrow( const Self& other ); - Self& operator=( const Self& other ); - }; - -} // ecapseman - -#endif // __FPAPLUGINS__IMAGEREGIONGROW__H__ - -// eof - $RCSfile$ diff --git a/plugins/fpa/ImageSkeleton.cxx b/plugins/fpa/ImageSkeleton.cxx deleted file mode 100644 index f121d66..0000000 --- a/plugins/fpa/ImageSkeleton.cxx +++ /dev/null @@ -1,75 +0,0 @@ -#include -#include -#include - -// ------------------------------------------------------------------------- -void fpaPlugins::ImageSkeleton:: -SetITK( itk::LightObject* o ) -{ - typedef - fpa::Base::ImageSkeleton< fpa::Image::MinimumSpanningTree< 2 > > _I2; - typedef - fpa::Base::ImageSkeleton< fpa::Image::MinimumSpanningTree< 3 > > _I3; - - bool r = this->_SetITK< _I2 >( o ); - if( !r ) r = this->_SetITK< _I3 >( o ); - if( !r ) - this->Superclass::SetITK( NULL ); -} - -// ------------------------------------------------------------------------- -void fpaPlugins::ImageSkeleton:: -SetVTK( vtkObjectBase* o ) -{ - // Do nothing: this only has sense in ITK -} - -// ------------------------------------------------------------------------- -fpaPlugins::ImageSkeleton:: -ImageSkeleton( ) - : Superclass( ) -{ -} - -// ------------------------------------------------------------------------- -fpaPlugins::ImageSkeleton:: -~ImageSkeleton( ) -{ -} - -// ------------------------------------------------------------------------- -template< class _TMST > -bool fpaPlugins::ImageSkeleton:: -_SetITK( itk::LightObject* o ) -{ - typedef fpa::VTK::Image::ImageSkeletonToPolyData< _TMST > _TFilter; - - _TMST* mst = dynamic_cast< _TMST* >( o ); - if( mst != NULL ) - { - _TFilter* f = dynamic_cast< _TFilter* >( this->m_ITKvVTK.GetPointer( ) ); - if( f == NULL ) - { - vtkSmartPointer< _TFilter > nf = _TFilter::New( ); - this->m_ITKvVTK = nf.GetPointer( ); - f = nf.GetPointer( ); - - } // fi - f->SetInput( mst ); - f->Update( ); - - // Keep object track - this->m_ITKObject = o; - this->m_VTKObject = f->GetOutput( ); - return( true ); - } - else - { - this->Superclass::SetITK( NULL ); - this->Superclass::SetVTK( NULL ); - return( false ); - - } // fi -} - -// eof - $RCSfile$ diff --git a/plugins/fpa/ImageSkeleton.h b/plugins/fpa/ImageSkeleton.h deleted file mode 100644 index e8a1345..0000000 --- a/plugins/fpa/ImageSkeleton.h +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef __FPAPLUGINS__IMAGESKELETON__H__ -#define __FPAPLUGINS__IMAGESKELETON__H__ - -#include -#include -#include -#include - -// ------------------------------------------------------------------------- -namespace fpaPlugins -{ - /** - */ - class fpaPlugins_EXPORT ImageSkeleton - : public cpPlugins::DataObject - { - public: - typedef ImageSkeleton Self; - typedef cpPlugins::DataObject Superclass; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; - - public: - itkNewMacro( Self ); - itkTypeMacro( ImageSkeleton, cpPlugins::DataObject ); - cpPlugins_Id_Macro( ImageSkeleton, ImageSkeleton ); - - public: - virtual void SetITK( itk::LightObject* o ) override; - virtual void SetVTK( vtkObjectBase* o ) override; - - protected: - ImageSkeleton( ); - virtual ~ImageSkeleton( ); - - template< class _TMST > - inline bool _SetITK( itk::LightObject* o ); - - private: - // Purposely not implemented - ImageSkeleton( const Self& ); - Self& operator=( const Self& ); - - protected: - vtkSmartPointer< vtkPolyDataAlgorithm > m_ITKvVTK; - }; - -} // ecapseman - -#endif // __FPAPLUGINS__IMAGESKELETON__H__ - -// eof - $RCSfile$ diff --git a/plugins/fpa/InvertCostFunction.cxx b/plugins/fpa/InvertCostFunction.cxx deleted file mode 100644 index 3664bfa..0000000 --- a/plugins/fpa/InvertCostFunction.cxx +++ /dev/null @@ -1,61 +0,0 @@ -#include "InvertCostFunction.h" - -#include -#include - -// ------------------------------------------------------------------------- -fpaPlugins::InvertCostFunction:: -InvertCostFunction( ) - : Superclass( ) -{ - this->_AddOutput< cpPlugins::DataObject >( "Output" ); - - this->m_Parameters.ConfigureAsReal( "Alpha" ); - this->m_Parameters.ConfigureAsReal( "Beta" ); - - std::vector< std::string > choices; - choices.push_back( "float" ); - choices.push_back( "double" ); - this->m_Parameters.ConfigureAsChoices( "ScalarType", choices ); - - this->m_Parameters.SetReal( "Alpha", 1 ); - this->m_Parameters.SetReal( "Beta", 1 ); - this->m_Parameters.SetSelectedChoice( "ScalarType", "float" ); -} - -// ------------------------------------------------------------------------- -fpaPlugins::InvertCostFunction:: -~InvertCostFunction( ) -{ -} - -// ------------------------------------------------------------------------- -void fpaPlugins::InvertCostFunction:: -_GenerateData( ) -{ - auto choice = this->m_Parameters.GetSelectedChoice( "ScalarType" ); - if ( choice == "float" ) this->_GD0< float >( ); - else if( choice == "double" ) this->_GD0< double >( ); - else this->_Error( "Invalid scalar type." ); -} - -// ------------------------------------------------------------------------- -template< class _TScalar > -void fpaPlugins::InvertCostFunction:: -_GD0( ) -{ - typedef fpa::Base::Functors::InvertCostFunction< _TScalar > _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->SetAlpha( this->m_Parameters.GetReal( "Alpha" ) ); - f->SetBeta( this->m_Parameters.GetReal( "Beta" ) ); -} - -// eof - $RCSfile$ diff --git a/plugins/fpa/InvertCostFunction.h b/plugins/fpa/InvertCostFunction.h deleted file mode 100644 index c623914..0000000 --- a/plugins/fpa/InvertCostFunction.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef __FPAPLUGINS__INVERTCOSTFUNCTION__H__ -#define __FPAPLUGINS__INVERTCOSTFUNCTION__H__ - -#include -#include - -namespace fpaPlugins -{ - /** - */ - class fpaPlugins_EXPORT InvertCostFunction - : public cpPlugins::ProcessObject - { - public: - typedef InvertCostFunction Self; - typedef cpPlugins::ProcessObject Superclass; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; - - public: - itkNewMacro( Self ); - itkTypeMacro( InvertCostFunction, cpPlugins::ProcessObject ); - cpPlugins_Id_Macro( InvertCostFunction, fpaImageAlgorithmFunctors ); - - protected: - InvertCostFunction( ); - virtual ~InvertCostFunction( ); - - virtual void _GenerateData( ) ITK_OVERRIDE; - - template< class _TScalar > - inline void _GD0( ); - - private: - // Purposely not implemented. - InvertCostFunction( const Self& other ); - Self& operator=( const Self& other ); - }; - -} // ecapseman - -#endif // __FPAPLUGINS__INVERTCOSTFUNCTION__H__ - -// eof - $RCSfile$ diff --git a/plugins/fpa/MinimumSpanningTree.cxx b/plugins/fpa/MinimumSpanningTree.cxx deleted file mode 100644 index 53bcdaf..0000000 --- a/plugins/fpa/MinimumSpanningTree.cxx +++ /dev/null @@ -1,57 +0,0 @@ -#include -#include - -// ------------------------------------------------------------------------- -void fpaPlugins::MinimumSpanningTree:: -SetITK( itk::LightObject* o ) -{ - typedef fpa::Image::MinimumSpanningTree< 2 > _I2; - typedef fpa::Image::MinimumSpanningTree< 3 > _I3; - - bool r = this->_SetITK< _I2 >( o ); - if( !r ) r = this->_SetITK< _I3 >( o ); - if( !r ) - this->Superclass::SetITK( NULL ); -} - -// ------------------------------------------------------------------------- -void fpaPlugins::MinimumSpanningTree:: -SetVTK( vtkObjectBase* o ) -{ - // Do nothing: this only has sense in ITK -} - -// ------------------------------------------------------------------------- -fpaPlugins::MinimumSpanningTree:: -MinimumSpanningTree( ) - : Superclass( ) -{ -} - -// ------------------------------------------------------------------------- -fpaPlugins::MinimumSpanningTree:: -~MinimumSpanningTree( ) -{ -} - -// ------------------------------------------------------------------------- -template< class _TMST > -bool fpaPlugins::MinimumSpanningTree:: -_SetITK( itk::LightObject* o ) -{ - _TMST* mst = dynamic_cast< _TMST* >( o ); - if( mst != NULL ) - { - this->Superclass::SetITK( o ); - return( true ); - } - else - { - this->Superclass::SetITK( NULL ); - this->Superclass::SetVTK( NULL ); - return( false ); - - } // fi -} - -// eof - $RCSfile$ diff --git a/plugins/fpa/MinimumSpanningTree.h b/plugins/fpa/MinimumSpanningTree.h deleted file mode 100644 index e391ae6..0000000 --- a/plugins/fpa/MinimumSpanningTree.h +++ /dev/null @@ -1,47 +0,0 @@ -#ifndef __FPAPLUGINS__MINIMUMSPANNINGTREE__H__ -#define __FPAPLUGINS__MINIMUMSPANNINGTREE__H__ - -#include -#include - -// ------------------------------------------------------------------------- -namespace fpaPlugins -{ - /** - */ - class fpaPlugins_EXPORT MinimumSpanningTree - : public cpPlugins::DataObject - { - public: - typedef MinimumSpanningTree Self; - typedef cpPlugins::DataObject Superclass; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; - - public: - itkNewMacro( Self ); - itkTypeMacro( MinimumSpanningTree, cpPlugins::DataObject ); - cpPlugins_Id_Macro( MinimumSpanningTree, MinimumSpanningTree ); - - public: - virtual void SetITK( itk::LightObject* o ) override; - virtual void SetVTK( vtkObjectBase* o ) override; - - protected: - MinimumSpanningTree( ); - virtual ~MinimumSpanningTree( ); - - template< class _TMST > - inline bool _SetITK( itk::LightObject* o ); - - private: - // Purposely not implemented - MinimumSpanningTree( const Self& ); - Self& operator=( const Self& ); - }; - -} // ecapseman - -#endif // __FPAPLUGINS__MINIMUMSPANNINGTREE__H__ - -// eof - $RCSfile$ diff --git a/plugins/fpa/MinimumSpanningTreeReader.cxx b/plugins/fpa/MinimumSpanningTreeReader.cxx deleted file mode 100644 index e0c4ffe..0000000 --- a/plugins/fpa/MinimumSpanningTreeReader.cxx +++ /dev/null @@ -1,70 +0,0 @@ -#include "MinimumSpanningTreeReader.h" -#include "MinimumSpanningTree.h" - -#include - -// ------------------------------------------------------------------------- -fpaPlugins::MinimumSpanningTreeReader:: -MinimumSpanningTreeReader( ) - : Superclass( ) -{ - this->_AddOutput< fpaPlugins::MinimumSpanningTree >( "Output" ); - this->m_Parameters.Clear( ); - this->m_Parameters.ConfigureAsOpenFileName( "FileName" ); - this->m_Parameters.SetAcceptedFileExtensions( - "FileName", - "Minimum spanning tree files (*.mst)" - ); -} - -// ------------------------------------------------------------------------- -fpaPlugins::MinimumSpanningTreeReader:: -~MinimumSpanningTreeReader( ) -{ -} - -// ------------------------------------------------------------------------- -void fpaPlugins::MinimumSpanningTreeReader:: -_GenerateData( ) -{ - // Infere MST dimensions - auto fname = this->m_Parameters.GetOpenFileName( "FileName" ); - std::ifstream input( fname.c_str( ) ); - if( !input ) - this->_Error( - std::string( "MinimumSpanningTreeReader: Error opening file \"" ) + - fname + - std::string( "\"" ) - ); - unsigned int dim; - input >> dim; - - // Real execution - if ( dim == 2 ) this->_GD0< 2 >( fname ); - else if( dim == 3 ) this->_GD0< 3 >( fname ); - else this->_Error( "Invalid dimensions." ); -} - -// ------------------------------------------------------------------------- -template< unsigned int _NDim > -void fpaPlugins::MinimumSpanningTreeReader:: -_GD0( const std::string& fname ) -{ - typedef fpa::Image::MinimumSpanningTree< _NDim > _TTree; - typedef fpa::IO::MinimumSpanningTreeReader< _TTree > _TFilter; - - _TFilter* reader = this->_CreateITK< _TFilter >( ); - reader->SetFileName( this->m_Parameters.GetOpenFileName( "FileName" ) ); - try - { - reader->Update( ); - } - catch( itk::ExceptionObject& err ) - { - this->_Error( err.GetDescription( ) ); - - } // yrt - this->GetOutput( "Output" )->SetITK( reader->GetOutput( ) ); -} - -// eof - $RCSfile$ diff --git a/plugins/fpa/MinimumSpanningTreeReader.h b/plugins/fpa/MinimumSpanningTreeReader.h deleted file mode 100644 index dce25da..0000000 --- a/plugins/fpa/MinimumSpanningTreeReader.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef __FPAPLUGINS__MINIMUMSPANNINGTREEREADER__H__ -#define __FPAPLUGINS__MINIMUMSPANNINGTREEREADER__H__ - -#include -#include - -namespace fpaPlugins -{ - /** - */ - class fpaPlugins_EXPORT MinimumSpanningTreeReader - : public cpPlugins::ProcessObject - { - public: - typedef MinimumSpanningTreeReader Self; - typedef cpPlugins::ProcessObject Superclass; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; - - public: - itkNewMacro( Self ); - itkTypeMacro( MinimumSpanningTreeReader, cpPlugins::ProcessObject ); - cpPlugins_Id_Macro( MinimumSpanningTreeReader, fpaIO ); - - protected: - MinimumSpanningTreeReader( ); - virtual ~MinimumSpanningTreeReader( ); - - virtual void _GenerateData( ) ITK_OVERRIDE; - - template< unsigned int _NDim > - inline void _GD0( const std::string& fname ); - - private: - // Purposely not implemented. - MinimumSpanningTreeReader( const Self& other ); - Self& operator=( const Self& other ); - }; - -} // ecapseman - -#endif // __FPAPLUGINS__MINIMUMSPANNINGTREEREADER__H__ - -// eof - $RCSfile$ diff --git a/plugins/fpa/MinimumSpanningTreeWriter.cxx b/plugins/fpa/MinimumSpanningTreeWriter.cxx deleted file mode 100644 index 9910908..0000000 --- a/plugins/fpa/MinimumSpanningTreeWriter.cxx +++ /dev/null @@ -1,62 +0,0 @@ -#include "MinimumSpanningTreeWriter.h" -#include "MinimumSpanningTree.h" - -#include - -// ------------------------------------------------------------------------- -fpaPlugins::MinimumSpanningTreeWriter:: -MinimumSpanningTreeWriter( ) - : Superclass( ) -{ - this->_AddInput( "Input" ); - this->m_Parameters.Clear( ); - this->m_Parameters.ConfigureAsSaveFileName( "FileName" ); - this->m_Parameters.SetAcceptedFileExtensions( - "FileName", - "Minimum spanning tree files (*.mst)" - ); -} - -// ------------------------------------------------------------------------- -fpaPlugins::MinimumSpanningTreeWriter:: -~MinimumSpanningTreeWriter( ) -{ -} - -// ------------------------------------------------------------------------- -void fpaPlugins::MinimumSpanningTreeWriter:: -_GenerateData( ) -{ - typedef fpa::Image::MinimumSpanningTree< 2 > _2D; - typedef fpa::Image::MinimumSpanningTree< 3 > _3D; - - auto _2d = this->GetInputData< _2D >( "Input" ); - auto _3d = this->GetInputData< _3D >( "Input" ); - - if ( _2d != NULL ) this->_GD0( _2d ); - else if( _3d != NULL ) this->_GD0( _3d ); - else this->_Error( "Not a valid MST." ); -} - -// ------------------------------------------------------------------------- -template< class _TTree > -void fpaPlugins::MinimumSpanningTreeWriter:: -_GD0( _TTree* tree ) -{ - typedef fpa::IO::MinimumSpanningTreeWriter< _TTree > _TFilter; - - _TFilter* writer = this->_CreateITK< _TFilter >( ); - writer->SetInput( tree ); - writer->SetFileName( this->m_Parameters.GetSaveFileName( "FileName" ) ); - try - { - writer->Update( ); - } - catch( itk::ExceptionObject& err ) - { - this->_Error( err.GetDescription( ) ); - - } // yrt -} - -// eof - $RCSfile$ diff --git a/plugins/fpa/MinimumSpanningTreeWriter.h b/plugins/fpa/MinimumSpanningTreeWriter.h deleted file mode 100644 index 6d2c02b..0000000 --- a/plugins/fpa/MinimumSpanningTreeWriter.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef __FPAPLUGINS__MINIMUMSPANNINGTREEWRITER__H__ -#define __FPAPLUGINS__MINIMUMSPANNINGTREEWRITER__H__ - -#include -#include - -namespace fpaPlugins -{ - /** - */ - class fpaPlugins_EXPORT MinimumSpanningTreeWriter - : public cpPlugins::ProcessObject - { - public: - typedef MinimumSpanningTreeWriter Self; - typedef cpPlugins::ProcessObject Superclass; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; - - public: - itkNewMacro( Self ); - itkTypeMacro( MinimumSpanningTreeWriter, cpPlugins::ProcessObject ); - cpPlugins_Id_Macro( MinimumSpanningTreeWriter, fpaIO ); - - protected: - MinimumSpanningTreeWriter( ); - virtual ~MinimumSpanningTreeWriter( ); - - virtual void _GenerateData( ) ITK_OVERRIDE; - - template< class _TTree > - inline void _GD0( _TTree* tree ); - - private: - // Purposely not implemented. - MinimumSpanningTreeWriter( const Self& other ); - Self& operator=( const Self& other ); - }; - -} // ecapseman - -#endif // __FPAPLUGINS__MINIMUMSPANNINGTREEWRITER__H__ - -// eof - $RCSfile$ diff --git a/plugins/fpa/RegionGrowThresholdFunction.cxx b/plugins/fpa/RegionGrowThresholdFunction.cxx deleted file mode 100644 index 4e8ca64..0000000 --- a/plugins/fpa/RegionGrowThresholdFunction.cxx +++ /dev/null @@ -1,59 +0,0 @@ -#include "RegionGrowThresholdFunction.h" - -#include -#include - -// ------------------------------------------------------------------------- -fpaPlugins::RegionGrowThresholdFunction:: -RegionGrowThresholdFunction( ) - : Superclass( ) -{ - this->_AddInput( "ReferenceImage" ); - this->_AddOutput< cpPlugins::DataObject >( "Output" ); - - this->m_Parameters.ConfigureAsReal( "LowerThreshold" ); - this->m_Parameters.ConfigureAsReal( "UpperThreshold" ); - - this->m_Parameters.SetReal( "LowerThreshold", 0 ); - this->m_Parameters.SetReal( "UpperThreshold", 1 ); -} - -// ------------------------------------------------------------------------- -fpaPlugins::RegionGrowThresholdFunction:: -~RegionGrowThresholdFunction( ) -{ -} - -// ------------------------------------------------------------------------- -void fpaPlugins::RegionGrowThresholdFunction:: -_GenerateData( ) -{ - auto image = this->GetInputData< itk::DataObject >( "ReferenceImage" ); - cpPlugins_Image_Demangle_Pixel_AllScalars ( _GD0, image, 2 ); - else cpPlugins_Image_Demangle_Pixel_AllScalars( _GD0, image, 3 ); - else this->_Error( "No valid input image." ); -} - -// ------------------------------------------------------------------------- -template< class _TImage > -void fpaPlugins::RegionGrowThresholdFunction:: -_GD0( _TImage* image ) -{ - typedef - fpa::Image::Functors::RegionGrowThresholdFunction< _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/fpa/RegionGrowThresholdFunction.h b/plugins/fpa/RegionGrowThresholdFunction.h deleted file mode 100644 index f2348c6..0000000 --- a/plugins/fpa/RegionGrowThresholdFunction.h +++ /dev/null @@ -1,46 +0,0 @@ -#ifndef __FPAPLUGINS__REGIONGROWTHRESHOLDFUNCTION__H__ -#define __FPAPLUGINS__REGIONGROWTHRESHOLDFUNCTION__H__ - -#include -#include - -namespace fpaPlugins -{ - /** - */ - class fpaPlugins_EXPORT RegionGrowThresholdFunction - : public cpPlugins::ProcessObject - { - public: - typedef RegionGrowThresholdFunction Self; - typedef cpPlugins::ProcessObject Superclass; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; - - public: - itkNewMacro( Self ); - itkTypeMacro( RegionGrowThresholdFunction, cpPlugins::ProcessObject ); - cpPlugins_Id_Macro( - RegionGrowThresholdFunction, fpaImageAlgorithmFunctors - ); - - protected: - RegionGrowThresholdFunction( ); - virtual ~RegionGrowThresholdFunction( ); - - virtual void _GenerateData( ) ITK_OVERRIDE; - - template< class _TImage > - inline void _GD0( _TImage* image ); - - private: - // Purposely not implemented. - RegionGrowThresholdFunction( const Self& other ); - Self& operator=( const Self& other ); - }; - -} // ecapseman - -#endif // __FPAPLUGINS__REGIONGROWTHRESHOLDFUNCTION__H__ - -// eof - $RCSfile$ -- 2.45.1