## ========================
SET(prj_NAME FrontAlgorithms)
-SET(prj_MAJOR_VERSION 0)
-SET(prj_MINOR_VERSION 1)
+SET(prj_MAJOR_VERSION 1)
+SET(prj_MINOR_VERSION 0)
SET(prj_RELEASE_VERSION 0)
-SET(_subdirs lib plugins examples)
+SET(_subdirs examples) # lib plugins)
SET(_policies CMP0015 CMP0020 CMP0042)
## ==========================
## ===========================
PROJECT(${prj_NAME})
-SET(
- prj_VERSION
- "${prj_MAJOR_VERSION}.${prj_MINOR_VERSION}.${prj_RELEASE_VERSION}"
- )
+SET(prj_VERSION "${prj_MAJOR_VERSION}.${prj_MINOR_VERSION}.${prj_RELEASE_VERSION}")
SET(prj_SHORT_VERSION "${prj_MAJOR_VERSION}")
## =====================================
## == Functions, packages and options ==
## =====================================
-INCLUDE(cmake/BaseConfig.cmake)
-OPTION(USE_cpPlugins "Build cpPlugins-based code" OFF)
-IF(USE_cpPlugins)
- FIND_PACKAGE(cpPlugins)
- MARK_AS_ADVANCED(CLEAR cpPlugins_DIR)
-ENDIF(USE_cpPlugins)
-INCLUDE(cmake/KitwareTools.cmake)
-INCLUDE(cmake/QtTools.cmake)
-INCLUDE(cmake/Functions.cmake)
+#INCLUDE(cmake/BaseConfig.cmake)
+#OPTION(USE_cpPlugins "Build cpPlugins-based code" OFF)
+#IF(USE_cpPlugins)
+# FIND_PACKAGE(cpPlugins)
+# MARK_AS_ADVANCED(CLEAR cpPlugins_DIR)
+#ENDIF(USE_cpPlugins)
+#INCLUDE(cmake/KitwareTools.cmake)
+#INCLUDE(cmake/QtTools.cmake)
+#INCLUDE(cmake/Functions.cmake)
## ===========================
## == Build different parts ==
+++ /dev/null
-OPTION(BUILD_EXAMPLES "Build simple examples" OFF)
-IF(BUILD_EXAMPLES)
- SUBDIRS(examples)
-ENDIF(BUILD_EXAMPLES)
-
-OPTION(BUILD_EXPERIMENTS "Build experiments" OFF)
-IF(BUILD_EXPERIMENTS)
- SUBDIRS(experiments)
-ENDIF(BUILD_EXPERIMENTS)
-
-## eof - $RCSfile$
+++ /dev/null
-ADD_EXECUTABLE(fpa_examples_ImageDijkstra ImageDijkstra.cxx)
-TARGET_LINK_LIBRARIES(fpa_examples_ImageDijkstra ${ITK_LIBRARIES} ${VTK_LIBRARIES})
-
-## eof - $RCSfile$
+++ /dev/null
-#include <itkImage.h>
-#include <itkRandomImageSource.h>
-#include <itkImageFileWriter.h>
-
-#include <fpa/Image/Functors/SimpleNeighborhood.h>
-#include <fpa/Image/Functors/SimpleDijkstraCost.h>
-#include <fpa/Base/Functors/Inverse.h>
-#include <fpa/Image/Dijkstra.h>
-
-// -------------------------------------------------------------------------
-static const unsigned int VDim = 2;
-typedef float TScalar;
-typedef itk::Image< unsigned char, VDim > TInputImage;
-typedef itk::Image< TScalar, VDim > TOutputImage;
-
-typedef itk::RandomImageSource< TInputImage > TImageSource;
-typedef itk::ImageFileWriter< TOutputImage > TImageWriter;
-
-typedef fpa::Image::Functors::SimpleNeighborhood< itk::ImageBase< VDim > > TNeighFunction;
-typedef fpa::Image::Functors::SimpleDijkstraCost< TInputImage, TScalar > TCostFunction;
-typedef fpa::Base::Functors::Inverse< TScalar, TScalar > TCostConversionFunction;
-
-typedef fpa::Image::Dijkstra< TInputImage, TOutputImage > TFilter;
-
-// -------------------------------------------------------------------------
-int main( int argc, char* argv[] )
-{
- static const unsigned long SIZE = 100;
- unsigned long size[] = { SIZE, SIZE };
-
- unsigned int neigh_order = 2;
- TInputImage::IndexType seed0, seed1;
-
- seed0.Fill( 0 );
- seed1.Fill( SIZE - 1 );
-
- TImageSource::Pointer source = TImageSource::New( );
- source->SetSize( size );
- source->SetSpacing( 1 );
- source->Update( );
- TInputImage::Pointer input = source->GetOutput( );
-
- TNeighFunction::Pointer neigh_function = TNeighFunction::New( );
- neigh_function->SetOrder( neigh_order );
-
- TCostFunction::Pointer cost_function = TCostFunction::New( );
-
- TCostConversionFunction::Pointer cost_conversion_function =
- TCostConversionFunction::New( );
-
- TFilter::Pointer filter = TFilter::New( );
- filter->SetInput( input );
- filter->SetNeighborhoodFunction( neigh_function );
- filter->SetCostFunction( cost_function );
- filter->SetCostConversionFunction( cost_conversion_function );
- filter->AddSeed( seed0, 0 );
- filter->AddSeed( seed1, 0 );
- filter->StopAtOneFrontOn( );
- filter->Update( );
-
- TImageWriter::Pointer writer = TImageWriter::New( );
- writer->SetInput( filter->GetOutput( ) );
- writer->SetFileName( "dijkstra.mhd" );
- writer->Update( );
-
- return( 0 );
-}
-
-// eof - $RCSfile$
+++ /dev/null
-INCLUDE_DIRECTORIES(
- ${PROJECT_SOURCE_DIR}/lib
- ${PROJECT_BINARY_DIR}/lib
- )
-ADD_EXECUTABLE(fpa_experiments_Skeleton_00 Skeleton_00.cxx)
-TARGET_LINK_LIBRARIES(fpa_experiments_Skeleton_00 ${ITK_LIBRARIES} ${VTK_LIBRARIES})
-
-ADD_EXECUTABLE(fpa_experiments_Hausdorff Hausdorff.cxx)
-TARGET_LINK_LIBRARIES(fpa_experiments_Hausdorff ${ITK_LIBRARIES} ${VTK_LIBRARIES})
-
-## eof - $RCSfile$
+++ /dev/null
-#include <itkImage.h>
-#include <itkImageFileReader.h>
-#include <itkHausdorffDistanceImageFilter.h>
-
-typedef double TScalar;
-typedef itk::Image< TScalar, 3 > TImage;
-typedef itk::ImageFileReader< TImage > TReader;
-typedef itk::HausdorffDistanceImageFilter< TImage, TImage > THausdorff;
-
-int main( int argc, char* argv[] )
-{
- if( argc < 3 )
- {
- std::cerr
- << "Usage: " << argv[ 0 ]
- << " image1 image2"
- << std::endl;
- return( 1 );
-
- } // fi
- std::string image1_name = argv[ 1 ];
- std::string image2_name = argv[ 2 ];
-
- TReader::Pointer reader1 = TReader::New( );
- reader1->SetFileName( image1_name );
- reader1->Update( );
-
- TReader::Pointer reader2 = TReader::New( );
- reader2->SetFileName( image2_name );
- reader2->Update( );
-
- THausdorff::Pointer hausdorff = THausdorff::New( );
- hausdorff->SetInput1( reader1->GetOutput( ) );
- hausdorff->SetInput2( reader2->GetOutput( ) );
- hausdorff->SetUseImageSpacing( true );
- hausdorff->Update( );
-
- std::cout
- << image1_name << " "
- << image2_name << " "
- << hausdorff->GetHausdorffDistance( ) << " "
- << hausdorff->GetAverageHausdorffDistance( )
- << std::endl;
-
- return( 0 );
-}
-
-// eof - $RCSfile$
+++ /dev/null
-#include <itkImage.h>
-#include <itkMinimumMaximumImageCalculator.h>
-#include <itkSignedMaurerDistanceMapImageFilter.h>
-#include <itkImageFileReader.h>
-#include <itkImageFileWriter.h>
-#include <fpa/Image/SkeletonFilter.h>
-#include <cpExtensions/Algorithms/SkeletonToImageFilter.h>
-
-typedef double TScalar;
-typedef itk::Image< TScalar, 3 > TImage;
-typedef itk::MinimumMaximumImageCalculator< TImage > TMinMax;
-typedef itk::SignedMaurerDistanceMapImageFilter< TImage, TImage > TDMap;
-typedef fpa::Image::SkeletonFilter< TImage > TSkeletonFilter;
-typedef TSkeletonFilter::TSkeleton TSkeleton;
-typedef cpExtensions::Algorithms::SkeletonToImageFilter< TSkeleton, TImage > TSkeletonToImage;
-typedef itk::ImageFileReader< TImage > TReader;
-typedef itk::ImageFileWriter< TImage > TWriter;
-
-int main( int argc, char* argv[] )
-{
- if( argc < 4 )
- {
- std::cerr
- << "Usage: " << argv[ 0 ]
- << " image prefix number_of_samples [seed_x seed_y seed_z]"
- << std::endl;
- return( 1 );
-
- } // fi
- std::string image_name = argv[ 1 ];
-
- TReader::Pointer reader = TReader::New( );
- reader->SetFileName( image_name );
- reader->Update( );
-
- TDMap::Pointer dmap = TDMap::New( );
- dmap->SetInput( reader->GetOutput( ) );
- dmap->InsideIsPositiveOn( );
- dmap->Update( );
- const TImage* image = dmap->GetOutput( );
-
- std::string prefix = argv[ 2 ];
- std::istringstream str( argv[ 3 ] );
- unsigned int number_of_samples;
- str >> number_of_samples;
- TImage::IndexType seed;
- if( argc < 7 )
- {
- TMinMax::Pointer minmax = TMinMax::New( );
- minmax->SetImage( image );
- minmax->Compute( );
- seed = minmax->GetIndexOfMaximum( );
- }
- else
- {
- std::istringstream str_x( argv[ 4 ] );
- std::istringstream str_y( argv[ 5 ] );
- std::istringstream str_z( argv[ 6 ] );
- TImage::PointType pnt;
- str_x >> pnt[ 0 ];
- str_y >> pnt[ 1 ];
- str_z >> pnt[ 2 ];
- image->TransformPhysicalPointToIndex( pnt, seed );
-
- } // fi
-
- for( unsigned int i = 0; i < number_of_samples; ++i )
- {
- std::cout << i << std::endl;
- TSkeletonFilter::Pointer skeleton = TSkeletonFilter::New( );
- skeleton->SetInput( image );
- skeleton->AddSeed( seed, 0 );
- skeleton->Update( );
-
- TSkeletonToImage::Pointer sk2im = TSkeletonToImage::New( );
- sk2im->SetTemplateImage( image );
- sk2im->SetSkeleton( skeleton->GetSkeleton( ) );
- sk2im->SetOutsideValue( 0 );
- sk2im->SetInsideValue( 1 );
- sk2im->Update( );
-
- TWriter::Pointer writer = TWriter::New( );
- writer->SetInput( sk2im->GetOutput( ) );
- writer->SetFileName( "skeleton.mhd" );
- writer->Update( );
-
- } // rof
- return( 0 );
-}
-
-// eof - $RCSfile$
+++ /dev/null
-## =======================================================================
-## == Force c++11 language version ==
-## == NOTE: It seems that by default on Visual Studio Compiler supports ==
-## == c++11, so it only need to be tested on other OS. ==
-## =======================================================================
-
-IF(NOT MSVC)
- INCLUDE(CheckCXXCompilerFlag)
- CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
- IF(COMPILER_SUPPORTS_CXX11)
- SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
- ELSE(COMPILER_SUPPORTS_CXX11)
- CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
- IF(COMPILER_SUPPORTS_CXX0X)
- SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
- ELSE(COMPILER_SUPPORTS_CXX0X)
- MESSAGE(
- FATAL_ERROR
- "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support."
- )
- ENDIF(COMPILER_SUPPORTS_CXX0X)
- ENDIF(COMPILER_SUPPORTS_CXX11)
-ENDIF(NOT MSVC)
-
-## ===================================================
-## == Prepare header generator to build shared libs ==
-## ===================================================
-
-INCLUDE(GenerateExportHeader)
-
-## ==================================================
-## == Do not allow to build inside the source tree ==
-## ==================================================
-
-IF(PROJECT_BINARY_DIR STREQUAL ${PROJECT_SOURCE_DIR})
- MESSAGE(FATAL_ERROR "Building in the source tree is not allowed.")
-ENDIF(PROJECT_BINARY_DIR STREQUAL ${PROJECT_SOURCE_DIR})
-
-## =================================================
-## == Where to put targets (executables and libs) ==
-## =================================================
-
-SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR})
-SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR})
-MARK_AS_ADVANCED(
- CMAKE_BACKWARDS_COMPATIBILITY
- EXECUTABLE_OUTPUT_PATH
- LIBRARY_OUTPUT_PATH
- )
-
-## eof - $RCSfile$
+++ /dev/null
-## =====================
-## == Configure files ==
-## =====================
-
-CONFIGURE_FILE(
- FrontAlgorithmsConfig.cmake.in
- ${PROJECT_BINARY_DIR}/FrontAlgorithmsConfig.cmake
- @ONLY
- )
-
-## eof - $RCSfile$
+++ /dev/null
-## -------------------------------------------------------------------------
-FUNCTION(NormPaths output_files)
-SET(_out)
-FOREACH(_f ${ARGN})
- SET(_d)
- FILE(TO_CMAKE_PATH ${_f} _d)
- LIST(APPEND _out ${_d})
-ENDFOREACH(_f)
-SET(${output_files} "${_out}" PARENT_SCOPE)
-ENDFUNCTION()
-
-## -------------------------------------------------------------------------
-FUNCTION(Wrap_Qt_CPP output_files)
-SET(_out)
-FOREACH(_f ${ARGN})
- IF(EXISTS ${_f})
- FILE(READ ${_f} _txt)
- STRING(FIND "${_txt}" "Q_OBJECT" _pos)
- IF(NOT ${_pos} EQUAL -1)
- SET(_s)
- QT4_WRAP_CPP(_s ${_f})
- SET(_out ${_out} ${_s})
- ENDIF(NOT ${_pos} EQUAL -1)
- ENDIF(EXISTS ${_f})
-ENDFOREACH(_f)
-SET(${output_files} "${_out}" PARENT_SCOPE)
-ENDFUNCTION()
-
-## -------------------------------------------------------------------------
-FUNCTION(Wrap_Qt_UI output_files)
-NormPaths(_source_dir ${PROJECT_SOURCE_DIR})
-NormPaths(_binary_dir ${PROJECT_BINARY_DIR})
-SET(_out)
-FOREACH(_f ${ARGN})
- IF(EXISTS ${_f})
- GET_FILENAME_COMPONENT(_name ${_f} NAME_WE)
- GET_FILENAME_COMPONENT(_dir ${_f} DIRECTORY)
- SET(_base_dir ${_source_dir})
- STRING(FIND "${_dir}" "${_base_dir}" _pos)
- IF(${_pos} EQUAL -1)
- SET(_base_dir ${_binary_dir})
- STRING(FIND "${_dir}" "${_base_dir}" _pos)
- ENDIF(${_pos} EQUAL -1)
- IF(NOT ${_pos} EQUAL -1)
- STRING(REPLACE "${_base_dir}/" "" _dir ${_dir})
- SET(_out_f ${_binary_dir}/${_dir}/ui_${_name}.h)
- LIST(APPEND _out ${_out_f})
- ADD_CUSTOM_COMMAND(
- OUTPUT ${_out_f}
- COMMAND Qt4::uic
- ARGS -o ${_out_f} ${_f}
- MAIN_DEPENDENCY ${_f} VERBATIM
- )
- ENDIF(NOT ${_pos} EQUAL -1)
- ENDIF(EXISTS ${_f})
-ENDFOREACH(_f)
-SET(${output_files} "${_out}" PARENT_SCOPE)
-ENDFUNCTION()
-
-## -------------------------------------------------------------------------
-FUNCTION(
- PrepareSourceFiles
- lib_name
- out_sources_list
- out_headers_list
- out_headers_paths
- )
-SET(_config_extensions .c.in .cpp.in .cxx.in .h.in .hpp.in .hxx.in .ui.in)
-SET(_sources_extensions .c .cpp .cxx)
-SET(_headers_extensions .h .hpp .hxx)
-SET(_qt_ui_extensions .ui)
-SET(_demangler_extensions .d)
-SET(_instances_extensions .i)
-
-## -- Configure inputs
-SET(_all_files)
-FOREACH(_file ${ARGN})
- GET_FILENAME_COMPONENT(_ext ${_file} EXT)
- LIST(FIND _config_extensions ${_ext} _cfg)
- IF(NOT ${_cfg} EQUAL -1)
- STRING(
- REPLACE
- ${PROJECT_SOURCE_DIR}
- ${PROJECT_BINARY_DIR}
- _file_bin
- ${_file}
- )
- STRING(LENGTH ${_file_bin} _file_bin_len)
- MATH(EXPR _file_bin_len "${_file_bin_len}-3")
- STRING(SUBSTRING ${_file_bin} 0 ${_file_bin_len} _file_bin)
- CONFIGURE_FILE(${_file} ${_file_bin} @ONLY)
- LIST(APPEND _all_files ${_file_bin})
- ELSE(NOT ${_cfg} EQUAL -1)
- LIST(APPEND _all_files ${_file})
- ENDIF(NOT ${_cfg} EQUAL -1)
-ENDFOREACH(_file)
-
-## -- Separate files
-SET(_srcs)
-SET(_hdrs)
-SET(_qts)
-SET(_demanglers)
-SET(_instances)
-FOREACH(_file ${_all_files})
- GET_FILENAME_COMPONENT(_ext ${_file} EXT)
- LIST(FIND _sources_extensions ${_ext} _src)
- LIST(FIND _headers_extensions ${_ext} _hdr)
- LIST(FIND _qt_ui_extensions ${_ext} _ui)
- LIST(FIND _demangler_extensions ${_ext} _dem)
- LIST(FIND _instances_extensions ${_ext} _ins)
- IF(NOT ${_src} EQUAL -1)
- LIST(APPEND _srcs ${_file})
- ENDIF(NOT ${_src} EQUAL -1)
- IF(NOT ${_hdr} EQUAL -1)
- LIST(APPEND _hdrs ${_file})
- ENDIF(NOT ${_hdr} EQUAL -1)
- IF(NOT ${_ui} EQUAL -1)
- LIST(APPEND _qts ${_file})
- ENDIF(NOT ${_ui} EQUAL -1)
- IF(NOT ${_dem} EQUAL -1)
- LIST(APPEND _demanglers ${_file})
- ENDIF(NOT ${_dem} EQUAL -1)
- IF(NOT ${_ins} EQUAL -1)
- LIST(APPEND _instances ${_file})
- ENDIF(NOT ${_ins} EQUAL -1)
-ENDFOREACH(_file)
-
-# -- Prepare Qt4-based code
-IF(Qt4_FOUND)
- ## -- Guess what headers sould be qt-moc'ed
- Wrap_Qt_CPP(_moc ${_hdrs})
- IF(_moc)
- LIST(APPEND _srcs ${_moc})
- ENDIF(_moc)
-
- ## -- Guess what qt-ui's sould be qt-uic'ed
- ## -- Wrap qt-ui headers: this is equivalent to QT4_WRAP_UI except to change
- ## -- the output file
- Wrap_Qt_UI(_qt_hdrs ${_qts})
- IF(_qt_hdrs)
- LIST(APPEND _hdrs ${_qt_hdrs})
- ENDIF(_qt_hdrs)
-ENDIF(Qt4_FOUND)
-
-## -- Create demanglers
-FOREACH(_d ${_demanglers})
- STRING(
- REPLACE
- ${PROJECT_SOURCE_DIR}
- ${PROJECT_BINARY_DIR}
- _d_bin
- ${_d}
- )
- GET_FILENAME_COMPONENT(_d_path ${_d_bin} DIRECTORY)
- GET_FILENAME_COMPONENT(_out_name ${_d_bin} NAME_WE)
- SET(_d_out ${_d_path}/${_out_name}_Demanglers.h)
- ADD_CUSTOM_COMMAND(
- OUTPUT ${_d_out}
- COMMAND ${CMAKE_COMMAND} -E make_directory ${_d_path}
- COMMAND ${cpPlugins_bash_CreateDemanglers_APP} ${_d} ${_out_name} ${_d_out}
- DEPENDS ${cpPlugins_bash_CreateDemanglers_APP} ${_d}
- )
- LIST(APPEND _hdrs ${_d_out})
-ENDFOREACH(_d)
-
-## -- Create instances
-FOREACH(_i ${_instances})
- STRING(
- REPLACE
- ${PROJECT_SOURCE_DIR}
- ${PROJECT_BINARY_DIR}
- _i_bin
- ${_i}
- )
- GET_FILENAME_COMPONENT(_i_path ${_i_bin} DIRECTORY)
- GET_FILENAME_COMPONENT(_out_name ${_i} NAME_WE)
-
- ## -- Infere source code filenames
- MATH(EXPR _last_range "${cpPlugins_NUMBER_OF_FILES}-1")
- SET(_out_code)
- FOREACH(_n RANGE 0 ${_last_range})
- LIST(APPEND _out_code ${_i_path}/${_out_name}_${_n}.cxx)
- LIST(APPEND _srcs ${_i_path}/${_out_name}_${_n}.cxx)
- ENDFOREACH(_n)
-
- ## -- Command to write source code
- ADD_CUSTOM_COMMAND(
- OUTPUT ${_out_code}
- DEPENDS ${cpPlugins_bash_CreateInstances_APP} ${_i}
- COMMAND ${CMAKE_COMMAND} -E make_directory ${_i_path}
- COMMAND ${cpPlugins_bash_CreateInstances_APP} ${_i} ${lib_name} ${_i_path}/${_out_name}
- )
-ENDFOREACH(_i)
-
-## -- Real compilation
-SET(_hdrs_paths)
-FOREACH(_hdr ${_hdrs})
- GET_FILENAME_COMPONENT(_path ${_hdr} DIRECTORY)
- LIST(FIND _hdrs_paths ${_path} _path_idx)
- IF(${_path_idx} EQUAL -1)
- LIST(APPEND _hdrs_paths ${_path})
- ENDIF(${_path_idx} EQUAL -1)
-ENDFOREACH(_hdr)
-
-SET(${out_sources_list} ${_srcs} PARENT_SCOPE)
-SET(${out_headers_list} ${_hdrs} PARENT_SCOPE)
-SET(${out_headers_paths} ${_hdrs_paths} PARENT_SCOPE)
-
-ENDFUNCTION()
-
-## -------------------------------------------------------------------------
-FUNCTION(cpPlugins_BuildLibrary lib_name lib_type)
-# -- Detect all source files
-SET(_all_files)
-FOREACH(_c ${ARGN})
- GET_FILENAME_COMPONENT(_cname ${_c} ABSOLUTE)
- SET(_files)
- IF(IS_DIRECTORY ${_cname})
- FILE(GLOB_RECURSE _files "${_cname}/*")
- ELSE(IS_DIRECTORY ${_cname})
- SET(_files ${_cname})
- ENDIF(IS_DIRECTORY ${_cname})
- LIST(APPEND _all_files ${_files})
-ENDFOREACH(_c ${ARGN})
-
-## -- Prepare sources by types
-PrepareSourceFiles(${lib_name} _srcs _hdrs _paths ${_all_files})
-
-## -- Build library
-IF(_srcs)
- INCLUDE_DIRECTORIES(
- ${CMAKE_CURRENT_SOURCE_DIR}
- ${CMAKE_CURRENT_BINARY_DIR}
- )
- ADD_LIBRARY(${lib_name} ${lib_type} ${_srcs} ${_hdrs})
- GENERATE_EXPORT_HEADER(
- ${lib_name}
- BASE_NAME ${lib_name}
- EXPORT_MACRO_NAME ${lib_name}_EXPORT
- EXPORT_FILE_NAME ${lib_name}_Export.h
- STATIC_DEFINE ${lib_name}_BUILT_AS_STATIC
- )
-ENDIF(_srcs)
-
-ENDFUNCTION()
-
-## -------------------------------------------------------------------------
-FUNCTION(cpPlugins_BuildPluginsLibrary lib_name)
-# -- Detect all source files
-SET(_all_files)
-FOREACH(_c ${ARGN})
- GET_FILENAME_COMPONENT(_cname ${_c} ABSOLUTE)
- SET(_files)
- IF(IS_DIRECTORY ${_cname})
- FILE(GLOB_RECURSE _files "${_cname}/*")
- ELSE(IS_DIRECTORY ${_cname})
- SET(_files ${_cname})
- ENDIF(IS_DIRECTORY ${_cname})
- LIST(APPEND _all_files ${_files})
-ENDFOREACH(_c ${ARGN})
-
-## -- Prepare sources by types
-PrepareSourceFiles(${lib_name} _srcs _hdrs _paths ${_all_files})
-
-## -- Check which headers need to be wrapped to build host code
-SET(_hdrs_to_wrap)
-FOREACH(_hdr ${_hdrs})
- IF(EXISTS ${_hdr})
- FILE(READ ${_hdr} _txt)
- STRING(FIND "${_txt}" "cpPluginsObject" _res)
- IF(NOT ${_res} EQUAL -1)
- LIST(APPEND _hdrs_to_wrap ${_hdr})
- ENDIF(NOT ${_res} EQUAL -1)
- ENDIF(EXISTS ${_hdr})
-ENDFOREACH(_hdr)
-
-## -- Wrap headers
-IF(_hdrs_to_wrap)
- SET(_host ${CMAKE_CURRENT_BINARY_DIR}/${lib_name}_host.cxx)
- ADD_CUSTOM_COMMAND(
- OUTPUT ${_host}
- DEPENDS ${cpPlugins_bash_HostCreator_APP} ${_hdrs_to_wrap}
- COMMAND ${cpPlugins_bash_HostCreator_APP} ${lib_name} ${_host} ${_hdrs_to_wrap}
- )
- LIST(APPEND _all_files ${_host})
-ENDIF(_hdrs_to_wrap)
-
-cpPlugins_BuildLibrary(${lib_name} SHARED ${_all_files})
-ENDFUNCTION()
-
-## -------------------------------------------------------------------------
-FUNCTION(cpPlugins_BuildApplication app_name)
-OPTION(BUILD_${app_name} "Build \"${app_name}\" application?" OFF)
-IF(BUILD_${app_name})
- # -- Detect all source files
- SET(_all_files)
- FOREACH(_c ${ARGN})
- GET_FILENAME_COMPONENT(_cname ${_c} ABSOLUTE)
- SET(_files)
- IF(IS_DIRECTORY ${_cname})
- FILE(GLOB_RECURSE _files "${_cname}/*")
- ELSE(IS_DIRECTORY ${_cname})
- SET(_files ${_cname})
- ENDIF(IS_DIRECTORY ${_cname})
- LIST(APPEND _all_files ${_files})
- ENDFOREACH(_c ${ARGN})
-
- ## -- Prepare sources by types
- PrepareSourceFiles(${app_name} _srcs _hdrs _paths ${_all_files})
-
- ## -- Build library
- IF(_srcs)
- INCLUDE_DIRECTORIES(
- ${CMAKE_CURRENT_SOURCE_DIR}
- ${CMAKE_CURRENT_BINARY_DIR}
- )
- SET(_app_os_target)
- IF(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
- SET(_app_os_target WIN32)
- ELSEIF(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
- SET(_app_os_target MACOSX_BUNDLE)
- ENDIF(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
- ADD_EXECUTABLE(${app_name} ${_app_os_target} ${_srcs} ${_hdrs})
- ENDIF(_srcs)
-ENDIF(BUILD_${app_name})
-ENDFUNCTION()
-
-## eof - $RCSfile$
+++ /dev/null
-# ======================
-# == Find ITK and VTK ==
-# ======================
-
-FIND_PACKAGE(ITK REQUIRED)
-FIND_PACKAGE(VTK REQUIRED)
-
-INCLUDE(${ITK_USE_FILE})
-INCLUDE(${VTK_USE_FILE})
-
-# ===================================================
-# == Do not use itk-vtk glue --> problems ahead!!! ==
-# ===================================================
-
-IF(ITKVtkGlue_LOADED)
- MESSAGE(FATAL_ERROR "ITKVtkGlue module is available. Please re-compile your ITK without it. It could lead to nasty compilation problems... Just waiting for Kitware to solve it.")
-ENDIF(ITKVtkGlue_LOADED)
-
-## eof - $RCSfile$
+++ /dev/null
-## ==================================================
-## == Find Qt4 and check if it was well configured ==
-## ==================================================
-
-IF(BUILD_QT4_COMPONENTS)
- FIND_PACKAGE(Qt4 REQUIRED)
- INCLUDE(${QT_USE_FILE})
- SET(
- _modules
- vtkGUISupportQt
- )
- FOREACH(_m ${_modules})
- IF(NOT ${_m}_LOADED)
- MESSAGE(FATAL_ERROR "${_m} module is required but not available.")
- BREAK()
- ENDIF(NOT ${_m}_LOADED)
- ENDFOREACH(_m)
- SET(
- cpPlugins_Qt4_VTKWidget
- QVTKWidget
- CACHE STRING "Base Qt4-based vtkRenderWindow"
- )
- MARK_AS_ADVANCED(CLEAR cpPlugins_Qt4_VTKWidget)
-ENDIF(BUILD_QT4_COMPONENTS)
-
-## eof - $RCSfile$
+++ /dev/null
-<cpPlugins_Workspace>
- <filter category="ImageFilters" class="CastImageFilter" name="cast" ViewX="-1098" ViewY="-242">
- <parameter name="CastType" value="char#short#int#long#uchar#ushort#uint#ulong#float#double@double" type="Choices"/>
- </filter>
- <filter category="fpaImageAlgorithmFunctors" class="InvertCostFunction" name="cost" ViewX="-951" ViewY="-428">
- <parameter name="Alpha" value="1" type="Real"/>
- <parameter name="Beta" value="1" type="Real"/>
- <parameter name="ScalarType" value="float#double@float" type="Choices"/>
- </filter>
- <filter category="fpaImageAlgorithm" class="ImageDijkstra" name="dijkstra" ViewX="-735" ViewY="-176">
- <parameter name="FillNodeQueue" value="1" type="Bool"/>
- <parameter name="NeighborhoodOrder" value="1#2@1" type="Choices"/>
- <parameter name="StopAtOneFront" value="0" type="Bool"/>
- <parameter name="VisualDebug" value="1" type="Bool"/>
- </filter>
- <filter category="ImageFilters" class="SignedMaurerDistanceMapImageFilter" name="dmap" ViewX="-1093" ViewY="-379">
- <parameter name="BackgroundValue" value="0" type="Real"/>
- <parameter name="InsideIsPositive" value="1" type="Bool"/>
- <parameter name="OutputResolution" value="float#double@float" type="Choices"/>
- <parameter name="SquaredDistance" value="0" type="Bool"/>
- <parameter name="UseImageSpacing" value="1" type="Bool"/>
- </filter>
- <filter category="fpaImageAlgorithm" class="ExtractEndPointsAndBifurcationsFromMinimumSpanningTree" name="eb" ViewX="-491" ViewY="-267">
- <parameter name="SquaredDistanceMap" value="0" type="Bool"/>
- </filter>
- <filter category="IO" class="ImageReader" name="reader" ViewX="-1366" ViewY="-264">
- <parameter name="FileNames" value="" type="OpenFileNameList"/>
- </filter>
- <filter category="Widgets" class="NoInteractiveSeedWidget" name="seed" ViewX="-1116" ViewY="-124">
- <parameter name="Text" value="" type="String"/>
- </filter>
- <connection>
- <origin filter="cost" name="Output"/>
- <destination filter="dijkstra" name="CostFunctor"/>
- </connection>
- <connection>
- <origin filter="dijkstra" name="Output"/>
- <destination filter="eb" name="CostsImage"/>
- </connection>
- <connection>
- <origin filter="dijkstra" name="MST"/>
- <destination filter="eb" name="MST"/>
- </connection>
- <connection>
- <origin filter="dmap" name="Output"/>
- <destination filter="dijkstra" name="Input"/>
- </connection>
- <connection>
- <origin filter="dmap" name="Output"/>
- <destination filter="eb" name="DistanceMap"/>
- </connection>
- <connection>
- <origin filter="reader" name="Output"/>
- <destination filter="cast" name="Input"/>
- </connection>
- <connection>
- <origin filter="reader" name="Output"/>
- <destination filter="dmap" name="Input"/>
- </connection>
- <connection>
- <origin filter="reader" name="Output"/>
- <destination filter="seed" name="ReferenceImage"/>
- </connection>
- <connection>
- <origin filter="seed" name="Output"/>
- <destination filter="dijkstra" name="Seeds"/>
- </connection>
- <exposed_output_port port_name="bifurcations" filter="eb" filter_port_name="Bifurcations"/>
- <exposed_output_port port_name="endpoints" filter="eb" filter_port_name="EndPoints"/>
- <exposed_output_port port_name="input_image_casted" filter="CastImageFilter" filter_port_name="Output"/>
- <exposed_output_port port_name="input_image_dmap" filter="dmap" filter_port_name="Output"/>
- <exposed_output_port port_name="skeleton" filter="eb" filter_port_name="Skeleton"/>
-</cpPlugins_Workspace>
+++ /dev/null
-OPTION(BUILD_Examples "Build simple examples?" OFF)
-
-IF(BUILD_Examples)
- SET(
- _examples
- RegionGrow_00
- FastMarching_00
- MoriRegionGrow_00
- Skeleton_00
- )
- INCLUDE_DIRECTORIES(
- ${PROJECT_SOURCE_DIR}/lib
- ${PROJECT_BINARY_DIR}/lib
- )
- FOREACH(_example ${_examples})
- ADD_EXECUTABLE(fpa_example_${_example} ${_example}.cxx)
- TARGET_LINK_LIBRARIES(fpa_example_${_example} ${ITK_LIBRARIES} ${VTK_LIBRARIES})
- ENDFOREACH(_example)
-ENDIF(BUILD_Examples)
-
-## eof - $RCSfile$
+++ /dev/null
-#include <itkImage.h>
-#include <itkImageFileWriter.h>
-#include <fpa/Image/FastMarching.h>
-
-// -------------------------------------------------------------------------
-typedef itk::Image< float, 2 > TImage;
-typedef fpa::Image::FastMarching< TImage, TImage > TFilter;
-typedef itk::ImageFileWriter< TImage > TWriter;
-
-// -------------------------------------------------------------------------
-int main( int argc, char* argv[] )
-{
- TImage::SizeType size;
- size.Fill( 512 );
-
- TImage::SpacingType spac;
- spac[ 0 ] = 0.4;
- spac[ 1 ] = 1.7;
-
- TImage::Pointer input = TImage::New( );
- input->SetRegions( size );
- input->SetSpacing( spac );
- input->Allocate( );
- input->FillBuffer( 1 );
-
- TImage::RegionType region = input->GetLargestPossibleRegion( );
- TImage::PointType p0, p1, p2, p3, p4;
- input->TransformIndexToPhysicalPoint( region.GetIndex( ), p0 );
- input->TransformIndexToPhysicalPoint(
- region.GetIndex( ) + region.GetSize( ), p1
- );
- p2 = ( p0.GetVectorFromOrigin( ) + p1.GetVectorFromOrigin( ) ) * 0.5;
- p3 = ( p0.GetVectorFromOrigin( ) + p1.GetVectorFromOrigin( ) ) * 0.25;
- p4 = ( p0.GetVectorFromOrigin( ) + p1.GetVectorFromOrigin( ) ) * 0.75;
- TImage::IndexType s0, s1, s2;
- input->TransformPhysicalPointToIndex( p2, s0 );
- input->TransformPhysicalPointToIndex( p3, s1 );
- input->TransformPhysicalPointToIndex( p4, s2 );
-
- TFilter::Pointer filter = TFilter::New( );
- filter->SetInput( input );
- filter->AddSeed( s0, 0 );
- filter->AddSeed( s1, 0 );
- filter->AddSeed( s2, 0 );
- filter->Update( );
-
- TWriter::Pointer writer = TWriter::New( );
- writer->SetInput( filter->GetOutput( ) );
- writer->SetFileName( "FastMarching_00.mhd" );
- writer->Update( );
-
- return( 0 );
-}
-
-// eof - $RCSfile$
+++ /dev/null
-#include <itkImage.h>
-#include <itkImageFileReader.h>
-#include <itkImageFileWriter.h>
-#include <fpa/Image/MoriRegionGrow.h>
-
-// -------------------------------------------------------------------------
-typedef itk::Image< unsigned char, 2 > TImage;
-typedef itk::ImageFileReader< TImage > TReader;
-typedef itk::ImageFileWriter< TImage > TWriter;
-typedef fpa::Image::MoriRegionGrow< TImage, TImage > TFilter;
-typedef itk::ImageFileWriter< TFilter::TAuxImage > TAuxWriter;
-
-// -------------------------------------------------------------------------
-int main( int argc, char* argv[] )
-{
- if( argc < 4 )
- {
- std::cerr
- << "Usage: " << argv[ 0 ]
- << " input_filename output_filename output_aux_filename" << std::endl;
- return( 1 );
-
- } // fi
- std::string in_fname = argv[ 1 ];
- std::string out_fname = argv[ 2 ];
- std::string out_aux_fname = argv[ 3 ];
- int seed_x = 111;
- int seed_y = 91;
-
- TReader::Pointer reader = TReader::New( );
- reader->SetFileName( in_fname );
-
- TImage::IndexType seed;
- seed[ 0 ] = seed_x;
- seed[ 1 ] = seed_y;
-
- TFilter::Pointer filter = TFilter::New( );
- filter->SetInput( reader->GetOutput( ) );
- filter->SetLower( 0 );
- filter->SetUpper( 255 );
- filter->SetStep( 1 );
- filter->SetInsideValue( 255 );
- filter->SetOutsideValue( 0 );
- filter->SetSeed( seed );
-
- TWriter::Pointer writer = TWriter::New( );
- writer->SetInput( filter->GetOutput( ) );
- writer->SetFileName( out_fname );
- writer->Update( );
-
- TAuxWriter::Pointer aux_writer = TAuxWriter::New( );
- aux_writer->SetInput( filter->GetAuxiliaryImage( ) );
- aux_writer->SetFileName( out_aux_fname );
- aux_writer->Update( );
-
-
- return( 0 );
-}
-
-// eof - $RCSfile$
+++ /dev/null
-#include <itkCommand.h>
-#include <itkImage.h>
-#include <itkImageFileWriter.h>
-#include <fpa/Image/RegionGrow.h>
-
-// -------------------------------------------------------------------------
-typedef itk::Image< unsigned char, 2 > TImage;
-typedef fpa::Image::RegionGrow< TImage, TImage > TFilter;
-typedef itk::ImageFileWriter< TImage > TWriter;
-
-// -------------------------------------------------------------------------
-/**
- */
-class MyObserver
- : public itk::Command
-{
-public:
- typedef TFilter::TStartEvent TStartEvent;
- typedef TFilter::TEndEvent TEndEvent;
- typedef TFilter::TStartLoopEvent TStartLoopEvent;
- typedef TFilter::TEndLoopEvent TEndLoopEvent;
- typedef TFilter::TPushEvent TPushEvent;
- typedef TFilter::TPopEvent TPopEvent;
- typedef TFilter::TMarkEvent TMarkEvent;
-
-public:
- itkNewMacro( MyObserver );
-
-public:
- virtual void Execute(
- itk::Object* caller, const itk::EventObject& event
- ) override
- {
- this->Execute( const_cast< const itk::Object* >( caller ), event );
- }
- virtual void Execute(
- const itk::Object* object, const itk::EventObject& event
- ) override
- {
- if( TStartEvent( ).CheckEvent( &event ) )
- std::cout << "Start" << std::endl;
- else if( TEndEvent( ).CheckEvent( &event ) )
- std::cout << "End" << std::endl;
- else if( TStartLoopEvent( ).CheckEvent( &event ) )
- std::cout << "StartLoop" << std::endl;
- else if( TEndLoopEvent( ).CheckEvent( &event ) )
- std::cout << "EndLoop" << std::endl;
- else if( TMarkEvent( ).CheckEvent( &event ) )
- {
- const TMarkEvent* mark = dynamic_cast< const TMarkEvent* >( &event );
- std::cout << "Mark: " << mark->Vertex << std::endl;
-
- } // fi
- /* TODO
- TPushEvent;
- TPopEvent;
- */
- }
-};
-
-// -------------------------------------------------------------------------
-int main( int argc, char* argv[] )
-{
- TImage::SizeType size;
- size.Fill( 10 );
-
- TImage::Pointer input = TImage::New( );
- input->SetRegions( size );
- input->Allocate( );
- input->FillBuffer( 0 );
-
- TImage::RegionType region = input->GetLargestPossibleRegion( );
- TImage::PointType p0, p1, p2;
- input->TransformIndexToPhysicalPoint( region.GetIndex( ), p0 );
- input->TransformIndexToPhysicalPoint(
- region.GetIndex( ) + region.GetSize( ), p1
- );
- p2 = ( p0.GetVectorFromOrigin( ) + p1.GetVectorFromOrigin( ) ) * 0.5;
- TImage::IndexType seed;
- input->TransformPhysicalPointToIndex( p2, seed );
-
- TFilter::Pointer filter = TFilter::New( );
- filter->SetInput( input );
- filter->SetInsideValue( 255 );
- filter->SetOutsideValue( 0 );
- filter->AddSeed( seed, filter->GetInsideValue( ) );
-
- MyObserver::Pointer obs = MyObserver::New( );
- filter->AddObserver( itk::AnyEvent( ), obs );
- filter->Update( );
-
- TWriter::Pointer writer = TWriter::New( );
- writer->SetInput( filter->GetOutput( ) );
- writer->SetFileName( "RegionGrow_00.png" );
- writer->Update( );
-
- return( 0 );
-}
-
-// eof - $RCSfile$
+++ /dev/null
-#include <itkImage.h>
-#include <itkImageFileReader.h>
-#include <itkSignedMaurerDistanceMapImageFilter.h>
-#include <itkMinimumMaximumImageCalculator.h>
-#include <fpa/Image/SkeletonFilter.h>
-#include <cpExtensions/Algorithms/SkeletonWriter.h>
-
-// -------------------------------------------------------------------------
-typedef itk::Image< double, 2 > TImage;
-typedef itk::ImageFileReader< TImage > TReader;
-typedef itk::SignedMaurerDistanceMapImageFilter< TImage, TImage > TDMap;
-typedef itk::MinimumMaximumImageCalculator< TImage > TMinMax;
-typedef fpa::Image::SkeletonFilter< TImage > TFilter;
-typedef TFilter::TSkeleton TSkeleton;
-typedef cpExtensions::Algorithms::SkeletonWriter< TSkeleton > TWriter;
-
-// -------------------------------------------------------------------------
-int main( int argc, char* argv[] )
-{
- if( argc < 3 )
- {
- std::cerr
- << "Usage: " << argv[ 0 ]
- << " input_filename output_filename" << std::endl;
- return( 1 );
-
- } // fi
- std::string in_fname = argv[ 1 ];
- std::string out_fname = argv[ 2 ];
-
- TReader::Pointer reader = TReader::New( );
- reader->SetFileName( in_fname );
-
- TDMap::Pointer dmap = TDMap::New( );
- dmap->SetInput( reader->GetOutput( ) );
- dmap->InsideIsPositiveOn( );
- dmap->SquaredDistanceOff( );
- dmap->UseImageSpacingOn( );
- dmap->Update( );
-
- TMinMax::Pointer minmax = TMinMax::New( );
- minmax->SetImage( dmap->GetOutput( ) );
- minmax->Compute( );
-
- TFilter::Pointer filter = TFilter::New( );
- filter->SetInput( dmap->GetOutput( ) );
- filter->AddSeed( minmax->GetIndexOfMaximum( ), 0 );
- filter->Update( );
-
- TWriter::Pointer writer = TWriter::New( );
- writer->SetInput( filter->GetSkeleton( ) );
- writer->SetFileName( out_fname );
- writer->Update( );
-
- return( 0 );
-}
-
-// eof - $RCSfile$
+++ /dev/null
-
-## ===================================
-## == Build instances for cpPlugins ==
-## ===================================
-
-SUBDIRS(fpaInstances)
-
-## eof - $RCSfile$
+++ /dev/null
-#ifndef __fpa__Base__Algorithm__h__
-#define __fpa__Base__Algorithm__h__
-
-#include <vector>
-#include <itkFunctionBase.h>
-#include <fpa/Config.h>
-#include <fpa/Base/Events.h>
-#include <fpa/Base/Functors/VertexCostFunctionBase.h>
-
-namespace fpa
-{
- namespace Base
- {
- /**
- */
- template< class _TFilter, class _TVertex, class _TOutput >
- class Algorithm
- : public _TFilter
- {
- public:
- typedef Algorithm Self;
- typedef _TFilter Superclass;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
-
- typedef _TVertex TVertex;
- typedef _TOutput TOutput;
- typedef unsigned long TFrontId;
-
- // Different functions
- typedef std::vector< TVertex > TNeighborhood;
- typedef itk::FunctionBase< TVertex, TNeighborhood > TNeighborhoodFunction;
- typedef itk::FunctionBase< TOutput, TOutput > TConversionFunction;
- typedef fpa::Base::Functors::VertexCostFunctionBase< TVertex, TOutput > TVertexFunction;
-
- // Minigraph to represent collisions
- typedef std::pair< _TVertex, bool > TCollision;
- typedef std::vector< TCollision > TCollisionsRow;
- typedef std::vector< TCollisionsRow > TCollisions;
-
- protected:
- struct _TQueueNode
- {
- TVertex Vertex;
- TVertex Parent;
- TOutput Result;
- TFrontId FrontId;
- _TQueueNode( );
- _TQueueNode( const TVertex& v );
- _TQueueNode( const TVertex& v, const _TQueueNode& n );
- };
-
- public:
- itkTypeMacro( Self, _TFilter );
-
- fpa_Base_NewEvent( TStartEvent );
- fpa_Base_NewEvent( TEndEvent );
- fpa_Base_NewEvent( TStartLoopEvent );
- fpa_Base_NewEvent( TEndLoopEvent );
- fpa_Base_NewEventWithVertex( TPushEvent, TVertex );
- fpa_Base_NewEventWithVertex( TPopEvent, TVertex );
- fpa_Base_NewEventWithVertex( TMarkEvent, TVertex );
-
- itkGetConstMacro( InitResult, _TOutput );
- itkSetMacro( InitResult, _TOutput );
-
- itkBooleanMacro( StopAtOneFront );
- itkGetConstMacro( StopAtOneFront, bool );
- itkSetMacro( StopAtOneFront, bool );
-
- itkGetObjectMacro( NeighborhoodFunction, TNeighborhoodFunction );
- itkGetObjectMacro( ConversionFunction, TConversionFunction );
- itkGetObjectMacro( VertexFunction, TVertexFunction );
-
- itkGetConstObjectMacro( NeighborhoodFunction, TNeighborhoodFunction );
- itkGetConstObjectMacro( ConversionFunction, TConversionFunction );
- itkGetConstObjectMacro( VertexFunction, TVertexFunction );
-
- itkSetObjectMacro( NeighborhoodFunction, TNeighborhoodFunction );
- itkSetObjectMacro( ConversionFunction, TConversionFunction );
- itkSetObjectMacro( VertexFunction, TVertexFunction );
-
- public:
- void ClearSeeds( );
- void AddSeed( const TVertex& seed, const TOutput& value );
-
- protected:
- Algorithm( );
- virtual ~Algorithm( );
-
- virtual void GenerateData( ) override;
-
- // Particular methods
- virtual bool _ContinueGenerateData( );
- virtual void _Loop( );
-
- virtual void _BeforeGenerateData( );
- virtual void _AfterGenerateData( );
- virtual void _BeforeLoop( );
- virtual void _AfterLoop( );
-
- virtual bool _ValidLoop( ) const;
- virtual void _UpdateCollisions( const TVertex& a, const TVertex& b );
-
- virtual _TOutput _GetInputValue( const _TQueueNode& v, const _TQueueNode& p );
-
- virtual void _InitMarks( ) = 0;
- virtual void _InitResults( const TOutput& init_value ) = 0;
- virtual bool _IsMarked( const _TVertex& v ) const = 0;
- virtual void _Mark( const _TQueueNode& n ) = 0;
- virtual TFrontId _GetMark( const _TVertex& v ) const = 0;
- virtual void _UpdateResult( const _TQueueNode& n ) = 0;
- virtual TOutput _GetResult( const _TVertex& v ) const = 0;
- virtual unsigned int _GetNumberOfDimensions( ) const = 0;
-
- virtual bool _UpdateValue( _TQueueNode& v, const _TQueueNode& p ) = 0;
- virtual unsigned long _QueueSize( ) const = 0;
- virtual void _QueueClear( ) = 0;
- virtual void _QueuePush( const _TQueueNode& node ) = 0;
- virtual _TQueueNode _QueuePop( ) = 0;
-
- private:
- // Purposely not implemented.
- Algorithm( const Self& other );
- Self& operator=( const Self& other );
-
- protected:
- _TOutput m_InitResult;
- bool m_StopAtOneFront;
-
- typename TNeighborhoodFunction::Pointer m_NeighborhoodFunction;
- typename TConversionFunction::Pointer m_ConversionFunction;
- typename TVertexFunction::Pointer m_VertexFunction;
-
- std::vector< _TQueueNode > m_Seeds;
- TCollisions m_Collisions;
- unsigned int m_NumberOfFronts;
- };
-
- } // ecaseman
-
-} // ecaseman
-
-#ifndef ITK_MANUAL_INSTANTIATION
-# include <fpa/Base/Algorithm.hxx>
-#endif // ITK_MANUAL_INSTANTIATION
-
-#endif // __fpa__Base__Algorithm__h__
-
-// eof - $RCSfile$
+++ /dev/null
-#ifndef __fpa__Base__Algorithm__hxx__
-#define __fpa__Base__Algorithm__hxx__
-
-#include <queue>
-
-// -------------------------------------------------------------------------
-template < class _TFilter, class _TVertex, class _TOutput >
-fpa::Base::Algorithm< _TFilter, _TVertex, _TOutput >::_TQueueNode::
-_TQueueNode( )
-{
- this->Vertex.Fill( 0 );
- this->Parent.Fill( 0 );
- this->Result = _TOutput( 0 );
- this->FrontId = 0;
-}
-
-// -------------------------------------------------------------------------
-template < class _TFilter, class _TVertex, class _TOutput >
-fpa::Base::Algorithm< _TFilter, _TVertex, _TOutput >::_TQueueNode::
-_TQueueNode( const _TVertex& v )
-{
- this->Vertex = v;
- this->Parent = v;
- this->Result = _TOutput( 0 );
- this->FrontId = 0;
-}
-
-// -------------------------------------------------------------------------
-template < class _TFilter, class _TVertex, class _TOutput >
-fpa::Base::Algorithm< _TFilter, _TVertex, _TOutput >::_TQueueNode::
-_TQueueNode( const _TVertex& v, const _TQueueNode& n )
-{
- this->Vertex = v;
- this->Parent = n.Vertex;
- this->Result = n.Result;
- this->FrontId = n.FrontId;
-}
-
-// -------------------------------------------------------------------------
-template < class _TFilter, class _TVertex, class _TOutput >
-void fpa::Base::Algorithm< _TFilter, _TVertex, _TOutput >::
-ClearSeeds( )
-{
- this->m_Seeds.clear( );
- this->Modified( );
-}
-
-// -------------------------------------------------------------------------
-template < class _TFilter, class _TVertex, class _TOutput >
-void fpa::Base::Algorithm< _TFilter, _TVertex, _TOutput >::
-AddSeed( const _TVertex& seed, const TOutput& value )
-{
- _TQueueNode node( seed );
- node.FrontId = this->m_Seeds.size( ) + 1;
- node.Result = value;
- this->m_Seeds.push_back( node );
- this->Modified( );
-}
-
-// -------------------------------------------------------------------------
-template < class _TFilter, class _TVertex, class _TOutput >
-fpa::Base::Algorithm< _TFilter, _TVertex, _TOutput >::
-Algorithm( )
- : Superclass( ),
- m_InitResult( _TOutput( 0 ) ),
- m_StopAtOneFront( false )
-{
-}
-
-// -------------------------------------------------------------------------
-template < class _TFilter, class _TVertex, class _TOutput >
-fpa::Base::Algorithm< _TFilter, _TVertex, _TOutput >::
-~Algorithm( )
-{
-}
-
-// -------------------------------------------------------------------------
-template < class _TFilter, class _TVertex, class _TOutput >
-void fpa::Base::Algorithm< _TFilter, _TVertex, _TOutput >::
-GenerateData( )
-{
- this->InvokeEvent( TStartEvent( ) );
- this->_BeforeGenerateData( );
- this->m_NumberOfFronts = this->m_Seeds.size( );
- if( this->m_NumberOfFronts > 0 )
- {
- // Prepare collisions
- TCollision coll( TVertex( ), false );
- TCollisionsRow row( this->m_NumberOfFronts, coll );
- this->m_Collisions.clear( );
- this->m_Collisions.resize( this->m_NumberOfFronts, row );
-
- // Put seeds on queue
- this->_QueueClear( );
- for(
- auto nIt = this->m_Seeds.begin( );
- nIt != this->m_Seeds.end( );
- ++nIt
- )
- this->_QueuePush( *nIt );
-
- // Init marks and results
- this->_InitMarks( );
- this->_InitResults( this->m_InitResult );
-
- // Main loop
- do
- this->_Loop( );
- while( this->_ContinueGenerateData( ) );
-
- } // fi
- this->_AfterGenerateData( );
- this->InvokeEvent( TEndEvent( ) );
-}
-
-// -------------------------------------------------------------------------
-template < class _TFilter, class _TVertex, class _TOutput >
-bool fpa::Base::Algorithm< _TFilter, _TVertex, _TOutput >::
-_ContinueGenerateData( )
-{
- return( false );
-}
-
-// -------------------------------------------------------------------------
-template < class _TFilter, class _TVertex, class _TOutput >
-void fpa::Base::Algorithm< _TFilter, _TVertex, _TOutput >::
-_Loop( )
-{
- this->InvokeEvent( TStartLoopEvent( ) );
- this->_BeforeLoop( );
- while( this->_ValidLoop( ) )
- {
- _TQueueNode node = this->_QueuePop( );
- this->InvokeEvent( TPopEvent( node.Vertex, node.FrontId ) );
-
- // Process actual vertex
- if( this->_IsMarked( node.Vertex ) )
- continue;
- this->_Mark( node );
- this->_UpdateResult( node );
- this->InvokeEvent( TMarkEvent( node.Vertex, node.FrontId ) );
-
- // Add neighbors to queue
- TNeighborhood neighs = this->m_NeighborhoodFunction->Evaluate( node.Vertex );
- for( auto it = neighs.begin( ); it != neighs.end( ); ++it )
- {
- if( !( this->_IsMarked( *it ) ) )
- {
- _TQueueNode neigh( *it, node );
- if( this->_UpdateValue( neigh, node ) )
- {
- this->_QueuePush( neigh );
- this->InvokeEvent( TPushEvent( node.Vertex, node.FrontId ) );
-
- } // fi
- }
- else
- this->_UpdateCollisions( node.Vertex, *it );
-
- } // rof
-
- } // elihw
- this->_AfterLoop( );
- this->InvokeEvent( TEndLoopEvent( ) );
-}
-
-// -------------------------------------------------------------------------
-template < class _TFilter, class _TVertex, class _TOutput >
-void fpa::Base::Algorithm< _TFilter, _TVertex, _TOutput >::
-_BeforeGenerateData( )
-{
-}
-
-// -------------------------------------------------------------------------
-template < class _TFilter, class _TVertex, class _TOutput >
-void fpa::Base::Algorithm< _TFilter, _TVertex, _TOutput >::
-_AfterGenerateData( )
-{
-}
-
-// -------------------------------------------------------------------------
-template < class _TFilter, class _TVertex, class _TOutput >
-void fpa::Base::Algorithm< _TFilter, _TVertex, _TOutput >::
-_BeforeLoop( )
-{
-}
-
-// -------------------------------------------------------------------------
-template < class _TFilter, class _TVertex, class _TOutput >
-void fpa::Base::Algorithm< _TFilter, _TVertex, _TOutput >::
-_AfterLoop( )
-{
-}
-
-// -------------------------------------------------------------------------
-template < class _TFilter, class _TVertex, class _TOutput >
-bool fpa::Base::Algorithm< _TFilter, _TVertex, _TOutput >::
-_ValidLoop( ) const
-{
- bool r = ( this->_QueueSize( ) > 0 );
- if( this->m_StopAtOneFront )
- r &= ( this->m_NumberOfFronts > 0 );
- return( r );
-}
-
-// -------------------------------------------------------------------------
-template < class _TFilter, class _TVertex, class _TOutput >
-void fpa::Base::Algorithm< _TFilter, _TVertex, _TOutput >::
-_UpdateCollisions( const TVertex& a, const TVertex& b )
-{
- auto ma = this->_GetMark( a );
- auto mb = this->_GetMark( b );
- if( ma == mb || ma == 0 || mb == 0 )
- return;
-
- // Mark collision, if it is new
- ma--; mb--;
- bool ret = false;
- bool exists = this->m_Collisions[ ma ][ mb ].second;
- exists &= this->m_Collisions[ mb ][ ma ].second;
- if( !exists )
- {
- this->m_Collisions[ ma ][ mb ].first = a;
- this->m_Collisions[ ma ][ mb ].second = true;
- this->m_Collisions[ mb ][ ma ].first = b;
- this->m_Collisions[ mb ][ ma ].second = true;
-
- // Update number of fronts
- unsigned long N = this->m_Seeds.size( );
- 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
- this->m_NumberOfFronts = N - count;
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-template < class _TFilter, class _TVertex, class _TOutput >
-_TOutput fpa::Base::Algorithm< _TFilter, _TVertex, _TOutput >::
-_GetInputValue( const _TQueueNode& v, const _TQueueNode& p )
-{
- _TOutput res = this->m_InitResult;
- if( this->m_VertexFunction.IsNotNull( ) )
- res = this->m_VertexFunction->Evaluate( v.Vertex, p.Vertex );
- if( this->m_ConversionFunction.IsNotNull( ) )
- res = this->m_ConversionFunction->Evaluate( res );
- return( res );
-}
-
-#endif // __fpa__Base__Algorithm__hxx__
-
-// eof - $RCSfile$
+++ /dev/null
-#ifndef __fpa__Base__Dijkstra__h__
-#define __fpa__Base__Dijkstra__h__
-
-#include <fpa/Base/PriorityQueueAlgorithm.h>
-
-namespace fpa
-{
- namespace Base
- {
- /**
- */
- template< class _TSuperclass, class _TMST >
- class Dijkstra
- : public fpa::Base::PriorityQueueAlgorithm< _TSuperclass >
- {
- public:
- typedef Dijkstra Self;
- typedef fpa::Base::PriorityQueueAlgorithm< _TSuperclass > Superclass;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
-
- typedef _TMST TMST;
- typedef typename Superclass::TOutput TOutput;
- typedef typename Superclass::TVertex TVertex;
-
- protected:
- typedef typename Superclass::_TQueueNode _TQueueNode;
-
- public:
- itkTypeMacro( Dijkstra, Algorithm );
-
- public:
- _TMST* GetMinimumSpanningTree( );
- const _TMST* GetMinimumSpanningTree( ) const;
-
- protected:
- Dijkstra( );
- virtual ~Dijkstra( );
-
- virtual void _AfterGenerateData( ) override;
-
- virtual void _UpdateResult( const _TQueueNode& n ) override;
- virtual bool _UpdateValue(
- _TQueueNode& v, const _TQueueNode& p
- ) override;
-
- private:
- // Purposely not defined
- Dijkstra( const Self& other );
- Self& operator=( const Self& other );
-
- protected:
- unsigned long m_MSTIndex;
- };
-
- } // ecapseman
-
-} // ecapseman
-
-#ifndef ITK_MANUAL_INSTANTIATION
-# include <fpa/Base/Dijkstra.hxx>
-#endif // ITK_MANUAL_INSTANTIATION
-
-#endif // __fpa__Base__Dijkstra__h__
-
-// eof - $RCSfile$
+++ /dev/null
-#ifndef __fpa__Base__Dijkstra__hxx__
-#define __fpa__Base__Dijkstra__hxx__
-
-#include <algorithm>
-#include <limits>
-
-// -------------------------------------------------------------------------
-template< class _TSuperclass, class _TMST >
-_TMST* fpa::Base::Dijkstra< _TSuperclass, _TMST >::
-GetMinimumSpanningTree( )
-{
- return(
- dynamic_cast< _TMST* >(
- this->itk::ProcessObject::GetOutput( this->m_MSTIndex )
- )
- );
-}
-
-// -------------------------------------------------------------------------
-template< class _TSuperclass, class _TMST >
-const _TMST* fpa::Base::Dijkstra< _TSuperclass, _TMST >::
-GetMinimumSpanningTree( ) const
-{
- return(
- dynamic_cast< const _TMST* >(
- this->itk::ProcessObject::GetOutput( this->m_MSTIndex )
- )
- );
-}
-
-// -------------------------------------------------------------------------
-template< class _TSuperclass, class _TMST >
-fpa::Base::Dijkstra< _TSuperclass, _TMST >::
-Dijkstra( )
- : Superclass( )
-{
- this->m_InitResult = TOutput( 0 );
- this->m_MSTIndex = this->GetNumberOfRequiredOutputs( );
- this->SetNumberOfRequiredOutputs( this->m_MSTIndex + 1 );
- this->itk::ProcessObject::SetNthOutput( this->m_MSTIndex, _TMST::New( ) );
-}
-
-// -------------------------------------------------------------------------
-template< class _TSuperclass, class _TMST >
-fpa::Base::Dijkstra< _TSuperclass, _TMST >::
-~Dijkstra( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TSuperclass, class _TMST >
-void fpa::Base::Dijkstra< _TSuperclass, _TMST >::
-_AfterGenerateData( )
-{
- this->Superclass::_AfterGenerateData( );
-
- auto mst = this->GetMinimumSpanningTree( );
- mst->ClearSeeds( );
- for( auto s = this->m_Seeds.begin( ); s != this->m_Seeds.end( ); ++s )
- mst->AddSeed( s->Vertex );
- mst->SetCollisions( this->m_Collisions );
-}
-
-// -------------------------------------------------------------------------
-template< class _TSuperclass, class _TMST >
-void fpa::Base::Dijkstra< _TSuperclass, _TMST >::
-_UpdateResult( const _TQueueNode& n )
-{
- this->Superclass::_UpdateResult( n );
- this->GetMinimumSpanningTree( )->SetParent( n.Vertex, n.Parent );
-}
-
-// -------------------------------------------------------------------------
-template< class _TSuperclass, class _TMST >
-bool fpa::Base::Dijkstra< _TSuperclass, _TMST >::
-_UpdateValue( _TQueueNode& v, const _TQueueNode& p )
-{
- v.Result = this->_GetInputValue( p.Vertex, v.Vertex );
- if( v.Result >= TOutput( 0 ) )
- {
- v.Result += p.Result;
- return( true );
- }
- else
- {
- v.Result = this->m_InitResult;
- return( false );
-
- } // fi
-}
-
-#endif // __fpa__Base__Dijkstra__hxx__
-
-// eof - $RCSfile$
+++ /dev/null
-#ifndef __fpa__Base__Events__h__
-#define __fpa__Base__Events__h__
-
-// -------------------------------------------------------------------------
-#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 _TVertex >
- class BaseEventWithVertex
- : public BaseEvent
- {
- public:
- BaseEventWithVertex( )
- : BaseEvent( )
- { }
- BaseEventWithVertex( const _TVertex& 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< _TVertex >* >( e ) != NULL
- );
- }
- itk::EventObject* MakeObject( ) const
- { return( new BaseEventWithVertex< _TVertex >( ) ); }
-
- public:
- _TVertex Vertex;
- long FrontId;
- };
-
- } // ecapseman
-
-} // ecapseman
-
-#endif // __fpa__Base__Events__h__
-
-// eof - $RCSfile$
+++ /dev/null
-#ifndef __fpa__Base__FastMarching__h__
-#define __fpa__Base__FastMarching__h__
-
-#include <fpa/Base/PriorityQueueAlgorithm.h>
-
-namespace fpa
-{
- namespace Base
- {
- /**
- */
- template< class _TSuperclass >
- class FastMarching
- : public fpa::Base::PriorityQueueAlgorithm< _TSuperclass >
- {
- public:
- typedef FastMarching Self;
- typedef fpa::Base::PriorityQueueAlgorithm< _TSuperclass > Superclass;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
-
- typedef typename Superclass::TFrontId TFrontId;
- typedef typename Superclass::TOutput TOutput;
- typedef typename Superclass::TVertex TVertex;
-
- typedef std::pair< TVertex, double > TFastMarchingNeighbor;
- typedef std::vector< TFastMarchingNeighbor > TFastMarchingNeighborhood;
-
- protected:
- typedef typename Superclass::_TQueueNode _TQueueNode;
-
- public:
- itkTypeMacro( FastMarching, Algorithm );
-
- protected:
- FastMarching( );
- virtual ~FastMarching( );
-
- virtual TFastMarchingNeighborhood _FastMarchingNeighbors( const TVertex& v ) const = 0;
-
- virtual bool _UpdateValue( _TQueueNode& v, const _TQueueNode& p ) override;
-
- private:
- // Purposely not defined
- FastMarching( const Self& other );
- Self& operator=( const Self& other );
- };
-
- } // ecapseman
-
-} // ecapseman
-
-#ifndef ITK_MANUAL_INSTANTIATION
-# include <fpa/Base/FastMarching.hxx>
-#endif // ITK_MANUAL_INSTANTIATION
-
-#endif // __fpa__Base__FastMarching__h__
-
-// eof - $RCSfile$
+++ /dev/null
-#ifndef __fpa__Base__FastMarching__hxx__
-#define __fpa__Base__FastMarching__hxx__
-
-// -------------------------------------------------------------------------
-template< class _TSuperclass >
-fpa::Base::FastMarching< _TSuperclass >::
-FastMarching( )
- : Superclass( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TSuperclass >
-fpa::Base::FastMarching< _TSuperclass >::
-~FastMarching( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TSuperclass >
-bool fpa::Base::FastMarching< _TSuperclass >::
-_UpdateValue( _TQueueNode& v, const _TQueueNode& p )
-{
- // Compute quadratic coefficients
- double a = double( 0 );
- double b = double( 0 );
- double c = double( 0 );
- TFastMarchingNeighborhood neighs = this->_FastMarchingNeighbors( v.Vertex );
- for( unsigned int i = 0; i < neighs.size( ); i += 2 )
- {
- double tn = double( this->_GetResult( neighs[ i ].first ) );
- double tp = double( this->_GetResult( neighs[ i + 1 ].first ) );
- double dd = double( 0 );
- double td = this->m_InitResult;
- if( tn < tp )
- {
- td = tn;
- dd = neighs[ i ].second;
- }
- else
- {
- td = tp;
- dd = neighs[ i + 1 ].second;
-
- } // fi
-
- if( td < double( this->m_InitResult ) )
- {
- dd = double( 1 ) / ( dd * dd );
- a += dd;
- b += td * dd;
- c += td * td * dd;
-
- } // fi
-
- } // rof
- double F = double( this->_GetInputValue( v, p ) );
- c -= double( 1 ) / ( F * F );
-
- // Solve quadratic equation
- double d = ( b * b ) - ( a * c );
- if( d >= double( 0 ) )
- {
- d = std::sqrt( d );
- b *= double( -1 );
- double s1 = std::fabs( ( b + d ) / a );
- double s2 = std::fabs( ( b - d ) / a );
- v.Result = TOutput( ( s2 < s1 )? s1: s2 );
- if( v.Result < this->_GetResult( v.Vertex ) )
- this->_UpdateResult( v );
- }
- else
- {
- std::cout << std::endl << "-- FM --> " << v.Vertex << " " << d << std::endl;
- std::exit( 1 );
- }
- return( true );
-}
-
-#endif // __fpa__Base__FastMarching__hxx__
-
-// eof - $RCSfile$
+++ /dev/null
-#ifndef __fpa__Base__Functors__GaussianModel__h__
-#define __fpa__Base__Functors__GaussianModel__h__
-
-#include <fpa/Config.h>
-#include <itkFunctionBase.h>
-#include <cpExtensions/Algorithms/IterativeGaussianModelEstimator.h>
-
-namespace fpa
-{
- namespace Base
- {
- namespace Functors
- {
- /**
- */
- template< class _TInput, class _TOutput >
- class GaussianModel
- : public itk::FunctionBase< _TInput, _TOutput >
- {
- public:
- typedef GaussianModel Self;
- typedef itk::FunctionBase< _TInput, _TOutput > Superclass;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
-
- typedef _TInput TInput;
- typedef _TOutput TOutput;
-
- // Model estimator
- typedef
- cpExtensions::Algorithms::IterativeGaussianModelEstimator< TOutput, 1 >
- TModel;
-
- public:
- itkNewMacro( Self );
- itkTypeMacro( GaussianModel, itk::FunctionBase );
-
- /* TODO
- itkGetConstMacro( SupportSize, unsigned int );
- itkGetConstMacro( MinimumCost, TOutput );
- itkGetObjectMacro( Model, TModel );
- itkGetConstObjectMacro( Model, TModel );
- itkSetMacro( SupportSize, unsigned int );
- itkSetMacro( MinimumCost, TOutput );
- */
-
- public:
- virtual TOutput Evaluate( const TInput& x ) const override;
-
- protected:
- GaussianModel( );
- virtual ~GaussianModel( );
-
- private:
- // Purposely not implemented
- GaussianModel( const Self& other );
- Self& operator=( const Self& other );
-
- protected:
- /* TODO
- unsigned int m_SupportSize;
- TOutput m_MinimumCost;
- typename TModel::Pointer m_Model;
- */
- mutable double m_S1;
- mutable double m_S2;
- mutable unsigned long m_N;
- };
-
- } // ecapseman
-
- } // ecapseman
-
-} // ecapseman
-
-#ifndef ITK_MANUAL_INSTANTIATION
-# include <fpa/Base/Functors/GaussianModel.hxx>
-#endif // ITK_MANUAL_INSTANTIATION
-
-#endif // __fpa__Base__Functors__GaussianModel__h__
-
-// eof - $RCSfile$
+++ /dev/null
-#ifndef __fpa__Base__Functors__GaussianModel__hxx__
-#define __fpa__Base__Functors__GaussianModel__hxx__
-
-// -------------------------------------------------------------------------
-template< class _TInput, class _TOutput >
-typename fpa::Base::Functors::GaussianModel< _TInput, _TOutput >::
-TOutput fpa::Base::Functors::GaussianModel< _TInput, _TOutput >::
-Evaluate( const TInput& x ) const
-{
- double v = double( x );
- double d = double( 0 );
- if( this->m_N > 1 )
- {
- double N = double( this->m_N );
- double m = this->m_S1 / N;
- double s =
- ( this->m_S2 - ( ( this->m_S1 * this->m_S1 ) / N ) ) /
- ( N - double( 1 ) );
- if( s > double( 0 ) )
- {
- d = ( v - m );
- d *= d;
- d /= s;
- d = std::sqrt( d );
- if( d <= double( 1.5 ) ) // 2sigma
- {
- this->m_S1 += v;
- this->m_S2 += v * v;
- this->m_N += 1;
-
- } // fi
- }
- else
- {
- this->m_S1 += v;
- this->m_S2 += v * v;
- this->m_N += 1;
-
- } // fi
- }
- else
- {
- this->m_S1 += v;
- this->m_S2 += v * v;
- this->m_N += 1;
-
- } // fi
- return( d );
-
- /* TODO
- TOutput r = TOutput( 0 );
- if( this->m_Model->GetNumberOfSamples( ) > this->m_SupportSize )
- {
- r = this->m_Model->SquaredMahalanobis( TOutput( x ) );
- if( r <= TOutput( 1 ) )
- this->m_Model->AddSample( TOutput( x ) );
- }
- else
- {
- this->m_Model->AddSample( TOutput( x ) );
- if( this->m_Model->GetNumberOfSamples( ) > 2 )
- r = this->m_Model->SquaredMahalanobis( TOutput( x ) );
-
- } // fi
- if( r < this->m_MinimumCost )
- return( this->m_MinimumCost );
- else
- return( r );
- */
-}
-
-// -------------------------------------------------------------------------
-template< class _TInput, class _TOutput >
-fpa::Base::Functors::GaussianModel< _TInput, _TOutput >::
-GaussianModel( )
- : Superclass( )
- /* TODO
- ,
- m_SupportSize( 30 ),
- m_MinimumCost( TOutput( 1e-10 ) )
- */
-{
- /* TODO
- this->m_Model = TModel::New( );
- */
- this->m_S1 = double( 0 );
- this->m_S2 = double( 0 );
- this->m_N = 0;
-}
-
-// -------------------------------------------------------------------------
-template< class _TInput, class _TOutput >
-fpa::Base::Functors::GaussianModel< _TInput, _TOutput >::
-~GaussianModel( )
-{
-}
-
-#endif // __fpa__Base__Functors__GaussianModel__hxx__
-
-// eof - $RCSfile$
+++ /dev/null
-#ifndef __fpa__Base__Functors__Inverse__h__
-#define __fpa__Base__Functors__Inverse__h__
-
-#include <fpa/Config.h>
-#include <itkFunctionBase.h>
-
-namespace fpa
-{
- namespace Base
- {
- namespace Functors
- {
- /**
- */
- template< class _TInput, class _TOutput >
- class Inverse
- : public itk::FunctionBase< _TInput, _TOutput >
- {
- public:
- typedef Inverse Self;
- typedef itk::FunctionBase< _TInput, _TOutput > Superclass;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
-
- typedef _TInput TInput;
- typedef _TOutput TOutput;
-
- public:
- itkNewMacro( Self );
- itkTypeMacro( Inverse, itk::FunctionBase );
-
- itkGetConstMacro( NegativeValue, _TOutput );
- itkSetMacro( NegativeValue, _TOutput );
-
- public:
- virtual TOutput Evaluate( const TInput& x ) const override;
-
- protected:
- Inverse( );
- virtual ~Inverse( );
-
- private:
- // Purposely not implemented
- Inverse( const Self& other );
- Self& operator=( const Self& other );
-
- protected:
- _TOutput m_NegativeValue;
- };
-
- } // ecapseman
-
- } // ecapseman
-
-} // ecapseman
-
-#ifndef ITK_MANUAL_INSTANTIATION
-# include <fpa/Base/Functors/Inverse.hxx>
-#endif // ITK_MANUAL_INSTANTIATION
-
-#endif // __fpa__Base__Functors__Inverse__h__
-
-// eof - $RCSfile$
+++ /dev/null
-#ifndef __fpa__Base__Functors__Inverse__hxx__
-#define __fpa__Base__Functors__Inverse__hxx__
-
-// -------------------------------------------------------------------------
-template< class _TInput, class _TOutput >
-typename fpa::Base::Functors::Inverse< _TInput, _TOutput >::
-TOutput fpa::Base::Functors::Inverse< _TInput, _TOutput >::
-Evaluate( const TInput& x ) const
-{
- TInput sign = TInput( ( x < TInput( 0 ) )? -1: 1 );
- TOutput y = TOutput( 1 ) / ( TOutput( 1 ) + TOutput( x * sign ) );
- if( sign < TInput( 0 ) )
- return( y * this->m_NegativeValue );
- else
- return( y );
-}
-
-// -------------------------------------------------------------------------
-template< class _TInput, class _TOutput >
-fpa::Base::Functors::Inverse< _TInput, _TOutput >::
-Inverse( )
- : Superclass( ),
- m_NegativeValue( _TOutput( -1 ) )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TInput, class _TOutput >
-fpa::Base::Functors::Inverse< _TInput, _TOutput >::
-~Inverse( )
-{
-}
-
-#endif // __fpa__Base__Functors__Inverse__hxx__
-
-// eof - $RCSfile$
+++ /dev/null
-#ifndef __fpa__Base__Functors__RegionGrow__Base__h__
-#define __fpa__Base__Functors__RegionGrow__Base__h__
-
-#include <itkObject.h>
-#include <itkObjectFactory.h>
-#include <fpa/Base/Functors/VertexCostFunctionBase.h>
-
-namespace fpa
-{
- namespace Base
- {
- namespace Functors
- {
- namespace RegionGrow
- {
- /**
- */
- template< class _TVertex, class _TOutput >
- class Base
- : public fpa::Base::Functors::VertexCostFunctionBase< _TVertex, _TOutput >
- {
- public:
- typedef fpa::Base::Functors::VertexCostFunctionBase< _TVertex, _TOutput > Superclass;
- typedef Base Self;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
-
- typedef _TVertex TVertex;
- typedef _TOutput TOutput;
-
- public:
- itkTypeMacro( Base, itk::Object );
-
- itkGetConstMacro( InsideValue, _TOutput );
- itkGetConstMacro( OutsideValue, _TOutput );
-
- itkSetMacro( InsideValue, _TOutput );
- itkSetMacro( OutsideValue, _TOutput );
-
- public:
- virtual TOutput Evaluate( const TVertex& a, const TVertex& b ) const = 0;
-
- protected:
- Base( )
- : Superclass( ),
- m_InsideValue( TOutput( 1 ) ),
- m_OutsideValue( TOutput( 0 ) )
- { }
- virtual ~Base( )
- { }
-
- private:
- // Purposely not defined
- Base( const Self& other );
- Self& operator=( const Self& other );
-
- protected:
- _TOutput m_InsideValue;
- _TOutput m_OutsideValue;
- };
-
- } // ecapseman
-
- } // ecapseman
-
- } // ecapseman
-
-} // ecapseman
-
-#endif // __fpa__Base__Functors__RegionGrow__Base__h__
-
-// eof - $RCSfile$
+++ /dev/null
-#ifndef __fpa__Base__Functors__RegionGrow__Tautology__h__
-#define __fpa__Base__Functors__RegionGrow__Tautology__h__
-
-#include <fpa/Base/Functors/RegionGrow/Base.h>
-
-namespace fpa
-{
- namespace Base
- {
- namespace Functors
- {
- namespace RegionGrow
- {
- /**
- */
- template< class _TVertex, class _TOutput >
- class Tautology
- : public Base< _TVertex, _TOutput >
- {
- public:
- typedef Tautology Self;
- typedef Base< _TVertex, _TOutput > Superclass;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
-
- typedef typename Superclass::TOutput TOutput;
- typedef typename Superclass::TVertex TVertex;
-
- public:
- itkNewMacro( Self );
- itkTypeMacro( Tautology, Base );
-
- public:
- virtual TOutput Evaluate( const TVertex& a, const TVertex& b ) const override
- {
- return( this->m_InsideValue );
- }
-
- protected:
- Tautology( )
- : Superclass( )
- { }
- virtual ~Tautology( )
- { }
-
- private:
- // Purposely not defined
- Tautology( const Self& other );
- Self& operator=( const Self& other );
- };
-
- } // ecapseman
-
- } // ecapseman
-
- } // ecapseman
-
-} // ecapseman
-
-#endif // __fpa__Base__Functors__RegionGrow__Tautology__h__
-
-// eof - $RCSfile$
+++ /dev/null
-#ifndef __fpa__Base__Functors__VertexCostFunctionBase__h__
-#define __fpa__Base__Functors__VertexCostFunctionBase__h__
-
-#include <itkObject.h>
-#include <itkObjectFactory.h>
-
-namespace fpa
-{
- namespace Base
- {
- namespace Functors
- {
- /**
- */
- template< class _TVertex, class _TOutput >
- class VertexCostFunctionBase
- : public itk::Object
- {
- public:
- typedef VertexCostFunctionBase Self;
- typedef itk::Object Superclass;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
-
- typedef _TVertex TVertex;
- typedef _TOutput TOutput;
-
- public:
- itkTypeMacro( VertexCostFunctionBase, itk::Object );
-
- public:
- virtual TOutput Evaluate( const TVertex& a, const TVertex& b ) const = 0;
-
- protected:
- VertexCostFunctionBase( )
- : Superclass( )
- { }
- virtual ~VertexCostFunctionBase( )
- { }
-
- private:
- // Purposely not defined
- VertexCostFunctionBase( const Self& other );
- Self& operator=( const Self& other );
- };
-
- } // ecapseman
-
- } // ecapseman
-
-} // ecapseman
-
-#endif // __fpa__Base__Functors__VertexCostFunctionBase__h__
-
-// eof - $RCSfile$
+++ /dev/null
-#ifndef __fpa__Base__MinimumSpanningTree__h__
-#define __fpa__Base__MinimumSpanningTree__h__
-
-#include <fpa/Config.h>
-#include <vector>
-#include <utility>
-#include <itkObject.h>
-
-namespace fpa
-{
- namespace Base
- {
- /**
- */
- template< class _TVertex, class _TPath, class _TSuperclass >
- 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 _TPath TPath;
- typedef std::pair< _TVertex, bool > TCollision;
- typedef std::vector< TCollision > TCollisionsRow;
- typedef std::vector< TCollisionsRow > TCollisions;
-
- protected:
- typedef std::vector< unsigned long > _TRow;
- typedef std::vector< _TRow > _TMatrix;
-
- public:
- itkTypeMacro( MinimumSpanningTree, _TSuperclass );
-
- public:
- const TCollisions& GetCollisions( ) const;
- void SetCollisions( const TCollisions& collisions );
-
- void ClearSeeds( );
- void AddSeed( const _TVertex& seed );
-
- virtual _TVertex GetParent( const _TVertex& v ) const = 0;
- virtual void SetParent( const _TVertex& v, const _TVertex& p ) = 0;
-
- virtual void GetPath(
- typename _TPath::Pointer& path, const _TVertex& a
- ) const;
- virtual void GetPath(
- typename _TPath::Pointer& path, const _TVertex& a, const _TVertex& b
- ) const;
-
- protected:
- MinimumSpanningTree( );
- virtual ~MinimumSpanningTree( );
-
- private:
- // Purposely not defined
- MinimumSpanningTree( const Self& other );
- Self& operator=( const Self& other );
-
- protected:
- TCollisions m_Collisions;
- _TMatrix m_FrontPaths;
- std::vector< _TVertex > m_Seeds;
- };
-
- } // ecapseman
-
-} // ecapseman
-
-#ifndef ITK_MANUAL_INSTANTIATION
-# include <fpa/Base/MinimumSpanningTree.hxx>
-#endif // ITK_MANUAL_INSTANTIATION
-
-#endif // __fpa__Base__MinimumSpanningTree__h__
-
-// eof - $RCSfile$
+++ /dev/null
-#ifndef __fpa__Base__MinimumSpanningTree__hxx__
-#define __fpa__Base__MinimumSpanningTree__hxx__
-
-#include <limits>
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _TPath, class _TSuperclass >
-const typename
-fpa::Base::MinimumSpanningTree< _TVertex, _TPath, _TSuperclass >::
-TCollisions&
-fpa::Base::MinimumSpanningTree< _TVertex, _TPath, _TSuperclass >::
-GetCollisions( ) const
-{
- return( this->m_Collisions );
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _TPath, class _TSuperclass >
-void fpa::Base::MinimumSpanningTree< _TVertex, _TPath, _TSuperclass >::
-SetCollisions( const TCollisions& collisions )
-{
- static const unsigned long _inf =
- std::numeric_limits< unsigned long >::max( );
- if( this->m_Collisions == collisions )
- return;
-
- this->m_Collisions = collisions;
-
- // Prepare a front graph
- unsigned long N = this->m_Collisions.size( );
- _TMatrix dist( N, _TRow( N, _inf ) );
- this->m_FrontPaths = dist;
- for( unsigned long i = 0; i < N; ++i )
- {
- for( unsigned long j = 0; j < N; ++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 between fronts
- for( unsigned long k = 0; k < N; ++k )
- {
- for( unsigned long i = 0; i < N; ++i )
- {
- for( unsigned long j = 0; j < N; ++j )
- {
- // WARNING: you don't want a numeric overflow!!!
- unsigned long dik = dist[ i ][ k ];
- unsigned long dkj = dist[ k ][ j ];
- unsigned long sum = _inf;
- if( dik < _inf && dkj < _inf )
- sum = dik + dkj;
-
- // Ok, continue Floyd-Warshall
- if( sum < dist[ i ][ j ] )
- {
- dist[ i ][ j ] = sum;
- this->m_FrontPaths[ i ][ j ] = this->m_FrontPaths[ i ][ k ];
-
- } // fi
-
- } // rof
-
- } // rof
-
- } // rof
- this->Modified( );
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _TPath, class _TSuperclass >
-void fpa::Base::MinimumSpanningTree< _TVertex, _TPath, _TSuperclass >::
-ClearSeeds( )
-{
- this->m_Seeds.clear( );
- this->Modified( );
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _TPath, class _TSuperclass >
-void fpa::Base::MinimumSpanningTree< _TVertex, _TPath, _TSuperclass >::
-AddSeed( const _TVertex& seed )
-{
- this->m_Seeds.push_back( seed );
- this->Modified( );
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _TPath, class _TSuperclass >
-void fpa::Base::MinimumSpanningTree< _TVertex, _TPath, _TSuperclass >::
-GetPath( typename _TPath::Pointer& path, const _TVertex& a ) const
-{
- std::vector< _TVertex > vertices;
- _TVertex it = a;
- _TVertex p = this->GetParent( it );
- while( it != p )
- {
- vertices.push_back( it );
- it = p;
- p = this->GetParent( it );
-
- } // elihw
- vertices.push_back( it );
-
- if( path.IsNull( ) )
- path = _TPath::New( );
- for( auto v = vertices.begin( ); v != vertices.end( ); ++v )
- path->AddVertex( *v );
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _TPath, class _TSuperclass >
-void fpa::Base::MinimumSpanningTree< _TVertex, _TPath, _TSuperclass >::
-GetPath(
- typename _TPath::Pointer& path, const _TVertex& a, const _TVertex& b
- ) const
-{
- static const unsigned long _inf =
- std::numeric_limits< unsigned long >::max( );
-
- if( path.IsNull( ) )
- path = _TPath::New( );
- typename _TPath::Pointer pa, pb;
- this->GetPath( pa, a );
- this->GetPath( pb, b );
- if( pa->GetSize( ) > 0 && pb->GetSize( ) > 0 )
- {
- // Find front identifiers
- unsigned long ia = _inf, ib = _inf;
- unsigned long N = this->m_Seeds.size( );
- for( unsigned long i = 0; i < N; ++i )
- {
- if( this->m_Seeds[ i ] == pa->GetVertex( pa->GetSize( ) - 1 ) )
- ia = i;
- if( this->m_Seeds[ i ] == pb->GetVertex( pb->GetSize( ) - 1 ) )
- ib = i;
-
- } // rof
-
- // Check if there is a front-jump between given seeds
- if( ia != ib )
- {
- // Compute front path
- std::vector< long > fpath;
- fpath.push_back( ia );
- while( ia != ib )
- {
- ia = this->m_FrontPaths[ ia ][ ib ];
- fpath.push_back( ia );
-
- } // elihw
-
- // Continue only if both fronts are connected
- unsigned int N = fpath.size( );
- if( N > 0 )
- {
- // First path: from start vertex to first collision
- this->GetPath(
- path, a,
- this->m_Collisions[ fpath[ 0 ] ][ fpath[ 1 ] ].first
- );
-
- // Intermediary paths
- for( unsigned int i = 1; i < N - 1; ++i )
- {
- typename _TPath::Pointer ipath;
- this->GetPath(
- ipath,
- this->m_Collisions[ fpath[ i ] ][ fpath[ i - 1 ] ].first,
- this->m_Collisions[ fpath[ i ] ][ fpath[ i + 1 ] ].first
- );
- for( long id = 0; id < ipath->GetSize( ); ++id )
- path->AddVertex( ipath->GetVertex( id ) );
-
- } // rof
-
- // Final path: from last collision to end point
- typename _TPath::Pointer lpath;
- this->GetPath(
- lpath,
- this->m_Collisions[ fpath[ N - 1 ] ][ fpath[ N - 2 ] ].first, b
- );
- for( long id = 0; id < lpath->GetSize( ); ++id )
- path->AddVertex( lpath->GetVertex( id ) );
-
- } // fi
- }
- else
- {
- // Ignore common part: find common ancestor
- long aIt = pa->GetSize( ) - 1;
- long bIt = pb->GetSize( ) - 1;
- bool cont = true;
- while( aIt >= 0 && bIt >= 0 && cont )
- {
- cont = ( pa->GetVertex( aIt ) == pb->GetVertex( bIt ) );
- aIt--;
- bIt--;
-
- } // elihw
- aIt++;
- bIt++;
-
- // Glue both parts
- for( long cIt = 0; cIt <= aIt; ++cIt )
- path->AddVertex( pa->GetVertex( cIt ) );
- for( ; bIt >= 0; --bIt )
- path->AddVertex( pb->GetVertex( bIt ) );
-
- } // fi
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _TPath, class _TSuperclass >
-fpa::Base::MinimumSpanningTree< _TVertex, _TPath, _TSuperclass >::
-MinimumSpanningTree( )
- : Superclass( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _TPath, class _TSuperclass >
-fpa::Base::MinimumSpanningTree< _TVertex, _TPath, _TSuperclass >::
-~MinimumSpanningTree( )
-{
-}
-
-#endif // __fpa__Base__MinimumSpanningTree__hxx__
-
-// eof - $RCSfile$
+++ /dev/null
-#ifndef __fpa__Base__PriorityQueueAlgorithm__h__
-#define __fpa__Base__PriorityQueueAlgorithm__h__
-
-#include <queue>
-
-namespace fpa
-{
- namespace Base
- {
- /**
- */
- template< class _TSuperclass >
- class PriorityQueueAlgorithm
- : public _TSuperclass
- {
- public:
- typedef PriorityQueueAlgorithm Self;
- typedef _TSuperclass Superclass;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
-
- protected:
- typedef typename Superclass::_TQueueNode _TQueueNode;
- struct _TQueueNodeCompare
- {
- bool operator( )( const _TQueueNode& a, const _TQueueNode& b )
- {
- return( b.Result < a.Result );
- }
- };
- typedef std::vector< _TQueueNode > _TQueue;
-
- public:
- itkTypeMacro( PriorityQueueAlgorithm, Algorithm );
-
- protected:
- PriorityQueueAlgorithm( );
- virtual ~PriorityQueueAlgorithm( );
-
- virtual unsigned long _QueueSize( ) const override;
- virtual void _QueueClear( ) override;
- virtual void _QueuePush( const _TQueueNode& node ) override;
- virtual _TQueueNode _QueuePop( ) override;
-
- private:
- // Purposely not defined
- PriorityQueueAlgorithm( const Self& other );
- Self& operator=( const Self& other );
-
- protected:
- _TQueue m_Queue;
- };
-
- } // ecapseman
-
-} // ecapseman
-
-#ifndef ITK_MANUAL_INSTANTIATION
-# include <fpa/Base/PriorityQueueAlgorithm.hxx>
-#endif // ITK_MANUAL_INSTANTIATION
-
-#endif // __fpa__Base__PriorityQueueAlgorithm__h__
-
-// eof - $RCSfile$
+++ /dev/null
-#ifndef __fpa__Base__PriorityQueueAlgorithm__hxx__
-#define __fpa__Base__PriorityQueueAlgorithm__hxx__
-
-// -------------------------------------------------------------------------
-template< class _TSuperclass >
-fpa::Base::PriorityQueueAlgorithm< _TSuperclass >::
-PriorityQueueAlgorithm( )
- : Superclass( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TSuperclass >
-fpa::Base::PriorityQueueAlgorithm< _TSuperclass >::
-~PriorityQueueAlgorithm( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TSuperclass >
-unsigned long fpa::Base::PriorityQueueAlgorithm< _TSuperclass >::
-_QueueSize( ) const
-{
- return( this->m_Queue.size( ) );
-}
-
-// -------------------------------------------------------------------------
-template< class _TSuperclass >
-void fpa::Base::PriorityQueueAlgorithm< _TSuperclass >::
-_QueueClear( )
-{
- this->m_Queue.clear( );
-}
-
-// -------------------------------------------------------------------------
-template< class _TSuperclass >
-void fpa::Base::PriorityQueueAlgorithm< _TSuperclass >::
-_QueuePush( const _TQueueNode& node )
-{
- static _TQueueNodeCompare cmp;
- this->m_Queue.push_back( node );
- std::push_heap( this->m_Queue.begin( ), this->m_Queue.end( ), cmp );
-}
-
-// -------------------------------------------------------------------------
-template< class _TSuperclass >
-typename fpa::Base::PriorityQueueAlgorithm< _TSuperclass >::
-_TQueueNode fpa::Base::PriorityQueueAlgorithm< _TSuperclass >::
-_QueuePop( )
-{
- static _TQueueNodeCompare cmp;
- std::pop_heap( this->m_Queue.begin( ), this->m_Queue.end( ), cmp );
- _TQueueNode f = this->m_Queue.back( );
- this->m_Queue.pop_back( );
- return( f );
-}
-
-#endif // __fpa__Base__PriorityQueueAlgorithm__hxx__
-
-// eof - $RCSfile$
+++ /dev/null
-#ifndef __fpa__Base__QueueAlgorithm__h__
-#define __fpa__Base__QueueAlgorithm__h__
-
-#include <queue>
-#include <itkMacro.h>
-#include <itkSmartPointer.h>
-
-namespace fpa
-{
- namespace Base
- {
- /**
- */
- template< class _TSuperclass >
- class QueueAlgorithm
- : public _TSuperclass
- {
- public:
- typedef QueueAlgorithm Self;
- typedef _TSuperclass Superclass;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
-
- protected:
- typedef typename Superclass::_TQueueNode _TQueueNode;
- typedef std::queue< _TQueueNode > _TQueue;
-
- public:
- itkTypeMacro( QueueAlgorithm, _TSuperclass );
-
- protected:
- QueueAlgorithm( );
- virtual ~QueueAlgorithm( );
-
- virtual unsigned long _QueueSize( ) const override;
- virtual void _QueueClear( ) override;
- virtual void _QueuePush( const _TQueueNode& node ) override;
- virtual _TQueueNode _QueuePop( ) override;
-
- private:
- // Purposely not defined
- QueueAlgorithm( const Self& other );
- Self& operator=( const Self& other );
-
- protected:
- _TQueue m_Queue;
- };
-
- } // ecapseman
-
-} // ecapseman
-
-#ifndef ITK_MANUAL_INSTANTIATION
-# include <fpa/Base/QueueAlgorithm.hxx>
-#endif // ITK_MANUAL_INSTANTIATION
-
-#endif // __fpa__Base__QueueAlgorithm__h__
-
-// eof - $RCSfile$
+++ /dev/null
-#ifndef __fpa__Base__QueueAlgorithm__hxx__
-#define __fpa__Base__QueueAlgorithm__hxx__
-
-// -------------------------------------------------------------------------
-template< class _TSuperclass >
-fpa::Base::QueueAlgorithm< _TSuperclass >::
-QueueAlgorithm( )
- : Superclass( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TSuperclass >
-fpa::Base::QueueAlgorithm< _TSuperclass >::
-~QueueAlgorithm( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TSuperclass >
-unsigned long fpa::Base::QueueAlgorithm< _TSuperclass >::
-_QueueSize( ) const
-{
- return( this->m_Queue.size( ) );
-}
-
-// -------------------------------------------------------------------------
-template< class _TSuperclass >
-void fpa::Base::QueueAlgorithm< _TSuperclass >::
-_QueueClear( )
-{
- while( this->m_Queue.size( ) > 0 )
- this->m_Queue.pop( );
-}
-
-// -------------------------------------------------------------------------
-template< class _TSuperclass >
-void fpa::Base::QueueAlgorithm< _TSuperclass >::
-_QueuePush( const _TQueueNode& node )
-{
- this->m_Queue.push( node );
-}
-
-// -------------------------------------------------------------------------
-template< class _TSuperclass >
-typename fpa::Base::QueueAlgorithm< _TSuperclass >::
-_TQueueNode fpa::Base::QueueAlgorithm< _TSuperclass >::
-_QueuePop( )
-{
- _TQueueNode f = this->m_Queue.front( );
- this->m_Queue.pop( );
- return( f );
-}
-
-#endif // __fpa__Base__QueueAlgorithm__hxx__
-
-// eof - $RCSfile$
+++ /dev/null
-#ifndef __fpa__Base__RegionGrow__h__
-#define __fpa__Base__RegionGrow__h__
-
-#include <queue>
-#include <fpa/Base/QueueAlgorithm.h>
-#include <fpa/Base/Functors/RegionGrow/Base.h>
-
-namespace fpa
-{
- namespace Base
- {
- /**
- */
- template< class _TSuperclass >
- class RegionGrow
- : public fpa::Base::QueueAlgorithm< _TSuperclass >
- {
- public:
- typedef RegionGrow Self;
- typedef fpa::Base::QueueAlgorithm< _TSuperclass > Superclass;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
-
- typedef typename Superclass::TOutput TOutput;
- typedef typename Superclass::TVertex TVertex;
- typedef fpa::Base::Functors::RegionGrow::Base< TVertex, TOutput > TGrowFunction;
-
- protected:
- typedef typename Superclass::_TQueueNode _TQueueNode;
-
- public:
- itkTypeMacro( RegionGrow, Algorithm );
-
- public:
- TGrowFunction* GetGrowFunction( );
- const TGrowFunction* GetGrowFunction( ) const;
- TOutput GetInsideValue( ) const;
- TOutput GetOutsideValue( ) const;
-
- void SetGrowFunction( TGrowFunction* f );
- void SetInsideValue( const TOutput& v );
- void SetOutsideValue( const TOutput& v );
-
- protected:
- RegionGrow( );
- virtual ~RegionGrow( );
-
- virtual bool _UpdateValue(
- _TQueueNode& v, const _TQueueNode& p
- ) override;
- virtual TOutput _GetInputValue( const _TQueueNode& v, const _TQueueNode& p ) override
- {
- TOutput res = this->m_InitResult;
- if( this->m_GrowFunction.IsNotNull( ) )
- res = this->m_GrowFunction->Evaluate( v.Vertex, p.Vertex );
- return( res );
- }
-
-
- private:
- // Purposely not defined
- RegionGrow( const Self& other );
- Self& operator=( const Self& other );
-
- protected:
- typename TGrowFunction::Pointer m_GrowFunction;
- };
-
- } // ecapseman
-
-} // ecapseman
-
-#ifndef ITK_MANUAL_INSTANTIATION
-# include <fpa/Base/RegionGrow.hxx>
-#endif // ITK_MANUAL_INSTANTIATION
-
-#endif // __fpa__Base__RegionGrow__h__
-
-// eof - $RCSfile$
+++ /dev/null
-#ifndef __fpa__Base__RegionGrow__hxx__
-#define __fpa__Base__RegionGrow__hxx__
-
-#include <fpa/Base/Functors/RegionGrow/Tautology.h>
-
-// -------------------------------------------------------------------------
-template< class _TSuperclass >
-typename fpa::Base::RegionGrow< _TSuperclass >::
-TGrowFunction* fpa::Base::RegionGrow< _TSuperclass >::
-GetGrowFunction( )
-{
- // TODO: return( dynamic_cast< TGrowFunction* >( this->GetVertexFunction( ) ) );
- return( this->m_GrowFunction );
-}
-
-// -------------------------------------------------------------------------
-template< class _TSuperclass >
-const typename fpa::Base::RegionGrow< _TSuperclass >::
-TGrowFunction* fpa::Base::RegionGrow< _TSuperclass >::
-GetGrowFunction( ) const
-{
- /* TODO
- return(
- dynamic_cast< const TGrowFunction* >( this->GetVertexFunction( ) )
- );
- */
- return( this->m_GrowFunction );
-}
-
-// -------------------------------------------------------------------------
-template< class _TSuperclass >
-typename fpa::Base::RegionGrow< _TSuperclass >::
-TOutput fpa::Base::RegionGrow< _TSuperclass >::
-GetInsideValue( ) const
-{
- const TGrowFunction* f = this->GetGrowFunction( );
- if( f != NULL )
- return( f->GetInsideValue( ) );
- else
- return( this->m_InitResult );
-}
-
-// -------------------------------------------------------------------------
-template< class _TSuperclass >
-typename fpa::Base::RegionGrow< _TSuperclass >::
-TOutput fpa::Base::RegionGrow< _TSuperclass >::
-GetOutsideValue( ) const
-{
- const TGrowFunction* f = this->GetGrowFunction( );
- if( f != NULL )
- return( f->GetOutsideValue( ) );
- else
- return( this->m_InitResult );
-}
-
-// -------------------------------------------------------------------------
-template< class _TSuperclass >
-void fpa::Base::RegionGrow< _TSuperclass >::
-SetGrowFunction( TGrowFunction* f )
-{
- TGrowFunction* old_f = this->GetGrowFunction( );
- if( old_f != NULL )
- {
- f->SetInsideValue( old_f->GetInsideValue( ) );
- f->SetOutsideValue( old_f->GetOutsideValue( ) );
-
- } // fi
- this->m_GrowFunction = f;
-}
-
-// -------------------------------------------------------------------------
-template< class _TSuperclass >
-void fpa::Base::RegionGrow< _TSuperclass >::
-SetInsideValue( const TOutput& v )
-{
- TGrowFunction* f = this->GetGrowFunction( );
- if( f != NULL )
- {
- f->SetInsideValue( v );
- this->Modified( );
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-template< class _TSuperclass >
-void fpa::Base::RegionGrow< _TSuperclass >::
-SetOutsideValue( const TOutput& v )
-{
- TGrowFunction* f = this->GetGrowFunction( );
- if( f != NULL )
- {
- f->SetOutsideValue( v );
- this->Modified( );
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-template< class _TSuperclass >
-fpa::Base::RegionGrow< _TSuperclass >::
-RegionGrow( )
- : Superclass( )
-{
- typedef fpa::Base::Functors::RegionGrow::Tautology< TVertex, TOutput > _TFunc;
- this->SetGrowFunction( _TFunc::New( ) );
- this->m_InitResult = this->GetGrowFunction( )->GetOutsideValue( );
-}
-
-// -------------------------------------------------------------------------
-template< class _TSuperclass >
-fpa::Base::RegionGrow< _TSuperclass >::
-~RegionGrow( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TSuperclass >
-bool fpa::Base::RegionGrow< _TSuperclass >::
-_UpdateValue( _TQueueNode& v, const _TQueueNode& p )
-{
- v.Result = this->_GetInputValue( v, p );
- return( v.Result == this->GetInsideValue( ) );
-}
-
-#endif // __fpa__Base__RegionGrow__hxx__
-
-// eof - $RCSfile$
+++ /dev/null
-#ifndef __fpa__Config__h__
-#define __fpa__Config__h__
-
-/*
- * =========================================================================
- * Language related macros
- * =========================================================================
- */
-
-#endif // __fpa__Config__h__
-
-// eof - $RCSfile$
+++ /dev/null
-#ifndef __fpa__Image__Algorithm__h__
-#define __fpa__Image__Algorithm__h__
-
-#include <itkFunctionBase.h>
-#include <itkImageToImageFilter.h>
-#include <fpa/Base/Algorithm.h>
-#include <fpa/Image/Functors/Base.h>
-
-namespace fpa
-{
- namespace Image
- {
- /**
- */
- template< class _TInputImage, class _TOutputImage >
- class Algorithm
- : public fpa::Base::Algorithm< itk::ImageToImageFilter< _TInputImage, _TOutputImage >, typename _TInputImage::IndexType, typename _TOutputImage::PixelType >
- {
- public:
- typedef itk::ImageToImageFilter< _TInputImage, _TOutputImage > TFilter;
- typedef typename _TInputImage::IndexType TVertex;
- typedef typename _TOutputImage::PixelType TOutput;
-
- typedef Algorithm Self;
- typedef fpa::Base::Algorithm< TFilter, TVertex, TOutput > Superclass;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
-
- typedef typename Superclass::TFrontId TFrontId;
- typedef typename Superclass::TNeighborhood TNeighborhood;
-
- typedef fpa::Image::Functors::Base< itk::ImageBase< _TInputImage::ImageDimension >, typename Superclass::TNeighborhoodFunction > TNeighborhoodFunction;
- typedef fpa::Image::Functors::Base< _TInputImage, typename Superclass::TVertexFunction > TVertexFunction;
-
- protected:
- typedef typename Superclass::_TQueueNode _TQueueNode;
-
- public:
- itkTypeMacro( fpa::Image::Algorithm, fpa::Base::Algorithm );
-
- protected:
- Algorithm( );
- virtual ~Algorithm( );
-
- virtual void _BeforeGenerateData( ) override;
- virtual void _InitMarks( ) override;
- virtual void _InitResults( const TOutput& init_value ) override;
- virtual bool _IsMarked( const TVertex& v ) const override;
- virtual void _Mark( const _TQueueNode& n ) override;
- virtual TFrontId _GetMark( const TVertex& v ) const override;
- virtual void _UpdateResult( const _TQueueNode& n ) override;
- virtual TOutput _GetResult( const TVertex& v ) const override;
- virtual unsigned int _GetNumberOfDimensions( ) const override;
-
- private:
- // Purposely not defined
- Algorithm( const Self& other );
- Self& operator=( const Self& other );
-
- protected:
- unsigned int m_MarksIdx;
- };
-
- } // ecapseman
-
-} // ecapseman
-
-#ifndef ITK_MANUAL_INSTANTIATION
-# include <fpa/Image/Algorithm.hxx>
-#endif // ITK_MANUAL_INSTANTIATION
-
-#endif // __fpa__Image__Algorithm__h__
-
-// eof - $RCSfile$
+++ /dev/null
-#ifndef __fpa__Image__Algorithm__hxx__
-#define __fpa__Image__Algorithm__hxx__
-
-// Send Piotr's code to Anna
-
-#include <itkImage.h>
-#include <fpa/Image/Functors/SimpleNeighborhood.h>
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage >
-fpa::Image::Algorithm< _TInputImage, _TOutputImage >::
-Algorithm( )
- : Superclass( )
-{
- typedef fpa::Image::Functors::SimpleNeighborhood< _TInputImage::ImageDimension > _TNeigh;
- typedef itk::Image< TFrontId, _TInputImage::ImageDimension > _TMarks;
-
- this->m_MarksIdx = this->GetNumberOfRequiredOutputs( );
- this->itk::ProcessObject::SetNumberOfRequiredOutputs( this->m_MarksIdx + 1 );
- typename _TMarks::Pointer marks = _TMarks::New( );
- this->SetNthOutput( this->m_MarksIdx, marks );
-
- typename _TNeigh::Pointer neigh = _TNeigh::New( );
- this->SetNeighborhoodFunction( neigh );
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage >
-fpa::Image::Algorithm< _TInputImage, _TOutputImage >::
-~Algorithm( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage >
-void fpa::Image::Algorithm< _TInputImage, _TOutputImage >::
-_BeforeGenerateData( )
-{
- this->Superclass::_BeforeGenerateData( );
- this->AllocateOutputs( );
-
- TNeighborhoodFunction* neighFunc =
- dynamic_cast< TNeighborhoodFunction* >(
- this->GetNeighborhoodFunction( )
- );
- if( neighFunc == NULL )
- itkExceptionMacro( << "NeighborhoodFunction not well defined." );
- neighFunc->SetImage( this->GetInput( ) );
-
- TVertexFunction* vertexFunc =
- dynamic_cast< TVertexFunction* >(
- this->GetVertexFunction( )
- );
- if( vertexFunc != NULL )
- vertexFunc->SetImage( this->GetInput( ) );
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage >
-void fpa::Image::Algorithm< _TInputImage, _TOutputImage >::
-_InitMarks( )
-{
- typedef itk::Image< TFrontId, _TInputImage::ImageDimension > _TMarks;
- _TMarks* marks =
- dynamic_cast< _TMarks* >(
- this->itk::ProcessObject::GetOutput( this->m_MarksIdx )
- );
- marks->FillBuffer( 0 );
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage >
-void fpa::Image::Algorithm< _TInputImage, _TOutputImage >::
-_InitResults( const TOutput& init_value )
-{
- this->GetOutput( )->FillBuffer( init_value );
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage >
-bool fpa::Image::Algorithm< _TInputImage, _TOutputImage >::
-_IsMarked( const TVertex& v ) const
-{
- typedef itk::Image< TFrontId, _TInputImage::ImageDimension > _TMarks;
- const _TMarks* marks =
- dynamic_cast< const _TMarks* >(
- this->itk::ProcessObject::GetOutput( this->m_MarksIdx )
- );
- return( marks->GetPixel( v ) != 0 );
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage >
-void fpa::Image::Algorithm< _TInputImage, _TOutputImage >::
-_Mark( const _TQueueNode& n )
-{
- typedef itk::Image< TFrontId, _TInputImage::ImageDimension > _TMarks;
- _TMarks* marks =
- dynamic_cast< _TMarks* >(
- this->itk::ProcessObject::GetOutput( this->m_MarksIdx )
- );
- marks->SetPixel( n.Vertex, n.FrontId );
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage >
-typename fpa::Image::Algorithm< _TInputImage, _TOutputImage >::
-TFrontId fpa::Image::Algorithm< _TInputImage, _TOutputImage >::
-_GetMark( const TVertex& v ) const
-{
- typedef itk::Image< TFrontId, _TInputImage::ImageDimension > _TMarks;
- const _TMarks* marks =
- dynamic_cast< const _TMarks* >(
- this->itk::ProcessObject::GetOutput( this->m_MarksIdx )
- );
- return( marks->GetPixel( v ) );
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage >
-void fpa::Image::Algorithm< _TInputImage, _TOutputImage >::
-_UpdateResult( const _TQueueNode& n )
-{
- this->GetOutput( )->SetPixel( n.Vertex, n.Result );
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage >
-typename fpa::Image::Algorithm< _TInputImage, _TOutputImage >::TOutput
-fpa::Image::Algorithm< _TInputImage, _TOutputImage >::
-_GetResult( const TVertex& v ) const
-{
- if( this->GetOutput( )->GetLargestPossibleRegion( ).IsInside( v ) )
- return( this->GetOutput( )->GetPixel( v ) );
- else
- return( this->m_InitResult );
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage >
-unsigned int fpa::Image::Algorithm< _TInputImage, _TOutputImage >::
-_GetNumberOfDimensions( ) const
-{
- return( _TInputImage::ImageDimension );
-}
-
-#endif // __fpa__Image__Algorithm__hxx__
-
-// eof - $RCSfile$
+++ /dev/null
-#ifndef __fpa__Image__Dijkstra__h__
-#define __fpa__Image__Dijkstra__h__
-
-#include <fpa/Base/Dijkstra.h>
-#include <fpa/Image/Algorithm.h>
-#include <fpa/Image/MinimumSpanningTree.h>
-#include <fpa/Image/Functors/Base.h>
-
-namespace fpa
-{
- namespace Image
- {
- /**
- */
- template< class _TInputImage, class _TOutputImage >
- class Dijkstra
- : public fpa::Base::Dijkstra< fpa::Image::Algorithm< _TInputImage, _TOutputImage >, fpa::Image::MinimumSpanningTree< _TInputImage::ImageDimension > >
- {
- public:
- typedef Dijkstra Self;
- typedef fpa::Image::Algorithm< _TInputImage, _TOutputImage > TAlgorithm;
- typedef fpa::Image::MinimumSpanningTree< _TInputImage::ImageDimension > TMST;
- typedef fpa::Base::Dijkstra< TAlgorithm, TMST > Superclass;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
-
- typedef typename Superclass::TOutput TOutput;
- typedef typename Superclass::TVertex TVertex;
-
- public:
- itkNewMacro( Self );
- itkTypeMacro( fpa::Image::Dijkstra, fpa::Base::Dijkstra );
-
- protected:
- Dijkstra( );
- virtual ~Dijkstra( );
-
- private:
- // Purposely not defined
- Dijkstra( const Self& other );
- Self& operator=( const Self& other );
- };
-
- } // ecapseman
-
-} // ecapseman
-
-#ifndef ITK_MANUAL_INSTANTIATION
-# include <fpa/Image/Dijkstra.hxx>
-#endif // ITK_MANUAL_INSTANTIATION
-
-#endif // __fpa__Image__Dijkstra__h__
-
-// eof - $RCSfile$
+++ /dev/null
-#ifndef __fpa__Image__Dijkstra__hxx__
-#define __fpa__Image__Dijkstra__hxx__
-
-#include <fpa/Image/Functors/VertexCost.h>
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage >
-fpa::Image::Dijkstra< _TInputImage, _TOutputImage >::
-Dijkstra( )
- : Superclass( )
-{
- typedef fpa::Image::Functors::VertexCost< _TInputImage, TOutput > _TCost;
- typename _TCost::Pointer cost = _TCost::New( );
- this->SetVertexFunction( cost );
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage >
-fpa::Image::Dijkstra< _TInputImage, _TOutputImage >::
-~Dijkstra( )
-{
-}
-
-#endif // __fpa__Image__Dijkstra__hxx__
-
-// eof - $RCSfile$
+++ /dev/null
-#ifndef __fpa__Image__EndPointsFilter__h__
-#define __fpa__Image__EndPointsFilter__h__
-
-#include <fpa/Image/MinimumSpanningTree.h>
-#include <set>
-
-namespace fpa
-{
- namespace Image
- {
- /**
- */
- template< class _TDistanceMap, class _TCostMap >
- class EndPointsFilter
- : public itk::Object
- {
- public:
- typedef EndPointsFilter Self;
- typedef itk::Object Superclass;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
-
- typedef _TDistanceMap TDistanceMap;
- typedef _TCostMap TCostMap;
- typedef typename TCostMap::IndexType TIndex;
- typedef MinimumSpanningTree< TCostMap::ImageDimension > TMST;
-
- typedef itk::Functor::IndexLexicographicCompare< _TCostMap::ImageDimension > TIndexCompare;
- typedef std::set< TIndex, TIndexCompare > TIndices;
-
- public:
- itkNewMacro( Self );
- itkTypeMacro( fpa::Image::EndPointsFilter, itk::Object );
-
- itkGetConstObjectMacro( DistanceMap, _TDistanceMap );
- itkGetConstObjectMacro( CostMap, _TCostMap );
- itkGetConstObjectMacro( MST, TMST );
-
- itkSetConstObjectMacro( DistanceMap, _TDistanceMap );
- itkSetConstObjectMacro( CostMap, _TCostMap );
- itkSetConstObjectMacro( MST, TMST );
-
- public:
- const TIndices& GetBifurcations( ) const;
- const TIndices& GetEndPoints( ) const;
-
- void Compute( );
-
- protected:
- EndPointsFilter( );
- virtual ~EndPointsFilter( );
-
- private:
- // Purposely not defined
- EndPointsFilter( const Self& other );
- Self& operator=( const Self& other );
-
- protected:
- typename _TDistanceMap::ConstPointer m_DistanceMap;
- typename _TCostMap::ConstPointer m_CostMap;
- typename TMST::ConstPointer m_MST;
-
- TIndices m_Bifurcations;
- TIndices m_EndPoints;
- };
-
- } // ecapseman
-
-} // ecapseman
-
-#ifndef ITK_MANUAL_INSTANTIATION
-# include <fpa/Image/EndPointsFilter.hxx>
-#endif // ITK_MANUAL_INSTANTIATION
-
-#endif // __fpa__Image__EndPointsFilter__h__
-
-// eof - $RCSfile$
+++ /dev/null
-#ifndef __fpa__Image__EndPointsFilter__hxx__
-#define __fpa__Image__EndPointsFilter__hxx__
-
-#include <functional>
-#include <map>
-#include <queue>
-#include <itkImageRegionConstIteratorWithIndex.h>
-
-// -------------------------------------------------------------------------
-template< class _TDistanceMap, class _TCostMap >
-const typename fpa::Image::EndPointsFilter< _TDistanceMap, _TCostMap >::
-TIndices& fpa::Image::EndPointsFilter< _TDistanceMap, _TCostMap >::
-GetBifurcations( ) const
-{
- return( this->m_Bifurcations );
-}
-
-// -------------------------------------------------------------------------
-template< class _TDistanceMap, class _TCostMap >
-const typename fpa::Image::EndPointsFilter< _TDistanceMap, _TCostMap >::
-TIndices& fpa::Image::EndPointsFilter< _TDistanceMap, _TCostMap >::
-GetEndPoints( ) const
-{
- return( this->m_EndPoints );
-}
-
-// -------------------------------------------------------------------------
-template< class _TDistanceMap, class _TCostMap >
-void fpa::Image::EndPointsFilter< _TDistanceMap, _TCostMap >::
-Compute( )
-{
- typedef itk::ImageRegionConstIteratorWithIndex< _TDistanceMap > _TDistMapIt;
- typedef itk::ImageRegionConstIteratorWithIndex< _TCostMap > _TCostMapIt;
- typedef std::multimap< double, TIndex, std::greater< double > > _TQueue;
- typedef typename _TQueue::value_type _TQueueValue;
- typedef itk::Image< unsigned char, _TCostMap::ImageDimension > _TMarks;
-
- // Some values
- typename _TDistanceMap::RegionType region =
- this->m_DistanceMap->GetRequestedRegion( );
- typename _TMarks::Pointer marks = _TMarks::New( );
- marks->SetLargestPossibleRegion( this->m_DistanceMap->GetLargestPossibleRegion( ) );
- marks->SetRequestedRegion( this->m_DistanceMap->GetRequestedRegion( ) );
- marks->SetBufferedRegion( this->m_DistanceMap->GetBufferedRegion( ) );
- marks->SetSpacing( this->m_DistanceMap->GetSpacing( ) );
- marks->SetOrigin( this->m_DistanceMap->GetOrigin( ) );
- marks->SetDirection( this->m_DistanceMap->GetDirection( ) );
- marks->Allocate( );
- marks->FillBuffer( 0 );
-
- // Create queue
- _TQueue queue;
- _TDistMapIt dIt( this->m_DistanceMap, region );
- _TCostMapIt cIt( this->m_CostMap, region );
- dIt.GoToBegin( );
- cIt.GoToBegin( );
- for( ; !dIt.IsAtEnd( ) && !cIt.IsAtEnd( ); ++dIt, ++cIt )
- {
- double d = double( dIt.Get( ) );
- if( d > 0 )
- {
- double v = double( cIt.Get( ) ) / ( d * d );
- queue.insert( _TQueueValue( v, dIt.GetIndex( ) ) );
-
- } // fi
-
- } // rof
-
- // BFS from maximum queue
- while( queue.size( ) > 0 )
- {
- // Get node
- auto nIt = queue.begin( );
- auto n = *nIt;
- queue.erase( nIt );
-
- unsigned char m = marks->GetPixel( n.second );
- if( ( m & 0x01 ) == 0x01 )
- continue;
-
- // Mark it
- m |= 0x01;
- marks->SetPixel( n.second, m );
- this->m_EndPoints.insert( n.second );
-
- // Get path
- typename TMST::TPath::Pointer path;
- this->m_MST->GetPath( path, n.second );
- for( unsigned long i = 0; i < path->GetSize( ); ++i )
- {
- TIndex idx = path->GetVertex( path->GetSize( ) - 1 - i );
- typename _TCostMap::PointType cnt;
- this->m_CostMap->TransformIndexToPhysicalPoint( idx, cnt );
- double d = double( this->m_DistanceMap->GetPixel( idx ) );
- d *= double( 2 );
-
- // Mark sphere
- std::queue< TIndex > q;
- q.push( idx );
- while( q.size( ) > 0 )
- {
- TIndex v = q.front( );
- q.pop( );
- unsigned char m = marks->GetPixel( v );
- if( ( m & 0x02 ) == 0x02 )
- continue;
- m |= 0x03;
- marks->SetPixel( v, m );
-
- for( unsigned int x = 0; x < _TCostMap::ImageDimension; ++x )
- {
- for( int y = -1; y <= 1; y += 2 )
- {
- TIndex w = v;
- w[ x ] += y;
- if( region.IsInside( w ) )
- {
- typename _TCostMap::PointType p;
- this->m_CostMap->TransformIndexToPhysicalPoint( w, p );
- if( cnt.EuclideanDistanceTo( p ) <= d )
- q.push( w );
-
- } // fi
-
- } // rof
-
- } // rof
-
- } // elihw
-
- } // rof
-
- } // elihw
-}
-
-// -------------------------------------------------------------------------
-template< class _TDistanceMap, class _TCostMap >
-fpa::Image::EndPointsFilter< _TDistanceMap, _TCostMap >::
-EndPointsFilter( )
- : Superclass( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TDistanceMap, class _TCostMap >
-fpa::Image::EndPointsFilter< _TDistanceMap, _TCostMap >::
-~EndPointsFilter( )
-{
-}
-
-#endif // __fpa__Image__EndPointsFilter__hxx__
-
-// eof - $RCSfile$
+++ /dev/null
-#ifndef __fpa__Image__FastMarching__h__
-#define __fpa__Image__FastMarching__h__
-
-#include <fpa/Base/FastMarching.h>
-#include <fpa/Image/Algorithm.h>
-
-namespace fpa
-{
- namespace Image
- {
- /**
- */
- template< class _TInputImage, class _TOutputImage >
- class FastMarching
- : public fpa::Base::FastMarching< fpa::Image::Algorithm< _TInputImage, _TOutputImage > >
- {
- public:
- typedef FastMarching Self;
- typedef fpa::Image::Algorithm< _TInputImage, _TOutputImage > TAlgorithm;
- typedef fpa::Base::FastMarching< TAlgorithm > Superclass;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
-
- typedef typename Superclass::TOutput TOutput;
- typedef typename Superclass::TVertex TVertex;
- typedef typename Superclass::TFastMarchingNeighbor TFastMarchingNeighbor;
- typedef typename Superclass::TFastMarchingNeighborhood TFastMarchingNeighborhood;
-
- public:
- itkNewMacro( Self );
- itkTypeMacro( fpa::Image::FastMarching, fpa::Base::FastMarching );
-
- protected:
- FastMarching( );
- virtual ~FastMarching( );
-
- virtual TFastMarchingNeighborhood _FastMarchingNeighbors( const TVertex& v ) const override;
-
- private:
- // Purposely not defined
- FastMarching( const Self& other );
- Self& operator=( const Self& other );
- };
-
- } // ecapseman
-
-} // ecapseman
-
-#ifndef ITK_MANUAL_INSTANTIATION
-# include <fpa/Image/FastMarching.hxx>
-#endif // ITK_MANUAL_INSTANTIATION
-
-#endif // __fpa__Image__FastMarching__h__
-
-// eof - $RCSfile$
+++ /dev/null
-#ifndef __fpa__Image__FastMarching__hxx__
-#define __fpa__Image__FastMarching__hxx__
-
-#include <fpa/Image/Functors/VertexCost.h>
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage >
-fpa::Image::FastMarching< _TInputImage, _TOutputImage >::
-FastMarching( )
- : Superclass( )
-{
- typedef fpa::Image::Functors::VertexCost< _TInputImage, TOutput > _TCost;
- typename _TCost::Pointer cost = _TCost::New( );
- this->SetVertexFunction( cost );
- this->m_InitResult = std::numeric_limits< TOutput >::max( );
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage >
-fpa::Image::FastMarching< _TInputImage, _TOutputImage >::
-~FastMarching( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage >
-typename fpa::Image::FastMarching< _TInputImage, _TOutputImage >::
-TFastMarchingNeighborhood
-fpa::Image::FastMarching< _TInputImage, _TOutputImage >::
-_FastMarchingNeighbors( const TVertex& v ) const
-{
- TFastMarchingNeighborhood neighs;
- typename _TInputImage::SpacingType spac = this->GetInput( )->GetSpacing( );
- for( unsigned int d = 0; d < _TInputImage::ImageDimension; ++d )
- {
- for( int i = -1; i <= 1; i += 2 )
- {
- TVertex n = v;
- n[ d ] += i;
- neighs.push_back( TFastMarchingNeighbor( n, spac[ d ] ) );
-
- } // rof
-
- } // rof
- return( neighs );
-}
-
-#endif // __fpa__Image__FastMarching__hxx__
-
-// eof - $RCSfile$
+++ /dev/null
-#ifndef __fpa__Image__Functors__Base__h__
-#define __fpa__Image__Functors__Base__h__
-
-#include <fpa/Config.h>
-#include <itkFunctionBase.h>
-#include <itkImageBase.h>
-
-namespace fpa
-{
- namespace Image
- {
- namespace Functors
- {
- /**
- */
- template< class _TImage, class _TSuperclass >
- class Base
- : public _TSuperclass
- {
- public:
- typedef Base Self;
- typedef _TSuperclass Superclass;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
-
- typedef _TImage TImage;
- typedef itk::ImageBase< TImage::ImageDimension > TImageBase;
-
- public:
- itkTypeMacro( Base, itk::FunctionBase );
-
- itkGetConstObjectMacro( Image, TImage );
- itkSetConstObjectMacro( Image, TImage );
-
- protected:
- Base( ) : Superclass( ) { }
- virtual ~Base( ) { }
-
- private:
- // Purposely not implemented
- Base( const Self& other );
- Self& operator=( const Self& other );
-
- protected:
- typename TImage::ConstPointer m_Image;
- };
-
- } // ecapseman
-
- } // ecapseman
-
-} // ecapseman
-
-#endif // __fpa__Image__Functors__Base__h__
-
-// eof - $RCSfile$
+++ /dev/null
-#ifndef __fpa__Image__Functors__RegionGrow__BinaryThreshold__h__
-#define __fpa__Image__Functors__RegionGrow__BinaryThreshold__h__
-
-#include <fpa/Image/Functors/Base.h>
-#include <fpa/Base/Functors/RegionGrow/Base.h>
-
-namespace fpa
-{
- namespace Image
- {
- namespace Functors
- {
- namespace RegionGrow
- {
- /**
- */
- template< class _TImage, class _TOutput >
- class BinaryThreshold
- : public fpa::Image::Functors::Base< _TImage, fpa::Base::Functors::RegionGrow::Base< typename _TImage::IndexType, _TOutput > >
- {
- public:
- typedef _TImage TImage;
- typedef _TOutput TOutput;
- typedef typename TImage::IndexType TIndex;
- typedef typename TImage::PixelType TPixel;
-
- typedef fpa::Base::Functors::RegionGrow::Base< TIndex, TOutput > TBase;
- typedef fpa::Image::Functors::Base< TImage, TBase > Superclass;
- typedef BinaryThreshold Self;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
-
- public:
- itkNewMacro( Self );
- itkTypeMacro( BinaryThreshold, Base );
-
- itkGetConstMacro( Lower, TPixel );
- itkGetConstMacro( Upper, TPixel );
- itkSetMacro( Lower, TPixel );
- itkSetMacro( Upper, TPixel );
-
- public:
- virtual TOutput Evaluate(
- const TIndex& a, const TIndex& b
- ) const override;
-
- protected:
- BinaryThreshold( );
- virtual ~BinaryThreshold( );
-
- private:
- // Purposely not implemented
- BinaryThreshold( const Self& other );
- Self& operator=( const Self& other );
-
- protected:
- TPixel m_Lower;
- TPixel m_Upper;
- };
-
- } // ecapseman
-
- } // ecapseman
-
- } // ecapseman
-
-} // ecapseman
-
-#ifndef ITK_MANUAL_INSTANTIATION
-# include <fpa/Image/Functors/RegionGrow/BinaryThreshold.hxx>
-#endif // ITK_MANUAL_INSTANTIATION
-
-#endif // __fpa__Image__Functors__RegionGrow__BinaryThreshold__h__
-
-// eof - $RCSfile$
+++ /dev/null
-#ifndef __fpa__Image__Functors__RegionGrow__BinaryThreshold__hxx__
-#define __fpa__Image__Functors__RegionGrow__BinaryThreshold__hxx__
-
-#include <limits>
-
-// -------------------------------------------------------------------------
-template< class _TImage, class _TOutput >
-_TOutput
-fpa::Image::Functors::RegionGrow::BinaryThreshold< _TImage, _TOutput >::
-Evaluate( const TIndex& a, const TIndex& b ) const
-{
- const _TImage* im =
- dynamic_cast< const _TImage* >( this->m_Image.GetPointer( ) );
- if( im != NULL )
- {
- TPixel v = im->GetPixel( b );
- return(
- ( this->m_Lower < v && v < this->m_Upper )?
- this->m_InsideValue:
- this->m_OutsideValue
- );
- }
- else
- return( this->m_OutsideValue );
-}
-
-// -------------------------------------------------------------------------
-template< class _TImage, class _TOutput >
-fpa::Image::Functors::RegionGrow::BinaryThreshold< _TImage, _TOutput >::
-BinaryThreshold( )
- : Superclass( )
-{
- this->m_Upper = std::numeric_limits< TPixel >::max( );
- if( std::numeric_limits< TPixel >::is_integer )
- this->m_Lower = std::numeric_limits< TPixel >::min( );
- else
- this->m_Lower = -this->m_Upper;
-}
-
-// -------------------------------------------------------------------------
-template< class _TImage, class _TOutput >
-fpa::Image::Functors::RegionGrow::BinaryThreshold< _TImage, _TOutput >::
-~BinaryThreshold( )
-{
-}
-
-#endif // __fpa__Image__Functors__RegionGrow__BinaryThreshold__hxx__
-
-// eof - $RCSfile$
+++ /dev/null
-#ifndef __fpa__Image__Functors__SimpleNeighborhood__h__
-#define __fpa__Image__Functors__SimpleNeighborhood__h__
-
-#include <vector>
-#include <fpa/Image/Functors/Base.h>
-#include <itkFunctionBase.h>
-#include <itkImageBase.h>
-
-namespace fpa
-{
- namespace Image
- {
- namespace Functors
- {
- /**
- */
- template< unsigned int _VDim >
- class SimpleNeighborhood
- : public fpa::Image::Functors::Base< itk::ImageBase< _VDim >, itk::FunctionBase< itk::Index< _VDim >, std::vector< itk::Index< _VDim > > > >
- {
- public:
- typedef itk::ImageBase< _VDim > TImage;
- typedef typename TImage::IndexType TIndex;
- typedef typename TIndex::OffsetType TOffset;
- typedef std::vector< TIndex > TOutput;
- typedef itk::FunctionBase< TIndex, TOutput > TBaseFunctor;
- typedef fpa::Image::Functors::Base< TImage, TBaseFunctor > Superclass;
- typedef SimpleNeighborhood Self;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
-
- public:
- itkNewMacro( Self );
- itkTypeMacro( SimpleNeighborhood, Base );
-
- itkGetConstMacro( Order, unsigned int );
- itkSetMacro( Order, unsigned int );
-
- public:
- virtual TOutput Evaluate( const TIndex& center ) const override;
-
- protected:
- SimpleNeighborhood( );
- virtual ~SimpleNeighborhood( );
-
- void _1stCombination( ) const;
- void _2ndCombination( ) const;
-
- private:
- // Purposely not implemented
- SimpleNeighborhood( const Self& other );
- Self& operator=( const Self& other );
-
- protected:
- unsigned int m_Order;
- mutable std::vector< TOffset > m_Offsets;
- };
-
- } // ecapseman
-
- } // ecapseman
-
-} // ecapseman
-
-#ifndef ITK_MANUAL_INSTANTIATION
-# include <fpa/Image/Functors/SimpleNeighborhood.hxx>
-#endif // ITK_MANUAL_INSTANTIATION
-
-#endif // __fpa__Image__Functors__SimpleNeighborhood__h__
-
-// eof - $RCSfile$
+++ /dev/null
-#ifndef __fpa__Image__Functors__SimpleNeighborhood__hxx__
-#define __fpa__Image__Functors__SimpleNeighborhood__hxx__
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-typename fpa::Image::Functors::SimpleNeighborhood< _VDim >::
-TOutput fpa::Image::Functors::SimpleNeighborhood< _VDim >::
-Evaluate( const TIndex& center ) const
-{
- if( this->m_Offsets.size( ) == 0 )
- {
- if( this->m_Order == 1 )
- this->_1stCombination( );
- else
- this->_2ndCombination( );
-
- } // fi
-
- TOutput res;
- typename TImage::RegionType reg = this->m_Image->GetRequestedRegion( );
- for( int i = 0; i < this->m_Offsets.size( ); ++i )
- {
- TIndex idx = center + this->m_Offsets[ i ];
- if( reg.IsInside( idx ) && idx != center )
- res.push_back( idx );
-
- } // rof
- return( res );
-}
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-fpa::Image::Functors::SimpleNeighborhood< _VDim >::
-SimpleNeighborhood( )
- : Superclass( ),
- m_Order( 1 )
-{
-}
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
- fpa::Image::Functors::SimpleNeighborhood< _VDim >::
-~SimpleNeighborhood( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-void fpa::Image::Functors::SimpleNeighborhood< _VDim >::
-_1stCombination( ) const
-{
- for( int d = 0; d < TImage::ImageDimension; ++d )
- {
- typename TIndex::OffsetType off;
- off.Fill( 0 );
- for( int i = -1; i <= 1; i += 2 )
- {
- off[ d ] = i;
- this->m_Offsets.push_back( off );
-
- } // rof
-
- } // rof
-}
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-void fpa::Image::Functors::SimpleNeighborhood< _VDim >::
-_2ndCombination( ) const
-{
- std::vector< std::vector< std::vector< int > > > M;
- M.push_back( std::vector< std::vector< int > >( ) );
-
- std::vector< int > base;
- base.push_back( -1 );
- base.push_back( 0 );
- base.push_back( 1 );
- int dim = TImage::ImageDimension;
-
- M.push_back( std::vector< std::vector< int > >( ) );
- for( int j = 0; j < base.size( ); ++j )
- M[ 1 ].push_back( std::vector< int >( 1, base[ j ] ) );
-
- for( int i = 2; i <= dim; ++i )
- {
- M.push_back( std::vector< std::vector< int > >( ) );
- for( int j = 0; j < base.size( ); ++j )
- {
- for( int k = 0; k < M[ i - 1 ].size( ); ++k )
- {
- M[ i ].push_back( std::vector< int >( 1, base[ j ] ) );
- for( int l = 0; l < M[ i - 1 ][ k ].size( ); ++l )
- M[ i ].back( ).push_back( M[ i - 1 ][ k ][ l ] );
-
- } // rof
-
- } // rof
-
- } // rof
-
- for( int i = 0; i < M[ dim ].size( ); ++i )
- {
- TOffset off;
- for( int j = 0; j < M[ dim ][ i ].size( ); ++j )
- off[ j ] = M[ dim ][ i ][ j ];
- this->m_Offsets.push_back( off );
-
- } // rof
-}
-
-#endif // __fpa__Image__Functors__SimpleNeighborhood__hxx__
-
-// eof - $RCSfile$
+++ /dev/null
-#ifndef __fpa__Image__Functors__VertexCost__h__
-#define __fpa__Image__Functors__VertexCost__h__
-
-#include <fpa/Image/Functors/Base.h>
-#include <fpa/Base/Functors/VertexCostFunctionBase.h>
-
-namespace fpa
-{
- namespace Image
- {
- namespace Functors
- {
- /**
- */
- template< class _TImage, class _TOutput >
- class VertexCost
- : public fpa::Image::Functors::Base< _TImage, fpa::Base::Functors::VertexCostFunctionBase< typename _TImage::IndexType, _TOutput > >
- {
- public:
- typedef _TImage TImage;
- typedef typename TImage::IndexType TIndex;
- typedef _TOutput TOutput;
-
- typedef fpa::Base::Functors::VertexCostFunctionBase< TIndex, TOutput > TBaseFunctor;
- typedef fpa::Image::Functors::Base< TImage, TBaseFunctor > Superclass;
- typedef VertexCost Self;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
-
- public:
- itkNewMacro( Self );
- itkTypeMacro( VertexCost, Base );
-
- itkBooleanMacro( UseImageSpacing );
- itkGetConstMacro( UseImageSpacing, bool );
- itkSetMacro( UseImageSpacing, bool );
-
- public:
- virtual TOutput Evaluate(
- const TIndex& a, const TIndex& b
- ) const override;
-
- protected:
- VertexCost( );
- virtual ~VertexCost( );
-
- private:
- // Purposely not implemented
- VertexCost( const Self& other );
- Self& operator=( const Self& other );
-
- protected:
- bool m_UseImageSpacing;
- };
-
- } // ecapseman
-
- } // ecapseman
-
-} // ecapseman
-
-#ifndef ITK_MANUAL_INSTANTIATION
-# include <fpa/Image/Functors/VertexCost.hxx>
-#endif // ITK_MANUAL_INSTANTIATION
-
-#endif // __fpa__Image__Functors__VertexCost__h__
-
-// eof - $RCSfile$
+++ /dev/null
-#ifndef __fpa__Image__Functors__VertexCost__hxx__
-#define __fpa__Image__Functors__VertexCost__hxx__
-
-// -------------------------------------------------------------------------
-template< class _TImage, class _TOutput >
-typename fpa::Image::Functors::VertexCost< _TImage, _TOutput >::
-TOutput fpa::Image::Functors::VertexCost< _TImage, _TOutput >::
-Evaluate( const TIndex& a, const TIndex& b ) const
-{
- const _TImage* im =
- dynamic_cast< const _TImage* >( this->m_Image.GetPointer( ) );
- TOutput coeff = TOutput( 1 );
- if( this->m_UseImageSpacing )
- {
- typename _TImage::PointType pa, pb;
- im->TransformIndexToPhysicalPoint( a, pa );
- im->TransformIndexToPhysicalPoint( b, pb );
- coeff = TOutput( pa.EuclideanDistanceTo( pb ) );
-
- } // fi
- return( TOutput( im->GetPixel( a ) ) * coeff );
-}
-
-// -------------------------------------------------------------------------
-template< class _TImage, class _TOutput >
-fpa::Image::Functors::VertexCost< _TImage, _TOutput >::
-VertexCost( )
- : Superclass( ),
- m_UseImageSpacing( false )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TImage, class _TOutput >
-fpa::Image::Functors::VertexCost< _TImage, _TOutput >::
-~VertexCost( )
-{
-}
-
-#endif // __fpa__Image__Functors__VertexCost__hxx__
-
-// eof - $RCSfile$
+++ /dev/null
-#ifndef __fpa__Image__MinimumSpanningTree__h__
-#define __fpa__Image__MinimumSpanningTree__h__
-
-#include <fpa/Base/MinimumSpanningTree.h>
-#include <cpExtensions/DataStructures/PolyLineParametricPath.h>
-#include <itkImage.h>
-
-namespace fpa
-{
- namespace Image
- {
- /**
- */
- template< unsigned int _VDim >
- class MinimumSpanningTree
- : public fpa::Base::MinimumSpanningTree< itk::Index< _VDim >, cpExtensions::DataStructures::PolyLineParametricPath< _VDim >, itk::Image< itk::Offset< _VDim >, _VDim > >
- {
- public:
- typedef itk::Index< _VDim > TVertex;
- typedef cpExtensions::DataStructures::PolyLineParametricPath< _VDim > TPath;
- typedef itk::Offset< _VDim > TOffset;
- typedef itk::Image< TOffset, _VDim > TImage;
- typedef fpa::Base::MinimumSpanningTree< TVertex, TPath, TImage > Superclass;
- typedef MinimumSpanningTree Self;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
-
- public:
- itkNewMacro( Self );
- itkTypeMacro(
- fpa::Image::MinimumSpanningTree, fpa::Base::MinimumSpanningTree
- );
-
- public:
- virtual TVertex GetParent( const TVertex& v ) const override;
- virtual void SetParent( const TVertex& v, const TVertex& p ) override;
-
- virtual void GetPath(
- typename TPath::Pointer& path, const TVertex& a
- ) const override;
- virtual void GetPath(
- typename TPath::Pointer& path, const TVertex& a, const TVertex& b
- ) const override;
-
- protected:
- MinimumSpanningTree( );
- virtual ~MinimumSpanningTree( );
-
- private:
- // Purposely not defined
- MinimumSpanningTree( const Self& other );
- Self& operator=( const Self& other );
- };
-
- } // ecapseman
-
-} // ecapseman
-
-#ifndef ITK_MANUAL_INSTANTIATION
-# include <fpa/Image/MinimumSpanningTree.hxx>
-#endif // ITK_MANUAL_INSTANTIATION
-
-#endif // __fpa__Image__MinimumSpanningTree__h__
-
-// eof - $RCSfile$
+++ /dev/null
-#ifndef __fpa__Image__MinimumSpanningTree__hxx__
-#define __fpa__Image__MinimumSpanningTree__hxx__
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-typename fpa::Image::MinimumSpanningTree< _VDim >::
-TVertex fpa::Image::MinimumSpanningTree< _VDim >::
-GetParent( const TVertex& v ) const
-{
- TVertex p = v + this->GetPixel( v );
- return( p );
-}
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-void fpa::Image::MinimumSpanningTree< _VDim >::
-SetParent( const TVertex& v, const TVertex& p )
-{
- this->SetPixel( v, p - v );
-}
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-void fpa::Image::MinimumSpanningTree< _VDim >::
-GetPath( typename TPath::Pointer& path, const TVertex& a ) const
-{
- if( path.GetPointer( ) == NULL )
- path = TPath::New( );
- path->SetReferenceImage( this );
- this->Superclass::GetPath( path, a );
-}
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-void fpa::Image::MinimumSpanningTree< _VDim >::
-GetPath(
- typename TPath::Pointer& path, const TVertex& a, const TVertex& b
- ) const
-{
- if( path.GetPointer( ) == NULL )
- path = TPath::New( );
- path->SetReferenceImage( this );
- this->Superclass::GetPath( path, a, b );
-}
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-fpa::Image::MinimumSpanningTree< _VDim >::
-MinimumSpanningTree( )
- : Superclass( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-fpa::Image::MinimumSpanningTree< _VDim >::
-~MinimumSpanningTree( )
-{
-}
-
-#endif // __fpa__Image__MinimumSpanningTree__hxx__
-
-// eof - $RCSfile$
+++ /dev/null
-#ifndef __fpa__Image__MoriRegionGrow__h__
-#define __fpa__Image__MoriRegionGrow__h__
-
-#include <itkImageToImageFilter.h>
-#include <itkBinaryThresholdImageFilter.h>
-#include <fpa/Image/MoriRegionGrowHelper.h>
-
-namespace fpa
-{
- namespace Image
- {
- /**
- */
- template< class _TInputImage, class _TOutputImage, class _TAuxPixel = unsigned short >
- class MoriRegionGrow
- : public itk::ImageToImageFilter< _TInputImage, _TOutputImage >
- {
- public:
- typedef MoriRegionGrow Self;
- typedef itk::ImageToImageFilter< _TInputImage, _TOutputImage > Superclass;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
-
- typedef itk::Image< _TAuxPixel, _TInputImage::ImageDimension > TAuxImage;
- typedef fpa::Image::MoriRegionGrowHelper< _TInputImage, TAuxImage > THelper;
- typedef itk::BinaryThresholdImageFilter< TAuxImage, _TOutputImage > TThreshold;
-
- typedef typename _TInputImage::IndexType TIndex;
- typedef typename _TInputImage::PixelType TInputPixel;
- typedef typename _TOutputImage::PixelType TOutputPixel;
-
- public:
- itkNewMacro( Self );
- itkTypeMacro( fpa::Image::MoriRegionGrow, itk::ImageToImageFilter );
-
- itkGetConstMacro( Seed, TIndex );
- itkSetMacro( Seed, TIndex );
-
- public:
- TAuxImage* GetAuxiliaryImage( );
- const TAuxImage* GetAuxiliaryImage( ) const;
-
- TInputPixel GetLower( ) const;
- TInputPixel GetUpper( ) const;
- TInputPixel GetStep( ) const;
- TOutputPixel GetInsideValue( ) const;
- TOutputPixel GetOutsideValue( ) const;
-
- void SetLower( const TInputPixel& v );
- void SetUpper( const TInputPixel& v );
- void SetStep( const TInputPixel& v );
- void SetInsideValue( const TOutputPixel& v );
- void SetOutsideValue( const TOutputPixel& v );
-
-
- /* TODO
- itkGetConstMacro( Lower, TPixel );
- itkGetConstMacro( Upper, TPixel );
- itkGetConstMacro( Step, TPixel );
- itkGetConstMacro( Sensitivity, double );
- itkSetMacro( Lower, TPixel );
- itkSetMacro( Upper, TPixel );
- itkSetMacro( Step, TPixel );
- itkSetMacro( Sensitivity, double );
- */
-
- protected:
- MoriRegionGrow( );
- virtual ~MoriRegionGrow( );
-
- virtual void GenerateData( ) override;
-
- private:
- // Purposely not defined
- MoriRegionGrow( const Self& other );
- Self& operator=( const Self& other );
-
- protected:
- typename THelper::Pointer m_Helper;
- typename TThreshold::Pointer m_Threshold;
- TIndex m_Seed;
- };
-
- } // ecapseman
-
-} // ecapseman
-
-#ifndef ITK_MANUAL_INSTANTIATION
-# include <fpa/Image/MoriRegionGrow.hxx>
-#endif // ITK_MANUAL_INSTANTIATION
-
-#endif // __fpa__Image__MoriRegionGrow__h__
-
-// eof - $RCSfile$
+++ /dev/null
-#ifndef __fpa__Image__MoriRegionGrow__hxx__
-#define __fpa__Image__MoriRegionGrow__hxx__
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage, class _TAuxPixel >
-typename
-fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage, _TAuxPixel >::
-TAuxImage*
-fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage, _TAuxPixel >::
-GetAuxiliaryImage( )
-{
- return( this->m_Helper->GetOutput( ) );
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage, class _TAuxPixel >
-const typename
-fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage, _TAuxPixel >::
-TAuxImage*
-fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage, _TAuxPixel >::
-GetAuxiliaryImage( ) const
-{
- return( this->m_Helper->GetOutput( ) );
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage, class _TAuxPixel >
-typename
-fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage, _TAuxPixel >::
-TInputPixel
-fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage, _TAuxPixel >::
-GetLower( ) const
-{
- return( this->m_Helper->GetLower( ) );
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage, class _TAuxPixel >
-typename
-fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage, _TAuxPixel >::
-TInputPixel
-fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage, _TAuxPixel >::
-GetUpper( ) const
-{
- return( this->m_Helper->GetUpper( ) );
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage, class _TAuxPixel >
-typename
-fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage, _TAuxPixel >::
-TInputPixel
-fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage, _TAuxPixel >::
-GetStep( ) const
-{
- return( this->m_Helper->GetStep( ) );
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage, class _TAuxPixel >
-typename
-fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage, _TAuxPixel >::
-TOutputPixel
-fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage, _TAuxPixel >::
-GetInsideValue( ) const
-{
- return( this->m_Threshold->GetInsideValue( ) );
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage, class _TAuxPixel >
-typename
-fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage, _TAuxPixel >::
-TOutputPixel
-fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage, _TAuxPixel >::
-GetOutsideValue( ) const
-{
- return( this->m_Threshold->GetInsideValue( ) );
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage, class _TAuxPixel >
-void fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage, _TAuxPixel >::
-SetLower( const TInputPixel& v )
-{
- this->m_Helper->SetLower( v );
- this->Modified( );
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage, class _TAuxPixel >
-void fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage, _TAuxPixel >::
-SetUpper( const TInputPixel& v )
-{
- this->m_Helper->SetUpper( v );
- this->Modified( );
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage, class _TAuxPixel >
-void fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage, _TAuxPixel >::
-SetStep( const TInputPixel& v )
-{
- this->m_Helper->SetStep( v );
- this->Modified( );
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage, class _TAuxPixel >
-void fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage, _TAuxPixel >::
-SetInsideValue( const TOutputPixel& v )
-{
- this->m_Threshold->SetInsideValue( v );
- this->Modified( );
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage, class _TAuxPixel >
-void fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage, _TAuxPixel >::
-SetOutsideValue( const TOutputPixel& v )
-{
- this->m_Threshold->SetOutsideValue( v );
- this->Modified( );
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage, class _TAuxPixel >
-fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage, _TAuxPixel >::
-MoriRegionGrow( )
- : Superclass( )
-{
- this->m_Helper = THelper::New( );
- this->m_Threshold = TThreshold::New( );
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage, class _TAuxPixel >
-fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage, _TAuxPixel >::
-~MoriRegionGrow( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage, class _TAuxPixel >
-void fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage, _TAuxPixel >::
-GenerateData( )
-{
- this->m_Helper->ClearSeeds( );
- this->m_Helper->AddSeed( this->m_Seed, 0 );
- this->m_Helper->SetInput( this->GetInput( ) );
- this->m_Helper->Update( );
-
- this->m_Threshold->SetInput( this->m_Helper->GetOutput( ) );
- this->m_Threshold->SetLowerThreshold( std::numeric_limits< _TAuxPixel >::min( ) );
- this->m_Threshold->SetUpperThreshold( this->m_Helper->GetOptimumThreshold( ) );
- this->m_Threshold->Update( );
- this->GetOutput( )->Graft( this->m_Threshold->GetOutput( ) );
-}
-
-#endif // __fpa__Image__MoriRegionGrow__hxx__
-
-// eof - $RCSfile$
+++ /dev/null
-#ifndef __fpa__Image__MoriRegionGrowHelper__h__
-#define __fpa__Image__MoriRegionGrowHelper__h__
-
-#include <utility>
-#include <vector>
-#include <fpa/Image/RegionGrow.h>
-#include <fpa/Image/Functors/RegionGrow/BinaryThreshold.h>
-
-namespace fpa
-{
- namespace Image
- {
- /**
- */
- template< class _TInputImage, class _TOutputImage >
- class MoriRegionGrowHelper
- : public fpa::Image::RegionGrow< _TInputImage, _TOutputImage >
- {
- public:
- typedef MoriRegionGrowHelper Self;
- typedef fpa::Image::RegionGrow< _TInputImage, _TOutputImage > Superclass;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
-
- typedef typename Superclass::TOutput TOutput;
- typedef typename Superclass::TVertex TVertex;
- typedef typename Superclass::TGrowFunction TGrowFunction;
- typedef typename _TInputImage::PixelType TPixel;
- typedef fpa::Image::Functors::RegionGrow::BinaryThreshold< _TInputImage, TOutput > TBinThresholdFunction;
-
- protected:
- typedef typename Superclass::_TQueueNode _TQueueNode;
- typedef typename Superclass::_TQueue _TQueue;
-
- typedef std::pair< TPixel, unsigned long > TCurveData;
- typedef std::vector< TCurveData > TCurve;
-
- public:
- itkNewMacro( Self );
- itkTypeMacro( fpa::Image::MoriRegionGrowHelper, fpa::Image::RegionGrow );
-
- itkGetConstMacro( Lower, TPixel );
- itkGetConstMacro( Upper, TPixel );
- itkGetConstMacro( Step, TPixel );
- itkGetConstMacro( OptimumThreshold, typename _TOutputImage::PixelType );
-
- itkSetMacro( Lower, TPixel );
- itkSetMacro( Upper, TPixel );
- itkSetMacro( Step, TPixel );
-
-
- protected:
- MoriRegionGrowHelper( );
- virtual ~MoriRegionGrowHelper( );
-
- virtual bool _ContinueGenerateData( ) override;
- virtual void _BeforeGenerateData( ) override;
- virtual void _AfterGenerateData( ) override;
- virtual void _BeforeLoop( ) override;
- virtual void _AfterLoop( ) override;
- virtual bool _UpdateValue( _TQueueNode& v, const _TQueueNode& p ) override;
- virtual void _UpdateResult( const _TQueueNode& n ) override;
-
- private:
- // Purposely not defined
- MoriRegionGrowHelper( const Self& other );
- Self& operator=( const Self& other );
-
- protected:
- TPixel m_Lower;
- TPixel m_Upper;
- TPixel m_Step;
- typename _TOutputImage::PixelType m_OptimumThreshold;
-
- _TQueue m_NextQueue;
- unsigned long m_ActualCount;
- TCurve m_Curve;
- };
-
- } // ecapseman
-
-} // ecapseman
-
-#ifndef ITK_MANUAL_INSTANTIATION
-# include <fpa/Image/MoriRegionGrowHelper.hxx>
-#endif // ITK_MANUAL_INSTANTIATION
-
-#endif // __fpa__Image__MoriRegionGrowHelper__h__
-
-// eof - $RCSfile$
+++ /dev/null
-#ifndef __fpa__Image__MoriRegionGrowHelper__hxx__
-#define __fpa__Image__MoriRegionGrowHelper__hxx__
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage >
-fpa::Image::MoriRegionGrowHelper< _TInputImage, _TOutputImage >::
-MoriRegionGrowHelper( )
- : Superclass( ),
- m_Step( TPixel( 1 ) )
-{
- this->m_Upper = std::numeric_limits< TPixel >::max( );
- if( std::numeric_limits< TPixel >::is_integer )
- this->m_Lower = std::numeric_limits< TPixel >::min( );
- else
- this->m_Lower = -this->m_Upper;
- typename TBinThresholdFunction::Pointer functor =
- TBinThresholdFunction::New( );
- this->SetGrowFunction( functor );
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage >
-fpa::Image::MoriRegionGrowHelper< _TInputImage, _TOutputImage >::
-~MoriRegionGrowHelper( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage >
-bool fpa::Image::MoriRegionGrowHelper< _TInputImage, _TOutputImage >::
-_ContinueGenerateData( )
-{
- TBinThresholdFunction* functor =
- dynamic_cast< TBinThresholdFunction* >( this->GetGrowFunction( ) );
- TPixel u = functor->GetUpper( );
-
- // Update flooding data
- this->m_Curve.push_back( TCurveData( u, this->m_ActualCount ) );
-
- // Update thresholds
- if( u < this->m_Upper )
- {
- u += this->m_Step;
- if( u > this->m_Upper )
- u = this->m_Upper;
- functor->SetUpper( u );
- this->m_Queue = this->m_NextQueue;
- while( this->m_NextQueue.size( ) > 0 )
- this->m_NextQueue.pop( );
- return( true );
- }
- else
- return( false );
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage >
-void fpa::Image::MoriRegionGrowHelper< _TInputImage, _TOutputImage >::
-_BeforeGenerateData( )
-{
- this->Superclass::_BeforeGenerateData( );
-
- while( this->m_NextQueue.size( ) > 0 )
- this->m_NextQueue.pop( );
- this->m_OptimumThreshold = ( typename _TOutputImage::PixelType )( 0 );
- this->m_ActualCount = 0;
- this->m_Curve.clear( );
- TBinThresholdFunction* functor =
- dynamic_cast< TBinThresholdFunction* >( this->GetGrowFunction( ) );
- functor->SetLower( this->m_Lower );
- functor->SetUpper( this->m_Lower + this->m_Step );
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage >
-void fpa::Image::MoriRegionGrowHelper< _TInputImage, _TOutputImage >::
-_AfterGenerateData( )
-{
- typedef typename _TOutputImage::PixelType _TOut;
-
- this->Superclass::_AfterGenerateData( );
- while( this->m_NextQueue.size( ) > 0 )
- this->m_NextQueue.pop( );
-
- // Find optimum threshold by dicotomy
- unsigned long l = 0;
- unsigned long r = this->m_Curve.size( ) - 1;
- while( ( r - l ) > 1 )
- {
- unsigned long m = ( r + l ) >> 1;
- double vm = double( this->m_Curve[ m ].second );
- double dl = vm - double( this->m_Curve[ l ].second );
- double dr = double( this->m_Curve[ r ].second ) - vm;
- if( dl > dr )
- r = m;
- else
- l = m;
-
- } // elihw
- this->m_OptimumThreshold = _TOut( ( r + l ) >> 1 );
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage >
-void fpa::Image::MoriRegionGrowHelper< _TInputImage, _TOutputImage >::
-_BeforeLoop( )
-{
- this->Superclass::_BeforeLoop( );
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage >
-void fpa::Image::MoriRegionGrowHelper< _TInputImage, _TOutputImage >::
-_AfterLoop( )
-{
- this->Superclass::_AfterLoop( );
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage >
-bool fpa::Image::MoriRegionGrowHelper< _TInputImage, _TOutputImage >::
-_UpdateValue( _TQueueNode& v, const _TQueueNode& p )
-{
- typedef typename _TOutputImage::PixelType _TOut;
-
- bool ret = this->Superclass::_UpdateValue( v, p );
- v.Result = _TOut( this->m_Curve.size( ) + 1 );
- if( !ret )
- this->m_NextQueue.push( v );
- return( ret );
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage >
-void fpa::Image::MoriRegionGrowHelper< _TInputImage, _TOutputImage >::
-_UpdateResult( const _TQueueNode& n )
-{
- this->Superclass::_UpdateResult( n );
- this->m_ActualCount += 1;
-}
-
-#endif // __fpa__Image__MoriRegionGrowHelper__hxx__
-
-// eof - $RCSfile$
+++ /dev/null
-#ifndef __fpa__Image__RegionGrow__h__
-#define __fpa__Image__RegionGrow__h__
-
-#include <fpa/Base/RegionGrow.h>
-#include <fpa/Image/Algorithm.h>
-
-namespace fpa
-{
- namespace Image
- {
- /**
- */
- template< class _TInputImage, class _TOutputImage >
- class RegionGrow
- : public fpa::Base::RegionGrow< fpa::Image::Algorithm< _TInputImage, _TOutputImage > >
- {
- public:
- typedef fpa::Image::Algorithm< _TInputImage, _TOutputImage > TAlgorithm;
- typedef RegionGrow Self;
- typedef fpa::Base::RegionGrow< TAlgorithm > Superclass;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
-
- typedef typename Superclass::TOutput TOutput;
- typedef typename Superclass::TVertex TVertex;
-
- typedef fpa::Image::Functors::Base< _TInputImage, typename Superclass::TGrowFunction > TGrowFunction;
-
- public:
- itkNewMacro( Self );
- itkTypeMacro( fpa::Image::RegionGrow, fpa::Base::RegionGrow );
-
- protected:
- RegionGrow( );
- virtual ~RegionGrow( );
-
- virtual void _BeforeGenerateData( ) override;
-
- private:
- // Purposely not defined
- RegionGrow( const Self& other );
- Self& operator=( const Self& other );
- };
-
- } // ecapseman
-
-} // ecapseman
-
-#ifndef ITK_MANUAL_INSTANTIATION
-# include <fpa/Image/RegionGrow.hxx>
-#endif // ITK_MANUAL_INSTANTIATION
-
-#endif // __fpa__Image__RegionGrow__h__
-
-// eof - $RCSfile$
+++ /dev/null
-#ifndef __fpa__Image__RegionGrow__hxx__
-#define __fpa__Image__RegionGrow__hxx__
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage >
-fpa::Image::RegionGrow< _TInputImage, _TOutputImage >::
-RegionGrow( )
- : Superclass( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage >
-fpa::Image::RegionGrow< _TInputImage, _TOutputImage >::
-~RegionGrow( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage >
-void fpa::Image::RegionGrow< _TInputImage, _TOutputImage >::
-_BeforeGenerateData( )
-{
- this->Superclass::_BeforeGenerateData( );
- this->m_InitResult = this->GetOutsideValue( );
- TGrowFunction* grow =
- dynamic_cast< TGrowFunction* >( this->GetGrowFunction( ) );
- if( grow != NULL )
- grow->SetImage( this->GetInput( ) );
-}
-
-#endif // __fpa__Image__RegionGrow__hxx__
-
-// eof - $RCSfile$
+++ /dev/null
-#ifndef __fpa__Image__SkeletonFilter__h__
-#define __fpa__Image__SkeletonFilter__h__
-
-#include <map>
-#include <vector>
-#include <fpa/Image/Dijkstra.h>
-#include <cpExtensions/DataStructures/Skeleton.h>
-#include <itkSimpleDataObjectDecorator.h>
-
-namespace fpa
-{
- namespace Image
- {
- /**
- */
- template< class _TImage >
- class SkeletonFilter
- : public Dijkstra< _TImage, _TImage >
- {
- public:
- typedef SkeletonFilter Self;
- typedef Dijkstra< _TImage, _TImage > Superclass;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
-
- typedef _TImage TImage;
- itkStaticConstMacro(
- Dimension, unsigned int, TImage::ImageDimension
- );
-
- typedef typename Superclass::TMST TMST;
- typedef typename TImage::IndexType TIndex;
- typedef itk::Image< unsigned char, Self::Dimension > TMarks;
- typedef cpExtensions::DataStructures::Skeleton< Self::Dimension > TSkeleton;
-
- protected:
- typedef typename Superclass::_TQueueNode _TQueueNode;
- typedef std::multimap< double, TIndex, std::greater< double > > _TSkeletonQueue;
- typedef std::map< TIndex, TIndex, typename TIndex::LexicographicCompare > _TAdjacencies;
-
- public:
- itkNewMacro( Self );
- itkTypeMacro( fpa::Image::SkeletonFilter, itk::Object );
-
- public:
- TSkeleton* GetSkeleton( );
- TMarks* GetMarks( );
-
- protected:
- SkeletonFilter( );
- virtual ~SkeletonFilter( );
-
- virtual void _BeforeGenerateData( ) override;
- virtual void _UpdateResult( const _TQueueNode& n ) override;
- virtual void _AfterGenerateData( ) override;
-
- void _EndPoints( std::vector< TIndex >& end_points, _TAdjacencies& A );
- void _Skeleton( const std::vector< TIndex >& end_points, _TAdjacencies& A );
- void _MarkSphere( const TIndex& idx );
-
- private:
- // Purposely not defined
- SkeletonFilter( const Self& other );
- Self& operator=( const Self& other );
-
- protected:
- _TSkeletonQueue m_SkeletonQueue;
-
- unsigned long m_SkeletonIdx;
- unsigned long m_MarksIdx;
- };
-
- } // ecapseman
-
-} // ecapseman
-
-#ifndef ITK_MANUAL_INSTANTIATION
-# include <fpa/Image/SkeletonFilter.hxx>
-#endif // ITK_MANUAL_INSTANTIATION
-
-#endif // __fpa__Image__SkeletonFilter__h__
-
-// eof - $RCSfile$
+++ /dev/null
-#ifndef __fpa__Image__SkeletonFilter__hxx__
-#define __fpa__Image__SkeletonFilter__hxx__
-
-#include <fpa/Base/Functors/Inverse.h>
-#include <fpa/Image/Functors/SimpleNeighborhood.h>
-#include <itkImageRegionIteratorWithIndex.h>
-
-// -------------------------------------------------------------------------
-#define fpa_Image_SkeletonFilter_OutputMacro( o_n, o_t ) \
- template< class _TImage > \
- typename fpa::Image::SkeletonFilter< _TImage >:: \
- o_t* fpa::Image::SkeletonFilter< _TImage >:: \
- Get##o_n( ) \
- { \
- return( \
- dynamic_cast< o_t* >( \
- this->itk::ProcessObject::GetOutput( this->m_##o_n##Idx ) \
- ) \
- ); \
- }
-
-fpa_Image_SkeletonFilter_OutputMacro( Skeleton, TSkeleton );
-fpa_Image_SkeletonFilter_OutputMacro( Marks, TMarks );
-
-// -------------------------------------------------------------------------
-template< class _TImage >
-fpa::Image::SkeletonFilter< _TImage >::
-SkeletonFilter( )
- : Superclass( )
-{
- typedef typename _TImage::PixelType _TPixel;
- typedef fpa::Image::Functors::SimpleNeighborhood< _TImage::ImageDimension > _TNeighFunc;
- typedef fpa::Base::Functors::Inverse< _TPixel, _TPixel > _TInvFunc;
-
- unsigned int nOutputs = this->GetNumberOfRequiredOutputs( );
- this->SetNumberOfRequiredOutputs( nOutputs + 2 );
- this->m_SkeletonIdx = nOutputs;
- this->m_MarksIdx = nOutputs + 1;
-
- typename TSkeleton::Pointer skeleton = TSkeleton::New( );
- typename TMarks::Pointer marks = TMarks::New( );
- this->SetNthOutput( this->m_SkeletonIdx, skeleton.GetPointer( ) );
- this->SetNthOutput( this->m_MarksIdx, marks.GetPointer( ) );
-
- typename _TNeighFunc::Pointer nfunc = _TNeighFunc::New( );
- nfunc->SetOrder( 2 );
- this->SetNeighborhoodFunction( nfunc );
-
- typename _TInvFunc::Pointer ifunc = _TInvFunc::New( );
- this->SetConversionFunction( ifunc );
-}
-
-// -------------------------------------------------------------------------
-template< class _TImage >
-fpa::Image::SkeletonFilter< _TImage >::
-~SkeletonFilter( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TImage >
-void fpa::Image::SkeletonFilter< _TImage >::
-_BeforeGenerateData( )
-{
- this->Superclass::_BeforeGenerateData( );
- this->m_SkeletonQueue.clear( );
-}
-
-// -------------------------------------------------------------------------
-template< class _TImage >
-void fpa::Image::SkeletonFilter< _TImage >::
-_UpdateResult( const _TQueueNode& n )
-{
- typedef typename _TSkeletonQueue::value_type _TSkeletonQueueValue;
-
- this->Superclass::_UpdateResult( n );
- double d = double( this->GetInput( )->GetPixel( n.Vertex ) );
- if( d >= double( 0 ) )
- {
- // Update skeleton candidates
- d += double( 1e-5 );
- double v = double( n.Result ) / ( d * d );
- this->m_SkeletonQueue.insert( _TSkeletonQueueValue( v, n.Vertex ) );
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-template< class _TImage >
-void fpa::Image::SkeletonFilter< _TImage >::
-_AfterGenerateData( )
-{
- this->Superclass::_AfterGenerateData( );
-
- _TAdjacencies A;
- std::vector< TIndex > end_points;
- this->_EndPoints( end_points, A );
- this->_Skeleton( end_points, A );
-}
-
-// -------------------------------------------------------------------------
-template< class _TImage >
-void fpa::Image::SkeletonFilter< _TImage >::
-_EndPoints( std::vector< TIndex >& end_points, _TAdjacencies& A )
-{
- auto marks = this->GetMarks( );
- auto mst = this->GetMinimumSpanningTree( );
- auto spac = marks->GetSpacing( );
-
- // Some values
- marks->SetLargestPossibleRegion( mst->GetLargestPossibleRegion( ) );
- marks->SetRequestedRegion( mst->GetRequestedRegion( ) );
- marks->SetBufferedRegion( mst->GetBufferedRegion( ) );
- marks->SetSpacing( mst->GetSpacing( ) );
- marks->SetOrigin( mst->GetOrigin( ) );
- marks->SetDirection( mst->GetDirection( ) );
- marks->Allocate( );
- marks->FillBuffer( 0 );
-
- // BFS from maximum queue
- while( this->m_SkeletonQueue.size( ) > 0 )
- {
- // Get node
- auto nIt = this->m_SkeletonQueue.begin( );
- auto n = *nIt;
- this->m_SkeletonQueue.erase( nIt );
-
- // Mark it and update end-points
- unsigned char m = marks->GetPixel( n.second );
- if( m != 0 )
- continue;
- marks->SetPixel( n.second, 1 );
- end_points.push_back( n.second );
-
- // Mark path
- TIndex it = n.second;
- TIndex p = mst->GetParent( it );
- while( it != p )
- {
- this->_MarkSphere( it );
- it = p;
- p = mst->GetParent( it );
-
- } // elihw
- this->_MarkSphere( it );
- A[ n.second ] = it;
-
- } // elihw
-}
-
-// -------------------------------------------------------------------------
-template< class _TImage >
-void fpa::Image::SkeletonFilter< _TImage >::
-_Skeleton( const std::vector< TIndex >& end_points, _TAdjacencies& A )
-{
- typedef itk::Image< unsigned long, Self::Dimension > _TTagsImage;
- typedef typename TMST::TPath _TPath;
-
- auto mst = this->GetMinimumSpanningTree( );
- auto skeleton = this->GetSkeleton( );
-
- // Tag branches
- typename _TTagsImage::Pointer tags = _TTagsImage::New( );
- tags->SetLargestPossibleRegion( mst->GetLargestPossibleRegion( ) );
- tags->SetRequestedRegion( mst->GetRequestedRegion( ) );
- tags->SetBufferedRegion( mst->GetBufferedRegion( ) );
- tags->Allocate( );
- tags->FillBuffer( 0 );
- for( auto eIt = end_points.begin( ); eIt != end_points.end( ); ++eIt )
- {
- TIndex it = *eIt;
- TIndex p = mst->GetParent( it );
- while( it != p )
- {
- tags->SetPixel( it, tags->GetPixel( it ) + 1 );
- it = p;
- p = mst->GetParent( it );
-
- } // elihw
- tags->SetPixel( it, tags->GetPixel( it ) + 1 );
-
- } // rof
-
- // Build paths (branches)
- for( auto eIt = end_points.begin( ); eIt != end_points.end( ); ++eIt )
- {
- TIndex it = *eIt;
- TIndex p = mst->GetParent( it );
- TIndex sIdx = *eIt;
- typename _TPath::Pointer path = _TPath::New( );
- path->SetReferenceImage( mst );
- while( it != p )
- {
- if( tags->GetPixel( sIdx ) != tags->GetPixel( it ) )
- {
- // Ok, a new branch has been added
- path->AddVertex( it );
- skeleton->AddBranch( path );
-
- // Update a new starting index
- path = _TPath::New( );
- path->SetReferenceImage( mst );
- sIdx = it;
- }
- else
- path->AddVertex( it );
- it = p;
- p = mst->GetParent( it );
-
- } // elihw
-
- // Finally, add last branch
- path->AddVertex( it );
- skeleton->AddBranch( path );
-
- } // rof
-}
-
-// -------------------------------------------------------------------------
-template< class _TImage >
-void fpa::Image::SkeletonFilter< _TImage >::
-_MarkSphere( const TIndex& idx )
-{
- typedef itk::ImageRegionIteratorWithIndex< TMarks > _TMarksIt;
-
- static const double _eps = std::sqrt( double( Self::Dimension + 1 ) );
- auto input = this->GetInput( );
- auto marks = this->GetMarks( );
- auto spac = input->GetSpacing( );
- auto region = input->GetRequestedRegion( );
-
- typename _TImage::PointType cnt;
- input->TransformIndexToPhysicalPoint( idx, cnt );
- double r = double( input->GetPixel( idx ) ) * _eps;
-
- TIndex i0, i1;
- for( unsigned int d = 0; d < Self::Dimension; ++d )
- {
- long off = long( std::ceil( r / double( spac[ d ] ) ) );
- if( off < 3 )
- off = 3;
- i0[ d ] = idx[ d ] - off;
- i1[ d ] = idx[ d ] + off;
-
- if( i0[ d ] < region.GetIndex( )[ d ] )
- i0[ d ] = region.GetIndex( )[ d ];
-
- if( i1[ d ] >= region.GetIndex( )[ d ] + region.GetSize( )[ d ] )
- i1[ d ] = region.GetIndex( )[ d ] + region.GetSize( )[ d ] - 1;
-
- } // rof
-
- typename _TImage::SizeType size;
- for( unsigned int d = 0; d < Self::Dimension; ++d )
- size[ d ] = i1[ d ] - i0[ d ] + 1;
-
- typename _TImage::RegionType neighRegion;
- neighRegion.SetIndex( i0 );
- neighRegion.SetSize( size );
-
- _TMarksIt mIt( marks, neighRegion );
- for( mIt.GoToBegin( ); !mIt.IsAtEnd( ); ++mIt )
- {
- TIndex w = mIt.GetIndex( );
- typename _TImage::PointType p;
- marks->TransformIndexToPhysicalPoint( w, p );
- mIt.Set( 1 );
-
- } // rof
-}
-
-#endif // __fpa__Image__SkeletonFilter__hxx__
-
-// eof - $RCSfile$
+++ /dev/null
-header #define ITK_MANUAL_INSTANTIATION
-
-*define i_scalars=#scalar_types#
-*define o_scalars=#scalar_types#
-
-*tinclude fpa/Base/Algorithm:h|hxx
-*tinclude fpa/Image/Algorithm:h|hxx
-
-*instances fpa::Base::Algorithm< itk::ImageToImageFilter< itk::Image< #i_scalars#, #pdims# >, itk::Image< #o_scalars#, #pdims# > >, itk::Index< #pdims# >, #o_scalars# >
-*instances fpa::Image::Algorithm< itk::Image< #i_scalars#, #pdims# >, itk::Image< #o_scalars#, #pdims# > >
-
-** eof - $RCSfile$
+++ /dev/null
-## ===========================
-## == Compile each instance ==
-## ===========================
-IF(USE_cpPlugins)
- INCLUDE_DIRECTORIES(
- ${PROJECT_SOURCE_DIR}/lib
- ${PROJECT_BINARY_DIR}/lib
- )
- SET(_pfx fpaInstaces)
- SET(_instances
- DataObjects
- ImageFunctors
- ImageFilters
- )
- SET(_build_instances)
- FOREACH(_i ${_instances})
- cpPlugins_BuildLibrary(
- ${_pfx}${_i} SHARED ${CMAKE_CURRENT_SOURCE_DIR}/${_i}.i
- )
- TARGET_LINK_LIBRARIES(
- ${_pfx}${_i}
- ${cpPlugins_AllInstances} ${ITK_LIBRARIES} ${VTK_LIBRARIES}
- )
- LIST(APPEND _build_instances ${_pfx}${_i})
- ENDFOREACH(_i)
-
- TARGET_LINK_LIBRARIES(
- ${_pfx}ImageFilters
- ${_pfx}DataObjects
- ${_pfx}ImageFunctors
- cpPlugins_ITKUnaryFunctorFilters
- )
- SET(
- fpa_AllInstances
- ${_build_instances}
- CACHE INTERNAL "All valid instances." FORCE
- )
-ENDIF(USE_cpPlugins)
-
-## eof - $RCSfile$
+++ /dev/null
-header #define ITK_MANUAL_INSTANTIATION
-
-tinclude fpa/Base/MinimumSpanningTree:h|hxx
-tinclude fpa/Image/MinimumSpanningTree:h|hxx
-
-instances fpa::Base::MinimumSpanningTree< itk::Index< #pdims# >, cpExtensions::DataStructures::PolyLineParametricPath< #pdims# >, itk::Image< itk::Offset< #pdims# >, #pdims# > >
-instances fpa::Image::MinimumSpanningTree< #pdims# >
-
-** eof - $RCSfile$
+++ /dev/null
-header #define ITK_MANUAL_INSTANTIATION
-
-define all_inputs=#scalar_types#
-define all_outputs=#scalar_types#
-define all_int_types=#int_types#;#uint_types#
-
-tinclude fpa/Base/Algorithm:h|hxx
-tinclude fpa/Image/Algorithm:h|hxx
-tinclude fpa/Image/RegionGrow:h|hxx
-tinclude fpa/Base/RegionGrow:h|hxx
-tinclude fpa/Image/Dijkstra:h|hxx
-tinclude fpa/Image/FastMarching:h|hxx
-
-cinclude fpa/Base/QueueAlgorithm.hxx
-cinclude fpa/Base/PriorityQueueAlgorithm.hxx
-cinclude fpa/Base/Dijkstra.hxx
-cinclude fpa/Base/FastMarching.hxx
-
-instances fpa::Base::Algorithm< itk::ImageToImageFilter< itk::Image< #all_inputs#, #pdims# >, itk::Image< #all_outputs#, #pdims# > >, itk::Index< #pdims# >, #all_outputs# >
-instances fpa::Image::Algorithm< itk::Image< #scalar_types#, #pdims# >, itk::Image< #all_int_types#, #pdims# > >
-
-instances fpa::Base::RegionGrow< fpa::Image::Algorithm< itk::Image< #scalar_types#, #pdims# >, itk::Image< #all_int_types#, #pdims# > > >
-instances fpa::Image::RegionGrow< itk::Image< #scalar_types#, #pdims# >, itk::Image< #all_int_types#, #pdims# > >
-
-instances fpa::Image::Dijkstra< itk::Image< #scalar_types#, #pdims# >, itk::Image< #real_types#, #pdims# > >
-instances fpa::Image::FastMarching< itk::Image< #scalar_types#, #pdims# >, itk::Image< #real_types#, #pdims# > >
-
-** eof - $RCSfile$
+++ /dev/null
-header #define ITK_MANUAL_INSTANTIATION
-
-define all_int_types=#int_types#;#uint_types#
-define i_scalar_types=#scalar_types#
-define o_scalar_types=#scalar_types#
-
-tinclude fpa/Image/Functors/VertexCost:h|hxx
-tinclude fpa/Image/Functors/SimpleNeighborhood:h|hxx
-tinclude fpa/Image/Functors/RegionGrow/BinaryThreshold:h|hxx
-cinclude itkImage.h
-
-instances fpa::Image::Functors::VertexCost< itk::Image< #i_scalar_types#, #pdims# >, #o_scalar_types# >
-instances fpa::Image::Functors::SimpleNeighborhood< #pdims# >
-instances fpa::Image::Functors::RegionGrow::BinaryThreshold< itk::Image< #scalar_types#, #pdims# >, #all_int_types# >
-
-** eof - $RCSfile$
+++ /dev/null
-## ==========================
-## == Build plugin library ==
-## ==========================
-
-IF(USE_cpPlugins)
- INCLUDE_DIRECTORIES(
- ${PROJECT_SOURCE_DIR}/lib
- ${PROJECT_BINARY_DIR}/lib
- ${PROJECT_SOURCE_DIR}/plugins
- ${PROJECT_BINARY_DIR}/plugins
- )
-
- SET(
- _dirs
- Functors
- ImageFunctors
- ImageAlgorithms
- # RegionGrowFunctors
- # DijkstraFunctors
- )
-
- FOREACH(_d ${_dirs})
- cpPlugins_BuildPluginsLibrary(
- fpaPlugins_${_d} ${CMAKE_CURRENT_SOURCE_DIR}/${_d}
- )
- TARGET_LINK_LIBRARIES(
- fpaPlugins_${_d}
- cpPlugins cpPluginsDataObjects cpExtensions
- ${fpa_AllInstances}
- )
- ENDFOREACH(_d)
-
-
-# OPTION(BUILD_ExperimentationPlugins "Build plugins for experimentation?" OFF)
-# IF(BUILD_ExperimentationPlugins)
-# LIST(APPEND _dirs Experiments)
-# ENDIF(BUILD_ExperimentationPlugins)
-
-# FOREACH(_d ${_dirs})
-# cpPlugins_BuildPluginsLibrary(
-# fpaPlugins${_d} ${CMAKE_CURRENT_SOURCE_DIR}/${_d}
-# )
-# TARGET_LINK_LIBRARIES(
-# fpaPlugins${_d}
-# cpPlugins cpPluginsDataObjects cpExtensions
-# ${fpa_AllInstances}
-# )
-# ENDFOREACH(_d)
-# TARGET_LINK_LIBRARIES(
-# fpaPluginsImageAlgorithms
-# cpPlugins_ITKUnaryFunctorFilters
-# fpaPluginsRegionGrowFunctors
-# fpaPluginsDijkstraFunctors
-# )
-ENDIF(USE_cpPlugins)
-
-## eof - $RCSfile$
+++ /dev/null
-header #define ITK_MANUAL_INSTANTIATION
-
-define i_reals=#real_types#
-define o_reals=#real_types#
-tinclude fpa/Base/Functors/Inverse:h|hxx
-tinclude fpa/Base/Functors/GaussianModel:h|hxx
-
-instances fpa::Base::Functors::Inverse< #i_reals#, #o_reals# >
-instances fpa::Base::Functors::GaussianModel< #i_reals#, #o_reals# >
-
-
-** eof - $RCSfile$
+++ /dev/null
-#include <DijkstraFunctors/ExtractPathFromMinimumSpanningTree.h>
-#include <cpInstances/DataObjects/Image.h>
-#include <cpInstances/DataObjects/PolyLineParametricPath.h>
-#include <vtkPolyData.h>
-#include <fpa/Image/MinimumSpanningTree.h>
-
-// -------------------------------------------------------------------------
-fpaPluginsDijkstraFunctors::ExtractPathFromMinimumSpanningTree::
-ExtractPathFromMinimumSpanningTree( )
- : Superclass( )
-{
- typedef cpPlugins::Pipeline::DataObject _TData;
- typedef cpInstances::DataObjects::Image _TMST;
- typedef cpInstances::DataObjects::PolyLineParametricPath _TPath;
-
- this->_ConfigureInput< _TMST >( "MST", true, false );
- this->_ConfigureInput< _TData >( "Seeds", true, false );
- this->_ConfigureOutput< _TPath >( "Output" );
-}
-
-// -------------------------------------------------------------------------
-fpaPluginsDijkstraFunctors::ExtractPathFromMinimumSpanningTree::
-~ExtractPathFromMinimumSpanningTree( )
-{
-}
-
-// -------------------------------------------------------------------------
-void fpaPluginsDijkstraFunctors::ExtractPathFromMinimumSpanningTree::
-_GenerateData( )
-{
- typedef fpa::Image::MinimumSpanningTree< 2 > _TMST2;
- typedef fpa::Image::MinimumSpanningTree< 3 > _TMST3;
-
- auto mst2 = this->GetInputData< _TMST2 >( "MST" );
- auto mst3 = this->GetInputData< _TMST3 >( "MST" );
- if ( mst2 != NULL ) this->_GD0( mst2 );
- else if( mst3 != NULL ) this->_GD0( mst3 );
- else this->_Error( "Invalid input spanning tree." );
-}
-
-// -------------------------------------------------------------------------
-template< class _TMST >
-void fpaPluginsDijkstraFunctors::ExtractPathFromMinimumSpanningTree::
-_GD0( _TMST* mst )
-{
- typedef typename _TMST::IndexType _TIndex;
- typedef typename _TMST::TPath _TPath;
-
- // Get seeds
- std::vector< _TIndex > seeds;
- auto points = this->GetInputData< vtkPolyData >( "Seeds" );
- if( points != NULL )
- {
- if( points->GetNumberOfPoints( ) < 2 )
- this->_Error( "Not enough seeds (<2)." );
-
- typename _TMST::PointType pnt;
- typename _TMST::IndexType idx;
- unsigned int dim =
- ( _TMST::ImageDimension < 3 )? _TMST::ImageDimension: 3;
- for( unsigned int i = 0; i < 2; ++i )
- {
- double buf[ 3 ];
- points->GetPoint( i, buf );
- pnt.Fill( 0 );
- for( unsigned int d = 0; d < dim; ++d )
- pnt[ d ] = buf[ d ];
- if( mst->TransformPhysicalPointToIndex( pnt, idx ) )
- seeds.push_back( idx );
-
- } // rof
-
- } // fi
-
- typename _TPath::Pointer path;
- mst->GetPath( path, seeds[ 0 ], seeds[ 1 ] );
- this->GetOutput( "Output" )->SetITK( path );
-}
-
-// eof - $RCSfile$
+++ /dev/null
-#ifndef __fpaPluginsDijkstraFunctors__ExtractPathFromMinimumSpanningTree__h__
-#define __fpaPluginsDijkstraFunctors__ExtractPathFromMinimumSpanningTree__h__
-
-#include <fpaPluginsDijkstraFunctors_Export.h>
-#include <cpPlugins/Pipeline/ProcessObject.h>
-
-namespace fpaPluginsDijkstraFunctors
-{
- /**
- */
- class fpaPluginsDijkstraFunctors_EXPORT ExtractPathFromMinimumSpanningTree
- : public cpPlugins::Pipeline::ProcessObject
- {
- cpPluginsObject(
- ExtractPathFromMinimumSpanningTree,
- cpPlugins::Pipeline::ProcessObject,
- fpaDijkstraFunctors
- );
-
- protected:
- template< class _TMST >
- inline void _GD0( _TMST* mst );
- };
-
-} // ecapseman
-
-#endif // __fpaPluginsDijkstraFunctors__ExtractPathFromMinimumSpanningTree__h__
-
-// eof - $RCSfile$
+++ /dev/null
-#include <DijkstraFunctors/GaussianModelCost.h>
-#include <cpInstances/DataObjects/Image.h>
-
-#include <fpa/Base/Functors/GaussianModel.h>
-
-// -------------------------------------------------------------------------
-fpaPluginsDijkstraFunctors::GaussianModelCost::
-GaussianModelCost( )
- : Superclass( )
-{
- typedef cpPlugins::Pipeline::DataObject _TData;
- this->_ConfigureOutput< _TData >( "Output" );
-
- std::vector< std::string > choices;
- choices.push_back( "float" );
- choices.push_back( "double" );
- this->m_Parameters.ConfigureAsChoices( "ResultType", choices );
- this->m_Parameters.SetSelectedChoice( "ResultType", "float" );
-}
-
-// -------------------------------------------------------------------------
-fpaPluginsDijkstraFunctors::GaussianModelCost::
-~GaussianModelCost( )
-{
-}
-
-// -------------------------------------------------------------------------
-void fpaPluginsDijkstraFunctors::GaussianModelCost::
-_GenerateData( )
-{
- auto rtype = this->m_Parameters.GetSelectedChoice( "ResultType" );
- if ( rtype == "float" ) this->_GD0< float >( );
- else if( rtype == "double" ) this->_GD0< double >( );
-}
-
-// -------------------------------------------------------------------------
-template< class _TOutput >
-void fpaPluginsDijkstraFunctors::GaussianModelCost::
-_GD0( )
-{
- typedef fpa::Base::Functors::GaussianModel< _TOutput, _TOutput > _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
-}
-
-// eof - $RCSfile$
+++ /dev/null
-#ifndef __fpa__Plugins__GaussianModelCost__h__
-#define __fpa__Plugins__GaussianModelCost__h__
-
-#include <fpaPluginsDijkstraFunctors_Export.h>
-#include <cpPlugins/Pipeline/ProcessObject.h>
-
-namespace fpaPluginsDijkstraFunctors
-{
- /**
- */
- class fpaPluginsDijkstraFunctors_EXPORT GaussianModelCost
- : public cpPlugins::Pipeline::ProcessObject
- {
- cpPluginsObject(
- GaussianModelCost,
- cpPlugins::Pipeline::ProcessObject,
- fpaDijkstraFunctors
- );
-
- protected:
- template< class _TOutput >
- inline void _GD0( );
- };
-
-} // ecapseman
-
-#endif // __fpa__Plugins__GaussianModelCost__h__
-
-// eof - $RCSfile$
+++ /dev/null
-#include <DijkstraFunctors/InvertCost.h>
-#include <cpInstances/DataObjects/Image.h>
-
-#include <fpa/Base/Functors/Inverse.h>
-
-// -------------------------------------------------------------------------
-fpaPluginsDijkstraFunctors::InvertCost::
-InvertCost( )
- : Superclass( )
-{
- typedef cpPlugins::Pipeline::DataObject _TData;
- this->_ConfigureOutput< _TData >( "Output" );
-
- std::vector< std::string > choices;
- choices.push_back( "float" );
- choices.push_back( "double" );
- this->m_Parameters.ConfigureAsChoices( "ResultType", choices );
- this->m_Parameters.ConfigureAsReal( "NegativeValue", -1 );
- this->m_Parameters.SetSelectedChoice( "ResultType", "float" );
-}
-
-// -------------------------------------------------------------------------
-fpaPluginsDijkstraFunctors::InvertCost::
-~InvertCost( )
-{
-}
-
-// -------------------------------------------------------------------------
-void fpaPluginsDijkstraFunctors::InvertCost::
-_GenerateData( )
-{
- auto rtype = this->m_Parameters.GetSelectedChoice( "ResultType" );
- if ( rtype == "float" ) this->_GD0< float >( );
- else if( rtype == "double" ) this->_GD0< double >( );
-}
-
-// -------------------------------------------------------------------------
-template< class _TOutput >
-void fpaPluginsDijkstraFunctors::InvertCost::
-_GD0( )
-{
- typedef fpa::Base::Functors::Inverse< _TOutput, _TOutput > _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->SetNegativeValue( this->m_Parameters.GetReal( "NegativeValue" ) );
-}
-
-// eof - $RCSfile$
+++ /dev/null
-#ifndef __fpa__Plugins__InvertCost__h__
-#define __fpa__Plugins__InvertCost__h__
-
-#include <fpaPluginsDijkstraFunctors_Export.h>
-#include <cpPlugins/Pipeline/ProcessObject.h>
-
-namespace fpaPluginsDijkstraFunctors
-{
- /**
- */
- class fpaPluginsDijkstraFunctors_EXPORT InvertCost
- : public cpPlugins::Pipeline::ProcessObject
- {
- cpPluginsObject(
- InvertCost,
- cpPlugins::Pipeline::ProcessObject,
- fpaDijkstraFunctors
- );
-
- protected:
- template< class _TOutput >
- inline void _GD0( );
- };
-
-} // ecapseman
-
-#endif // __fpa__Plugins__InvertCost__h__
-
-// eof - $RCSfile$
+++ /dev/null
-#include <DijkstraFunctors/SimpleImageDijkstraCost.h>
-#include <cpInstances/DataObjects/Image.h>
-
-#include <itkImage.h>
-
-// TODO: #include <fpa/Image/Functors/SimpleDijkstraCost.h>
-
-// -------------------------------------------------------------------------
-fpaPluginsDijkstraFunctors::SimpleImageDijkstraCost::
-SimpleImageDijkstraCost( )
- : Superclass( )
-{
- typedef cpPlugins::Pipeline::DataObject _TData;
- typedef cpInstances::DataObjects::Image _TImage;
-
- this->_ConfigureInput< _TImage >( "Input", true, false );
- this->_ConfigureOutput< _TData >( "Output" );
-
- std::vector< std::string > choices;
- choices.push_back( "float" );
- choices.push_back( "double" );
- this->m_Parameters.ConfigureAsChoices( "ResultType", choices );
- this->m_Parameters.SetSelectedChoice( "ResultType", "float" );
- this->m_Parameters.ConfigureAsBool( "UseImageSpacing", false );
-}
-
-// -------------------------------------------------------------------------
-fpaPluginsDijkstraFunctors::SimpleImageDijkstraCost::
-~SimpleImageDijkstraCost( )
-{
-}
-
-// -------------------------------------------------------------------------
-void fpaPluginsDijkstraFunctors::SimpleImageDijkstraCost::
-_GenerateData( )
-{
- auto o = this->GetInputData( "Input" );
- cpPlugins_Demangle_Image_ScalarPixels_AllDims_1( o, _GD0 )
- this->_Error( "Invalid input image." );
-}
-
-// -------------------------------------------------------------------------
-template< class _TImage >
-void fpaPluginsDijkstraFunctors::SimpleImageDijkstraCost::
-_GD0( _TImage* image )
-{
- auto rtype = this->m_Parameters.GetSelectedChoice( "ResultType" );
- if ( rtype == "float" ) this->_GD1< _TImage, float >( image );
- else if( rtype == "double" ) this->_GD1< _TImage, double >( image );
-}
-
-// -------------------------------------------------------------------------
-template< class _TImage, class _TOutput >
-void fpaPluginsDijkstraFunctors::SimpleImageDijkstraCost::
-_GD1( _TImage* image )
-{
- /* TODO
- typedef
- fpa::Image::Functors::SimpleDijkstraCost< _TImage, _TOutput >
- _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->SetUseImageSpacing( this->m_Parameters.GetBool( "UseImageSpacing" ) );
- */
-}
-
-// eof - $RCSfile$
+++ /dev/null
-#ifndef __fpa__Plugins__SimpleImageDijkstraCost__h__
-#define __fpa__Plugins__SimpleImageDijkstraCost__h__
-
-#include <fpaPluginsDijkstraFunctors_Export.h>
-#include <cpPlugins/Pipeline/ProcessObject.h>
-
-namespace fpaPluginsDijkstraFunctors
-{
- /**
- */
- class fpaPluginsDijkstraFunctors_EXPORT SimpleImageDijkstraCost
- : public cpPlugins::Pipeline::ProcessObject
- {
- cpPluginsObject(
- SimpleImageDijkstraCost,
- cpPlugins::Pipeline::ProcessObject,
- fpaDijkstraFunctors
- );
-
- protected:
- template< class _TImage >
- inline void _GD0( _TImage* image );
-
- template< class _TImage, class _TOutput >
- inline void _GD1( _TImage* image );
- };
-
-} // ecapseman
-
-#endif // __fpa__Plugins__SimpleImageDijkstraCost__h__
-
-// eof - $RCSfile$
+++ /dev/null
-#include <Experiments/InsertNoiseIntoPoints.h>
-#include <cpInstances/DataObjects/Image.h>
-#include <cpInstances/DataObjects/Mesh.h>
-
-#include <random>
-#include <vtkImageData.h>
-#include <vtkPolyData.h>
-
-// -------------------------------------------------------------------------
-fpaPluginsExperiments::InsertNoiseIntoPoints::
-InsertNoiseIntoPoints( )
- : Superclass( )
-{
- typedef cpInstances::DataObjects::Image _TImage;
- typedef cpInstances::DataObjects::Mesh _TMesh;
-
- this->_ConfigureInput< _TMesh >( "Seeds", true, false );
- this->_ConfigureInput< _TImage >( "DistanceMap", true, false );
- this->_ConfigureOutput< _TMesh >( "Output" );
- this->m_Parameters.ConfigureAsBool( "InsertNoise", false );
-
- // Create output data
- auto out = this->_CreateVTK< vtkPolyData >( );
- out->SetPoints( vtkSmartPointer< vtkPoints >::New( ) );
- out->SetVerts( vtkSmartPointer< vtkCellArray >::New( ) );
- out->SetLines( vtkSmartPointer< vtkCellArray >::New( ) );
- out->SetPolys( vtkSmartPointer< vtkCellArray >::New( ) );
- out->SetStrips( vtkSmartPointer< vtkCellArray >::New( ) );
- this->GetOutput( "Output" )->SetVTK( out );
-}
-
-// -------------------------------------------------------------------------
-fpaPluginsExperiments::InsertNoiseIntoPoints::
-~InsertNoiseIntoPoints( )
-{
-}
-
-// -------------------------------------------------------------------------
-void fpaPluginsExperiments::InsertNoiseIntoPoints::
-_GenerateData( )
-{
- auto dmap = this->GetInputData< vtkImageData >( "DistanceMap" );
- auto seeds = this->GetInputData< vtkPolyData >( "Seeds" );
- auto out = this->GetOutputData< vtkPolyData >( "Output" );
-
- typedef std::uniform_real_distribution< double > _TDist;
- std::random_device rd;
- std::mt19937 gen( rd( ) );
- for( int i = 0; i < seeds->GetNumberOfPoints( ); ++i )
- {
- double buf[ 3 ], pcoords[ 3 ];
- seeds->GetPoint( i, buf );
-
- if( this->m_Parameters.GetBool( "InsertNoise" ) )
- {
- int ijk[ 3 ];
- dmap->ComputeStructuredCoordinates( buf, ijk, pcoords );
- double radius =
- dmap->GetScalarComponentAsDouble( ijk[ 0 ], ijk[ 1 ], ijk[ 2 ], 0 );
- double rad_dis = _TDist( 1e-2, radius * 0.9 )( gen );
- double the_dis = _TDist( 0, 3.14159265359 )( gen );
- double phi_dis = _TDist( 0, 6.28318530718 )( gen );
- buf[ 0 ] += rad_dis * std::sin( the_dis ) * std::cos( phi_dis );
- buf[ 1 ] += rad_dis * std::sin( the_dis ) * std::sin( phi_dis );
- buf[ 2 ] += rad_dis * std::cos( the_dis );
-
- } // fi
- out->GetPoints( )->InsertNextPoint( buf );
- out->GetVerts( )->InsertNextCell( 1 );
- out->GetVerts( )->InsertCellPoint( i );
- out->Modified( );
-
- } // rof
-}
-
-// eof - $RCSfile$
+++ /dev/null
-#ifndef __fpaPluginsExperiments__InsertNoiseIntoPoints__h__
-#define __fpaPluginsExperiments__InsertNoiseIntoPoints__h__
-
-#include <fpaPluginsExperiments_Export.h>
-#include <cpPlugins/Pipeline/ProcessObject.h>
-
-namespace fpaPluginsExperiments
-{
- /**
- */
- class fpaPluginsExperiments_EXPORT InsertNoiseIntoPoints
- : public cpPlugins::Pipeline::ProcessObject
- {
- cpPluginsObject(
- InsertNoiseIntoPoints,
- cpPlugins::Pipeline::ProcessObject,
- fpaExperiments
- );
- };
-
-} // ecapseman
-
-#endif // __fpaPluginsExperiments__InsertNoiseIntoPoints__h__
-
-// eof - $RCSfile$
+++ /dev/null
-#include <Experiments/SkeletonHausdorffDistance.h>
-#include <cpInstances/DataObjects/Image.h>
-#include <cpInstances/DataObjects/Mesh.h>
-#include <cpInstances/DataObjects/Skeleton.h>
-#include <cpExtensions/DataStructures/Skeleton.h>
-
-#include <vtkImageData.h>
-#include <vtkPolyData.h>
-
-// -------------------------------------------------------------------------
-fpaPluginsExperiments::SkeletonHausdorffDistance::
-SkeletonHausdorffDistance( )
- : Superclass( )
-{
- this->_ConfigureInput< cpInstances::DataObjects::Image >( "DistanceMap", true, false );
- this->_ConfigureInput< cpInstances::DataObjects::Mesh >( "Seeds", true, false );
- this->_ConfigureInput< cpInstances::DataObjects::Skeleton >( "Skeleton1", true, false );
- this->_ConfigureInput< cpInstances::DataObjects::Skeleton >( "Skeleton2", true, false );
-}
-
-// -------------------------------------------------------------------------
-fpaPluginsExperiments::SkeletonHausdorffDistance::
-~SkeletonHausdorffDistance( )
-{
-}
-
-// -------------------------------------------------------------------------
-void fpaPluginsExperiments::SkeletonHausdorffDistance::
-_GenerateData( )
-{
- typedef cpExtensions::DataStructures::Skeleton< 3 > _TSkeleton;
-
- auto dmap = this->GetInputData< vtkImageData >( "DistanceMap" );
- auto seeds = this->GetInputData< vtkPolyData >( "Seeds" );
- auto sk1 = this->GetInputData< _TSkeleton >( "Skeleton1" );
- auto sk2 = this->GetInputData< _TSkeleton >( "Skeleton2" );
-
- double buf[ 3 ], pcoords[ 3 ];
- seeds->GetPoint( 0, buf );
- int ijk[ 3 ];
- dmap->ComputeStructuredCoordinates( buf, ijk, pcoords );
- double radius =
- dmap->GetScalarComponentAsDouble( ijk[ 0 ], ijk[ 1 ], ijk[ 2 ], 0 );
-
- double d1 = this->_Distance( sk1, sk2, NULL, 0 );
- double d2 = this->_Distance( sk1, sk2, buf, radius );
-
- std::cout
- << std::endl
- << "-------------------------------" << std::endl
- << "D1 : " << d1 << std::endl
- << "D2 : " << d2 << std::endl
- << "Radius: " << radius << std::endl
- << "Seed : " << buf[ 0 ] << " " << buf[ 1 ] << " " << buf[ 2 ] << std::endl
- << "-------------------------------" << std::endl;
-}
-
-// -------------------------------------------------------------------------
-template< class _TSkeleton >
-double fpaPluginsExperiments::SkeletonHausdorffDistance::
-_Distance( _TSkeleton* sk1, _TSkeleton* sk2, double* center, double radius )
-{
- auto lst1 = this->_PointList( sk1, center, radius );
- auto lst2 = this->_PointList( sk2, center, radius );
- double dist = -std::numeric_limits< double >::max( );
- typename _TSkeleton::TPath::TPoint point;
- for( auto p1 : lst1 )
- {
- double ldist = std::numeric_limits< double >::max( );
- typename _TSkeleton::TPath::TPoint lpoint;
- for( auto p2 : lst2 )
- {
- double d = p1.EuclideanDistanceTo( p2 );
- if( d < ldist )
- {
- ldist = d;
- lpoint = p2;
-
- } // fi
-
- } // rof
- if( ldist > dist )
- {
- dist = ldist;
- point = lpoint;
-
- } // fi
-
- } // rof
- return( dist );
-}
-
-// -------------------------------------------------------------------------
-template< class _TSkeleton >
-std::vector< typename _TSkeleton::TPath::TPoint >
-fpaPluginsExperiments::SkeletonHausdorffDistance::
-_PointList( _TSkeleton* sk, double* center, double radius )
-{
- typename _TSkeleton::TPath::TPoint p_center;
- if( center != NULL )
- for( unsigned int d = 0; d < _TSkeleton::Dimension; ++d )
- p_center[ d ] = center[ d ];
-
- std::vector< typename _TSkeleton::TPath::TPoint > lst;
- auto mIt = sk->BeginEdgesRows( );
- for( ; mIt != sk->EndEdgesRows( ); ++mIt )
- {
- auto rIt = mIt->second.begin( );
- for( ; rIt != mIt->second.end( ); ++rIt )
- {
- auto eIt = rIt->second.begin( );
- for( ; eIt != rIt->second.end( ); ++eIt )
- {
- auto path = *eIt;
- for( unsigned int i = 0; i < path->GetSize( ); ++i )
- {
- auto p = path->GetPoint( i );
- if( center != NULL )
- {
- if( p_center.EuclideanDistanceTo( p ) > radius )
- lst.push_back( p );
- }
- else
- lst.push_back( p );
-
- } // rof
-
- } // rof
-
- } // rof
-
- } // rof
- return( lst );
-}
-
-// eof - $RCSfile$
+++ /dev/null
-#ifndef __fpaPluginsExperiments__SkeletonHausdorffDistance__h__
-#define __fpaPluginsExperiments__SkeletonHausdorffDistance__h__
-
-#include <fpaPluginsExperiments_Export.h>
-#include <cpPlugins/Pipeline/ProcessObject.h>
-
-namespace fpaPluginsExperiments
-{
- /**
- */
- class fpaPluginsExperiments_EXPORT SkeletonHausdorffDistance
- : public cpPlugins::Pipeline::ProcessObject
- {
- cpPluginsObject(
- SkeletonHausdorffDistance,
- cpPlugins::Pipeline::ProcessObject,
- fpaExperiments
- );
-
- protected:
- template< class _TSkeleton >
- inline double _Distance(
- _TSkeleton* sk1, _TSkeleton* sk2,
- double* center,
- double radius
- );
-
- template< class _TSkeleton >
- inline std::vector< typename _TSkeleton::TPath::TPoint > _PointList(
- _TSkeleton* sk,
- double* center,
- double radius
- );
- };
-
-} // ecapseman
-
-#endif // __fpaPluginsExperiments__SkeletonHausdorffDistance__h__
-
-// eof - $RCSfile$
+++ /dev/null
-
-tinclude fpa/Base/Functors/Inverse:h|hxx
-
-instances fpa::Base::Functors::Inverse< #scalar_types#, #real_types# >
-
-** eof - $RCSfile$
+++ /dev/null
-#include "Inverse.h"
-
-#include <cpInstances/DataObjects/Image.h>
-
-#include <itkImage.h>
-#include <fpa/Base/Functors/Inverse.h>
-
-// -------------------------------------------------------------------------
-void fpaPlugins_Functors::Inverse::
-Instantiate( itk::LightObject* filter )
-{
- auto itk_filter = dynamic_cast< itk::ProcessObject* >( filter );
- if( itk_filter != NULL )
- {
- auto inputs = itk_filter->GetInputs( );
- if( inputs.size( ) > 0 )
- {
- cpPlugins_Demangle_Image_ScalarPixels_AllDims_2(
- inputs[ 0 ].GetPointer( ), _GD0, itk_filter
- )
- this->_Error( "Invalid input data." );
- }
- else
- this->_Error( "Not enough inputs." );
- }
- else
- this->_Error( "Invalid instantiation filter." );
-}
-
-// -------------------------------------------------------------------------
-fpaPlugins_Functors::Inverse::
-Inverse( )
- : Superclass( )
-{
- this->_ConfigureOutput< cpPlugins::Pipeline::DataObject >( "Functor" );
- this->m_Parameters.ConfigureAsReal( "NegativeValue", -1 );
- this->GetOutput( "Functor" )->SetITK( this );
-}
-
-// -------------------------------------------------------------------------
-fpaPlugins_Functors::Inverse::
-~Inverse( )
-{
-}
-
-// -------------------------------------------------------------------------
-void fpaPlugins_Functors::Inverse::
-_GenerateData( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TInput >
-void fpaPlugins_Functors::Inverse::
-_GD0( _TInput* input, itk::ProcessObject* filter )
-{
- auto outputs = filter->GetOutputs( );
- if( outputs.size( ) > 0 )
- {
- cpPlugins_Demangle_Image_RealPixels_3(
- outputs[ 0 ].GetPointer( ), _GD1, _TInput::ImageDimension, input, filter
- )
- this->_Error( "Invalid output data." );
- }
- else
- this->_Error( "Not enough outputs." );
-}
-
-// -------------------------------------------------------------------------
-template< class _TInput, class _TOutput >
-void fpaPlugins_Functors::Inverse::
-_GD1( _TOutput* output, _TInput* input, itk::ProcessObject* filter )
-{
- typedef typename _TInput::PixelType _TIValue;
- typedef typename _TOutput::PixelType _TOValue;
- typedef fpa::Base::Functors::Inverse< _TIValue, _TOValue > _TFunctor;
-
- auto f = dynamic_cast< _TFunctor* >( this->m_Functor.GetPointer( ) );
- if( f == NULL )
- {
- typename _TFunctor::Pointer ptr_f = _TFunctor::New( );
- f = ptr_f.GetPointer( );
- this->m_Functor = f;
-
- } // fi
- f->SetNegativeValue( this->m_Parameters.GetReal( "NegativeValue" ) );
-}
-
-// eof - $RCSfile$
+++ /dev/null
-#ifndef __fpaPlugins_Functors__Inverse__h__
-#define __fpaPlugins_Functors__Inverse__h__
-
-#include <itkProcessObject.h>
-#include <fpaPlugins_Functors_Export.h>
-#include <cpPlugins/Pipeline/Functor.h>
-
-namespace fpaPlugins_Functors
-{
- /**
- */
- class fpaPlugins_Functors_EXPORT Inverse
- : public cpPlugins::Pipeline::Functor
- {
- cpPluginsObject( Inverse, cpPlugins::Pipeline::Functor, fpaFunctors );
-
- public:
- virtual void Instantiate( itk::LightObject* filter ) override;
-
- protected:
- template< class _TInput >
- inline void _GD0( _TInput* input, itk::ProcessObject* filter );
-
- template< class _TInput, class _TOutput >
- inline void _GD1( _TOutput* output, _TInput* input, itk::ProcessObject* filter );
- };
-
-} // ecapseman
-
-#endif // __fpaPlugins_Functors__Inverse__h__
-
-// eof - $RCSfile$
+++ /dev/null
-#include "BaseFilter.h"
-#include <cpInstances/DataObjects/Image.h>
-
-// -------------------------------------------------------------------------
-fpaPlugins_ImageAlgorithms::BaseFilter::
-BaseFilter( )
- : Superclass( )
-{
- typedef cpPlugins::Pipeline::DataObject _TData;
- typedef cpInstances::DataObjects::Image _TImage;
-
- this->_ConfigureInput< _TImage >( "Input", true, false );
- this->_ConfigureInput< _TData >( "Seeds", true, false );
- this->_ConfigureOutput< _TImage >( "Output" );
-
- this->m_Parameters.ConfigureAsUint( "NeighborhoodOrder", 1 );
- this->m_Parameters.ConfigureAsBool( "VisualDebug", false );
- this->m_Parameters.ConfigureAsBool( "StopAtOneFront", false );
-}
-
-// -------------------------------------------------------------------------
-fpaPlugins_ImageAlgorithms::BaseFilter::
-~BaseFilter( )
-{
-}
-
-// eof - $RCSfile$
+++ /dev/null
-#ifndef __fpaPlugins_ImageAlgorithms__BaseFilter__h__
-#define __fpaPlugins_ImageAlgorithms__BaseFilter__h__
-
-#include <fpaPlugins_ImageAlgorithms_Export.h>
-
-#include <vtkPolyData.h>
-#include <cpPlugins/Pipeline/ProcessObject.h>
-
-namespace fpaPlugins_ImageAlgorithms
-{
- /**
- */
- class fpaPlugins_ImageAlgorithms_EXPORT BaseFilter
- : public cpPlugins::Pipeline::ProcessObject
- {
- public:
- typedef BaseFilter Self;
- typedef cpPlugins::Pipeline::ProcessObject Superclass;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
-
- public:
- itkTypeMacro( BaseFilter, cpPlugins::Pipeline::ProcessObject );
- cpPlugins_Id_Macro( BaseFilter, fpaImageAlgorithm );
-
- protected:
- BaseFilter( );
- virtual ~BaseFilter( );
-
- template< class _TFilter, class _TImage >
- inline void _ConfigureFilter(
- _TFilter* filter, _TImage* image,
- std::vector< typename _TImage::IndexType >& seeds
- );
-
- private:
- // Purposely not implemented.
- BaseFilter( const Self& other );
- Self& operator=( const Self& other );
- };
-
-} // ecapseman
-
-// -------------------------------------------------------------------------
-#define ITK_MANUAL_INSTANTIATION
-#include <fpa/Image/Functors/SimpleNeighborhood.h>
-
-// -------------------------------------------------------------------------
-template< class _TFilter, class _TImage >
-void fpaPlugins_ImageAlgorithms::BaseFilter::
-_ConfigureFilter(
- _TFilter* filter, _TImage* image,
- std::vector< typename _TImage::IndexType >& seeds
- )
-{
- typedef typename _TFilter::TNeighborhoodFunction _TNeighborhood;
- typedef
- fpa::Image::Functors::SimpleNeighborhood< _TImage::ImageDimension >
- _TSimpleNeigh;
-
- // Simple configuration
- filter->SetInput( image );
- filter->SetStopAtOneFront( this->m_Parameters.GetBool( "StopAtOneFront" ) );
-
- // Neighborhood function
- typename _TSimpleNeigh::Pointer sfunc = _TSimpleNeigh::New( );
- sfunc->SetOrder( this->m_Parameters.GetUint( "NeighborhoodOrder" ) );
- filter->SetNeighborhoodFunction( sfunc );
-
- // Assign seeds
- seeds.clear( );
- auto pnt_seeds = this->GetInputData< vtkPolyData >( "Seeds" );
- if( pnt_seeds != NULL )
- {
- typename _TImage::PointType pnt;
- typename _TImage::IndexType idx;
- unsigned int dim =
- ( _TImage::ImageDimension < 3 )? _TImage::ImageDimension: 3;
-
- for( int i = 0; i < pnt_seeds->GetNumberOfPoints( ); ++i )
- {
- double buf[ 3 ];
- pnt_seeds->GetPoint( i, buf );
- pnt.Fill( 0 );
- for( unsigned int d = 0; d < dim; ++d )
- pnt[ d ] = buf[ d ];
-
- if( image->TransformPhysicalPointToIndex( pnt, idx ) )
- seeds.push_back( idx );
-
- } // rof
-
- } // fi
-}
-
-#endif // __fpaPlugins_ImageAlgorithms__BaseFilter__h__
-
-// eof - $RCSfile$
+++ /dev/null
-#include "Dijkstra.h"
-#include <cpPlugins/Pipeline/Functor.h>
-#include <cpInstances/DataObjects/Image.h>
-
-#include <fpa/Image/Dijkstra.h>
-
-// -------------------------------------------------------------------------
-fpaPlugins_ImageAlgorithms::Dijkstra::
-Dijkstra( )
- : Superclass( )
-{
- typedef cpPlugins::Pipeline::DataObject _TFunctor;
- typedef cpInstances::DataObjects::Image _TMST;
-
- this->_ConfigureInput< _TFunctor >( "VertexFunction", false, false );
- this->_ConfigureInput< _TFunctor >( "ConversionFunction", false, false );
- this->_ConfigureOutput< _TMST >( "MST" );
-
- std::vector< std::string > choices;
- choices.push_back( "float" );
- choices.push_back( "double" );
- this->m_Parameters.ConfigureAsChoices( "ResultType", choices );
- this->m_Parameters.SetSelectedChoice( "ResultType", "float" );
-}
-
-// -------------------------------------------------------------------------
-fpaPlugins_ImageAlgorithms::Dijkstra::
-~Dijkstra( )
-{
-}
-
-// -------------------------------------------------------------------------
-void fpaPlugins_ImageAlgorithms::Dijkstra::
-_GenerateData( )
-{
- auto o = this->GetInputData( "Input" );
- cpPlugins_Demangle_Image_ScalarPixels_AllDims_1( o, _GD0 )
- this->_Error( "Invalid input image." );
-}
-
-// -------------------------------------------------------------------------
-template< class _TImage >
-void fpaPlugins_ImageAlgorithms::Dijkstra::
-_GD0( _TImage* image )
-{
- typedef itk::Image< float, _TImage::ImageDimension > _TFloat;
- typedef itk::Image< double, _TImage::ImageDimension > _TDouble;
-
- auto rtype = this->m_Parameters.GetSelectedChoice( "ResultType" );
- if ( rtype == "float" ) this->_GD1< _TImage, _TFloat >( image );
- else if( rtype == "double" ) this->_GD1< _TImage, _TDouble >( image );
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage >
-void fpaPlugins_ImageAlgorithms::Dijkstra::
-_GD1( _TInputImage* image )
-{
- typedef cpPlugins::Pipeline::Functor _TFunctor;
- typedef fpa::Image::Dijkstra< _TInputImage, _TOutputImage > _TFilter;
- typedef typename _TFilter::TConversionFunction _TConversionFunction;
- typedef typename _TFilter::TVertexFunction _TVertexFunction;
-
- // Create filter
- auto filter = this->_CreateITK< _TFilter >( );
- std::vector< typename _TInputImage::IndexType > seeds;
- this->_ConfigureFilter( filter, image, seeds );
-
- // Instantiate functors
- auto cost_conversion = this->GetInputData< _TFunctor >( "ConversionFunction" );
- if( cost_conversion != NULL )
- {
- cost_conversion->Instantiate( filter );
- auto cost_conversion_functor = cost_conversion->GetFunctor< _TConversionFunction >( );
- if( cost_conversion_functor != NULL )
- filter->SetConversionFunction( cost_conversion_functor );
-
- } // fi
-
- auto vertex = this->GetInputData< _TFunctor >( "VertexFunction" );
- if( vertex != NULL )
- {
- vertex->Instantiate( filter );
- auto vertex_functor = vertex->GetFunctor< _TVertexFunction >( );
- if( vertex_functor != NULL )
- filter->SetVertexFunction( vertex_functor );
-
- } // fi
-
- // Finish filter's configuration
- filter->ClearSeeds( );
- for( auto seed : seeds )
- filter->AddSeed( seed, ( typename _TOutputImage::PixelType )( 0 ) );
- filter->Update( );
- this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) );
- this->GetOutput( "MST" )->SetITK( filter->GetMinimumSpanningTree( ) );
-}
-
-// eof - $RCSfile$
+++ /dev/null
-#ifndef __fpaPlugins_ImageAlgorithms__Dijkstra__h__
-#define __fpaPlugins_ImageAlgorithms__Dijkstra__h__
-
-#include <ImageAlgorithms/BaseFilter.h>
-
-namespace fpaPlugins_ImageAlgorithms
-{
- /**
- */
- class fpaPlugins_ImageAlgorithms_EXPORT Dijkstra
- : public BaseFilter
- {
- cpPluginsObject( Dijkstra, BaseFilter, fpaImageAlgorithms );
-
- protected:
- template< class _TImage >
- inline void _GD0( _TImage* image );
-
- template< class _TInputImage, class _TOutputImage >
- inline void _GD1( _TInputImage* image );
- };
-
-} // ecapseman
-
-#endif // __fpaPlugins_ImageAlgorithms__Dijkstra__h__
-
-// eof - $RCSfile$
+++ /dev/null
-#include "ExtractPathFromMinimumSpanningTree.h"
-#include <cpInstances/DataObjects/Image.h>
-#include <cpInstances/DataObjects/PolyLineParametricPath.h>
-#include <vtkPolyData.h>
-#include <fpa/Image/MinimumSpanningTree.h>
-
-// -------------------------------------------------------------------------
-fpaPlugins_ImageAlgorithms::ExtractPathFromMinimumSpanningTree::
-ExtractPathFromMinimumSpanningTree( )
- : Superclass( )
-{
- typedef cpPlugins::Pipeline::DataObject _TData;
- typedef cpInstances::DataObjects::Image _TMST;
- typedef cpInstances::DataObjects::PolyLineParametricPath _TPath;
-
- this->_ConfigureInput< _TMST >( "MST", true, false );
- this->_ConfigureInput< _TData >( "Seeds", true, false );
- this->_ConfigureOutput< _TPath >( "Output" );
-}
-
-// -------------------------------------------------------------------------
-fpaPlugins_ImageAlgorithms::ExtractPathFromMinimumSpanningTree::
-~ExtractPathFromMinimumSpanningTree( )
-{
-}
-
-// -------------------------------------------------------------------------
-void fpaPlugins_ImageAlgorithms::ExtractPathFromMinimumSpanningTree::
-_GenerateData( )
-{
- typedef fpa::Image::MinimumSpanningTree< 2 > _TMST2;
- typedef fpa::Image::MinimumSpanningTree< 3 > _TMST3;
-
- auto mst2 = this->GetInputData< _TMST2 >( "MST" );
- auto mst3 = this->GetInputData< _TMST3 >( "MST" );
- if ( mst2 != NULL ) this->_GD0( mst2 );
- else if( mst3 != NULL ) this->_GD0( mst3 );
- else this->_Error( "Invalid input spanning tree." );
-}
-
-// -------------------------------------------------------------------------
-template< class _TMST >
-void fpaPlugins_ImageAlgorithms::ExtractPathFromMinimumSpanningTree::
-_GD0( _TMST* mst )
-{
- typedef typename _TMST::IndexType _TIndex;
- typedef typename _TMST::TPath _TPath;
-
- // Get seeds
- std::vector< _TIndex > seeds;
- auto points = this->GetInputData< vtkPolyData >( "Seeds" );
- if( points != NULL )
- {
- if( points->GetNumberOfPoints( ) < 2 )
- this->_Error( "Not enough seeds (<2)." );
-
- typename _TMST::PointType pnt;
- typename _TMST::IndexType idx;
- unsigned int dim =
- ( _TMST::ImageDimension < 3 )? _TMST::ImageDimension: 3;
- for( unsigned int i = 0; i < 2; ++i )
- {
- double buf[ 3 ];
- points->GetPoint( i, buf );
- pnt.Fill( 0 );
- for( unsigned int d = 0; d < dim; ++d )
- pnt[ d ] = buf[ d ];
- if( mst->TransformPhysicalPointToIndex( pnt, idx ) )
- seeds.push_back( idx );
-
- } // rof
-
- } // fi
-
- typename _TPath::Pointer path;
- mst->GetPath( path, seeds[ 0 ], seeds[ 1 ] );
- this->GetOutput( "Output" )->SetITK( path );
-}
-
-// eof - $RCSfile$
+++ /dev/null
-#ifndef __fpaPlugins_ImageAlgorithms__ExtractPathFromMinimumSpanningTree__h__
-#define __fpaPlugins_ImageAlgorithms__ExtractPathFromMinimumSpanningTree__h__
-
-#include <fpaPlugins_ImageAlgorithms_Export.h>
-#include <cpPlugins/Pipeline/ProcessObject.h>
-
-namespace fpaPlugins_ImageAlgorithms
-{
- /**
- */
- class fpaPlugins_ImageAlgorithms_EXPORT ExtractPathFromMinimumSpanningTree
- : public cpPlugins::Pipeline::ProcessObject
- {
- cpPluginsObject(
- ExtractPathFromMinimumSpanningTree,
- cpPlugins::Pipeline::ProcessObject,
- fpaImageAlgorithms
- );
-
- protected:
- template< class _TMST >
- inline void _GD0( _TMST* mst );
- };
-
-} // ecapseman
-
-#endif // __fpaPlugins_ImageAlgorithms__ExtractPathFromMinimumSpanningTree__h__
-
-// eof - $RCSfile$
+++ /dev/null
-#include "FastMarching.h"
-#include <cpPlugins/Pipeline/Functor.h>
-#include <cpInstances/DataObjects/Image.h>
-
-#include <fpa/Image/FastMarching.h>
-
-// -------------------------------------------------------------------------
-fpaPlugins_ImageAlgorithms::FastMarching::
-FastMarching( )
- : Superclass( )
-{
- typedef cpPlugins::Pipeline::DataObject _TFunctor;
-
- this->_ConfigureInput< _TFunctor >( "VertexFunction", false, false );
- this->_ConfigureInput< _TFunctor >( "ConversionFunction", false, false );
-
- std::vector< std::string > choices;
- choices.push_back( "float" );
- choices.push_back( "double" );
- this->m_Parameters.ConfigureAsChoices( "ResultType", choices );
- this->m_Parameters.SetSelectedChoice( "ResultType", "float" );
-}
-
-// -------------------------------------------------------------------------
-fpaPlugins_ImageAlgorithms::FastMarching::
-~FastMarching( )
-{
-}
-
-// -------------------------------------------------------------------------
-void fpaPlugins_ImageAlgorithms::FastMarching::
-_GenerateData( )
-{
- auto o = this->GetInputData( "Input" );
- cpPlugins_Demangle_Image_ScalarPixels_AllDims_1( o, _GD0 )
- this->_Error( "Invalid input image." );
-}
-
-// -------------------------------------------------------------------------
-template< class _TImage >
-void fpaPlugins_ImageAlgorithms::FastMarching::
-_GD0( _TImage* image )
-{
- typedef itk::Image< float, _TImage::ImageDimension > _TFloat;
- typedef itk::Image< double, _TImage::ImageDimension > _TDouble;
-
- auto rtype = this->m_Parameters.GetSelectedChoice( "ResultType" );
- if ( rtype == "float" ) this->_GD1< _TImage, _TFloat >( image );
- else if( rtype == "double" ) this->_GD1< _TImage, _TDouble >( image );
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage >
-void fpaPlugins_ImageAlgorithms::FastMarching::
-_GD1( _TInputImage* image )
-{
- typedef cpPlugins::Pipeline::Functor _TFunctor;
- typedef fpa::Image::FastMarching< _TInputImage, _TOutputImage > _TFilter;
- typedef typename _TFilter::TConversionFunction _TConversionFunction;
- typedef typename _TFilter::TVertexFunction _TVertexFunction;
-
- // Create filter
- auto filter = this->_CreateITK< _TFilter >( );
- std::vector< typename _TInputImage::IndexType > seeds;
- this->_ConfigureFilter( filter, image, seeds );
-
- // Instantiate functors
- auto cost_conversion = this->GetInputData< _TFunctor >( "ConversionFunction" );
- if( cost_conversion != NULL )
- {
- cost_conversion->Instantiate( filter );
- auto cost_conversion_functor = cost_conversion->GetFunctor< _TConversionFunction >( );
- if( cost_conversion_functor != NULL )
- filter->SetConversionFunction( cost_conversion_functor );
-
- } // fi
-
- auto vertex = this->GetInputData< _TFunctor >( "VertexFunction" );
- if( vertex != NULL )
- {
- vertex->Instantiate( filter );
- auto vertex_functor = vertex->GetFunctor< _TVertexFunction >( );
- if( vertex_functor != NULL )
- filter->SetVertexFunction( vertex_functor );
-
- } // fi
-
- // Finish filter's configuration
- filter->ClearSeeds( );
- for( auto seed : seeds )
- filter->AddSeed( seed, ( typename _TOutputImage::PixelType )( 0 ) );
- filter->Update( );
- this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) );
-}
-
-// eof - $RCSfile$
+++ /dev/null
-#ifndef __fpaPlugins_ImageAlgorithms__FastMarching__h__
-#define __fpaPlugins_ImageAlgorithms__FastMarching__h__
-
-#include <ImageAlgorithms/BaseFilter.h>
-
-namespace fpaPlugins_ImageAlgorithms
-{
- /**
- */
- class fpaPlugins_ImageAlgorithms_EXPORT FastMarching
- : public BaseFilter
- {
- cpPluginsObject( FastMarching, BaseFilter, fpaImageAlgorithms );
-
- protected:
- template< class _TImage >
- inline void _GD0( _TImage* image );
-
- template< class _TInputImage, class _TOutputImage >
- inline void _GD1( _TInputImage* image );
- };
-
-} // ecapseman
-
-#endif // __fpaPlugins_ImageAlgorithms__FastMarching__h__
-
-// eof - $RCSfile$
+++ /dev/null
-header #define ITK_MANUAL_INSTANTIATION
-
-*tinclude fpa/Image/Functors/SimpleNeighborhood:h|hxx
-*instances fpa::Image::Functors::SimpleNeighborhood< itk::Image< #scalar_types#, #pdims# > >
-
-*cinclude fpa/Base/RegionGrow.hxx
-*define all_int_types=#int_types#;#uint_types#
-*tinclude fpa/Image/RegionGrow:h|hxx
-*tinclude fpa/Image/MoriRegionGrowHelper:h|hxx
-*tinclude fpa/Image/MoriRegionGrow:h|hxx
-*instances fpa::Image::RegionGrow< itk::Image< #scalar_types#, #pdims# >, itk::Image< #all_int_types#, #pdims# > >
-*instances fpa::Image::MoriRegionGrowHelper< itk::Image< #scalar_types#, #pdims# >, itk::Image< #all_int_types#, #pdims# > >
-*instances fpa::Image::MoriRegionGrow< itk::Image< #scalar_types#, #pdims# >, itk::Image< #all_int_types#, #pdims# > >
-
-*cinclude fpa/Base/Dijkstra.hxx
-*tinclude fpa/Image/Dijkstra:h|hxx
-*instances fpa::Image::Dijkstra< itk::Image< #scalar_types#, #pdims# >, itk::Image< #real_types#, #pdims# > >
-
-*tinclude fpa/Image/SkeletonFilter:h|hxx
-*instances fpa::Image::SkeletonFilter< itk::Image< #real_types#, #pdims# > >
-
-
-
-*define i_real=#real_types#
-*define o_real=#real_types#
-
-*tinclude fpa/Image/Functors/SimpleDijkstraCost:h|hxx
-*tinclude fpa/Base/Functors/Inverse:h|hxx
-*tinclude fpa/Base/Functors/GaussianModel:h|hxx
-*tinclude fpa/Image/Dijkstra:h|hxx
-*tinclude fpa/Image/SkeletonFilter:h|hxx
-*tinclude fpa/Image/Functors/RegionGrowBinaryThreshold:h|hxx
-
-*cinclude itkImage.h
-*cinclude itkSimpleDataObjectDecorator.hxx
-*cinclude fpa/Base/Dijkstra.hxx
-
-*instances fpa::Image::Functors::SimpleNeighborhood< itk::Image< #scalar_pixels#, #process_dims# > >
-*instances fpa::Image::Functors::SimpleDijkstraCost< itk::Image< #scalar_pixels#, #process_dims# >, #real_types# >
-*instances fpa::Image::Functors::RegionGrowBinaryThreshold< itk::Image< #scalar_pixels#, #process_dims# > >
-
-*instances fpa::Base::Functors::Inverse< #i_real#, #o_real# >
-*instances fpa::Base::Functors::GaussianModel< #i_real#, #o_real# >
-
-*instances fpa::Image::Dijkstra< itk::Image< #scalar_pixels#, #process_dims# >, itk::Image< #real_types#, #process_dims# > >
-*instances fpa::Image::RegionGrow< itk::Image< #scalar_pixels#, #process_dims# >, itk::Image< #int_types#, #process_dims# > >
-*instances fpa::Image::RegionGrow< itk::Image< #scalar_pixels#, #process_dims# >, itk::Image< #uint_types#, #process_dims# > >
-*instances fpa::Image::SkeletonFilter< itk::Image< #real_types#, #process_dims# > >
-
-** eof - $RCSfile$
+++ /dev/null
-#include "RegionGrow.h"
-#include <cpPlugins/Pipeline/Functor.h>
-#include <cpInstances/DataObjects/Image.h>
-
-#include <fpa/Image/RegionGrow.h>
-
-// -------------------------------------------------------------------------
-fpaPlugins_ImageAlgorithms::RegionGrow::
-RegionGrow( )
- : Superclass( )
-{
- typedef cpPlugins::Pipeline::DataObject _TFunctor;
- typedef cpInstances::DataObjects::Image _TMST;
-
- this->_ConfigureInput< _TFunctor >( "GrowFunction", true, false );
- this->m_Parameters.ConfigureAsInt( "InsideValue", 1 );
- this->m_Parameters.ConfigureAsInt( "OutsideValue", 0 );
- this->m_Parameters.ConfigureAsIntTypesChoices( "ResultType" );
-}
-
-// -------------------------------------------------------------------------
-fpaPlugins_ImageAlgorithms::RegionGrow::
-~RegionGrow( )
-{
-}
-
-// -------------------------------------------------------------------------
-void fpaPlugins_ImageAlgorithms::RegionGrow::
-_GenerateData( )
-{
- auto o = this->GetInputData( "Input" );
- cpPlugins_Demangle_Image_ScalarPixels_AllDims_1( o, _GD0 )
- this->_Error( "Invalid input image." );
-}
-
-// -------------------------------------------------------------------------
-template< class _TImage >
-void fpaPlugins_ImageAlgorithms::RegionGrow::
-_GD0( _TImage* image )
-{
- auto rtype = this->m_Parameters.GetSelectedChoice( "ResultType" );
- if( rtype == "char" ) this->_GD1< _TImage, char >( image );
- else if( rtype == "uchar" ) this->_GD1< _TImage, unsigned char >( image );
- else if( rtype == "short" ) this->_GD1< _TImage, short >( image );
- else if( rtype == "ushort" ) this->_GD1< _TImage, unsigned short >( image );
- else if( rtype == "int" ) this->_GD1< _TImage, int >( image );
- else if( rtype == "uint" ) this->_GD1< _TImage, unsigned int >( image );
- else if( rtype == "long" ) this->_GD1< _TImage, long >( image );
- else if( rtype == "ulong" ) this->_GD1< _TImage, unsigned long >( image );
- else this->_GD1< _TImage, char >( image );
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputPixel >
-void fpaPlugins_ImageAlgorithms::RegionGrow::
-_GD1( _TInputImage* image )
-{
- typedef cpPlugins::Pipeline::Functor _TFunctor;
- typedef itk::Image< _TOutputPixel, _TInputImage::ImageDimension > _TOutputImage;
- typedef fpa::Image::RegionGrow< _TInputImage, _TOutputImage > _TFilter;
- typedef typename _TFilter::TGrowFunction _TGrowFunction;
-
- // Create filter
- auto filter = this->_CreateITK< _TFilter >( );
- std::vector< typename _TInputImage::IndexType > seeds;
- this->_ConfigureFilter( filter, image, seeds );
-
- // Instantiate functors
- auto growfunc = this->GetInputData< _TFunctor >( "GrowFunction" );
- if( growfunc != NULL )
- {
- growfunc->Instantiate( filter );
- auto growfunc_functor = growfunc->GetFunctor< _TGrowFunction >( );
- if( growfunc_functor != NULL )
- filter->SetGrowFunction( growfunc_functor );
-
- } // fi
-
- // Finish filter's configuration
- filter->ClearSeeds( );
- for( auto seed : seeds )
- filter->AddSeed( seed, ( typename _TOutputImage::PixelType )( 0 ) );
- filter->Update( );
- this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) );
-}
-
-// eof - $RCSfile$
+++ /dev/null
-#ifndef __fpaPlugins_ImageAlgorithms__RegionGrow__h__
-#define __fpaPlugins_ImageAlgorithms__RegionGrow__h__
-
-#include <ImageAlgorithms/BaseFilter.h>
-
-namespace fpaPlugins_ImageAlgorithms
-{
- /**
- */
- class fpaPlugins_ImageAlgorithms_EXPORT RegionGrow
- : public BaseFilter
- {
- cpPluginsObject( RegionGrow, BaseFilter, fpaImageAlgorithms );
-
- protected:
- template< class _TImage >
- inline void _GD0( _TImage* image );
-
- template< class _TInputImage, class _TOutputPixel >
- inline void _GD1( _TInputImage* image );
- };
-
-} // ecapseman
-
-#endif // __fpaPlugins_ImageAlgorithms__RegionGrow__h__
-
-// eof - $RCSfile$
+++ /dev/null
-#include "BinaryThreshold.h"
-
-#include <cpInstances/DataObjects/Image.h>
-
-#include <itkImage.h>
-#include <fpa/Image/Functors/RegionGrow/BinaryThreshold.h>
-
-// -------------------------------------------------------------------------
-void fpaPlugins_ImageFunctors::BinaryThreshold::
-Instantiate( itk::LightObject* filter )
-{
- auto itk_filter = dynamic_cast< itk::ProcessObject* >( filter );
- if( itk_filter != NULL )
- {
- auto inputs = itk_filter->GetInputs( );
- if( inputs.size( ) > 0 )
- {
- cpPlugins_Demangle_Image_ScalarPixels_AllDims_2(
- inputs[ 0 ].GetPointer( ), _GD0, itk_filter
- )
- this->_Error( "Invalid input data." );
- }
- else
- this->_Error( "Not enough inputs." );
- }
- else
- this->_Error( "Invalid instantiation filter." );
-}
-
-// -------------------------------------------------------------------------
-fpaPlugins_ImageFunctors::BinaryThreshold::
-BinaryThreshold( )
- : Superclass( )
-{
- this->_ConfigureOutput< cpPlugins::Pipeline::DataObject >( "Functor" );
- this->GetOutput( "Functor" )->SetITK( this );
- this->m_Parameters.ConfigureAsReal( "Lower", 0 );
- this->m_Parameters.ConfigureAsReal( "Upper", 1 );
-}
-
-// -------------------------------------------------------------------------
-fpaPlugins_ImageFunctors::BinaryThreshold::
-~BinaryThreshold( )
-{
-}
-
-// -------------------------------------------------------------------------
-void fpaPlugins_ImageFunctors::BinaryThreshold::
-_GenerateData( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TInput >
-void fpaPlugins_ImageFunctors::BinaryThreshold::
-_GD0( _TInput* input, itk::ProcessObject* filter )
-{
- auto outputs = filter->GetOutputs( );
- if( outputs.size( ) > 0 )
- {
- cpPlugins_Demangle_Image_IntPixels_3(
- outputs[ 0 ].GetPointer( ), _GD1, _TInput::ImageDimension, input, filter
- )
- this->_Error( "Invalid output data." );
- }
- else
- this->_Error( "Not enough outputs." );
-}
-
-// -------------------------------------------------------------------------
-template< class _TInput, class _TOutput >
-void fpaPlugins_ImageFunctors::BinaryThreshold::
-_GD1( _TOutput* output, _TInput* input, itk::ProcessObject* filter )
-{
- typedef typename _TOutput::PixelType _TValue;
- typedef fpa::Image::Functors::RegionGrow::BinaryThreshold< _TInput, _TValue > _TFunctor;
-
- auto f = dynamic_cast< _TFunctor* >( this->m_Functor.GetPointer( ) );
- if( f == NULL )
- {
- typename _TFunctor::Pointer ptr_f = _TFunctor::New( );
- f = ptr_f.GetPointer( );
- this->m_Functor = f;
-
- } // fi
- f->SetLower( this->m_Parameters.GetReal( "Lower" ) );
- f->SetUpper( this->m_Parameters.GetReal( "Upper" ) );
-}
-
-// eof - $RCSfile$
+++ /dev/null
-#ifndef __fpaPlugins_ImageFunctors__BinaryThreshold__h__
-#define __fpaPlugins_ImageFunctors__BinaryThreshold__h__
-
-#include <itkProcessObject.h>
-#include <fpaPlugins_ImageFunctors_Export.h>
-#include <cpPlugins/Pipeline/Functor.h>
-
-namespace fpaPlugins_ImageFunctors
-{
- /**
- */
- class fpaPlugins_ImageFunctors_EXPORT BinaryThreshold
- : public cpPlugins::Pipeline::Functor
- {
- cpPluginsObject( BinaryThreshold, cpPlugins::Pipeline::Functor, fpaImageFunctors );
-
- public:
- virtual void Instantiate( itk::LightObject* filter ) override;
-
- protected:
- template< class _TInput >
- inline void _GD0( _TInput* input, itk::ProcessObject* filter );
-
- template< class _TInput, class _TOutput >
- inline void _GD1( _TOutput* output, _TInput* input, itk::ProcessObject* filter );
- };
-
-} // ecapseman
-
-#endif // __fpaPlugins_ImageFunctors__BinaryThreshold__h__
-
-// eof - $RCSfile$
+++ /dev/null
-#include "Tautology.h"
-
-#include <cpInstances/DataObjects/Image.h>
-
-#include <itkImage.h>
-#include <fpa/Base/Functors/RegionGrow/Tautology.h>
-
-// -------------------------------------------------------------------------
-void fpaPlugins_ImageFunctors::Tautology::
-Instantiate( itk::LightObject* filter )
-{
- auto itk_filter = dynamic_cast< itk::ProcessObject* >( filter );
- if( itk_filter != NULL )
- {
- auto inputs = itk_filter->GetInputs( );
- if( inputs.size( ) > 0 )
- {
- cpPlugins_Demangle_Image_ScalarPixels_AllDims_2(
- inputs[ 0 ].GetPointer( ), _GD0, itk_filter
- )
- this->_Error( "Invalid input data." );
- }
- else
- this->_Error( "Not enough inputs." );
- }
- else
- this->_Error( "Invalid instantiation filter." );
-}
-
-// -------------------------------------------------------------------------
-fpaPlugins_ImageFunctors::Tautology::
-Tautology( )
- : Superclass( )
-{
- this->_ConfigureOutput< cpPlugins::Pipeline::DataObject >( "Functor" );
- this->GetOutput( "Functor" )->SetITK( this );
-}
-
-// -------------------------------------------------------------------------
-fpaPlugins_ImageFunctors::Tautology::
-~Tautology( )
-{
-}
-
-// -------------------------------------------------------------------------
-void fpaPlugins_ImageFunctors::Tautology::
-_GenerateData( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TInput >
-void fpaPlugins_ImageFunctors::Tautology::
-_GD0( _TInput* input, itk::ProcessObject* filter )
-{
- auto outputs = filter->GetOutputs( );
- if( outputs.size( ) > 0 )
- {
- cpPlugins_Demangle_Image_IntPixels_3(
- outputs[ 0 ].GetPointer( ), _GD1, _TInput::ImageDimension, input, filter
- )
- this->_Error( "Invalid output data." );
- }
- else
- this->_Error( "Not enough outputs." );
-}
-
-// -------------------------------------------------------------------------
-template< class _TInput, class _TOutput >
-void fpaPlugins_ImageFunctors::Tautology::
-_GD1( _TOutput* output, _TInput* input, itk::ProcessObject* filter )
-{
- typedef typename _TInput::IndexType _TVertex;
- typedef typename _TOutput::PixelType _TValue;
- typedef fpa::Base::Functors::RegionGrow::Tautology< _TVertex, _TValue > _TFunctor;
-
- auto f = dynamic_cast< _TFunctor* >( this->m_Functor.GetPointer( ) );
- if( f == NULL )
- {
- typename _TFunctor::Pointer ptr_f = _TFunctor::New( );
- f = ptr_f.GetPointer( );
- this->m_Functor = f;
-
- } // fi
-}
-
-// eof - $RCSfile$
+++ /dev/null
-#ifndef __fpaPlugins_ImageFunctors__Tautology__h__
-#define __fpaPlugins_ImageFunctors__Tautology__h__
-
-#include <itkProcessObject.h>
-#include <fpaPlugins_ImageFunctors_Export.h>
-#include <cpPlugins/Pipeline/Functor.h>
-
-namespace fpaPlugins_ImageFunctors
-{
- /**
- */
- class fpaPlugins_ImageFunctors_EXPORT Tautology
- : public cpPlugins::Pipeline::Functor
- {
- cpPluginsObject( Tautology, cpPlugins::Pipeline::Functor, fpaImageFunctors );
-
- public:
- virtual void Instantiate( itk::LightObject* filter ) override;
-
- protected:
- template< class _TInput >
- inline void _GD0( _TInput* input, itk::ProcessObject* filter );
-
- template< class _TInput, class _TOutput >
- inline void _GD1( _TOutput* output, _TInput* input, itk::ProcessObject* filter );
- };
-
-} // ecapseman
-
-#endif // __fpaPlugins_ImageFunctors__Tautology__h__
-
-// eof - $RCSfile$
+++ /dev/null
-#include "VertexCost.h"
-
-#include <cpInstances/DataObjects/Image.h>
-
-#include <itkImage.h>
-#include <fpa/Image/Functors/VertexCost.h>
-
-// -------------------------------------------------------------------------
-void fpaPlugins_ImageFunctors::VertexCost::
-Instantiate( itk::LightObject* filter )
-{
- auto itk_filter = dynamic_cast< itk::ProcessObject* >( filter );
- if( itk_filter != NULL )
- {
- auto inputs = itk_filter->GetInputs( );
- if( inputs.size( ) > 0 )
- {
- cpPlugins_Demangle_Image_ScalarPixels_AllDims_2(
- inputs[ 0 ].GetPointer( ), _GD0, itk_filter
- )
- this->_Error( "Invalid input data." );
- }
- else
- this->_Error( "Not enough inputs." );
- }
- else
- this->_Error( "Invalid instantiation filter." );
-}
-
-// -------------------------------------------------------------------------
-fpaPlugins_ImageFunctors::VertexCost::
-VertexCost( )
- : Superclass( )
-{
- this->_ConfigureOutput< cpPlugins::Pipeline::DataObject >( "Functor" );
- this->m_Parameters.ConfigureAsBool( "UseImageSpacing", false );
- this->GetOutput( "Functor" )->SetITK( this );
-}
-
-// -------------------------------------------------------------------------
-fpaPlugins_ImageFunctors::VertexCost::
-~VertexCost( )
-{
-}
-
-// -------------------------------------------------------------------------
-void fpaPlugins_ImageFunctors::VertexCost::
-_GenerateData( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TInput >
-void fpaPlugins_ImageFunctors::VertexCost::
-_GD0( _TInput* input, itk::ProcessObject* filter )
-{
- auto outputs = filter->GetOutputs( );
- if( outputs.size( ) > 0 )
- {
- cpPlugins_Demangle_Image_ScalarPixels_3(
- outputs[ 0 ].GetPointer( ), _GD1, _TInput::ImageDimension, input, filter
- )
- this->_Error( "Invalid output data." );
- }
- else
- this->_Error( "Not enough outputs." );
-}
-
-// -------------------------------------------------------------------------
-template< class _TInput, class _TOutput >
-void fpaPlugins_ImageFunctors::VertexCost::
-_GD1( _TOutput* output, _TInput* input, itk::ProcessObject* filter )
-{
- typedef typename _TInput::PixelType _TIValue;
- typedef typename _TOutput::PixelType _TOValue;
- typedef fpa::Image::Functors::VertexCost< _TInput, _TOValue > _TFunctor;
-
- auto f = dynamic_cast< _TFunctor* >( this->m_Functor.GetPointer( ) );
- if( f == NULL )
- {
- typename _TFunctor::Pointer ptr_f = _TFunctor::New( );
- f = ptr_f.GetPointer( );
- this->m_Functor = f;
-
- } // fi
- f->SetUseImageSpacing( this->m_Parameters.GetReal( "UseImageSpacing" ) );
-}
-
-// eof - $RCSfile$
+++ /dev/null
-#ifndef __fpaPlugins_ImageFunctors__VertexCost__h__
-#define __fpaPlugins_ImageFunctors__VertexCost__h__
-
-#include <itkProcessObject.h>
-#include <fpaPlugins_ImageFunctors_Export.h>
-#include <cpPlugins/Pipeline/Functor.h>
-
-namespace fpaPlugins_ImageFunctors
-{
- /**
- */
- class fpaPlugins_ImageFunctors_EXPORT VertexCost
- : public cpPlugins::Pipeline::Functor
- {
- cpPluginsObject( VertexCost, cpPlugins::Pipeline::Functor, fpaImageFunctors );
-
- public:
- virtual void Instantiate( itk::LightObject* filter ) override;
-
- protected:
- template< class _TInput >
- inline void _GD0( _TInput* input, itk::ProcessObject* filter );
-
- template< class _TInput, class _TOutput >
- inline void _GD1( _TOutput* output, _TInput* input, itk::ProcessObject* filter );
- };
-
-} // ecapseman
-
-#endif // __fpaPlugins_ImageFunctors__VertexCost__h__
-
-// eof - $RCSfile$
+++ /dev/null
-#include <RegionGrowFunctors/BinaryThreshold.h>
-#include <cpInstances/DataObjects/Image.h>
-
-#include <fpa/Image/Functors/RegionGrow/BinaryThreshold.h>
-#include <itkConstNeighborhoodIterator.h>
-#include <vtkPolyData.h>
-
-// -------------------------------------------------------------------------
-fpaPluginsRegionGrowFunctors::BinaryThreshold::
-BinaryThreshold( )
- : Superclass( )
-{
- typedef cpPlugins::Pipeline::DataObject _TData;
- typedef cpInstances::DataObjects::Image _TImage;
-
- this->_ConfigureInput< _TImage >( "Input", true, false );
- this->_ConfigureInput< _TData >( "Seeds", false, false );
- this->_ConfigureOutput< _TData >( "Output" );
-
- this->m_Parameters.ConfigureAsUint( "Radius", 1 );
- this->m_Parameters.ConfigureAsReal( "Lower", 0 );
- this->m_Parameters.ConfigureAsReal( "Upper", 0 );
-}
-
-// -------------------------------------------------------------------------
-fpaPluginsRegionGrowFunctors::BinaryThreshold::
-~BinaryThreshold( )
-{
-}
-
-// -------------------------------------------------------------------------
-void fpaPluginsRegionGrowFunctors::BinaryThreshold::
-_GenerateData( )
-{
- auto o = this->GetInputData( "Input" );
- cpPlugins_Demangle_Image_ScalarPixels_AllDims_1( o, _GD0 )
- this->_Error( "Invalid input image." );
-}
-
-// -------------------------------------------------------------------------
-template< class _TImage >
-void fpaPluginsRegionGrowFunctors::BinaryThreshold::
-_GD0( _TImage* image )
-{
- /* TODO
- typedef itk::ConstNeighborhoodIterator< _TImage > _TInIt;
- typedef
- fpa::Image::Functors::RegionGrow::BinaryThreshold< _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
-
- // Compute thresholds from seeds
- auto seeds = this->GetInputData< vtkPolyData >( "Seeds" );
- if( seeds != NULL )
- {
- std::vector< typename _TImage::IndexType > indices;
- typename _TImage::PointType pnt;
- typename _TImage::IndexType idx;
- unsigned int dim =
- ( _TImage::ImageDimension < 3 )? _TImage::ImageDimension: 3;
-
- for( int i = 0; i < seeds->GetNumberOfPoints( ); ++i )
- {
- double buf[ 3 ];
- seeds->GetPoint( i, buf );
- pnt.Fill( 0 );
- for( unsigned int d = 0; d < dim; ++d )
- pnt[ d ] = buf[ d ];
- if( image->TransformPhysicalPointToIndex( pnt, idx ) )
- indices.push_back( idx );
-
- } // rof
-
- typename _TImage::SizeType r;
- r.Fill( this->m_Parameters.GetUint( "Radius" ) );
-
- _TInIt iIt( r, image, image->GetRequestedRegion( ) );
- double v_s1 = double( 0 );
- double v_s2 = double( 0 );
- double v_n = double( 0 );
- double v_min = std::numeric_limits< double >::max( );
- double v_max = -v_min;
- for( auto idxIt = indices.begin( ); idxIt != indices.end( ); ++idxIt )
- {
- iIt.SetLocation( *idxIt );
- for( unsigned int i = 0; i < iIt.Size( ); ++i )
- {
- double v = double( iIt.GetPixel( i ) );
- v_s1 += v;
- v_s2 += v * v;
- v_n += double( 1 );
- v_min = ( v < v_min )? v: v_min;
- v_max = ( v_max < v )? v: v_max;
-
- } // rof
-
- } // rof
- double m = v_s1 / v_n;
- double s = ( v_s2 - ( ( v_s1 * v_s1 ) / v_n ) ) / ( v_n - double( 1 ) );
- s = std::sqrt( s );
- v_min = m - s;
- v_max = m + s;
- f->SetLower( v_min );
- f->SetUpper( v_max );
- this->m_Parameters.SetReal( "Lower", f->GetLower( ) );
- this->m_Parameters.SetReal( "Upper", f->GetUpper( ) );
- }
- else
- {
- f->SetLower( this->m_Parameters.GetReal( "Lower" ) );
- f->SetUpper( this->m_Parameters.GetReal( "Upper" ) );
-
- } // fi
- */
-}
-
-// eof - $RCSfile$
+++ /dev/null
-#ifndef __fpaPluginsRegionGrowFunctors__BinaryThreshold__h__
-#define __fpaPluginsRegionGrowFunctors__BinaryThreshold__h__
-
-#include <fpaPluginsRegionGrowFunctors_Export.h>
-#include <cpPlugins/Pipeline/ProcessObject.h>
-
-namespace fpaPluginsRegionGrowFunctors
-{
- /**
- */
- class fpaPluginsRegionGrowFunctors_EXPORT BinaryThreshold
- : public cpPlugins::Pipeline::ProcessObject
- {
- cpPluginsObject(
- BinaryThreshold,
- cpPlugins::Pipeline::ProcessObject,
- fpaRegionGrowFunctors
- );
-
- protected:
- template< class _TImage >
- inline void _GD0( _TImage* image );
- };
-
-} // ecapseman
-
-#endif // __fpaPluginsRegionGrowFunctors__BinaryThreshold__h__
-
-// eof - $RCSfile$
+++ /dev/null
-header #define ITK_MANUAL_INSTANTIATION
-
-cinclude itkImage.h
-tinclude fpa/Image/Functors/RegionGrow/BinaryThreshold:h|hxx
-** instances fpa::Image::Functors::RegionGrow::BinaryThreshold< itk::Image< #scalar_types#, #pdims# > >
-
-** eof - $RCSfile$