+++ /dev/null
-cmake_minimum_required(VERSION 3.0)
-
-## ========================
-## == Project definition ==
-## ========================
-
-set(prj_MAJ_VERSION 0)
-set(prj_MIN_VERSION 1)
-set(prj_REL_VERSION 0)
-set(prj_VERSION "${prj_MAJ_VERSION}.${prj_MIN_VERSION}.${prj_REL_VERSION}")
-set(prj_SHORT_VERSION "${prj_MAJ_VERSION}")
-project(fpa VERSION ${prj_VERSION})
-
-## ==========================
-## == Some useful policies ==
-## ==========================
-
-set(_policies CMP0015 CMP0020 CMP0042 CMP0053)
-foreach(_p ${_policies})
- if(POLICY ${_p})
- cmake_policy(SET ${_p} NEW)
- endif(POLICY ${_p})
-endforeach(_p)
-
-## ===============================
-## == Some basic configurations ==
-## ===============================
-
-include(cmake/fpaBaseConfig.cmake)
-
-## ==============
-## == Find ITK ==
-## ==============
-
-find_package(ITK CONFIG REQUIRED)
-include(${ITK_USE_FILE})
-
-## =========================
-## == Installation values ==
-## =========================
-
-set(config_install_dir "lib/cmake/${PROJECT_NAME}")
-set(include_install_dir "include")
-set(generated_dir "${CMAKE_CURRENT_BINARY_DIR}/generated")
-set(version_config "${generated_dir}/${PROJECT_NAME}ConfigVersion.cmake")
-set(project_config "${generated_dir}/${PROJECT_NAME}Config.cmake")
-set(targets_export_name "${PROJECT_NAME}Targets")
-set(namespace "${PROJECT_NAME}::")
-
-## ===========================
-## == Build different parts ==
-## ===========================
-
-subdirs(examples lib)
-
-## ===============================
-## == Global installation rules ==
-## ===============================
-
-include(CMakePackageConfigHelpers)
-write_basic_package_version_file(
- "${version_config}" COMPATIBILITY SameMajorVersion
- )
-configure_package_config_file(
- "cmake/${PROJECT_NAME}Config.cmake.in"
- "${project_config}"
- INSTALL_DESTINATION "${config_install_dir}"
- )
-install(
- FILES
- "${project_config}"
- "${version_config}"
- "${CMAKE_CURRENT_SOURCE_DIR}/cmake/${PROJECT_NAME}BaseConfig.cmake"
- DESTINATION "${config_install_dir}"
- )
-install(
- EXPORT "${targets_export_name}"
- NAMESPACE "${namespace}"
- DESTINATION "${config_install_dir}"
- )
-
-## eof - $RCSfile$
+++ /dev/null
-## =========================================================
-## == If working on a MacOSX, activate the use of RPATH's ==
-## =========================================================
-
-set(EXECUTABLE_TYPE "" CACHE STRING "Executable linking." FORCE)
-if(APPLE)
- set(EXECUTABLE_TYPE "MACOSX_BUNDLE" CACHE STRING "Executable linking." FORCE)
- set(CMAKE_MACOSX_RPATH true CACHE BOOL "Use RPATH's on MacOSX systems." FORCE)
- mark_as_advanced(CMAKE_MACOSX_RPATH)
-elseif(WIN32)
- set(EXECUTABLE_TYPE "WIN32" CACHE STRING "Executable linking." FORCE)
-endif(APPLE)
-mark_as_advanced(EXECUTABLE_TYPE)
-
-## =======================================================================
-## == 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
-@PACKAGE_INIT@
-
-include("${CMAKE_CURRENT_LIST_DIR}/fpaBaseConfig.cmake")
-include("${CMAKE_CURRENT_LIST_DIR}/@targets_export_name@.cmake")
-check_required_components("@PROJECT_NAME@")
-
-## ==============
-## == Find ITK ==
-## ==============
-
-set(ITK_DIR @ITK_DIR@)
-
-find_package(ITK CONFIG REQUIRED)
-include(${ITK_USE_FILE})
-
-## eof - $RCSfile$
+++ /dev/null
-#include <climits>
-#include <cstdlib>
-#include <fstream>
-#include <iostream>
-#include <string>
-
-#include <itkImage.h>
-#include <itkImageFileReader.h>
-#include <itkImageFileWriter.h>
-
-#include <fpa/Image/RegionGrow.h>
-#include <fpa/Image/Functors/RegionGrow/BinaryThreshold.h>
-
-// -------------------------------------------------------------------------
-static const unsigned int Dim = 3;
-typedef short TPixel;
-typedef itk::Image< TPixel, Dim > TImage;
-
-// -------------------------------------------------------------------------
-std::string GetFullPath( const std::string& filename )
-{
- /* On windows:
- #include <windows.h>
- TCHAR full_path[MAX_PATH];
- GetFullPathName(_T("foo.dat"), MAX_PATH, full_path, NULL);
- */
-
- char* buffer = realpath( filename.c_str( ), NULL );
- std::string path = buffer;
- std::free( buffer );
- return( path );
-}
-
-// -------------------------------------------------------------------------
-std::string GetFullPathToDirectory( const std::string& filename )
-{
- std::string path = GetFullPath( filename );
- std::size_t found = path.find_last_of( "/\\" );
- return( path.substr( 0, found + 1 ) );
-}
-
-// -------------------------------------------------------------------------
-int main( int argc, char* argv[] )
-{
- // Command configuration
- if( argc < 5 )
- {
- std::cerr
- << "Usage: " << argv[ 0 ] << " input_image output_image lower upper"
- << std::endl;
- return( 1 );
-
- } // fi
- std::string input_image_filename = GetFullPath( argv[ 1 ] );
- std::string output_image_filename = argv[ 2 ];
- std::string output_auxiliary_image_filename = output_image_filename + "_aux.mhd";
- TPixel lower = std::atoi( argv[ 3 ] );
- TPixel upper = std::atoi( argv[ 4 ] );
-
- // Try to guess initial seed
- std::string seed_filename = GetFullPathToDirectory( argv[ 1 ] ) + "seed.txt";
- std::ifstream seed_str( seed_filename.c_str( ) );
- if( !seed_str )
- {
- std::cerr
- << "No \"seed.txt\" file in the same input image directory."
- << std::endl;
- return( 1 );
-
- } // fi
- TImage::IndexType seed;
- seed_str >> seed[ 0 ] >> seed[ 1 ] >> seed[ 2 ];
- seed_str.close( );
-
- // Read image
- typedef itk::ImageFileReader< TImage > TReader;
- TReader::Pointer reader = TReader::New( );
- reader->SetFileName( input_image_filename );
-
- // Growing predicate
- typedef fpa::Image::Functors::RegionGrow::BinaryThreshold< TImage, TImage::PixelType > TPredicate;
- TPredicate::Pointer predicate = TPredicate::New( );
- predicate->SetLower( lower );
- predicate->SetUpper( upper );
-
- // RegionGrow algorithm
- typedef fpa::Image::RegionGrow< TImage, TImage > TFilter;
- TFilter::Pointer filter = TFilter::New( );
- filter->SetInput( reader->GetOutput( ) );
- filter->AddSeed( seed, 1 );
- filter->SetInsideValue( 1 );
- filter->SetOutsideValue( 0 );
- filter->SetGrowFunction( predicate );
-
- // Write results
- typedef itk::ImageFileWriter< TImage > TWriter;
- TWriter::Pointer writer = TWriter::New( );
- writer->SetInput( filter->GetOutput( ) );
- writer->SetFileName( output_image_filename );
-
- // Execute pipeline
- try
- {
- writer->Update( );
- }
- catch( std::exception& err )
- {
- std::cerr << "Error caught: " << err.what( ) << std::endl;
- return( 1 );
-
- } // yrt
-
- return( 0 );
-}
-
-// eof - $RCSfile$
+++ /dev/null
-#include <climits>
-#include <cstdlib>
-#include <fstream>
-#include <iostream>
-#include <string>
-
-#include <itkImage.h>
-#include <itkImageFileReader.h>
-#include <itkImageFileWriter.h>
-
-#include <fpa/Image/MoriFilter.h>
-
-// -------------------------------------------------------------------------
-static const unsigned int Dim = 3;
-typedef short TPixel;
-typedef itk::Image< TPixel, Dim > TImage;
-
-// -------------------------------------------------------------------------
-std::string GetFullPath( const std::string& filename )
-{
- /* On windows:
- #include <windows.h>
- TCHAR full_path[MAX_PATH];
- GetFullPathName(_T("foo.dat"), MAX_PATH, full_path, NULL);
- */
-
- char* buffer = realpath( filename.c_str( ), NULL );
- std::string path = buffer;
- std::free( buffer );
- return( path );
-}
-
-// -------------------------------------------------------------------------
-std::string GetFullPathToDirectory( const std::string& filename )
-{
- std::string path = GetFullPath( filename );
- std::size_t found = path.find_last_of( "/\\" );
- return( path.substr( 0, found + 1 ) );
-}
-
-// -------------------------------------------------------------------------
-int main( int argc, char* argv[] )
-{
- // Command configuration
- if( argc < 3 )
- {
- std::cerr
- << "Usage: " << argv[ 0 ] << " input_image output_image"
- << std::endl;
- return( 1 );
-
- } // fi
- std::string input_image_filename = GetFullPath( argv[ 1 ] );
- std::string output_image_filename = argv[ 2 ];
- std::string output_auxiliary_image_filename = output_image_filename + "_aux.mhd";
-
- // Try to guess initial seed
- std::string seed_filename = GetFullPathToDirectory( argv[ 1 ] ) + "seed.txt";
- std::ifstream seed_str( seed_filename.c_str( ) );
- if( !seed_str )
- {
- std::cerr
- << "No \"seed.txt\" file in the same input image directory."
- << std::endl;
- return( 1 );
-
- } // fi
- TImage::IndexType seed;
- seed_str >> seed[ 0 ] >> seed[ 1 ] >> seed[ 2 ];
- seed_str.close( );
-
- // Read image
- typedef itk::ImageFileReader< TImage > TReader;
- TReader::Pointer reader = TReader::New( );
- reader->SetFileName( input_image_filename );
-
- // Mori's algorithms
- typedef fpa::Image::MoriFilter< TImage, TImage > TFilter;
- TFilter::Pointer filter = TFilter::New( );
- filter->SetInput( reader->GetOutput( ) );
- filter->SetSeed( seed );
- filter->SetThresholdRange( -200, 100, 1 );
- filter->SetInsideValue( 1 );
- filter->SetOutsideValue( 0 );
-
- // Write results
- typedef itk::ImageFileWriter< TImage > TWriter;
- TWriter::Pointer writer = TWriter::New( );
- writer->SetInput( filter->GetOutput( ) );
- writer->SetFileName( output_image_filename );
-
- // Execute pipeline
- try
- {
- writer->Update( );
- }
- catch( std::exception& err )
- {
- std::cerr << "Error caught: " << err.what( ) << std::endl;
- return( 1 );
-
- } // yrt
-
- // Write auxiliary image
- typedef itk::ImageFileWriter< TFilter::TAuxImage > TAuxWriter;
- TAuxWriter::Pointer aux_writer = TAuxWriter::New( );
- aux_writer->SetInput( filter->GetAuxiliaryImage( ) );
- aux_writer->SetFileName( output_auxiliary_image_filename );
-
- // Execute pipeline
- try
- {
- aux_writer->Update( );
- }
- catch( std::exception& err )
- {
- std::cerr << "Error caught: " << err.what( ) << std::endl;
- return( 1 );
-
- } // yrt
-
- // Write result signal
- std::string output_signal_filename = output_image_filename + ".csv";
- std::ofstream output_signal_str( output_signal_filename.c_str( ) );
- TFilter::TCurve curve = filter->GetCurve( );
- unsigned long max_count = 0;
- for( TFilter::TCurve::value_type d : curve )
- {
- output_signal_str << d.first << " " << d.second << std::endl;
- if( max_count < d.second )
- max_count = d.second;
-
- } // rof
- output_signal_str.close( );
-
- // Write gnuplot script
- std::string output_gnuplot_filename = output_image_filename + ".gnuplot";
- std::ofstream output_gnuplot_str( output_gnuplot_filename.c_str( ) );
- unsigned int thr_pos = filter->GetOptimumThreshold( );
- int thr = curve[ thr_pos ].first;
- output_gnuplot_str
- << "set term png" << std::endl
- << "set output \"" << output_image_filename << ".png\"" << std::endl
- << "set arrow 1 from " << thr
- << ",0 to " << thr << "," << max_count
- << std::endl
- << "show arrow 1" << std::endl
- << "plot \"" << output_signal_filename
- << "\" using 1:2 with linespoints title \"Evolution ("
- << thr << "," << thr_pos << ") " << "\""
- << std::endl;
- output_gnuplot_str.close( );
-
- return( 0 );
-}
-
-// eof - $RCSfile$
+++ /dev/null
-option(BUILD_EXAMPLES "Build cpPlugins-free examples." OFF)
-if(BUILD_EXAMPLES)
- set(
- _examples
- RegionGrow_Tautology
- RegionGrow_BinaryThreshold
- RegionGrow_Mori
- Dijkstra_Gaussian
- Dijkstra_Maurer
- SkeletonFilter
- #CreateMoriInputImage
- #BronchiiInitialSegmentationWithMori
- #BronchiiInitialSegmentationWithBinaryThresholdRegionGrow
- )
- option(BUILD_EXAMPLE_SANDBOX "Build sandbox example." OFF)
- if(BUILD_EXAMPLE_SANDBOX)
- list(APPEND _examples sandbox)
- endif(BUILD_EXAMPLE_SANDBOX)
- include_directories(
- ${PROJECT_SOURCE_DIR}/lib
- ${PROJECT_BINARY_DIR}/lib
- )
- foreach(_e ${_examples})
- add_executable(fpa_example_${_e} ${_e}.cxx)
- target_link_libraries(fpa_example_${_e} fpa)
- endforeach(_e)
-endif(BUILD_EXAMPLES)
-
-## eof - $RCSfile$
+++ /dev/null
-#include <queue>
-#include <itkImage.h>
-#include <itkImageFileReader.h>
-#include <itkSignedMaurerDistanceMapImageFilter.h>
-#include <itkImageFileWriter.h>
-
-// -------------------------------------------------------------------------
-static const unsigned int Dim = 2;
-typedef short TInputPixel;
-typedef float TOutputPixel;
-typedef itk::Image< TInputPixel, Dim > TInputImage;
-typedef itk::Image< TOutputPixel, Dim > TOutputImage;
-
-// -------------------------------------------------------------------------
-int main( int argc, char* argv[] )
-{
- // Command configuration
- if( argc < 3 )
- {
- std::cerr
- << "Usage: " << argv[ 0 ] << " input_image output_image"
- << std::endl;
- return( 1 );
-
- } // fi
- std::string input_image_filename = argv[ 1 ];
- std::string output_image_filename = argv[ 2 ];
-
- // Read image
- typedef itk::ImageFileReader< TInputImage > TReader;
- TReader::Pointer reader = TReader::New( );
- reader->SetFileName( input_image_filename );
-
- // Distance map
- typedef itk::SignedMaurerDistanceMapImageFilter< TInputImage, TOutputImage > TFilter;
- TFilter::Pointer filter = TFilter::New( );
- filter->SetInput( reader->GetOutput( ) );
- filter->SetBackgroundValue( 0 );
- filter->InsideIsPositiveOn( );
- filter->SquaredDistanceOff( );
- filter->UseImageSpacingOn( );
-
- // Write image
- typedef itk::ImageFileWriter< TOutputImage > TWriter;
- TWriter::Pointer writer = TWriter::New( );
- writer->SetInput( filter->GetOutput( ) );
- writer->SetFileName( output_image_filename );
-
- // Execute pipeline
- try
- {
- writer->Update( );
- }
- catch( std::exception& err )
- {
- std::cerr << "Error caught: " << err.what( ) << std::endl;
- return( 1 );
-
- } // yrt
-
- return( 0 );
-}
-
-// eof - $RCSfile$
+++ /dev/null
-#include <itkImage.h>
-#include <itkImageFileReader.h>
-#include <itkImageFileWriter.h>
-
-#include <fpa/Image/Dijkstra.h>
-#include <fpa/Image/Functors/GaussianWeight.h>
-
-// -------------------------------------------------------------------------
-static const unsigned int VDim = 2;
-typedef double TPixel;
-typedef itk::Image< TPixel, VDim > TImage;
-typedef itk::ImageFileReader< TImage > TReader;
-typedef itk::ImageFileWriter< TImage > TWriter;
-typedef fpa::Image::Dijkstra< TImage, TImage > TFilter;
-typedef fpa::Image::Functors::GaussianWeight< TImage, TPixel > TVertexFunc;
-
-// -------------------------------------------------------------------------
-int main( int argc, char* argv[] )
-{
- // Get arguments
- if( argc < 5 + VDim )
- {
- std::cerr
- << "Usage: " << argv[ 0 ]
- << " input_image output_image stop_at_one_front beta";
- for( unsigned int i = 0; i < VDim; ++i )
- std::cerr << " s_" << i;
- std::cerr << " ..." << std::endl;
- return( 1 );
-
- } // fi
- std::string input_image_filename = argv[ 1 ];
- std::string output_image_filename = argv[ 2 ];
- bool stop_at_one_front = ( std::atoi( argv[ 3 ] ) == 1 );
- double beta = std::atof( argv[ 4 ] );
-
- TReader::Pointer reader = TReader::New( );
- reader->SetFileName( input_image_filename );
-
- TFilter::Pointer filter = TFilter::New( );
- filter->SetInput( reader->GetOutput( ) );
- filter->SetStopAtOneFront( stop_at_one_front );
-
- for( int i = 5; i < argc; i += VDim )
- {
- if( i + VDim <= argc )
- {
- TImage::IndexType seed;
- for( int j = 0; j < VDim; ++j )
- seed[ j ] = std::atoi( argv[ i + j ] );
- filter->AddSeed( seed );
-
- } // fi
-
- } // rof
-
- TVertexFunc::Pointer vertex_func = TVertexFunc::New( );
- vertex_func->SetBeta( beta );
- vertex_func->InvertOn( );
- filter->SetFunctor( vertex_func );
-
- TWriter::Pointer writer = TWriter::New( );
- writer->SetInput( filter->GetOutput( ) );
- writer->SetFileName( output_image_filename );
-
- try
- {
- writer->Update( );
- }
- catch( std::exception& err )
- {
- std::cerr << "ERROR: " << err.what( ) << std::endl;
- return( 1 );
-
- } // yrt
- return( 0 );
-}
-
-// eof - $RCSfile$
+++ /dev/null
-#include <itkImage.h>
-#include <itkImageFileReader.h>
-#include <itkImageFileWriter.h>
-#include <itkMinimumMaximumImageCalculator.h>
-#include <itkSignedMaurerDistanceMapImageFilter.h>
-
-#include <fpa/Image/Dijkstra.h>
-#include <fpa/Image/Functors/VertexIdentity.h>
-#include <fpa/Base/Functors/InvertValue.h>
-#include <fpa/Image/MinimumSpanningTreeToImageFilter.h>
-
-// -------------------------------------------------------------------------
-static const unsigned int VDim = 2;
-typedef short TPixel;
-typedef double TScalar;
-typedef itk::Image< TPixel, VDim > TImage;
-typedef itk::Image< TScalar, VDim > TScalarImage;
-typedef itk::ImageFileReader< TImage > TReader;
-typedef itk::ImageFileWriter< TScalarImage > TWriter;
-typedef fpa::Image::Dijkstra< TScalarImage, TScalarImage > TFilter;
-typedef itk::MinimumMaximumImageCalculator< TImage > TMinMax;
-typedef itk::SignedMaurerDistanceMapImageFilter< TImage, TScalarImage > TDMap;
-
-typedef TImage::IndexType TIndex;
-
-typedef fpa::Image::Functors::VertexIdentity< TScalarImage, TScalar > TVertexFunc;
-typedef fpa::Base::Functors::InvertValue< TScalar, TScalar > TValueFunc;
-
-typedef TFilter::TMST TMST;
-typedef itk::ImageFileWriter< TMST > TMSTWriter;
-
-typedef unsigned char TColorValue;
-typedef fpa::Image::MinimumSpanningTreeToImageFilter< TMST, TColorValue > TMSTToImage;
-typedef TMSTToImage::TOutputImage TColorImage;
-typedef itk::ImageFileWriter< TColorImage > TColorImageWriter;
-
-// -------------------------------------------------------------------------
-int main( int argc, char* argv[] )
-{
- // Get arguments
- if( argc < 5 + VDim )
- {
- std::cerr
- << "Usage: " << argv[ 0 ]
- << " input_image output_image output_paths stop_at_one_front";
- for( unsigned int i = 0; i < VDim; ++i )
- std::cerr << " s_" << i;
- std::cerr << " ..." << std::endl;
- return( 1 );
-
- } // fi
- std::string input_image_filename = argv[ 1 ];
- std::string output_image_filename = argv[ 2 ];
- std::string output_paths_filename = argv[ 3 ];
- bool stop_at_one_front = ( std::atoi( argv[ 4 ] ) == 1 );
-
- TReader::Pointer reader = TReader::New( );
- reader->SetFileName( input_image_filename );
- try
- {
- reader->Update( );
- }
- catch( std::exception& err )
- {
- std::cerr << "Error caught: " << err.what( ) << std::endl;
- return( 1 );
-
- } // yrt
-
- TMinMax::Pointer minmax = TMinMax::New( );
- minmax->SetImage( reader->GetOutput( ) );
- minmax->Compute( );
-
- TDMap::Pointer dmap = TDMap::New( );
- dmap->SetInput( reader->GetOutput( ) );
- dmap->SetBackgroundValue( minmax->GetMinimum( ) );
- dmap->InsideIsPositiveOn( );
- dmap->UseImageSpacingOn( );
- dmap->SquaredDistanceOff( );
-
- TFilter::Pointer filter = TFilter::New( );
- filter->SetInput( dmap->GetOutput( ) );
- filter->SetStopAtOneFront( stop_at_one_front );
-
- for( int i = 5; i < argc; i += VDim )
- {
- if( i + VDim <= argc )
- {
- TImage::IndexType seed;
- for( int j = 0; j < VDim; ++j )
- seed[ j ] = std::atoi( argv[ i + j ] );
- filter->AddSeed( seed );
-
- } // fi
-
- } // rof
-
- TVertexFunc::Pointer vertex_func = TVertexFunc::New( );
- filter->SetFunctor( vertex_func );
-
- TValueFunc::Pointer value_func = TValueFunc::New( );
- value_func->SetAlpha( 1 );
- value_func->SetBeta( 1 );
- filter->SetFunctor( value_func );
-
- TWriter::Pointer writer = TWriter::New( );
- writer->SetInput( filter->GetOutput( ) );
- writer->SetFileName( output_image_filename );
-
- TMSTToImage::Pointer mst_image = TMSTToImage::New( );
- mst_image->SetInput( filter->GetMinimumSpanningTree( ) );
- TFilter::TSeedsInterface::TSeeds::const_iterator iseed =
- filter->BeginSeeds( );
- TFilter::TSeedsInterface::TSeeds::const_iterator jseed;
- for( ; iseed != filter->EndSeeds( ); ++iseed )
- for( jseed = filter->BeginSeeds( ); jseed != filter->EndSeeds( ); ++jseed )
- mst_image->AddPath( *iseed, *jseed, 255, 0, 0 );
-
- TColorImageWriter::Pointer paths_writer = TColorImageWriter::New( );
- paths_writer->SetInput( mst_image->GetOutput( ) );
- paths_writer->SetFileName( output_paths_filename );
-
- try
- {
- writer->Update( );
- paths_writer->Update( );
- }
- catch( std::exception& err )
- {
- std::cerr << "ERROR: " << err.what( ) << std::endl;
- return( 1 );
-
- } // yrt
- return( 0 );
-}
-
-// eof - $RCSfile$
+++ /dev/null
-#include <itkImage.h>
-#include <itkImageFileReader.h>
-#include <itkImageFileWriter.h>
-
-#include <fpa/Image/RegionGrow.h>
-#include <fpa/Image/Functors/RegionGrow/BinaryThreshold.h>
-
-// -------------------------------------------------------------------------
-typedef unsigned char TPixel;
-typedef itk::Image< TPixel, 2 > TImage;
-typedef itk::ImageFileReader< TImage > TReader;
-typedef itk::ImageFileWriter< TImage > TWriter;
-
-typedef fpa::Image::RegionGrow< TImage, TImage > TFilter;
-typedef fpa::Image::Functors::RegionGrow::BinaryThreshold< TPixel > TPredicate;
-
-// -------------------------------------------------------------------------
-int main( int argc, char* argv[] )
-{
- // Get arguments
- if( argc < 7 )
- {
- std::cerr
- << "Usage: " << argv[ 0 ]
- << " input_image output_image lower upper s0x s0y s1x s1y ..."
- << std::endl;
- return( 1 );
-
- } // fi
- std::string input_image_filename = argv[ 1 ];
- std::string output_image_filename = argv[ 2 ];
- TPixel lower = std::atof( argv[ 3 ] );
- TPixel upper = std::atof( argv[ 4 ] );
-
- TReader::Pointer reader = TReader::New( );
- reader->SetFileName( input_image_filename );
-
- TPredicate::Pointer predicate = TPredicate::New( );
- predicate->SetLower( lower );
- predicate->SetUpper( upper );
-
- TFilter::Pointer filter = TFilter::New( );
- filter->SetInput( reader->GetOutput( ) );
- filter->SetPredicate( predicate );
- for( int i = 5; i < argc; i += 2 )
- {
- if( i + 1 < argc )
- {
- TImage::IndexType seed;
- seed[ 0 ] = std::atoi( argv[ i ] );
- seed[ 1 ] = std::atoi( argv[ i + 1 ] );
- filter->AddSeed( seed );
-
- } // fi
-
- } // rof
- filter->SetInsideValue( 255 );
- filter->SetOutsideValue( 0 );
-
- TWriter::Pointer writer = TWriter::New( );
- writer->SetInput( filter->GetOutput( ) );
- writer->SetFileName( output_image_filename );
- try
- {
- writer->Update( );
- }
- catch( std::exception& err )
- {
- std::cerr << "ERROR: " << err.what( ) << std::endl;
- return( 1 );
-
- } // yrt
- return( 0 );
-}
-
-// eof - $RCSfile$
+++ /dev/null
-#include <chrono>
-#include <iomanip>
-#include <itkCommand.h>
-#include <itkImage.h>
-#include <itkImageFileReader.h>
-#include <itkImageFileWriter.h>
-#include <itkBinaryThresholdImageFilter.h>
-
-#include <fpa/Image/MoriRegionGrow.h>
-
-// -------------------------------------------------------------------------
-static const unsigned int VDim = 3;
-typedef short TPixel;
-typedef itk::Image< TPixel, VDim > TImage;
-typedef itk::ImageFileReader< TImage > TReader;
-typedef itk::ImageFileWriter< TImage > TWriter;
-typedef fpa::Image::MoriRegionGrow< TImage, TImage > TFilter;
-typedef itk::BinaryThresholdImageFilter< TImage, TImage > TThreshold;
-
-// -------------------------------------------------------------------------
-class ShowProgressObject
-{
-public:
- ShowProgressObject( itk::ProcessObject* o )
- {
- this->m_Process = o;
- }
- void ShowProgress( )
- {
- std::cerr
- << "\rProgress " << std::fixed << std::setprecision( 2 )
- << ( this->m_Process->GetProgress( ) * 100 )
- << " %" << std::flush;
- }
- itk::ProcessObject::Pointer m_Process;
-};
-
-// -------------------------------------------------------------------------
-int main( int argc, char* argv[] )
-{
- // Get arguments
- if( argc < 6 + VDim )
- {
- std::cerr
- << "Usage: " << argv[ 0 ]
- << " input_image output_image lower upper delta";
- for( unsigned int i = 0; i < VDim; ++i )
- std::cerr << " s_" << i;
- std::cerr << std::endl;
- return( 1 );
-
- } // fi
- std::string input_image_filename = argv[ 1 ];
- std::string output_image_filename = argv[ 2 ];
- TPixel lower = std::atof( argv[ 3 ] );
- TPixel upper = std::atof( argv[ 4 ] );
- TPixel delta = std::atof( argv[ 5 ] );
-
- TReader::Pointer reader = TReader::New( );
- reader->SetFileName( input_image_filename );
- try
- {
- reader->Update( );
- }
- catch( std::exception& err )
- {
- std::cerr << "ERROR: " << err.what( ) << std::endl;
- return( 1 );
-
- } // yrt
-
- TFilter::Pointer filter = TFilter::New( );
- filter->SetInput( reader->GetOutput( ) );
- filter->SetThresholdRange( lower, upper, delta );
- TImage::PointType pnt;
- for( int i = 0; i < VDim; ++i )
- pnt[ i ] = std::atof( argv[ i + 6 ] );
-
- TImage::IndexType seed;
- if( !( reader->GetOutput( )->TransformPhysicalPointToIndex( pnt, seed ) ) )
- {
- std::cerr << "ERROR: seed outside image." << std::endl;
- return( 1 );
-
- } // fi
- filter->AddSeed( seed );
-
- // to test ProgressReporter
- /* TODO
- ShowProgressObject progressWatch( filter );
- typedef itk::SimpleMemberCommand< ShowProgressObject > CommandType;
- CommandType::Pointer command = CommandType::New();
- command->SetCallbackFunction( &progressWatch,
- &ShowProgressObject::ShowProgress );
- filter->AddObserver( itk::ProgressEvent( ), command );
- */
- std::chrono::time_point< std::chrono::system_clock > start, end;
- start = std::chrono::system_clock::now( );
- filter->Update( );
- end = std::chrono::system_clock::now( );
- std::chrono::duration< double > elapsed_seconds = end - start;
-
- TThreshold::Pointer threshold = TThreshold::New( );
- threshold->SetInput( filter->GetOutput( ) );
- threshold->SetInsideValue( 255 );
- threshold->SetOutsideValue( 0 );
- threshold->SetLowerThreshold( 0 );
- threshold->SetUpperThreshold( filter->GetOptimumThreshold( ) );
-
- TWriter::Pointer writer = TWriter::New( );
- writer->SetInput( threshold->GetOutput( ) );
- writer->SetFileName( output_image_filename );
- try
- {
- writer->Update( );
- }
- catch( std::exception& err )
- {
- std::cerr << "ERROR: " << err.what( ) << std::endl;
- return( 1 );
-
- } // yrt
-
- // Show data
- TFilter::TCurve curve = filter->GetCurve( );
- TFilter::TCurve::const_iterator data = curve.begin( );
- for( ; data != curve.end( ); ++data )
- {
- std::cout << data->XValue << " " << data->YValue << " " << data->Diff1 << std::endl;
- }
- std::cout
- << std::endl
- << "# Opt: "
- << curve[ filter->GetOptimumThreshold( ) ].XValue
- << "("
- << filter->GetOptimumThreshold( )
- << ")"
- << std::endl;
- std::cout << "Time: " << elapsed_seconds.count( ) << "s" << std::endl;
- return( 0 );
-}
-
-// eof - $RCSfile$
+++ /dev/null
-#include <itkImage.h>
-#include <itkImageFileWriter.h>
-
-#include <fpa/Image/RegionGrow.h>
-#include <fpa/Image/Functors/RegionGrow/Tautology.h>
-
-// -------------------------------------------------------------------------
-typedef unsigned char TPixel;
-typedef itk::Image< TPixel, 2 > TImage;
-typedef itk::ImageFileWriter< TImage > TWriter;
-
-typedef fpa::Image::RegionGrow< TImage, TImage > TFilter;
-typedef fpa::Image::Functors::RegionGrow::Tautology< TPixel > TPredicate;
-
-// -------------------------------------------------------------------------
-int main( int argc, char* argv[] )
-{
- // Get arguments
- if( argc < 6 )
- {
- std::cerr
- << "Usage: " << argv[ 0 ]
- << " output_image width height s0x s0y s1x s1y ..."
- << std::endl;
- return( 1 );
-
- } // fi
- std::string output_image_filename = argv[ 1 ];
- TImage::SizeType size;
- size[ 0 ] = std::atoi( argv[ 2 ] );
- size[ 1 ] = std::atoi( argv[ 3 ] );
-
- TImage::Pointer input = TImage::New( );
- input->SetRegions( size );
- input->Allocate( );
- input->FillBuffer( 0 );
-
- TPredicate::Pointer predicate = TPredicate::New( );
-
- TFilter::Pointer filter = TFilter::New( );
- filter->SetInput( input );
- filter->SetPredicate( predicate );
- for( int i = 4; i < argc; i += 2 )
- {
- if( i + 1 < argc )
- {
- TImage::IndexType seed;
- seed[ 0 ] = std::atoi( argv[ i ] );
- seed[ 1 ] = std::atoi( argv[ i + 1 ] );
- filter->AddSeed( seed );
-
- } // fi
-
- } // rof
- filter->SetInsideValue( 255 );
- filter->SetOutsideValue( 0 );
-
- TWriter::Pointer writer = TWriter::New( );
- writer->SetInput( filter->GetOutput( ) );
- writer->SetFileName( output_image_filename );
- try
- {
- writer->Update( );
- }
- catch( std::exception& err )
- {
- std::cerr << "ERROR: " << err.what( ) << std::endl;
- return( 1 );
-
- } // yrt
- return( 0 );
-}
-
-// eof - $RCSfile$
+++ /dev/null
-
-#include <chrono>
-#include <iomanip>
-#include <itkImage.h>
-#include <itkImageFileReader.h>
-
-#include <fpa/Base/SkeletonWriter.h>
-#include <fpa/Image/SkeletonFilter.h>
-
-// -------------------------------------------------------------------------
-static const unsigned int VDim = 3;
-typedef unsigned char TPixel;
-typedef double TScalar;
-typedef itk::Image< TPixel, VDim > TImage;
-typedef itk::ImageFileReader< TImage > TReader;
-typedef fpa::Image::SkeletonFilter< TImage, TScalar > TFilter;
-typedef fpa::Base::SkeletonWriter< TFilter::TSkeleton > TWriter;
-
-// -------------------------------------------------------------------------
-int main( int argc, char* argv[] )
-{
- // Get arguments
- if( argc != 3 && argc != 3 + VDim )
- {
- std::cerr
- << "Usage: " << argv[ 0 ]
- << " input_image output_skeleton [";
- for( unsigned int i = 0; i < VDim; ++i )
- std::cerr << " s_" << i;
- std::cerr << " ]" << std::endl;
- return( 1 );
-
- } // fi
- std::string input_image_filename = argv[ 1 ];
- std::string output_skeleton_filename = argv[ 2 ];
-
- TReader::Pointer reader = TReader::New( );
- reader->SetFileName( input_image_filename );
- try
- {
- reader->Update( );
- }
- catch( std::exception& err )
- {
- std::cerr << "ERROR: " << err.what( ) << std::endl;
- return( 1 );
-
- } // yrt
-
- TFilter::Pointer filter = TFilter::New( );
- filter->SetInput( reader->GetOutput( ) );
-
- if( argc > 3 )
- {
- filter->SeedFromMaximumDistanceOff( );
- TImage::PointType pnt;
- for( int i = 0; i < VDim; ++i )
- pnt[ i ] = std::atof( argv[ i + 3 ] );
- TImage::IndexType seed;
- if( !( reader->GetOutput( )->TransformPhysicalPointToIndex( pnt, seed ) ) )
- {
- std::cerr << "ERROR: seed outside image." << std::endl;
- return( 1 );
-
- } // fi
- filter->AddSeed( seed );
- }
- else
- filter->SeedFromMaximumDistanceOn( );
-
- std::chrono::time_point< std::chrono::system_clock > start, end;
- start = std::chrono::system_clock::now( );
- filter->Update( );
- end = std::chrono::system_clock::now( );
- std::chrono::duration< double > elapsed_seconds = end - start;
-
- TWriter::Pointer writer = TWriter::New( );
- writer->SetInput( filter->GetSkeleton( ) );
- writer->SetFileName( output_skeleton_filename );
- try
- {
- writer->Update( );
- }
- catch( std::exception& err )
- {
- std::cerr << "ERROR: " << err.what( ) << std::endl;
- return( 1 );
-
- } // yrt
-
- // Show data
- std::cout << "Time: " << elapsed_seconds.count( ) << "s" << std::endl;
- return( 0 );
-}
-
-// eof - $RCSfile$
+++ /dev/null
-#include <itkFunctionBase.h>
-#include <itkImage.h>
-#include <itkImageToImageFilter.h>
-#include <fpa/Base/Algorithm.h>
-#include <fpa/Base/SeedsInterface.h>
-#include <fpa/Base/MarksInterface.h>
-
-// -------------------------------------------------------------------------
-namespace fpa
-{
- namespace Base
- {
- namespace Functors
- {
- namespace RegionGrow
- {
- /**
- */
- template< class _TValue >
- class Tautology
- : public itk::FunctionBase< _TValue, bool >
- {
- public:
- typedef Tautology Self;
- typedef itk::FunctionBase< _TValue, bool > Superclass;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
-
- public:
- itkNewMacro( Self );
- itkTypeMacro(
- fpa::Base::Functors::RegionGrow::Tautology,
- itk::FunctionBase
- );
-
- public:
- virtual bool Evaluate( const _TValue& input ) const override
- {
- return( true );
- }
- protected:
- Tautology( )
- : Superclass( )
- {
- }
- virtual ~Tautology( )
- {
- }
- private:
- // Purposely not implemented
- Tautology( const Self& other );
- Self& operator=( const Self& other );
- };
-
- } // ecapseman
-
- } // ecapseman
-
- } // ecapseman
-
-} // ecapseman
-
-// -------------------------------------------------------------------------
-namespace fpa
-{
- namespace Base
- {
- /**
- */
- template< class _TAlgorithm >
- class RegionGrow
- : public _TAlgorithm
- {
- };
-
- } // ecapseman
-
-} // ecapseman
-
-// -------------------------------------------------------------------------
-namespace fpa
-{
- namespace Image
- {
- /**
- */
- template< class _TInputImage >
- class MarksInterface
- {
- };
-
- } // ecapseman
-
-} // ecapseman
-
-// -------------------------------------------------------------------------
-namespace fpa
-{
- namespace Image
- {
- /**
- */
- template< class _TInputImage, class _TOutputImage, class _TSeedsInterface, class _TMarksInterface >
- class Algorithm
- : public fpa::Base::Algorithm< itk::ImageToImageFilter< _TInputImage, _TOutputImage >, _TSeedsInterface, _TMarksInterface >
- {
- };
-
- } // ecapseman
-
-} // ecapseman
-
-// -------------------------------------------------------------------------
-namespace fpa
-{
- namespace Image
- {
- /**
- */
- template< class _TInputImage, class _TOutputImage >
- class RegionGrow
- : public fpa::Base::RegionGrow< fpa::Image::Algorithm< _TInputImage, _TOutputImage, fpa::Base::SeedsInterface< typename _TInputImage::IndexType, typename _TInputImage::IndexType::LexicographicCompare >, fpa::Image::MarksInterface< _TInputImage > > >
- {
- };
-
- } // ecapseman
-
-} // ecapseman
-
-// -------------------------------------------------------------------------
-const unsigned int Dim = 2;
-typedef short TInputPixel;
-typedef unsigned char TOutputPixel;
-typedef itk::Image< TInputPixel, Dim > TInputImage;
-typedef itk::Image< TOutputPixel, Dim > TOutputImage;
-
-// -------------------------------------------------------------------------
-int main( int argc, char* argv[] )
-{
- TInputImage::IndexType seed;
- seed.Fill( 0 );
-
- typedef fpa::Base::Functors::RegionGrow::Tautology< TInputPixel > TPredicate;
- TPredicate::Pointer tautology = TPredicate::New( );
-
- typedef fpa::Image::RegionGrow< TInputImage, TOutputImage > TFilter;
- TFilter::Pointer filter = TFilter::New( );
- filter->SetInput( input_image );
- filter->AddSeed( seed );
- filter->SetPredicate( tautology );
- filter->Update( );
-
- return( 0 );
-}
-
-// eof - $RCSfile$
+++ /dev/null
-
-include_directories(
- ${CMAKE_CURRENT_SOURCE_DIR}
- ${CMAKE_CURRENT_BINARY_DIR}
- )
-subdirs(fpa)
-
-## eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Base__Algorithm__h__
-#define __fpa__Base__Algorithm__h__
-
-#include <vector>
-#include <itkObject.h>
-/* TODO
- #include <itkMacro.h>
- #include <itkSmartPointer.h>
-*/
-namespace fpa
-{
- namespace Base
- {
- /**
- */
- template< class _TFilter, class _TMarksInterface, class _TSeedsInterface >
- class Algorithm
- : public _TFilter,
- public _TMarksInterface,
- public _TSeedsInterface
- {
- public:
- typedef Algorithm Self;
- typedef _TFilter Superclass;
- typedef _TMarksInterface TMarksInterface;
- typedef _TSeedsInterface TSeedsInterface;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
-
- typedef typename _TMarksInterface::TOutputValue TOutputValue;
- typedef typename _TSeedsInterface::TNode TNode;
- typedef typename _TSeedsInterface::TSeeds TSeeds;
-
- typedef std::vector< TNode > TNeighborhood;
-
- public:
- itkTypeMacro( fpa::Base::Algorithm, _TFilter );
-
- itkGetConstMacro( InitValue, TOutputValue );
- itkSetMacro( InitValue, TOutputValue );
-
- protected:
- Algorithm( );
- virtual ~Algorithm( );
-
- virtual void GenerateData( ) override;
-
- virtual void _ConfigureOutput( const TOutputValue& v ) = 0;
- virtual void _QueueInit( ) = 0;
- virtual void _QueuePush( const TNode& node ) = 0;
- virtual unsigned long _QueueSize( ) const = 0;
- virtual TNode _QueuePop( ) = 0;
-
- private:
- // Purposely not implemented
- Algorithm( const Self& other );
- Self& operator=( const Self& other );
-
- protected:
- TOutputValue m_InitValue;
- };
-
- } // ecapseman
-
-} // ecapseman
-
-#ifndef ITK_MANUAL_INSTANTIATION
-# include <fpa/Base/Algorithm.hxx>
-#endif // ITK_MANUAL_INSTANTIATION
-
-#endif // __fpa__Base__Algorithm__h__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Base__Algorithm__hxx__
-#define __fpa__Base__Algorithm__hxx__
-
-// -------------------------------------------------------------------------
-template< class _TFilter, class _TMarksInterface, class _TSeedsInterface >
-fpa::Base::Algorithm< _TFilter, _TMarksInterface, _TSeedsInterface >::
-Algorithm( )
- : Superclass( ),
- _TMarksInterface( this ),
- _TSeedsInterface( this )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TFilter, class _TMarksInterface, class _TSeedsInterface >
-fpa::Base::Algorithm< _TFilter, _TMarksInterface, _TSeedsInterface >::
-~Algorithm( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TFilter, class _TMarksInterface, class _TSeedsInterface >
-void fpa::Base::Algorithm< _TFilter, _TMarksInterface, _TSeedsInterface >::
-GenerateData( )
-{
- // Init objects
- this->_ConfigureOutput( this->m_InitValue );
- this->_InitMarks( this->GetNumberOfSeeds( ) );
-
- // Init queue
- this->_QueueInit( );
- typename TSeeds::const_iterator sIt = this->BeginSeeds( );
- for( ; sIt != this->EndSeeds( ); ++sIt )
- this->_QueuePush( *sIt );
-
- // Main loop
- while( this->_QueueSize( ) > 0 )
- {
- // Get next candidate
- TNode node = this->_QueuePop( );
- if( !( this->_IsMarked( node ) ) )
- {
- // Mark it
- if( this->_Mark( node ) )
- {
- // Add neighborhood
- TNeighborhood neighbors = this->_GetNeighbors( node );
- typename TNeighborhood::const_iterator nIt = neighbors.begin( );
- bool coll = false;
- while( nIt != neighbors.end( ) && !coll )
- {
- if( this->_IsMarked( *nIt ) )
- {
- // Invoke stop at collisions
- if( this->_Collisions( node, *nIt ) )
- {
- this->_QueueClear( );
- coll = true;
-
- } // fi
- }
- else
- this->_QueuePush( *nIt );
- ++nIt;
-
- } // elihw
-
- } // fi
-
- } // fi
-
- } // elihw
-}
-
-#endif // __fpa__Base__Algorithm__hxx__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Base__Dijkstra__h__
-#define __fpa__Base__Dijkstra__h__
-
-#include <itkFunctionBase.h>
-#include <fpa/Base/MinimumSpanningTree.h>
-#include <fpa/Base/Functors/VertexParentBase.h>
-
-namespace fpa
-{
- namespace Base
- {
- /**
- */
- template< class _TFilter, class _TMarksInterface, class _TSeedsInterface, class _TMST >
- class Dijkstra
- : public _TFilter,
- public _TMarksInterface,
- public _TSeedsInterface
- {
- public:
- typedef Dijkstra Self;
- typedef _TFilter Superclass;
- typedef _TMarksInterface TMarksInterface;
- typedef _TSeedsInterface TSeedsInterface;
- typedef _TMST TMST;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
-
- typedef typename Superclass::TInputValue TInputValue;
- typedef typename Superclass::TOutputValue TOutputValue;
- typedef typename Superclass::TVertex TVertex;
- typedef typename Superclass::TVertices TVertices;
-
- typedef itk::FunctionBase< TInputValue, TOutputValue > TIntensityFunctor;
- typedef fpa::Base::Functors::VertexParentBase< TVertex, TOutputValue > TVertexFunctor;
-
- protected:
- struct _TNode
- {
- TVertex Vertex;
- TVertex Parent;
- TOutputValue Cost;
- unsigned long FrontId;
- _TNode( const TVertex& v, const TVertex& p, const unsigned long& fId )
- {
- this->Vertex = v;
- this->Parent = p;
- this->FrontId = fId;
- this->Cost = TOutputValue( 0 );
- }
- bool operator<( const _TNode& b ) const
- {
- return( b.Cost < this->Cost );
- }
- };
-
- public:
- itkTypeMacro( Dijkstra, TFilter );
-
- public:
- TMST* GetMinimumSpanningTree( );
- const TMST* GetMinimumSpanningTree( ) const;
-
- const TIntensityFunctor* GetIntensityFunctor( ) const;
- const TVertexFunctor* GetVertexFunctor( ) const;
-
- void SetFunctor( TIntensityFunctor* functor );
- void SetFunctor( TVertexFunctor* functor );
-
- protected:
- Dijkstra( );
- virtual ~Dijkstra( );
-
- virtual void GenerateData( ) override;
-
- private:
- Dijkstra( const Self& other );
- Self& operator=( const Self& other );
-
- protected:
- typename TIntensityFunctor::Pointer m_IntensityFunctor;
- typename TVertexFunctor::Pointer m_VertexFunctor;
- 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
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Base__Dijkstra__hxx__
-#define __fpa__Base__Dijkstra__hxx__
-
-// -------------------------------------------------------------------------
-template< class _TFilter, class _TMarksInterface, class _TSeedsInterface, class _TMST >
-typename
-fpa::Base::Dijkstra< _TFilter, _TMarksInterface, _TSeedsInterface, _TMST >::
-TMST* fpa::Base::Dijkstra< _TFilter, _TMarksInterface, _TSeedsInterface, _TMST >::
-GetMinimumSpanningTree( )
-{
- return(
- dynamic_cast< TMST* >(
- this->itk::ProcessObject::GetOutput( this->m_MSTIndex )
- )
- );
-}
-
-// -------------------------------------------------------------------------
-template< class _TFilter, class _TMarksInterface, class _TSeedsInterface, class _TMST >
-const typename
-fpa::Base::Dijkstra< _TFilter, _TMarksInterface, _TSeedsInterface, _TMST >::
-TMST* fpa::Base::Dijkstra< _TFilter, _TMarksInterface, _TSeedsInterface, _TMST >::
-GetMinimumSpanningTree( ) const
-{
- return(
- dynamic_cast< const TMST* >(
- this->itk::ProcessObject::GetOutput( this->m_MSTIndex )
- )
- );
-}
-
-// -------------------------------------------------------------------------
-template< class _TFilter, class _TMarksInterface, class _TSeedsInterface, class _TMST >
-const typename
-fpa::Base::Dijkstra< _TFilter, _TMarksInterface, _TSeedsInterface, _TMST >::
-TIntensityFunctor*
-fpa::Base::Dijkstra< _TFilter, _TMarksInterface, _TSeedsInterface, _TMST >::
-GetIntensityFunctor( ) const
-{
- return( this->m_IntensityFunctor );
-}
-
-// -------------------------------------------------------------------------
-template< class _TFilter, class _TMarksInterface, class _TSeedsInterface, class _TMST >
-const typename
-fpa::Base::Dijkstra< _TFilter, _TMarksInterface, _TSeedsInterface, _TMST >::
-TVertexFunctor*
-fpa::Base::Dijkstra< _TFilter, _TMarksInterface, _TSeedsInterface, _TMST >::
-GetVertexFunctor( ) const
-{
- return( this->m_VertexFunctor );
-}
-
-// -------------------------------------------------------------------------
-template< class _TFilter, class _TMarksInterface, class _TSeedsInterface, class _TMST >
-void fpa::Base::Dijkstra< _TFilter, _TMarksInterface, _TSeedsInterface, _TMST >::
-SetFunctor( TIntensityFunctor* functor )
-{
- if( this->m_IntensityFunctor.GetPointer( ) != functor )
- {
- this->m_IntensityFunctor = functor;
- this->Modified( );
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-template< class _TFilter, class _TMarksInterface, class _TSeedsInterface, class _TMST >
-void fpa::Base::Dijkstra< _TFilter, _TMarksInterface, _TSeedsInterface, _TMST >::
-SetFunctor( TVertexFunctor* functor )
-{
- if( this->m_VertexFunctor.GetPointer( ) != functor )
- {
- this->m_VertexFunctor = functor;
- this->Modified( );
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-template< class _TFilter, class _TMarksInterface, class _TSeedsInterface, class _TMST >
-fpa::Base::Dijkstra< _TFilter, _TMarksInterface, _TSeedsInterface, _TMST >::
-Dijkstra( )
- : Superclass( ),
- _TMarksInterface( this ),
- _TSeedsInterface( this )
-{
- this->m_MSTIndex = this->GetNumberOfRequiredOutputs( );
- this->SetNumberOfRequiredOutputs( this->m_MSTIndex + 1 );
- this->itk::ProcessObject::SetNthOutput( this->m_MSTIndex, TMST::New( ) );
-}
-
-// -------------------------------------------------------------------------
-template< class _TFilter, class _TMarksInterface, class _TSeedsInterface, class _TMST >
-fpa::Base::Dijkstra< _TFilter, _TMarksInterface, _TSeedsInterface, _TMST >::
-~Dijkstra( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TFilter, class _TMarksInterface, class _TSeedsInterface, class _TMST >
-void fpa::Base::Dijkstra< _TFilter, _TMarksInterface, _TSeedsInterface, _TMST >::
-GenerateData( )
-{
- // Init objects
- this->_ConfigureOutputs( std::numeric_limits< TOutputValue >::max( ) );
- this->_InitMarks( this->GetNumberOfSeeds( ) );
- TMST* mst = this->GetMinimumSpanningTree( );
-
- // Init queue
- std::vector< _TNode > q;
- unsigned long frontId = 1;
- typename TSeedsInterface::TSeeds::const_iterator sIt = this->BeginSeeds( );
- for( ; sIt != this->EndSeeds( ); ++sIt )
- q.push_back( _TNode( *sIt, *sIt, frontId++ ) );
-
- // Main loop
- while( q.size( ) > 0 )
- {
- // Get next candidate
- std::pop_heap( q.begin( ), q.end( ) );
- _TNode node = q.back( );
- q.pop_back( );
- if( this->_IsMarked( node.Vertex ) )
- continue;
- this->_Mark( node.Vertex, node.FrontId );
-
- // Ok, pixel lays inside region
- this->_SetOutputValue( node.Vertex, node.Cost );
- mst->SetParent( node.Vertex, node.Parent );
-
- // Add neighborhood
- TVertices neighbors = this->_GetNeighbors( node.Vertex );
- typename TVertices::const_iterator neighIt = neighbors.begin( );
- bool coll = false;
- while( neighIt != neighbors.end( ) && !coll )
- {
- TVertex neigh = *neighIt;
- if( this->_IsMarked( neigh ) )
- {
- // Invoke stop at collisions
- unsigned long nColl = this->_Collisions( node.Vertex, neigh );
- if(
- this->StopAtOneFront( ) &&
- this->GetNumberOfSeeds( ) > 1 &&
- nColl == 1
- )
- {
- q.clear( );
- coll = true;
-
- } // fi
- }
- else
- {
- // Compute new cost
- TOutputValue ncost =
- this->m_VertexFunctor->Evaluate( neigh, node.Vertex );
- if( this->m_IntensityFunctor.IsNotNull( ) )
- ncost = this->m_IntensityFunctor->Evaluate( ncost );
-
- // This algorithm only supports positive values
- if( ncost >= TOutputValue( 0 ) )
- {
- // Insert new node
- _TNode nn( neigh, node.Vertex, node.FrontId );
- nn.Cost = node.Cost + ncost;
- q.push_back( nn );
- std::push_heap( q.begin( ), q.end( ) );
-
- } // fi
-
- } // fi
- ++neighIt;
-
- } // elihw
-
- } // elihw
- this->_FreeMarks( );
-
- // Complete data into minimum spanning tree
- mst->ClearSeeds( );
- mst->SetCollisions( this->m_Collisions );
- for( sIt = this->BeginSeeds( ); sIt != this->EndSeeds( ); ++sIt )
- mst->AddSeed( *sIt );
-}
-
-#endif // __fpa__Base__Dijkstra__hxx__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Base__Functors__InvertValue__h__
-#define __fpa__Base__Functors__InvertValue__h__
-
-#include <cmath>
-#include <itkFunctionBase.h>
-
-namespace fpa
-{
- namespace Base
- {
- namespace Functors
- {
- /**
- */
- template< class _TInputValue, class _TOutputValue >
- class InvertValue
- : public itk::FunctionBase< _TInputValue, _TOutputValue >
- {
- public:
- typedef InvertValue Self;
- typedef itk::FunctionBase< _TInputValue, _TOutputValue > Superclass;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
-
- typedef _TInputValue TInputValue;
- typedef _TOutputValue TOutputValue;
-
- public:
- itkNewMacro( Self );
- itkTypeMacro( InvertValue, itk::FunctionBase );
-
- itkGetConstMacro( Alpha, double );
- itkGetConstMacro( Beta, double );
- itkSetMacro( Alpha, double );
- itkSetMacro( Beta, double );
-
- public:
- virtual TOutputValue Evaluate( const TInputValue& a ) const override
- {
- double d = this->m_Alpha;
- d += std::pow( double( a ), this->m_Beta );
- double x = -1;
- if( std::fabs( d ) > double( 0 ) )
- x =
- double( 1 ) /
- ( this->m_Alpha + std::pow( double( a ), this->m_Beta ) );
- return( TOutputValue( x ) );
- }
-
- protected:
- InvertValue( )
- : Superclass( ),
- m_Alpha( double( 1 ) ),
- m_Beta( double( 1 ) )
- { }
- virtual ~InvertValue( ) { }
-
- private:
- InvertValue( const Self& other );
- Self& operator=( const Self& other );
-
- protected:
- double m_Alpha;
- double m_Beta;
- };
-
- } // ecapseman
-
- } // ecapseman
-
-} // ecapseman
-
-#endif // __fpa__Base__Functors__InvertValue__h__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Base__Functors__VertexParentBase__h__
-#define __fpa__Base__Functors__VertexParentBase__h__
-
-#include <itkObject.h>
-#include <itkObjectFactory.h>
-
-namespace fpa
-{
- namespace Base
- {
- namespace Functors
- {
- /**
- */
- template< class _TVertex, class _TOutputValue >
- class VertexParentBase
- : public itk::Object
- {
- public:
- typedef VertexParentBase Self;
- typedef itk::Object Superclass;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
-
- typedef _TVertex TVertex;
- typedef _TOutputValue TOutputValue;
-
- public:
- itkTypeMacro( VertexParentBase, TFilter );
-
- public:
- virtual TOutputValue Evaluate( const TVertex& v, const TVertex& p ) const = 0;
-
- protected:
- VertexParentBase( )
- : Superclass( )
- { }
- virtual ~VertexParentBase( ) { }
-
- private:
- VertexParentBase( const Self& other );
- Self& operator=( const Self& other );
- };
-
- } // ecapseman
-
- } // ecapseman
-
-} // ecapseman
-
-#endif // __fpa__Base__Functors__VertexParentBase__h__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Base__Graph__h__
-#define __fpa__Base__Graph__h__
-
-#include <map>
-#include <set>
-#include <vector>
-#include <itkDataObject.h>
-#include <itkObjectFactory.h>
-
-namespace fpa
-{
- namespace Base
- {
- /** \brief A generic graph with templated index types.
- *
- * @param _TVertex Vertex type.
- * @param _TCost Cost type.
- * @param _TIndex Index type (it should be a strict weak ordering type).
- */
- template< class _TVertex, class _TCost, class _TIndex = unsigned long, class _TIndexCompare = std::less< _TIndex > >
- class Graph
- : public itk::DataObject
- {
- public:
- typedef Graph Self;
- typedef itk::DataObject Superclass;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
-
- typedef _TVertex TVertex;
- typedef _TCost TCost;
- typedef _TIndex TIndex;
- typedef _TIndexCompare TIndexCompare;
-
- // Base types
- typedef std::map< TIndex, TVertex, TIndexCompare > TVertices;
- typedef std::vector< TCost > TEdges;
- typedef std::map< TIndex, TEdges, TIndexCompare > TMatrixRow;
- typedef std::map< TIndex, TMatrixRow, TIndexCompare > TMatrix;
-
- public:
- itkNewMacro( Self );
- itkTypeMacro( Graph, itk::DataObject );
-
- public:
- /*! \brief Iterators over vertices.
- * These allow you to iterate over all of graph's vertices.
- *
- * Typical iteration should be done as:
- *
- * TGraph g;
- * ...
- * TGraph::TVertices::[const_]iterator vIt = g.BeginVertices( );
- * for( ; vIt != g.EndVertices( ); ++vIt )
- * {
- * vIt->first; --> this is the vertex's index <--
- * vIt->second; --> this is the vertex's value <--
- * }
- */
- inline typename TVertices::iterator BeginVertices( )
- { return( this->m_Vertices.begin( ) ); }
- inline typename TVertices::iterator EndVertices( )
- { return( this->m_Vertices.end( ) ); }
- inline typename TVertices::const_iterator BeginVertices( ) const
- { return( this->m_Vertices.begin( ) ); }
- inline typename TVertices::const_iterator EndVertices( ) const
- { return( this->m_Vertices.end( ) ); }
-
- /*! \brief Iterators over edges.
- * These allow you to iterate over all of graph's edges.
- *
- * Typical iteration should be done as:
- *
- * TGraph g;
- * ...
- * TGraph::TMatrix::[const_]iterator mIt = g.BeginEdgesRows( );
- * for( ; mIt != g.EndEdgesRows( ); ++mIt )
- * {
- * mIt->first; --> this is the row index. <--
- * TGraph::TMatrixRow::[const_]iterator rIt = mIt->second.begin( );
- * for( ; rIt != mIt->second.end( ); ++rIt )
- * {
- * rIt->first; --> this is the column index.
- * TGraph::TEdges::[const_]iterator eIt = rIt->second.begin( );
- * for( ; eIt != rIt->second.end( ); ++eIt )
- * *eIt; --> this is the cost between mIt->first and rIt->first
- * }
- * }
- */
- inline typename TMatrix::iterator BeginEdgesRows( )
- { return( this->m_Matrix.begin( ) ); }
- inline typename TMatrix::iterator EndEdgetsRows( )
- { return( this->m_Matrix.end( ) ); }
- inline typename TMatrix::const_iterator BeginEdgesRows( ) const
- { return( this->m_Matrix.begin( ) ); }
- inline typename TMatrix::const_iterator EndEdgesRows( ) const
- { return( this->m_Matrix.end( ) ); }
-
- /*! \brief Clear all vertices and edges.
- */
- void Clear( );
-
- /*! \brief Clear all edges.
- */
- inline void ClearEdges( )
- { this->m_Matrix.clear( ); }
-
- /*! \brief Vertex manipulation methods.
- * Names are self-explanatory.
- */
- inline bool HasVertexIndex( const TIndex& i ) const
- { return( this->m_Vertices.find( i ) != this->m_Vertices.end( ) ); }
- inline void SetVertex( const TIndex& index, TVertex& vertex )
- { this->m_Vertices[ index ] = vertex; }
- inline TVertex& GetVertex( const TIndex& index )
- { return( this->m_Vertices[ index ] ); }
- inline const TVertex& GetVertex( const TIndex& index ) const
- { return( this->m_Vertices[ index ] ); }
- bool RenameVertex( const TIndex& old_index, const TIndex& new_index );
- void RemoveVertex( const TIndex& index );
-
- /*! \brief Edge manipulation methods.
- * Names are self-explanatory.
- */
- inline void AddEdge( const TIndex& orig, const TIndex& dest, const TCost& cost )
- { this->m_Matrix[ orig ][ dest ].push_back( cost ); }
- TEdges& GetEdges( const TIndex& orig, const TIndex& dest );
- const TEdges& GetEdges( const TIndex& orig, const TIndex& dest ) const;
- bool HasEdge( const TIndex& orig, const TIndex& dest ) const;
- void RemoveEdge( const TIndex& orig, const TIndex& dest, const TCost& cost );
- void RemoveEdges( const TIndex& orig, const TIndex& dest );
-
- /*! \brief Returns graph's sinks.
- *
- * A sink is a special vertex which does not have any "exiting" edges.
- *
- * @return Sinks ordered by their index.
- */
- std::set< TIndex, TIndexCompare > GetSinks( ) const;
-
- protected:
- Graph( );
- virtual ~Graph( );
-
- private:
- // Purposely not implemented
- Graph( const Self& other );
- Self& operator=( const Self& other );
-
- protected:
- TVertices m_Vertices;
- TMatrix m_Matrix;
- };
-
- } // ecapseman
-
-} // ecapseman
-
-#ifndef ITK_MANUAL_INSTANTIATION
-# include <fpa/Base/Graph.hxx>
-#endif // ITK_MANUAL_INSTANTIATION
-
-#endif // __fpa__Base__Graph__h__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Base__Graph__hxx__
-#define __fpa__Base__Graph__hxx__
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _TCost, class _TIndex, class _TIndexCompare >
-void fpa::Base::Graph< _TVertex, _TCost, _TIndex, _TIndexCompare >::
-Clear( )
-{
- this->m_Vertices.clear( );
- this->m_Matrix.clear( );
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _TCost, class _TIndex, class _TIndexCompare >
-bool fpa::Base::Graph< _TVertex, _TCost, _TIndex, _TIndexCompare >::
-RenameVertex( const TIndex& old_index, const TIndex& new_index )
-{
- typename TVertices::iterator old_v = this->m_Vertices.find( old_index );
- typename TVertices::iterator new_v = this->m_Vertices.find( new_index );
- if( old_v != this->m_Vertices.end( ) && new_v == this->m_Vertices.end( ) )
- {
- // Replace vertex
- this->m_Vertices[ new_index ] = old_v->second;
- this->m_Vertices.erase( old_index );
-
- // Duplicate edges
- typename TMatrix::iterator mIt = this->m_Matrix.begin( );
- typename TMatrix::iterator found_row = this->m_Matrix.end( );
- for( ; mIt != this->m_Matrix.end( ); ++mIt )
- {
- if( mIt->first == old_index )
- found_row = mIt;
-
- typename TMatrixRow::iterator rIt = mIt->second.begin( );
- for( ; rIt != mIt->second.end( ); ++rIt )
- {
- if( mIt->first == old_index )
- this->m_Matrix[ new_index ][ rIt->first ] = rIt->second;
- else if( rIt->first == old_index )
- this->m_Matrix[ mIt->first ][ new_index ] = rIt->second;
-
- } // rof
-
- } // rof
-
- // Delete old edges
- if( found_row != this->m_Matrix.end( ) )
- this->m_Matrix.erase( found_row );
-
- mIt = this->m_Matrix.begin( );
- for( ; mIt != this->m_Matrix.end( ); ++mIt )
- {
- typename TMatrixRow::iterator rIt = mIt->second.begin( );
- while( rIt != mIt->second.end( ) )
- {
- if( rIt->first == old_index )
- {
- mIt->second.erase( rIt );
- rIt = mIt->second.begin( );
- }
- else
- ++rIt;
-
- } // elihw
-
- } // rof
- return( true );
- }
- else
- return( false );
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _TCost, class _TIndex, class _TIndexCompare >
-void fpa::Base::Graph< _TVertex, _TCost, _TIndex, _TIndexCompare >::
-RemoveVertex( const TIndex& index )
-{
- typename TVertices::iterator i = this->m_Vertices.find( index );
- if( i != this->m_Vertices.end( ) )
- {
- // Delete vertex
- this->m_Vertices.erase( i );
-
- // Delete edges starting from given vertex
- typename TMatrix::iterator mIt = this->m_Matrix.find( index );
- if( mIt != this->m_Matrix.end( ) )
- this->m_Matrix.erase( mIt );
-
- // Delete edges arriving to given vertex
- mIt = this->m_Matrix.begin( );
- for( ; mIt != this->m_Matrix.end( ); ++mIt )
- {
- typename TMatrixRow::iterator rIt = mIt->second.begin( );
- while( rIt != mIt->second.end( ) )
- {
- if( rIt->first == index )
- {
- mIt->second.erase( rIt );
- rIt = mIt->second.begin( );
- }
- else
- ++rIt;
-
- } // elihw
-
- } // rof
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _TCost, class _TIndex, class _TIndexCompare >
-typename
-fpa::Base::Graph< _TVertex, _TCost, _TIndex, _TIndexCompare >::
-TEdges&
-fpa::Base::Graph< _TVertex, _TCost, _TIndex, _TIndexCompare >::
-GetEdges( const TIndex& orig, const TIndex& dest )
-{
- static TEdges null_edges;
- typename TMatrix::iterator o = this->m_Matrix.find( orig );
- if( o != this->m_Matrix.find( orig ) )
- {
- typename TMatrixRow::iterator d = o->second.find( dest );
- if( d == o->second.end( ) )
- {
- null_edges.clear( );
- return( null_edges );
- }
- else
- return( d->second );
- }
- else
- {
- null_edges.clear( );
- return( null_edges );
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _TCost, class _TIndex, class _TIndexCompare >
-const typename
-fpa::Base::Graph< _TVertex, _TCost, _TIndex, _TIndexCompare >::
-TEdges&
-fpa::Base::Graph< _TVertex, _TCost, _TIndex, _TIndexCompare >::
-GetEdges( const TIndex& orig, const TIndex& dest ) const
-{
- static const TEdges null_edges;
- typename TMatrix::iterator o = this->m_Matrix.find( orig );
- if( o != this->m_Matrix.find( orig ) )
- {
- typename TMatrixRow::iterator d = o->second.find( dest );
- if( d == o->second.end( ) )
- return( null_edges );
- else
- return( d->second );
- }
- else
- return( null_edges );
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _TCost, class _TIndex, class _TIndexCompare >
-bool fpa::Base::Graph< _TVertex, _TCost, _TIndex, _TIndexCompare >::
-HasEdge( const TIndex& orig, const TIndex& dest ) const
-{
- typename TMatrix::const_iterator mIt = this->m_Matrix.find( orig );
- if( mIt != this->m_Matrix.end( ) )
- return( mIt->second.find( dest ) != mIt->second.end( ) );
- else
- return( false );
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _TCost, class _TIndex, class _TIndexCompare >
-void fpa::Base::Graph< _TVertex, _TCost, _TIndex, _TIndexCompare >::
-RemoveEdge( const TIndex& orig, const TIndex& dest, const TCost& cost )
-{
- typename TMatrix::iterator m = this->m_Matrix.find( orig );
- if( m != this->m_Matrix.end( ) )
- {
- typename TMatrixRow::iterator r = m->second.find( dest );
- if( r != m->second.end( ) )
- {
- typename TEdges::iterator e = r->second.end( );
- for(
- typename TEdges::iterator i = r->second.begin( );
- i != r->second.end( ) && e == r->second.end( );
- ++i
- )
- if( *i == cost )
- e = i;
- if( e != r->second.end( ) )
- {
- r->second.erase( e );
- if( r->second.size( ) == 0 )
- {
- m->second.erase( r );
- if( m->second.size( ) == 0 )
- this->m_Matrix.erase( m );
-
- } // fi
-
- } // fi
-
- } // fi
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _TCost, class _TIndex, class _TIndexCompare >
-void fpa::Base::Graph< _TVertex, _TCost, _TIndex, _TIndexCompare >::
-RemoveEdges( const TIndex& orig, const TIndex& dest )
-{
- typename TMatrix::iterator m = this->m_Matrix.find( orig );
- if( m != this->m_Matrix.end( ) )
- {
- typename TMatrixRow::iterator r = m->second.find( dest );
- if( r != m->second.end( ) )
- {
- m->second.erase( r );
- if( m->second.size( ) == 0 )
- this->m_Matrix.erase( m );
-
- } // fi
-
- } // fi
-
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _TCost, class _TIndex, class _TIndexCompare >
-std::set< _TIndex, _TIndexCompare >
-fpa::Base::Graph< _TVertex, _TCost, _TIndex, _TIndexCompare >::
-GetSinks( ) const
-{
- std::set< _TIndex, _TIndexCompare > sinks;
-
- typename TVertices::iterator vIt = this->m_Vertices.begin( );
- for( ; vIt != this->m_Vertices.end( ); ++vIt )
- sinks.insert( vIt->first );
- typename TMatrix::iterator mIt = this->m_Matrix.begin( );
- for( ; mIt != this->m_Matrix.end( ); ++mIt )
- sinks.erase( mIt->first );
-
- return( sinks );
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _TCost, class _TIndex, class _TIndexCompare >
-fpa::Base::Graph< _TVertex, _TCost, _TIndex, _TIndexCompare >::
-Graph( )
- : Superclass( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _TCost, class _TIndex, class _TIndexCompare >
-fpa::Base::Graph< _TVertex, _TCost, _TIndex, _TIndexCompare >::
-~Graph( )
-{
-}
-
-#endif // __fpa__Base__Graph__hxx__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Base__MarksInterface__h__
-#define __fpa__Base__MarksInterface__h__
-
-#include <itkProcessObject.h>
-#include <vector>
-
-namespace fpa
-{
- namespace Base
- {
- /**
- */
- template< class _TVertex >
- class MarksInterface
- {
- public:
- typedef _TVertex TVertex;
- typedef MarksInterface Self;
-
- // Minigraph to represent collisions
- typedef std::pair< _TVertex, bool > TCollision;
- typedef std::vector< TCollision > TCollisionsRow;
- typedef std::vector< TCollisionsRow > TCollisions;
-
- public:
- bool StopAtOneFront( ) const;
- void StopAtOneFrontOn( );
- void StopAtOneFrontOff( );
- void SetStopAtOneFront( bool v );
-
- protected:
- MarksInterface( itk::ProcessObject* filter );
- virtual ~MarksInterface( );
-
- virtual bool _IsMarked( const TVertex& v ) const = 0;
- virtual unsigned long _GetMark( const TVertex& v ) const = 0;
- virtual void _Mark( const TVertex& v, unsigned long frontId ) = 0;
- virtual void _FreeMarks( ) = 0;
-
- virtual void _InitMarks( unsigned long nSeeds );
- unsigned long _Collisions( const TVertex& a, const TVertex& b );
-
- protected:
- bool m_StopAtOneFront;
- TCollisions m_Collisions;
- unsigned int m_NumberOfFronts;
- unsigned int m_NumberOfSeeds;
- itk::ProcessObject* m_Filter;
- };
-
- } // ecapseman
-
-} // ecapseman
-
-#ifndef ITK_MANUAL_INSTANTIATION
-# include <fpa/Base/MarksInterface.hxx>
-#endif // ITK_MANUAL_INSTANTIATION
-
-#endif // __fpa__Base__MarksInterface__h__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Base__MarksInterface__hxx__
-#define __fpa__Base__MarksInterface__hxx__
-
-#include <queue>
-
-// -------------------------------------------------------------------------
-template< class _TVertex >
-bool fpa::Base::MarksInterface< _TVertex >::
-StopAtOneFront( ) const
-{
- return( this->m_StopAtOneFront );
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex >
-void fpa::Base::MarksInterface< _TVertex >::
-StopAtOneFrontOn( )
-{
- this->SetStopAtOneFront( true );
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex >
-void fpa::Base::MarksInterface< _TVertex >::
-StopAtOneFrontOff( )
-{
- this->SetStopAtOneFront( false );
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex >
-void fpa::Base::MarksInterface< _TVertex >::
-SetStopAtOneFront( bool v )
-{
- if( this->m_StopAtOneFront != v )
- {
- this->m_StopAtOneFront = v;
- if( this->m_Filter != NULL )
- this->m_Filter->Modified( );
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex >
-fpa::Base::MarksInterface< _TVertex >::
-MarksInterface( itk::ProcessObject* filter )
- : m_StopAtOneFront( false ),
- m_NumberOfFronts( 0 ),
- m_NumberOfSeeds( 0 ),
- m_Filter( filter )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex >
-fpa::Base::MarksInterface< _TVertex >::
-~MarksInterface( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex >
-void fpa::Base::MarksInterface< _TVertex >::
-_InitMarks( unsigned long nSeeds )
-{
- this->m_NumberOfFronts = this->m_NumberOfSeeds = nSeeds;
- TCollision coll( TVertex( ), false );
- TCollisionsRow row( this->m_NumberOfFronts, coll );
- this->m_Collisions.clear( );
- this->m_Collisions.resize( this->m_NumberOfFronts, row );
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex >
-unsigned long fpa::Base::MarksInterface< _TVertex >::
-_Collisions( const TVertex& a, const TVertex& b )
-{
- unsigned long ma = this->_GetMark( a );
- unsigned long mb = this->_GetMark( b );
- if( ma == mb || ma == 0 || mb == 0 )
- return( this->m_NumberOfFronts );
-
- // 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 count = 0;
- std::vector< bool > m( this->m_NumberOfSeeds, 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 < this->m_NumberOfSeeds; ++n )
- if( this->m_Collisions[ f ][ n ].second && !m[ n ] )
- q.push( n );
-
- } // elihw
- this->m_NumberOfFronts = this->m_NumberOfSeeds - count + 1;
-
- } // fi
- return( this->m_NumberOfFronts );
-}
-
-#endif // __fpa__Base__MarksInterface__hxx__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Base__MinimumSpanningTree__h__
-#define __fpa__Base__MinimumSpanningTree__h__
-
-#include <vector>
-
-namespace fpa
-{
- namespace Base
- {
- /**
- */
- template< class _TVertex, class _Superclass >
- class MinimumSpanningTree
- : public _Superclass
- {
- public:
- typedef MinimumSpanningTree Self;
- typedef _Superclass Superclass;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
-
- typedef _TVertex TVertex;
- typedef std::pair< TVertex, bool > TCollision;
- typedef std::vector< TCollision > TCollisionsRow;
- typedef std::vector< TCollisionsRow > TCollisions;
- typedef std::vector< TVertex > TVertices;
-
- protected:
- typedef std::vector< unsigned long > _TRow;
- typedef std::vector< _TRow > _TMatrix;
-
- public:
- itkTypeMacro( fpa::Base::MinimumSpanningTree, _Superclass );
-
- 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 TVertices GetPath( const TVertex& a ) const;
- virtual TVertices GetPath( const TVertex& a, const TVertex& b ) const;
-
- protected:
- MinimumSpanningTree( );
- virtual ~MinimumSpanningTree( );
-
- private:
- 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
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Base__MinimumSpanningTree__hxx__
-#define __fpa__Base__MinimumSpanningTree__hxx__
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _Superclass >
-const typename fpa::Base::MinimumSpanningTree< _TVertex, _Superclass >::
-TCollisions& fpa::Base::MinimumSpanningTree< _TVertex, _Superclass >::
-GetCollisions( ) const
-{
- return( this->m_Collisions );
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _Superclass >
-void fpa::Base::MinimumSpanningTree< _TVertex, _Superclass >::
-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 _Superclass >
-void fpa::Base::MinimumSpanningTree< _TVertex, _Superclass >::
-ClearSeeds( )
-{
- this->m_Seeds.clear( );
- this->Modified( );
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _Superclass >
-void fpa::Base::MinimumSpanningTree< _TVertex, _Superclass >::
-AddSeed( const _TVertex& seed )
-{
- this->m_Seeds.push_back( seed );
- this->Modified( );
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _Superclass >
-typename fpa::Base::MinimumSpanningTree< _TVertex, _Superclass >::
-TVertices fpa::Base::MinimumSpanningTree< _TVertex, _Superclass >::
-GetPath( const _TVertex& a ) const
-{
- TVertices 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 );
- return( vertices );
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _Superclass >
-typename fpa::Base::MinimumSpanningTree< _TVertex, _Superclass >::
-TVertices fpa::Base::MinimumSpanningTree< _TVertex, _Superclass >::
-GetPath( const _TVertex& a, const _TVertex& b ) const
-{
- static const unsigned long _inf =
- std::numeric_limits< unsigned long >::max( );
-
- TVertices vertices;
- TVertices pa = this->GetPath( a );
- TVertices pb = this->GetPath( b );
- if( pa.size( ) > 0 && pb.size( ) > 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[ pa.size( ) - 1 ] )
- ia = i;
- if( this->m_Seeds[ i ] == pb[ pb.size( ) - 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
- vertices = this->GetPath(
- a, this->m_Collisions[ fpath[ 0 ] ][ fpath[ 1 ] ].first
- );
-
- // Intermediary paths
- for( unsigned int i = 1; i < N - 1; ++i )
- {
- TVertices ipath =
- this->GetPath(
- this->m_Collisions[ fpath[ i ] ][ fpath[ i - 1 ] ].first,
- this->m_Collisions[ fpath[ i ] ][ fpath[ i + 1 ] ].first
- );
- for( long id = 0; id < ipath.size( ); ++id )
- vertices.push_back( ipath[ id ] );
-
- } // rof
-
- // Final path: from last collision to end point
- TVertices lpath =
- this->GetPath(
- this->m_Collisions[ fpath[ N - 1 ] ][ fpath[ N - 2 ] ].first, b
- );
- for( long id = 0; id < lpath.size( ); ++id )
- vertices.push_back( lpath[ id ] );
-
- } // fi
- }
- else
- {
- // Ignore common part: find common ancestor
- long aIt = pa.size( ) - 1;
- long bIt = pb.size( ) - 1;
- bool cont = true;
- while( aIt >= 0 && bIt >= 0 && cont )
- {
- cont = ( pa[ aIt ] == pb[ bIt ] );
- aIt--;
- bIt--;
-
- } // elihw
- aIt++;
- bIt++;
-
- // Glue both parts
- for( long cIt = 0; cIt <= aIt; ++cIt )
- vertices.push_back( pa[ cIt ] );
- for( ; bIt >= 0; --bIt )
- vertices.push_back( pb[ bIt ] );
-
- } // fi
-
- } // fi
- return( vertices );
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _Superclass >
-fpa::Base::MinimumSpanningTree< _TVertex, _Superclass >::
-MinimumSpanningTree( )
- : Superclass( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _Superclass >
-fpa::Base::MinimumSpanningTree< _TVertex, _Superclass >::
-~MinimumSpanningTree( )
-{
-}
-
-#endif // __fpa__Base__MinimumSpanningTree__hxx__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Base__MoriRegionGrow__h__
-#define __fpa__Base__MoriRegionGrow__h__
-
-namespace fpa
-{
- namespace Base
- {
- /**
- */
- template< class _TFilter, class _TMarksInterface, class _TSeedsInterface >
- class MoriRegionGrow
- : public _TFilter,
- public _TMarksInterface,
- public _TSeedsInterface
- {
- public:
- typedef MoriRegionGrow Self;
- typedef _TFilter Superclass;
- typedef _TMarksInterface TMarksInterface;
- typedef _TSeedsInterface TSeedsInterface;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
-
- typedef typename Superclass::TInputValue TInputValue;
- typedef typename Superclass::TOutputValue TOutputValue;
- typedef typename Superclass::TVertex TVertex;
- typedef typename Superclass::TVertices TVertices;
-
- struct TCurveData
- {
- TInputValue XValue;
- unsigned long YValue;
- double Diff1;
- TCurveData( TInputValue v, unsigned long c )
- {
- this->XValue = v;
- this->YValue = c;
- this->Diff1 = double( 0 );
- }
- };
- typedef std::vector< TCurveData > TCurve;
-
- public:
- itkTypeMacro( MoriRegionGrow, TFilter );
-
- itkGetConstMacro( LowerThreshold, TInputValue );
- itkGetConstMacro( UpperThreshold, TInputValue );
- itkGetConstMacro( DeltaThreshold, TInputValue );
- itkGetConstMacro( Curve, TCurve );
- itkGetConstMacro( OptimumThreshold, TInputValue );
-
- itkSetMacro( LowerThreshold, TInputValue );
- itkSetMacro( UpperThreshold, TInputValue );
- itkSetMacro( DeltaThreshold, TInputValue );
-
- public:
- void SetThresholdRange(
- const TInputValue& lower, const TInputValue& upper,
- const TInputValue& delta = TInputValue( 1 )
- );
-
- protected:
- MoriRegionGrow( );
- virtual ~MoriRegionGrow( );
-
- virtual void GenerateData( ) override;
-
- private:
- MoriRegionGrow( const Self& other );
- Self& operator=( const Self& other );
-
- protected:
- TInputValue m_LowerThreshold;
- TInputValue m_UpperThreshold;
- TInputValue m_DeltaThreshold;
-
- TCurve m_Curve;
- TInputValue m_OptimumThreshold;
- };
-
- } // ecapseman
-
-} // ecapseman
-
-#ifndef ITK_MANUAL_INSTANTIATION
-# include <fpa/Base/MoriRegionGrow.hxx>
-#endif // ITK_MANUAL_INSTANTIATION
-
-#endif // __fpa__Base__MoriRegionGrow__h__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Base__MoriRegionGrow__hxx__
-#define __fpa__Base__MoriRegionGrow__hxx__
-
-#include <queue>
-#include <itkProgressReporter.h>
-
-// -------------------------------------------------------------------------
-template< class _TFilter, class _TMarksInterface, class _TSeedsInterface >
-void
-fpa::Base::MoriRegionGrow< _TFilter, _TMarksInterface, _TSeedsInterface >::
-SetThresholdRange(
- const TInputValue& lower, const TInputValue& upper,
- const TInputValue& delta
- )
-{
- this->SetLowerThreshold( lower );
- this->SetUpperThreshold( upper );
- this->SetDeltaThreshold( delta );
-}
-
-// -------------------------------------------------------------------------
-template< class _TFilter, class _TMarksInterface, class _TSeedsInterface >
-fpa::Base::MoriRegionGrow< _TFilter, _TMarksInterface, _TSeedsInterface >::
-MoriRegionGrow( )
- : Superclass( ),
- _TMarksInterface( this ),
- _TSeedsInterface( this )
-{
- this->m_UpperThreshold = std::numeric_limits< TInputValue >::max( );
- if( std::numeric_limits< TInputValue >::is_integer )
- this->m_LowerThreshold = std::numeric_limits< TInputValue >::min( );
- else
- this->m_LowerThreshold = -this->m_UpperThreshold;
- this->m_DeltaThreshold = TInputValue( 1 );
-}
-
-// -------------------------------------------------------------------------
-template< class _TFilter, class _TMarksInterface, class _TSeedsInterface >
-fpa::Base::MoriRegionGrow< _TFilter, _TMarksInterface, _TSeedsInterface >::
-~MoriRegionGrow( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TFilter, class _TMarksInterface, class _TSeedsInterface >
-void
-fpa::Base::MoriRegionGrow< _TFilter, _TMarksInterface, _TSeedsInterface >::
-GenerateData( )
-{
- // Prepare progress counter
- double prog_size = double( this->m_UpperThreshold - this->m_LowerThreshold );
- prog_size /= double( this->m_DeltaThreshold );
- itk::ProgressReporter progress( this, 0, prog_size, 100, 0, 1 );
-
- // Init objects
- this->_ConfigureOutputs( std::numeric_limits< TOutputValue >::max( ) );
- this->_InitMarks( this->GetNumberOfSeeds( ) );
-
- // Init queues
- typedef std::pair< TVertex, unsigned long > _TNode;
- std::queue< _TNode > queues[ 2 ];
- unsigned long frontId = 1;
- typename TSeedsInterface::TSeeds::const_iterator sIt = this->BeginSeeds( );
- for( ; sIt != this->EndSeeds( ); ++sIt )
- queues[ 0 ].push( _TNode( *sIt, frontId++ ) );
- unsigned int cur_queue = 0;
- unsigned int aux_queue = 1;
-
- // Incremental strategy
- TInputValue upper = this->m_LowerThreshold + this->m_DeltaThreshold;
- this->m_Curve.clear( );
- unsigned long count = 0;
- while( upper <= this->m_UpperThreshold )
- {
- // Main growing strategy
- while( queues[ cur_queue ].size( ) > 0 )
- {
- // Get next candidate
- _TNode node = queues[ cur_queue ].front( );
- queues[ cur_queue ].pop( );
- if( this->_IsMarked( node.first ) )
- continue;
- this->_Mark( node.first, node.second );
-
- // Apply inclusion predicate
- TInputValue value = this->_GetInputValue( node.first );
- bool in = ( ( this->m_LowerThreshold < value ) && ( value < upper ) );
- if( !in )
- {
- if( value < this->m_UpperThreshold )
- queues[ aux_queue ].push( node );
- this->_Mark( node.first, 0 );
- continue;
-
- } // fi
-
- // Ok, value lays inside region
- this->_SetOutputValue( node.first, this->m_Curve.size( ) + 1 );
- count++;
-
- // Add neighborhood
- TVertices neighbors = this->_GetNeighbors( node.first );
- typename TVertices::const_iterator neighIt = neighbors.begin( );
- for( ; neighIt != neighbors.end( ); ++neighIt )
- {
- TVertex neigh = *neighIt;
- if( this->_IsMarked( neigh ) )
- {
- // Invoke stop at collisions
- unsigned long nColl = this->_Collisions( node.first, neigh );
- if(
- this->StopAtOneFront( ) &&
- this->GetNumberOfSeeds( ) > 1 &&
- nColl == 1
- )
- {
- while( queues[ 0 ].size( ) > 0 )
- queues[ 0 ].pop( );
- while( queues[ 1 ].size( ) > 0 )
- queues[ 1 ].pop( );
-
- } // fi
- }
- else
- queues[ cur_queue ].push( _TNode( neigh, node.second ) );
-
- } // rof
-
- } // elihw
-
- // Update curve
- if( this->m_Curve.size( ) > 0 )
- {
- if( this->m_Curve.back( ).YValue < count )
- this->m_Curve.push_back( TCurveData( upper, count ) );
- if( this->m_Curve.size( ) > 2 )
- {
- long j = this->m_Curve.size( ) - 2;
- double yp = double( this->m_Curve[ j + 1 ].YValue );
- double yn = double( this->m_Curve[ j - 1 ].YValue );
- double xp = double( this->m_Curve[ j + 1 ].XValue );
- double xn = double( this->m_Curve[ j - 1 ].XValue );
- this->m_Curve[ j ].Diff1 = ( yp - yn ) / ( xp - xn );
-
- } // fi
- }
- else
- this->m_Curve.push_back( TCurveData( upper, count ) );
-
- // Update queue
- cur_queue = aux_queue;
- aux_queue = ( cur_queue + 1 ) % 2;
-
- // Update threshold
- upper += this->m_DeltaThreshold;
- progress.CompletedPixel( );
-
- } // elihw
-
- // Compute optimum threshold
- double dmax = -std::numeric_limits< double >::max( );
- long jmax = 0;
- for( long j = 1; j < this->m_Curve.size( ) - 1; ++j )
- {
- double dp = this->m_Curve[ j + 1 ].Diff1;
- double dn = this->m_Curve[ j - 1 ].Diff1;
- double xp = double( this->m_Curve[ j + 1 ].XValue );
- double xn = double( this->m_Curve[ j - 1 ].XValue );
- double d2 = ( dp - dn ) / ( xp - xn );
- if( d2 > dmax )
- {
- dmax = d2;
- jmax = j;
-
- } // fi
-
- } // rof
- this->m_OptimumThreshold = TOutputValue( jmax );
- this->_FreeMarks( );
-}
-
-#endif // __fpa__Base__MoriRegionGrow__hxx__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Base__PolyLineParametricPath__h__
-#define __fpa__Base__PolyLineParametricPath__h__
-
-#include <itkPolyLineParametricPath.h>
-#include <itkImageBase.h>
-
-namespace fpa
-{
- namespace Base
- {
- /**
- */
- template< unsigned int _VDim >
- class PolyLineParametricPath
- : public itk::PolyLineParametricPath< _VDim >
- {
- public:
- typedef PolyLineParametricPath Self;
- typedef itk::PolyLineParametricPath< _VDim > Superclass;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
-
- typedef itk::ImageBase< _VDim > TImageBase;
- typedef typename TImageBase::SpacingType TSpacing;
- typedef typename TImageBase::PointType TPoint;
- typedef typename TImageBase::DirectionType TDirection;
- typedef typename Superclass::ContinuousIndexType TContinuousIndex;
- typedef typename TContinuousIndex::IndexType TIndex;
-
- public:
- itkNewMacro( Self );
- itkTypeMacro( PolyLineParametricPath, itk::PolyLineParametricPath );
-
- itkGetConstReferenceMacro( Spacing, TSpacing );
- itkGetConstReferenceMacro( Origin, TPoint );
- itkGetConstReferenceMacro( Direction, TDirection );
- itkGetConstReferenceMacro( InverseDirection, TDirection );
-
- itkSetMacro( Origin, TPoint );
-
- public:
- unsigned long GetSize( ) const;
- TContinuousIndex GetContinuousVertex( unsigned long i ) const;
- TIndex GetVertex( unsigned long i ) const;
- TPoint GetPoint( unsigned long i ) const;
-
- virtual void SetSpacing( const TSpacing& spac );
- virtual void SetSpacing( const double spac[ _VDim ] );
- virtual void SetSpacing( const float spac[ _VDim ] );
- virtual void SetOrigin( const double ori[ _VDim ] );
- virtual void SetOrigin( const float ori[ _VDim ] );
- virtual void SetDirection( const TDirection& dir );
-
- template< class _TRefImage >
- inline void SetReferenceImage( const _TRefImage* image )
- {
- this->SetSpacing( image->GetSpacing( ) );
- this->SetOrigin( image->GetOrigin( ) );
- this->SetDirection( image->GetDirection( ) );
- }
-
- protected:
- PolyLineParametricPath( );
- virtual ~PolyLineParametricPath( );
-
- virtual void _ComputeIndexToPhysicalPointMatrices( );
-
- private:
- // Purposely not implemented
- PolyLineParametricPath( const Self& other );
- Self& operator=( const Self& other );
-
- protected:
- TSpacing m_Spacing;
- TPoint m_Origin;
- TDirection m_Direction;
- TDirection m_InverseDirection;
- TDirection m_IndexToPhysicalPoint;
- TDirection m_PhysicalPointToIndex;
- };
-
- } // ecapseman
-
-} // ecapseman
-
-#ifndef ITK_MANUAL_INSTANTIATION
-# include <fpa/Base/PolyLineParametricPath.hxx>
-#endif // ITK_MANUAL_INSTANTIATION
-
-#endif // __fpa__Base__PolyLineParametricPath__h__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Base__PolyLineParametricPath__hxx__
-#define __fpa__Base__PolyLineParametricPath__hxx__
-
-#include <itkMath.h>
-#include <itkNumericTraits.h>
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-unsigned long fpa::Base::PolyLineParametricPath< _VDim >::
-GetSize( ) const
-{
- return( this->GetVertexList( )->Size( ) );
-}
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-typename fpa::Base::PolyLineParametricPath< _VDim >::
-TContinuousIndex
-fpa::Base::PolyLineParametricPath< _VDim >::
-GetContinuousVertex( unsigned long i ) const
-{
- return( this->GetVertexList( )->GetElement( i ) );
-}
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-typename fpa::Base::PolyLineParametricPath< _VDim >::
-TIndex fpa::Base::PolyLineParametricPath< _VDim >::
-GetVertex( unsigned long i ) const
-{
- TContinuousIndex cidx = this->GetContinuousVertex( i );
- TIndex idx;
- for( unsigned int d = 0; d < _VDim; ++d )
- idx[ d ] = cidx[ d ];
- return( idx );
-}
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-typename fpa::Base::PolyLineParametricPath< _VDim >::
-TPoint fpa::Base::PolyLineParametricPath< _VDim >::
-GetPoint( unsigned long i ) const
-{
- typedef typename TPoint::CoordRepType _TCoordRep;
- TPoint pnt;
- TContinuousIndex idx = this->GetVertex( i );
- for( unsigned int r = 0; r < _VDim; ++r )
- {
- _TCoordRep sum = itk::NumericTraits< _TCoordRep >::ZeroValue( );
- for( unsigned int c = 0; c < _VDim; ++c )
- sum += this->m_IndexToPhysicalPoint( r, c ) * idx[ c ];
- pnt[ r ] = sum + this->m_Origin[ r ];
-
- } // rof
- return( pnt );
-}
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-void fpa::Base::PolyLineParametricPath< _VDim >::
-SetSpacing( const TSpacing& spac )
-{
- if( this->m_Spacing != spac )
- {
- this->m_Spacing = spac;
- this->_ComputeIndexToPhysicalPointMatrices( );
- this->Modified( );
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-void fpa::Base::PolyLineParametricPath< _VDim >::
-SetSpacing( const double spac[ _VDim ] )
-{
- this->SetSpacing( TSpacing( spac ) );
-}
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-void fpa::Base::PolyLineParametricPath< _VDim >::
-SetSpacing( const float spac[ _VDim ] )
-{
- TSpacing s;
- for( unsigned int d = 0; d < _VDim; ++d )
- s[ d ] = spac[ d ];
- this->SetSpacing( s );
-}
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-void fpa::Base::PolyLineParametricPath< _VDim >::
-SetOrigin( const double ori[ _VDim ] )
-{
- this->SetOrigin( TPoint( ori ) );
-}
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-void fpa::Base::PolyLineParametricPath< _VDim >::
-SetOrigin( const float ori[ _VDim ] )
-{
- this->SetOrigin( TPoint( ori ) );
-}
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-void fpa::Base::PolyLineParametricPath< _VDim >::
-SetDirection( const TDirection& dir )
-{
- bool modified = false;
- for( unsigned int r = 0; r < _VDim; r++ )
- {
- for( unsigned int c = 0; c < _VDim; c++ )
- {
- if(
- itk::Math::NotExactlyEquals(
- this->m_Direction[ r ][ c ], dir[ r ][ c ]
- )
- )
- {
- this->m_Direction[ r ][ c ] = dir[ r ][ c ];
- modified = true;
- } // fi
-
- } // rof
-
- } // rof
- if( modified )
- {
- this->_ComputeIndexToPhysicalPointMatrices( );
- this->m_InverseDirection = this->m_Direction.GetInverse( );
- this->Modified( );
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-fpa::Base::PolyLineParametricPath< _VDim >::
-PolyLineParametricPath( )
- : Superclass( )
-{
- this->m_Spacing.Fill( 1.0 );
- this->m_Origin.Fill( 0.0 );
- this->m_Direction.SetIdentity( );
- this->m_InverseDirection.SetIdentity( );
- this->m_IndexToPhysicalPoint.SetIdentity( );
- this->m_PhysicalPointToIndex.SetIdentity( );
-}
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-fpa::Base::PolyLineParametricPath< _VDim >::
-~PolyLineParametricPath( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-void fpa::Base::PolyLineParametricPath< _VDim >::
-_ComputeIndexToPhysicalPointMatrices( )
-{
- TDirection scale;
- scale.Fill( 0.0 );
- for( unsigned int i = 0; i < _VDim; i++ )
- {
- if( this->m_Spacing[ i ] == 0.0 )
- itkExceptionMacro(
- "A spacing of 0 is not allowed: Spacing is " << this->m_Spacing
- );
- scale[ i ][ i ] = this->m_Spacing[ i ];
-
- } // rof
-
- if( vnl_determinant( this->m_Direction.GetVnlMatrix( ) ) == 0.0 )
- itkExceptionMacro(
- << "Bad direction, determinant is 0. Direction is "
- << this->m_Direction
- );
- this->m_IndexToPhysicalPoint = this->m_Direction * scale;
- this->m_PhysicalPointToIndex = this->m_IndexToPhysicalPoint.GetInverse( );
- this->Modified( );
-}
-
-#endif // __fpa__Base__PolyLineParametricPath__hxx__
-
-// eof - $RCSfile$
+++ /dev/null
-#ifndef __fpa__Base__PriorityQueueAlgorithm__h__
-#define __fpa__Base__PriorityQueueAlgorithm__h__
-
-#include <queue>
-#include <itkObject.h>
-
-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
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Base__RegionGrow__h__
-#define __fpa__Base__RegionGrow__h__
-
-#include <itkFunctionBase.h>
-
-namespace fpa
-{
- namespace Base
- {
- /**
- */
- template< class _TFilter, class _TMarksInterface, class _TSeedsInterface >
- class RegionGrow
- : public _TFilter,
- public _TMarksInterface,
- public _TSeedsInterface
- {
- public:
- typedef RegionGrow Self;
- typedef _TFilter Superclass;
- typedef _TMarksInterface TMarksInterface;
- typedef _TSeedsInterface TSeedsInterface;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
-
- typedef typename Superclass::TInputValue TInputValue;
- typedef typename Superclass::TOutputValue TOutputValue;
- typedef typename Superclass::TVertex TVertex;
- typedef typename Superclass::TVertices TVertices;
-
- typedef itk::FunctionBase< TInputValue, bool > TIntensityFunctor;
- typedef itk::FunctionBase< TVertex, bool > TVertexFunctor;
-
- public:
- itkTypeMacro( RegionGrow, TFilter );
-
- itkGetConstMacro( InsideValue, TOutputValue );
- itkGetConstMacro( OutsideValue, TOutputValue );
-
- itkSetMacro( InsideValue, TOutputValue );
- itkSetMacro( OutsideValue, TOutputValue );
-
- public:
- const TIntensityFunctor* GetIntensityPredicate( ) const;
- const TVertexFunctor* GetVertexPredicate( ) const;
-
- void SetPredicate( TIntensityFunctor* functor );
- void SetPredicate( TVertexFunctor* functor );
-
- protected:
- RegionGrow( );
- virtual ~RegionGrow( );
-
- virtual void GenerateData( ) override;
-
- private:
- RegionGrow( const Self& other );
- Self& operator=( const Self& other );
-
- protected:
- typename TIntensityFunctor::Pointer m_IntensityFunctor;
- typename TVertexFunctor::Pointer m_VertexFunctor;
- TOutputValue m_InsideValue;
- TOutputValue m_OutsideValue;
- };
-
- } // ecapseman
-
-} // ecapseman
-
-#ifndef ITK_MANUAL_INSTANTIATION
-# include <fpa/Base/RegionGrow.hxx>
-#endif // ITK_MANUAL_INSTANTIATION
-
-#endif // __fpa__Base__RegionGrow__h__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Base__RegionGrow__hxx__
-#define __fpa__Base__RegionGrow__hxx__
-
-#include <queue>
-
-// -------------------------------------------------------------------------
-template< class _TFilter, class _TMarksInterface, class _TSeedsInterface >
-const typename
-fpa::Base::RegionGrow< _TFilter, _TMarksInterface, _TSeedsInterface >::
-TIntensityFunctor*
-fpa::Base::RegionGrow< _TFilter, _TMarksInterface, _TSeedsInterface >::
-GetIntensityPredicate( ) const
-{
- return( this->m_IntensityFunctor );
-}
-
-// -------------------------------------------------------------------------
-template< class _TFilter, class _TMarksInterface, class _TSeedsInterface >
-const typename
-fpa::Base::RegionGrow< _TFilter, _TMarksInterface, _TSeedsInterface >::
-TVertexFunctor*
-fpa::Base::RegionGrow< _TFilter, _TMarksInterface, _TSeedsInterface >::
-GetVertexPredicate( ) const
-{
- return( this->m_VertexFunctor );
-}
-
-// -------------------------------------------------------------------------
-template< class _TFilter, class _TMarksInterface, class _TSeedsInterface >
-void
-fpa::Base::RegionGrow< _TFilter, _TMarksInterface, _TSeedsInterface >::
-SetPredicate( TIntensityFunctor* functor )
-{
- if( this->m_IntensityFunctor.GetPointer( ) != functor )
- {
- this->m_IntensityFunctor = functor;
- this->Modified( );
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-template< class _TFilter, class _TMarksInterface, class _TSeedsInterface >
-void
-fpa::Base::RegionGrow< _TFilter, _TMarksInterface, _TSeedsInterface >::
-SetPredicate( TVertexFunctor* functor )
-{
- if( this->m_VertexFunctor.GetPointer( ) != functor )
- {
- this->m_VertexFunctor = functor;
- this->Modified( );
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-template< class _TFilter, class _TMarksInterface, class _TSeedsInterface >
-fpa::Base::RegionGrow< _TFilter, _TMarksInterface, _TSeedsInterface >::
-RegionGrow( )
- : Superclass( ),
- _TMarksInterface( this ),
- _TSeedsInterface( this ),
- m_InsideValue( TOutputValue( 1 ) ),
- m_OutsideValue( TOutputValue( 0 ) )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TFilter, class _TMarksInterface, class _TSeedsInterface >
-fpa::Base::RegionGrow< _TFilter, _TMarksInterface, _TSeedsInterface >::
-~RegionGrow( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TFilter, class _TMarksInterface, class _TSeedsInterface >
-void
-fpa::Base::RegionGrow< _TFilter, _TMarksInterface, _TSeedsInterface >::
-GenerateData( )
-{
- // Init objects
- this->_ConfigureOutputs( this->m_OutsideValue );
- this->_InitMarks( this->GetNumberOfSeeds( ) );
-
- // Init queue
- typedef std::pair< TVertex, unsigned long > _TNode;
- std::queue< _TNode > q;
- unsigned long frontId = 1;
- typename TSeedsInterface::TSeeds::const_iterator sIt = this->BeginSeeds( );
- for( ; sIt != this->EndSeeds( ); ++sIt )
- q.push( _TNode( *sIt, frontId++ ) );
-
- // Main loop
- while( q.size( ) > 0 )
- {
- // Get next candidate
- _TNode node = q.front( );
- q.pop( );
- if( this->_IsMarked( node.first ) )
- continue;
- this->_Mark( node.first, node.second );
-
- // Apply inclusion predicate
- TInputValue value = this->_GetInputValue( node.first );
- bool inside = false;
- if( this->m_IntensityFunctor.IsNotNull( ) )
- inside = this->m_IntensityFunctor->Evaluate( value );
- if( this->m_VertexFunctor.IsNotNull( ) )
- inside &= this->m_VertexFunctor->Evaluate( node.first );
- if( !inside )
- continue;
-
- // Ok, pixel lays inside region
- this->_SetOutputValue( node.first, this->m_InsideValue );
-
- // Add neighborhood
- TVertices neighbors = this->_GetNeighbors( node.first );
- typename TVertices::const_iterator neighIt = neighbors.begin( );
- bool coll = false;
- while( neighIt != neighbors.end( ) && !coll )
- {
- TVertex neigh = *neighIt;
- if( this->_IsMarked( neigh ) )
- {
- // Invoke stop at collisions
- unsigned long nColl = this->_Collisions( node.first, neigh );
- if(
- this->StopAtOneFront( ) &&
- this->GetNumberOfSeeds( ) > 1 &&
- nColl == 1
- )
- {
- while( q.size( ) > 0 )
- q.pop( );
- coll = true;
-
- } // fi
- }
- else
- q.push( _TNode( neigh, node.second ) );
- ++neighIt;
-
- } // elihw
-
- } // elihw
- this->_FreeMarks( );
-}
-
-#endif // __fpa__Base__RegionGrow__hxx__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Base__SeedsInterface__h__
-#define __fpa__Base__SeedsInterface__h__
-
-#include <itkProcessObject.h>
-#include <set>
-
-namespace fpa
-{
- namespace Base
- {
- /**
- */
- template< class _TVertex, class _TCompare >
- class SeedsInterface
- {
- public:
- typedef _TVertex TVertex;
- typedef _TCompare TCompare;
- typedef SeedsInterface Self;
- typedef std::set< TVertex, TCompare > TSeeds;
-
- public:
- unsigned int GetNumberOfSeeds( ) const;
- const TSeeds& GetSeeds( ) const;
- typename TSeeds::const_iterator BeginSeeds( ) const;
- typename TSeeds::const_iterator EndSeeds( ) const;
-
- void AddSeed( const TVertex& seed );
- void RemoveSeed( const TVertex& seed );
- void ClearSeeds( );
-
- protected:
- SeedsInterface( itk::ProcessObject* filter );
- virtual ~SeedsInterface( );
-
- protected:
- TSeeds m_Seeds;
- itk::ProcessObject* m_Filter;
- };
-
- } // ecapseman
-
-} // ecapseman
-
-#ifndef ITK_MANUAL_INSTANTIATION
-# include <fpa/Base/SeedsInterface.hxx>
-#endif // ITK_MANUAL_INSTANTIATION
-
-#endif // __fpa__Base__SeedsInterface__h__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Base__SeedsInterface__hxx__
-#define __fpa__Base__SeedsInterface__hxx__
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _TCompare >
-unsigned int fpa::Base::SeedsInterface< _TVertex, _TCompare >::
-GetNumberOfSeeds( ) const
-{
- return( this->m_Seeds.size( ) );
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _TCompare >
-const typename fpa::Base::SeedsInterface< _TVertex, _TCompare >::
-TSeeds& fpa::Base::SeedsInterface< _TVertex, _TCompare >::
-GetSeeds( ) const
-{
- return( this->m_Seeds );
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _TCompare >
-typename fpa::Base::SeedsInterface< _TVertex, _TCompare >::
-TSeeds::const_iterator fpa::Base::SeedsInterface< _TVertex, _TCompare >::
-BeginSeeds( ) const
-{
- return( this->m_Seeds.begin( ) );
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _TCompare >
-typename fpa::Base::SeedsInterface< _TVertex, _TCompare >::
-TSeeds::const_iterator fpa::Base::SeedsInterface< _TVertex, _TCompare >::
-EndSeeds( ) const
-{
- return( this->m_Seeds.end( ) );
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _TCompare >
-void fpa::Base::SeedsInterface< _TVertex, _TCompare >::
-AddSeed( const TVertex& seed )
-{
- if( this->m_Seeds.insert( seed ).second && this->m_Filter != NULL )
- this->m_Filter->Modified( );
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _TCompare >
-void fpa::Base::SeedsInterface< _TVertex, _TCompare >::
-RemoveSeed( const TVertex& seed )
-{
- typename TSeeds::const_iterator i = this->m_Seeds.find( seed );
- if( i != this->m_Seeds.end( ) )
- {
- this->m_Seeds.erase( i );
- if( this->m_Filter != NULL )
- this->m_Filter->Modified( );
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _TCompare >
-void fpa::Base::SeedsInterface< _TVertex, _TCompare >::
-ClearSeeds( )
-{
- if( this->m_Seeds.size( ) > 0 )
- {
- this->m_Seeds.clear( );
- if( this->m_Filter != NULL )
- this->m_Filter->Modified( );
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _TCompare >
-fpa::Base::SeedsInterface< _TVertex, _TCompare >::
-SeedsInterface( itk::ProcessObject* filter )
- : m_Filter( filter )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _TCompare >
-fpa::Base::SeedsInterface< _TVertex, _TCompare >::
-~SeedsInterface( )
-{
- this->m_Seeds.clear( );
-}
-
-#endif // __fpa__Base__SeedsInterface__hxx__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Base__Skeleton__h__
-#define __fpa__Base__Skeleton__h__
-
-#include <vector>
-#include <fpa/Base/Graph.h>
-#include <fpa/Base/PolyLineParametricPath.h>
-
-namespace fpa
-{
- namespace Base
- {
- /**
- */
- template< unsigned int _VDim >
- class Skeleton
- : public fpa::Base::Graph< typename fpa::Base::PolyLineParametricPath< _VDim >::TIndex, typename fpa::Base::PolyLineParametricPath< _VDim >::Pointer, typename fpa::Base::PolyLineParametricPath< _VDim >::TIndex, typename fpa::Base::PolyLineParametricPath< _VDim >::TIndex::LexicographicCompare >
- {
- public:
- typedef fpa::Base::PolyLineParametricPath< _VDim > TPath;
- typedef typename TPath::TIndex TIndex;
- typedef typename TIndex::LexicographicCompare TIndexCompare;
- typedef typename TPath::Pointer TPathPointer;
-
- itkStaticConstMacro( Dimension, unsigned int, _VDim );
-
- typedef fpa::Base::Graph< TIndex, TPathPointer, TIndex, TIndexCompare > Superclass;
- typedef Skeleton Self;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
-
- public:
- itkNewMacro( Self );
- itkTypeMacro( Skeleton, fpa::Base::Graph );
-
- public:
- void AddBranch( TPath* path );
- const TPath* GetBranch( const TIndex& a, const TIndex& b ) const;
-
- std::vector< TIndex > GetEndPoints( ) const;
- std::vector< TIndex > GetBifurcations( ) const;
-
- protected:
- Skeleton( );
- virtual ~Skeleton( );
-
- private:
- // Purposely not implemented
- Skeleton( const Self& other );
- Self& operator=( const Self& other );
- };
-
- } // ecapseman
-
-} // ecapseman
-
-#ifndef ITK_MANUAL_INSTANTIATION
-# include <fpa/Base/Skeleton.hxx>
-#endif // ITK_MANUAL_INSTANTIATION
-
-#endif // __fpa__Base__Skeleton__h__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Base__Skeleton__hxx__
-#define __fpa__Base__Skeleton__hxx__
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-void fpa::Base::Skeleton< _VDim >::
-AddBranch( TPath* path )
-{
- // Check inputs
- if( path == NULL )
- return;
- unsigned long size = path->GetSize( );
- if( size == 0 )
- return;
- TIndex a = path->GetVertex( 0 );
- TIndex b = path->GetVertex( size - 1 );
- if( this->HasEdge( a, b ) )
- return;
-
- // Add path
- this->SetVertex( a, a );
- this->SetVertex( b, b );
- this->AddEdge( a, b, path );
- this->AddEdge( b, a, path );
- // TODO: this->Modified( );
-}
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-const typename fpa::Base::Skeleton< _VDim >::
-TPath* fpa::Base::Skeleton< _VDim >::
-GetBranch( const TIndex& a, const TIndex& b ) const
-{
- static const TPath* null_path = NULL;
- if( this->HasEdge( a, b ) )
- return( this->GetEdges( a, b ).front( ) );
- else
- return( null_path );
-}
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-std::vector< typename fpa::Base::Skeleton< _VDim >::TIndex >
-fpa::Base::Skeleton< _VDim >::
-GetEndPoints( ) const
-{
- std::vector< TIndex > res;
- typename Superclass::TMatrix::const_iterator mIt = this->BeginEdgesRows( );
- for( ; mIt != this->EndEdgesRows( ); ++mIt )
- {
- unsigned long count = mIt->second.size( );
- if( count == 1 )
- res.push_back( mIt->first );
-
- } // rof
- return( res );
-}
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-std::vector< typename fpa::Base::Skeleton< _VDim >::TIndex >
-fpa::Base::Skeleton< _VDim >::
-GetBifurcations( ) const
-{
- std::vector< TIndex > res;
- typename Superclass::TMatrix::const_iterator mIt = this->BeginEdgesRows( );
- for( ; mIt != this->EndEdgesRows( ); ++mIt )
- {
- unsigned long count = mIt->second.size( );
- if( count > 1 )
- res.push_back( mIt->first );
-
- } // rof
- return( res );
-}
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-fpa::Base::Skeleton< _VDim >::
-Skeleton( )
- : Superclass( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-fpa::Base::Skeleton< _VDim >::
-~Skeleton( )
-{
-}
-
-#endif // __fpa__Base__Skeleton__hxx__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Base__SkeletonReader__h__
-#define __fpa__Base__SkeletonReader__h__
-
-#include <itkProcessObject.h>
-
-namespace fpa
-{
- namespace Base
- {
- /**
- */
- template< class _TSkeleton >
- class SkeletonReader
- : public itk::ProcessObject
- {
- public:
- // Basic types
- typedef SkeletonReader Self;
- typedef itk::ProcessObject Superclass;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
-
- typedef _TSkeleton TSkeleton;
-
- public:
- itkNewMacro( Self );
- itkTypeMacro( SkeletonReader, itk::ProcessObject );
-
- itkGetConstMacro( FileName, std::string );
- itkSetMacro( FileName, std::string );
-
- public:
- TSkeleton* GetOutput( );
- TSkeleton* GetOutput( unsigned int i );
-
- virtual void GraftOutput( itk::DataObject* out );
- virtual void GraftOutput(
- const typename Superclass::DataObjectIdentifierType& key,
- itk::DataObject* out
- );
- virtual void GraftNthOutput( unsigned int i, itk::DataObject* out );
- virtual itk::DataObject::Pointer MakeOutput(
- itk::ProcessObject::DataObjectPointerArraySizeType i
- ) override;
-
- virtual void Update( ) override
- { this->GenerateData( ); }
-
- protected:
- SkeletonReader( );
- virtual ~SkeletonReader( );
-
- virtual void GenerateData( ) override;
-
- // Do nothing
- virtual void GenerateOutputInformation( ) override
- { }
-
- private:
- // Purposely not implemented
- SkeletonReader( const Self& );
- void operator=( const Self& );
-
- protected:
- std::string m_FileName;
- };
-
- } // ecapseman
-
-} // ecapseman
-
-#ifndef ITK_MANUAL_INSTANTIATION
-# include <fpa/Base/SkeletonReader.hxx>
-#endif // ITK_MANUAL_INSTANTIATION
-
-#endif // __fpa__Base__SkeletonReader__h__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Base__SkeletonReader__hxx__
-#define __fpa__Base__SkeletonReader__hxx__
-
-// -------------------------------------------------------------------------
-template< class _TSkeleton >
-_TSkeleton* fpa::Base::SkeletonReader< _TSkeleton >::
-GetOutput( )
-{
- return(
- itkDynamicCastInDebugMode< TSkeleton* >( this->GetPrimaryOutput( ) )
- );
-}
-
-// -------------------------------------------------------------------------
-template< class _TSkeleton >
-_TSkeleton* fpa::Base::SkeletonReader< _TSkeleton >::
-GetOutput( unsigned int i )
-{
- return(
- itkDynamicCastInDebugMode< TSkeleton* >(
- this->itk::ProcessObject::GetOutput( i )
- )
- );
-}
-
-// -------------------------------------------------------------------------
-template< class _TSkeleton >
-void fpa::Base::SkeletonReader< _TSkeleton >::
-GraftOutput( itk::DataObject* out )
-{
- this->GraftNthOutput( 0, out );
-}
-
-// -------------------------------------------------------------------------
-template< class _TSkeleton >
-void fpa::Base::SkeletonReader< _TSkeleton >::
-GraftOutput(
- const typename Superclass::DataObjectIdentifierType& key,
- itk::DataObject* out
- )
-{
- if( out == NULL )
- {
- itkExceptionMacro(
- << "Requested to graft output that is a NULL pointer"
- );
-
- } // fi
- itk::DataObject* output = this->itk::ProcessObject::GetOutput( key );
- output->Graft( out );
-}
-
-// -------------------------------------------------------------------------
-template< class _TSkeleton >
-void fpa::Base::SkeletonReader< _TSkeleton >::
-GraftNthOutput( unsigned int i, itk::DataObject* out )
-{
- if( i >= this->GetNumberOfIndexedOutputs( ) )
- {
- itkExceptionMacro(
- << "Requested to graft output " << i
- << " but this filter only has "
- << this->GetNumberOfIndexedOutputs( )
- << " indexed Outputs."
- );
-
- } // fi
- this->GraftOutput( this->MakeNameFromOutputIndex( i ), out );
-}
-
-// -------------------------------------------------------------------------
-template< class _TSkeleton >
-itk::DataObject::Pointer
-fpa::Base::SkeletonReader< _TSkeleton >::
-MakeOutput( itk::ProcessObject::DataObjectPointerArraySizeType i )
-{
- return( TSkeleton::New( ).GetPointer( ) );
-}
-
-// -------------------------------------------------------------------------
-template< class _TSkeleton >
-fpa::Base::SkeletonReader< _TSkeleton >::
-SkeletonReader( )
- : Superclass( )
-{
- typename TSkeleton::Pointer out =
- static_cast< TSkeleton* >( this->MakeOutput( 0 ).GetPointer( ) );
- this->itk::ProcessObject::SetNumberOfRequiredInputs( 0 );
- this->itk::ProcessObject::SetNumberOfRequiredOutputs( 1 );
- this->itk::ProcessObject::SetNthOutput( 0, out.GetPointer( ) );
-}
-
-// -------------------------------------------------------------------------
-template< class _TSkeleton >
-fpa::Base::SkeletonReader< _TSkeleton >::
-~SkeletonReader( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TSkeleton >
-void fpa::Base::SkeletonReader< _TSkeleton >::
-GenerateData( )
-{
- typedef typename TSkeleton::TPath _TPath;
- typedef typename _TPath::TSpacing _TSpacing;
- typedef typename _TPath::TPoint _TPoint;
- typedef typename _TPath::TDirection _TDirection;
- typedef typename _TPath::TContinuousIndex _TContinuousIndex;
-
- std::string buffer;
- /* TODO
- if( !( fpa::Read( buffer, this->m_FileName ) ) )
- {
- itkExceptionMacro(
- << "Error reading skeleton from \"" << this->m_FileName << "\""
- );
- return;
- } // fi
- */
-
- std::istringstream in( buffer );
- unsigned int dim;
- in >> dim;
- if( dim != TSkeleton::Dimension )
- {
- itkExceptionMacro(
- << "Mismatched skeletons dimension: " << dim
- << " != " << TSkeleton::Dimension
- );
- return;
-
- } // fi
-
- TSkeleton* out = this->GetOutput( );
- unsigned long size;
- in >> size;
- while( size > 0 )
- {
- _TSpacing spa;
- _TPoint ori;
- _TDirection dir;
- for( unsigned int d = 0; d < dim; ++d )
- in >> spa[ d ];
- for( unsigned int d = 0; d < dim; ++d )
- in >> ori[ d ];
- for( unsigned int d = 0; d < dim; ++d )
- for( unsigned int e = 0; e < dim; ++e )
- in >> dir[ d ][ e ];
-
- typename _TPath::Pointer path = _TPath::New( );
- path->SetSpacing( spa );
- path->SetOrigin( ori );
- path->SetDirection( dir );
- for( unsigned long s = 0; s < size; ++s )
- {
- _TContinuousIndex idx;
- for( unsigned int d = 0; d < dim; ++d )
- in >> idx[ d ];
- path->AddVertex( idx );
-
- } // rof
- out->AddBranch( path );
- in >> size;
-
- } // elihw
-}
-
-#endif // __fpa__Base__SkeletonReader__hxx__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Base__SkeletonWriter__h__
-#define __fpa__Base__SkeletonWriter__h__
-
-#include <itkProcessObject.h>
-
-namespace fpa
-{
- namespace Base
- {
- /**
- */
- template< class _TSkeleton >
- class SkeletonWriter
- : public itk::ProcessObject
- {
- public:
- // Basic types
- typedef SkeletonWriter Self;
- typedef itk::ProcessObject Superclass;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
-
- typedef _TSkeleton TSkeleton;
- typedef typename TSkeleton::TEdges TEdges;
- typedef typename TSkeleton::TMatrix TMatrix;
- typedef typename TSkeleton::TMatrixRow TMatrixRow;
- typedef typename TSkeleton::TPath TPath;
- typedef typename TSkeleton::TVertex TVertex;
-
- public:
- itkNewMacro( Self );
- itkTypeMacro( SkeletonWriter, itk::ProcessObject );
-
- itkGetConstMacro( FileName, std::string );
- itkSetMacro( FileName, std::string );
-
- public:
- const TSkeleton* GetInput( ) const;
- void SetInput( const TSkeleton* skeleton );
- virtual void Update( ) override;
-
- protected:
- SkeletonWriter( );
- virtual ~SkeletonWriter( );
-
- virtual void GenerateData( ) override;
-
- private:
- // Purposely not implemented
- SkeletonWriter( const Self& );
- void operator=( const Self& );
-
- protected:
- std::string m_FileName;
- };
-
- } // ecapseman
-
-} // ecapseman
-
-#ifndef ITK_MANUAL_INSTANTIATION
-# include <fpa/Base/SkeletonWriter.hxx>
-#endif // ITK_MANUAL_INSTANTIATION
-
-#endif // __fpa__Base__SkeletonWriter__h__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Base__SkeletonWriter__hxx__
-#define __fpa__Base__SkeletonWriter__hxx__
-
-#include <fstream>
-
-// -------------------------------------------------------------------------
-template< class _TSkeleton >
-const _TSkeleton* fpa::Base::SkeletonWriter< _TSkeleton >::
-GetInput( ) const
-{
- return(
- dynamic_cast< const TSkeleton* >(
- this->itk::ProcessObject::GetInput( 0 )
- )
- );
-}
-
-// -------------------------------------------------------------------------
-template< class _TSkeleton >
-void fpa::Base::SkeletonWriter< _TSkeleton >::
-SetInput( const _TSkeleton* skeleton )
-{
- this->itk::ProcessObject::SetNthInput(
- 0, const_cast< TSkeleton* >( skeleton )
- );
-}
-
-// -------------------------------------------------------------------------
-template< class _TSkeleton >
-void fpa::Base::SkeletonWriter< _TSkeleton >::
-Update( )
-{
- TSkeleton* input = const_cast< TSkeleton* >( this->GetInput( ) );
- if( input != NULL )
- {
- input->UpdateOutputInformation( );
- input->UpdateOutputData( );
- this->GenerateData( );
- this->ReleaseInputs( );
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-template< class _TSkeleton >
-fpa::Base::SkeletonWriter< _TSkeleton >::
-SkeletonWriter( )
- : Superclass( ),
- m_FileName( "" )
-{
- this->SetNumberOfRequiredInputs( 1 );
-}
-
-// -------------------------------------------------------------------------
-template< class _TSkeleton >
-fpa::Base::SkeletonWriter< _TSkeleton >::
-~SkeletonWriter( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TSkeleton >
-void fpa::Base::SkeletonWriter< _TSkeleton >::
-GenerateData( )
-{
- const TSkeleton* sk = this->GetInput( );
- typename TMatrix::const_iterator mIt = sk->BeginEdgesRows( );
- typename TMatrixRow::const_iterator rIt = mIt->second.begin( );
- typename TEdges::const_iterator eIt = rIt->second.begin( );
- const TPath* path = *eIt;
-
- // Write base information
- std::stringstream out1, out2;
- out1 << TSkeleton::Dimension << std::endl;
- typename TPath::TSpacing spa = path->GetSpacing( );
- for( unsigned int d = 0; d < TSkeleton::Dimension; ++d )
- out1 << spa[ d ] << " ";
- out1 << std::endl;
- typename TPath::TDirection dir = path->GetDirection( );
- for( unsigned int d = 0; d < TSkeleton::Dimension; ++d )
- for( unsigned int e = 0; e < TSkeleton::Dimension; ++e )
- out1 << dir[ d ][ e ] << " ";
- out1 << std::endl;
- typename TPath::TPoint ori = path->GetOrigin( );
- for( unsigned int d = 0; d < TSkeleton::Dimension; ++d )
- out1 << ori[ d ] << " ";
- out1 << std::endl;
-
- // End points
- std::vector< TVertex > end_points = sk->GetEndPoints( );
- out1 << end_points.size( ) << std::endl;
- typename std::vector< TVertex >::const_iterator epIt = end_points.begin( );
- for( ; epIt != end_points.end( ); ++epIt )
- {
- for( unsigned int d = 0; d < TSkeleton::Dimension; ++d )
- out1 << ( *epIt )[ d ] << " ";
- out1 << std::endl;
-
- } // rof
-
- // Bifurcations
- std::vector< TVertex > bifurcations = sk->GetBifurcations( );
- out1 << bifurcations.size( ) << std::endl;
- typename std::vector< TVertex >::const_iterator bIt = bifurcations.begin( );
- for( ; bIt != bifurcations.end( ); ++bIt )
- {
- for( unsigned int d = 0; d < TSkeleton::Dimension; ++d )
- out1 << ( *bIt )[ d ] << " ";
- out1 << std::endl;
-
- } // rof
-
- // Write paths
- unsigned long pathCount = 0;
- mIt = sk->BeginEdgesRows( );
- for( ; mIt != sk->EndEdgesRows( ); ++mIt )
- {
- typename TMatrixRow::const_iterator rIt = mIt->second.begin( );
- for( ; rIt != mIt->second.end( ); ++rIt )
- {
- typename TEdges::const_iterator eIt = rIt->second.begin( );
- for( ; eIt != rIt->second.end( ); ++eIt )
- {
- TPath* path = *eIt;
- pathCount++;
- unsigned int size = path->GetSize( );
- out2 << size << std::endl;
- for( unsigned int i = 0; i < path->GetSize( ); ++i )
- {
- TVertex v = path->GetVertex( i );
- for( unsigned int d = 0; d < TSkeleton::Dimension; ++d )
- out2 << v[ d ] << " ";
-
- } // rof
- out2 << std::endl;
-
- } // rof
-
- } // rof
-
- } // rof
- out1 << pathCount << std::endl << out2.str( );
-
- // Real write
- std::ofstream file_stream( this->m_FileName.c_str( ), std::ofstream::binary );
- if( !file_stream )
- itkExceptionMacro(
- << "Unable to write skeleton to \""
- << this->m_FileName
- << "\""
- );
- file_stream.write( out1.str( ).c_str( ), out1.str( ).size( ) );
-}
-
-#endif // __fpa__Base__SkeletonWriter__hxx__
-
-// eof - $RCSfile$
+++ /dev/null
-
-## =====================
-## == Get source code ==
-## =====================
-
-configure_file(Version.cxx.in "${CMAKE_CURRENT_BINARY_DIR}/Version.cxx" @ONLY)
-file(GLOB_RECURSE _base_src "${CMAKE_CURRENT_SOURCE_DIR}/Base/*.cxx")
-file(GLOB_RECURSE _base_hdr "${CMAKE_CURRENT_SOURCE_DIR}/Base/*.h")
-file(GLOB_RECURSE _base_hrc "${CMAKE_CURRENT_SOURCE_DIR}/Base/*.hxx")
-file(GLOB_RECURSE _image_src "${CMAKE_CURRENT_SOURCE_DIR}/Image/*.cxx")
-file(GLOB_RECURSE _image_hdr "${CMAKE_CURRENT_SOURCE_DIR}/Image/*.h")
-file(GLOB_RECURSE _image_hrc "${CMAKE_CURRENT_SOURCE_DIR}/Image/*.hxx")
-
-set(_src
- ${_base_src} ${_image_src}
- "${CMAKE_CURRENT_BINARY_DIR}/Version.cxx"
- )
-set(_hdr ${_base_hdr} ${_image_hdr})
-set(_hrc ${_base_hrc} ${_image_hrc})
-
-## =====================
-## == Compile library ==
-## =====================
-
-add_library(fpa SHARED ${_src} ${_hdr} ${_hrc})
-generate_export_header(fpa)
-set_property(TARGET fpa PROPERTY VERSION ${prj_VERSION})
-set_property(TARGET fpa PROPERTY SOVERSION ${prj_SHORT_VERSION})
-set_property(
- TARGET fpa PROPERTY INTERFACE_fpa_MAJOR_VERSION ${prj_MAJ_VERSION}
- )
-set_property(
- TARGET fpa APPEND PROPERTY COMPATIBLE_INTERFACE_STRING ${prj_MAJ_VERSION}
- )
-target_link_libraries(fpa PUBLIC ${VTK_LIBRARIES} ${ITK_LIBRARIES})
-
-## ========================
-## == Installation rules ==
-## ========================
-
-install(
- TARGETS fpa
- EXPORT "${targets_export_name}"
- LIBRARY DESTINATION "lib"
- ARCHIVE DESTINATION "lib"
- RUNTIME DESTINATION "bin"
- INCLUDES DESTINATION "${include_install_dir}"
- )
-install(
- DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
- DESTINATION "${include_install_dir}"
- FILES_MATCHING PATTERN "*.h"
- )
-install(
- DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
- DESTINATION "${include_install_dir}"
- FILES_MATCHING PATTERN "*.hxx"
- )
-install(
- FILES "${CMAKE_CURRENT_BINARY_DIR}/fpa_export.h"
- DESTINATION "${include_install_dir}/fpa"
- )
-
-## eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Image__Dijkstra__h__
-#define __fpa__Image__Dijkstra__h__
-
-#include <fpa/Base/Dijkstra.h>
-#include <fpa/Base/SeedsInterface.h>
-#include <fpa/Image/MarksInterface.h>
-#include <fpa/Image/Filter.h>
-#include <fpa/Image/MinimumSpanningTree.h>
-#include <fpa/Image/Functors/VertexParentBase.h>
-#include <fpa/Image/Functors/VertexIdentity.h>
-
-namespace fpa
-{
- namespace Image
- {
- /**
- */
- template< class _TInputImage, class _TOutputImage >
- class Dijkstra
- : public fpa::Base::Dijkstra< fpa::Image::Filter< _TInputImage, _TOutputImage >, fpa::Image::MarksInterface< _TInputImage::ImageDimension >, fpa::Base::SeedsInterface< typename _TInputImage::IndexType, typename _TInputImage::IndexType::LexicographicCompare >, fpa::Image::MinimumSpanningTree< _TInputImage::ImageDimension > >
- {
- public:
- // Interfaces
- typedef fpa::Image::Filter< _TInputImage, _TOutputImage > TFilter;
- typedef fpa::Image::MarksInterface< _TInputImage::ImageDimension > TMarksInterface;
- typedef fpa::Base::SeedsInterface< typename _TInputImage::IndexType, typename _TInputImage::IndexType::LexicographicCompare > TSeedsInterface;
- typedef fpa::Image::MinimumSpanningTree< _TInputImage::ImageDimension > TMST;
-
- // Smart pointers
- typedef Dijkstra Self;
- typedef fpa::Base::Dijkstra< TFilter, TMarksInterface, TSeedsInterface, TMST > Superclass;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
-
- typedef typename TFilter::TInputImage TInputImage;
- typedef typename TFilter::TOutputValue TOutputValue;
- typedef typename TFilter::TVertex TVertex;
-
- public:
- itkNewMacro( Self );
- itkTypeMacro( fpa::Image::Dijkstra, fpa::Base::Dijkstra );
-
- protected:
- Dijkstra( )
- : Superclass( )
- {
- this->SetFunctor(
- fpa::Image::Functors::
- VertexIdentity< _TInputImage, typename TFilter::TOutputValue >::
- New( )
- );
- }
- virtual ~Dijkstra( ) { }
-
- virtual void _ConfigureOutputs( const TOutputValue& init_value ) override
- {
- this->Superclass::_ConfigureOutputs( init_value );
-
- typename TVertex::OffsetType o;
- o.Fill( 0 );
- const TInputImage* input = this->GetInput( );
- TMST* mst = this->GetMinimumSpanningTree( );
- mst->CopyInformation( input );
- mst->SetBufferedRegion( input->GetRequestedRegion( ) );
- mst->Allocate( );
- mst->FillBuffer( o );
- }
-
- virtual void GenerateData( ) override
- {
- // Configure functors with input image
- typedef typename TFilter::TOutputValue _TOutputValue;
- typedef fpa::Image::Functors::VertexParentBase< _TInputImage, _TOutputValue > _TVFunc;
- _TVFunc* vfunc =
- dynamic_cast< _TVFunc* >( this->m_VertexFunctor.GetPointer( ) );
- if( vfunc != NULL )
- vfunc->SetImage( this->GetInput( ) );
-
- // Ok, continue
- this->Superclass::GenerateData( );
- }
-
- private:
- Dijkstra( const Self& other );
- Self& operator=( const Self& other );
- };
-
- } // ecapseman
-
-} // ecapseman
-
-#endif // __fpa__Image__Dijkstra__h__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Image__Filter__h__
-#define __fpa__Image__Filter__h__
-
-#include <vector>
-#include <itkImageToImageFilter.h>
-
-namespace fpa
-{
- namespace Image
- {
- /**
- */
- template< class _TInputImage, class _TOutputImage >
- class Filter
- : public itk::ImageToImageFilter< _TInputImage, _TOutputImage >
- {
- public:
- typedef Filter Self;
- typedef itk::ImageToImageFilter< _TInputImage, _TOutputImage > Superclass;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
-
- typedef _TInputImage TInputImage;
- typedef _TOutputImage TOutputImage;
-
- typedef typename TInputImage::IndexType TVertex;
- typedef typename TInputImage::PixelType TInputValue;
- typedef typename TOutputImage::PixelType TOutputValue;
-
- typedef std::vector< TVertex > TVertices;
-
- protected:
- Filter( );
- virtual ~Filter( );
-
- virtual void GenerateInputRequestedRegion( ) override;
- virtual void EnlargeOutputRequestedRegion( itk::DataObject* output ) override;
-
- virtual TInputValue _GetInputValue( const TVertex& vertex ) const;
- virtual void _SetOutputValue( const TVertex& vertex, const TOutputValue& value );
- virtual void _ConfigureOutputs( const TOutputValue& init_value );
- virtual TVertices _GetNeighbors( const TVertex& vertex ) const;
- };
-
- } // ecapseman
-
-} // ecapseman
-
-#ifndef ITK_MANUAL_INSTANTIATION
-# include <fpa/Image/Filter.hxx>
-#endif // ITK_MANUAL_INSTANTIATION
-
-#endif // __fpa__Image__Filter__h__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Image__Filter__hxx__
-#define __fpa__Image__Filter__hxx__
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage >
-fpa::Image::Filter< _TInputImage, _TOutputImage >::
-Filter( )
- : Superclass( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage >
-fpa::Image::Filter< _TInputImage, _TOutputImage >::
-~Filter( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage >
-void fpa::Image::Filter< _TInputImage, _TOutputImage >::
-GenerateInputRequestedRegion( )
-{
- this->Superclass::GenerateInputRequestedRegion( );
- if( this->GetInput( ) )
- {
- TInputImage* input = const_cast< TInputImage* >( this->GetInput( ) );
- input->SetRequestedRegionToLargestPossibleRegion( );
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage >
-void fpa::Image::Filter< _TInputImage, _TOutputImage >::
-EnlargeOutputRequestedRegion( itk::DataObject* output )
-{
- this->Superclass::EnlargeOutputRequestedRegion( output );
- output->SetRequestedRegionToLargestPossibleRegion( );
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage >
-typename fpa::Image::Filter< _TInputImage, _TOutputImage >::
-TInputValue fpa::Image::Filter< _TInputImage, _TOutputImage >::
-_GetInputValue( const TVertex& vertex ) const
-{
- return( this->GetInput( )->GetPixel( vertex ) );
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage >
-void fpa::Image::Filter< _TInputImage, _TOutputImage >::
-_SetOutputValue( const TVertex& vertex, const TOutputValue& value )
-{
- this->GetOutput( )->SetPixel( vertex, value );
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage >
-void fpa::Image::Filter< _TInputImage, _TOutputImage >::
-_ConfigureOutputs( const TOutputValue& init_value )
-{
- const TInputImage* input = this->GetInput( );
- TOutputImage* output = this->GetOutput( );
- output->SetBufferedRegion( input->GetRequestedRegion( ) );
- output->Allocate( );
- output->FillBuffer( init_value );
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage >
-typename fpa::Image::Filter< _TInputImage, _TOutputImage >::
-TVertices fpa::Image::Filter< _TInputImage, _TOutputImage >::
-_GetNeighbors( const TVertex& vertex ) const
-{
- typename TInputImage::RegionType region =
- this->GetInput( )->GetRequestedRegion( );
-
- TVertices vertices;
- for( unsigned int d = 0; d < TInputImage::ImageDimension; ++d )
- {
- TVertex n = vertex;
- for( int a = -1; a <= 1; a += 2 )
- {
- n[ d ] = vertex[ d ] + a;
- if( region.IsInside( n ) )
- vertices.push_back( n );
-
- } // rof
-
- } // rof
- return( vertices );
-}
-
-#endif // __fpa__Image__Filter__hxx__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Image__Functors__GaussianWeight__h__
-#define __fpa__Image__Functors__GaussianWeight__h__
-
-#include <fpa/Image/Functors/VertexParentBase.h>
-#include <cmath>
-
-namespace fpa
-{
- namespace Image
- {
- namespace Functors
- {
- /**
- */
- template< class _TInputImage, class _TOutputValue >
- class GaussianWeight
- : public fpa::Image::Functors::VertexParentBase< _TInputImage, _TOutputValue >
- {
- public:
- typedef _TInputImage TInputImage;
- typedef _TOutputValue TOutputValue;
- typedef GaussianWeight Self;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
- typedef fpa::Image::Functors::VertexParentBase< TInputImage, TOutputValue > Superclass;
-
- typedef typename Superclass::TVertex TVertex;
-
- public:
- itkNewMacro( Self );
- itkTypeMacro(
- fpa::Image::Functors::GaussianWeight,
- fpa::Image::Functors::VertexParentBase
- );
-
- itkBooleanMacro( Invert );
- itkGetConstMacro( Beta, double );
- itkGetConstMacro( Invert, bool );
- itkSetMacro( Beta, double );
- itkSetMacro( Invert, bool );
-
- public:
- virtual TOutputValue Evaluate(
- const TVertex& a, const TVertex& p
- ) const override
- {
- double va = double( this->m_Image->GetPixel( a ) );
- double vp = double( this->m_Image->GetPixel( p ) );
- double d = va - vp;
- d = ( d * d ) / this->m_Beta;
- if( this->m_Invert )
- return( TOutputValue( double( 1 ) - std::exp( -d ) ) );
- else
- return( TOutputValue( std::exp( -d ) ) );
- }
-
- protected:
- GaussianWeight( )
- : Superclass( ),
- m_Invert( false ),
- m_Beta( double( 1 ) )
- { }
- virtual ~GaussianWeight( ) { }
-
- private:
- GaussianWeight( const Self& other );
- Self& operator=( const Self& other );
-
- protected:
- bool m_Invert;
- double m_Beta;
- };
-
- } // ecapseman
-
- } // ecapseman
-
-} // ecapseman
-
-#endif // __fpa__Image__Functors__GaussianWeight__h__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Image__Functors__RegionGrow__BinaryThreshold__h__
-#define __fpa__Image__Functors__RegionGrow__BinaryThreshold__h__
-
-#include <itkFunctionBase.h>
-
-namespace fpa
-{
- namespace Image
- {
- namespace Functors
- {
- namespace RegionGrow
- {
- /**
- */
- template< class _TPixel >
- class BinaryThreshold
- : public itk::FunctionBase< _TPixel, bool >
- {
- public:
- typedef _TPixel TPixel;
-
- typedef BinaryThreshold Self;
- typedef itk::FunctionBase< TPixel, bool > Superclass;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
-
- public:
- itkNewMacro( Self );
- itkTypeMacro(
- fpa::Image::Functors::RegionGrow::BinaryThreshold,
- itk::FunctionBase
- );
-
- itkGetConstMacro( Lower, TPixel );
- itkGetConstMacro( Upper, TPixel );
-
- itkSetMacro( Lower, TPixel );
- itkSetMacro( Upper, TPixel );
-
- public:
- virtual bool Evaluate( const TPixel& value ) 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
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Image__Functors__RegionGrow__BinaryThreshold__hxx__
-#define __fpa__Image__Functors__RegionGrow__BinaryThreshold__hxx__
-
-// -------------------------------------------------------------------------
-template< class _TPixel >
-bool fpa::Image::Functors::RegionGrow::BinaryThreshold< _TPixel >::
-Evaluate( const TPixel& value ) const
-{
- return( this->m_Lower < value && value < this->m_Upper );
-}
-
-// -------------------------------------------------------------------------
-template< class _TPixel >
-fpa::Image::Functors::RegionGrow::BinaryThreshold< _TPixel >::
-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 _TPixel >
-fpa::Image::Functors::RegionGrow::BinaryThreshold< _TPixel >::
-~BinaryThreshold( )
-{
-}
-
-#endif // __fpa__Image__Functors__RegionGrow__BinaryThreshold__hxx__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Image__Functors__RegionGrow__Tautology__h__
-#define __fpa__Image__Functors__RegionGrow__Tautology__h__
-
-#include <itkFunctionBase.h>
-
-namespace fpa
-{
- namespace Image
- {
- namespace Functors
- {
- namespace RegionGrow
- {
- /**
- */
- template< class _TPixel >
- class Tautology
- : public itk::FunctionBase< _TPixel, bool >
- {
- public:
- typedef _TPixel TPixel;
-
- typedef Tautology Self;
- typedef itk::FunctionBase< TPixel, bool > Superclass;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
-
- public:
- itkNewMacro( Self );
- itkTypeMacro(
- fpa::Image::Functors::RegionGrow::Tautology,
- itk::FunctionBase
- );
-
- public:
- virtual bool Evaluate( const TPixel& value ) const override
- { return( true ); }
-
- protected:
- Tautology( )
- : Superclass( )
- { }
- virtual ~Tautology( )
- { }
-
- private:
- // Purposely not implemented
- Tautology( const Self& other );
- Self& operator=( const Self& other );
- };
-
- } // ecapseman
-
- } // ecapseman
-
- } // ecapseman
-
-} // ecapseman
-
-#endif // __fpa__Image__Functors__RegionGrow__Tautology__h__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Image__Functors__VertexIdentity__h__
-#define __fpa__Image__Functors__VertexIdentity__h__
-
-#include <fpa/Image/Functors/VertexParentBase.h>
-
-namespace fpa
-{
- namespace Image
- {
- namespace Functors
- {
- /**
- */
- template< class _TInputImage, class _TOutputValue >
- class VertexIdentity
- : public fpa::Image::Functors::VertexParentBase< _TInputImage, _TOutputValue >
- {
- public:
- typedef _TInputImage TInputImage;
- typedef _TOutputValue TOutputValue;
- typedef VertexIdentity Self;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
- typedef fpa::Image::Functors::VertexParentBase< TInputImage, TOutputValue > Superclass;
-
- typedef typename Superclass::TVertex TVertex;
-
- public:
- itkNewMacro( Self );
- itkTypeMacro(
- fpa::Image::Functors::VertexIdentity,
- fpa::Image::Functors::VertexParentBase
- );
-
- public:
- virtual TOutputValue Evaluate(
- const TVertex& a, const TVertex& p
- ) const override
- {
- return( TOutputValue( this->m_Image->GetPixel( a ) ) );
- }
-
- protected:
- VertexIdentity( )
- : Superclass( )
- { }
- virtual ~VertexIdentity( ) { }
-
- private:
- VertexIdentity( const Self& other );
- Self& operator=( const Self& other );
- };
-
- } // ecapseman
-
- } // ecapseman
-
-} // ecapseman
-
-#endif // __fpa__Image__Functors__VertexIdentity__h__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Image__Functors__VertexParentBase__h__
-#define __fpa__Image__Functors__VertexParentBase__h__
-
-#include <fpa/Base/Functors/VertexParentBase.h>
-
-namespace fpa
-{
- namespace Image
- {
- namespace Functors
- {
- /**
- */
- template< class _TInputImage, class _TOutputValue >
- class VertexParentBase
- : public fpa::Base::Functors::VertexParentBase< typename _TInputImage::IndexType, _TOutputValue >
- {
- public:
- typedef _TInputImage TInputImage;
- typedef _TOutputValue TOutputValue;
- typedef typename TInputImage::IndexType TVertex;
- typedef VertexParentBase Self;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
- typedef fpa::Base::Functors::VertexParentBase< TVertex, TOutputValue > Superclass;
-
- public:
- itkTypeMacro(
- fpa::Image::Functors::VertexParentBase,
- fpa::Base::Functors::VertexParentBase
- );
-
- itkGetConstObjectMacro( Image, TInputImage );
- itkSetConstObjectMacro( Image, TInputImage );
-
- protected:
- VertexParentBase( )
- : Superclass( )
- { }
- virtual ~VertexParentBase( ) { }
-
- private:
- VertexParentBase( const Self& other );
- Self& operator=( const Self& other );
-
- protected:
- typename TInputImage::ConstPointer m_Image;
- };
-
- } // ecapseman
-
- } // ecapseman
-
-} // ecapseman
-
-#endif // __fpa__Image__Functors__VertexParentBase__h__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Image__MarksInterface__h__
-#define __fpa__Image__MarksInterface__h__
-
-#include <fpa/Base/MarksInterface.h>
-#include <itkIndex.h>
-#include <itkImage.h>
-
-namespace fpa
-{
- namespace Image
- {
- /**
- */
- template< unsigned int _VDim >
- class MarksInterface
- : public fpa::Base::MarksInterface< itk::Index< _VDim > >
- {
- public:
- typedef MarksInterface Self;
- typedef fpa::Base::MarksInterface< itk::Index< _VDim > > Superclass;
-
- typedef typename Superclass::TVertex TVertex;
- typedef typename Superclass::TCollision TCollision;
- typedef typename Superclass::TCollisionsRow TCollisionsRow;
- typedef typename Superclass::TCollisions TCollisions;
-
- typedef itk::Image< unsigned long, _VDim > TMarks;
-
- protected:
- virtual bool _IsMarked( const TVertex& v ) const override;
- virtual unsigned long _GetMark( const TVertex& v ) const override;
- virtual void _Mark( const TVertex& v, unsigned long frontId ) override;
- virtual void _FreeMarks( ) override;
- virtual void _InitMarks( unsigned long nSeeds ) override;
-
- protected:
- MarksInterface( itk::ProcessObject* filter );
- virtual ~MarksInterface( );
-
- private:
- typename TMarks::Pointer m_Marks;
- };
-
- } // ecapseman
-
-} // ecapseman
-
-#ifndef ITK_MANUAL_INSTANTIATION
-# include <fpa/Image/MarksInterface.hxx>
-#endif // ITK_MANUAL_INSTANTIATION
-
-#endif // __fpa__Image__MarksInterface__h__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Image__MarksInterface__hxx__
-#define __fpa__Image__MarksInterface__hxx__
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-bool fpa::Image::MarksInterface< _VDim >::
-_IsMarked( const TVertex& v ) const
-{
- return( this->m_Marks->GetPixel( v ) != 0 );
-}
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-unsigned long fpa::Image::MarksInterface< _VDim >::
-_GetMark( const TVertex& v ) const
-{
- return( this->m_Marks->GetPixel( v ) );
-}
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-void fpa::Image::MarksInterface< _VDim >::
-_Mark( const TVertex& v, unsigned long frontId )
-{
- this->m_Marks->SetPixel( v, frontId );
-}
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-void fpa::Image::MarksInterface< _VDim >::
-_FreeMarks( )
-{
- this->m_Marks = NULL;
-}
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-void fpa::Image::MarksInterface< _VDim >::
-_InitMarks( unsigned long nSeeds )
-{
- this->Superclass::_InitMarks( nSeeds );
-
- // Try to guess input
- if( this->m_Filter == NULL )
- return;
- if( this->m_Filter->GetInputs( ).size( ) == 0 )
- return;
- itk::ImageBase< _VDim >* input =
- dynamic_cast< itk::ImageBase< _VDim >* >(
- this->m_Filter->GetInputs( )[ 0 ].GetPointer( )
- );
- if( input == NULL )
- return;
-
- // Reserve memory for marks
- this->m_Marks = TMarks::New( );
- this->m_Marks->CopyInformation( input );
- this->m_Marks->SetRequestedRegion( input->GetRequestedRegion( ) );
- this->m_Marks->SetBufferedRegion( input->GetBufferedRegion( ) );
- this->m_Marks->Allocate( );
- this->m_Marks->FillBuffer( 0 );
-}
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-fpa::Image::MarksInterface< _VDim >::
-MarksInterface( itk::ProcessObject* filter )
- : Superclass( filter )
-{
-}
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-fpa::Image::MarksInterface< _VDim >::
-~MarksInterface( )
-{
-}
-
-#endif // __fpa__Image__MarksInterface__hxx__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Image__MinimumSpanningTree__h__
-#define __fpa__Image__MinimumSpanningTree__h__
-
-#include <fpa/Base/MinimumSpanningTree.h>
-#include <itkImage.h>
-
-namespace fpa
-{
- namespace Image
- {
- /**
- */
- template< unsigned int _VDim >
- class MinimumSpanningTree
- : public fpa::Base::MinimumSpanningTree< itk::Index< _VDim >, itk::Image< itk::Offset< _VDim >, _VDim > >
- {
- public:
- typedef itk::Index< _VDim > TVertex;
- typedef itk::Image< itk::Offset< _VDim >, _VDim > TBaseImage;
-
- typedef MinimumSpanningTree Self;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
- typedef fpa::Base::MinimumSpanningTree< TVertex, TBaseImage > Superclass;
-
- typedef typename Superclass::TCollision TCollision;
- typedef typename Superclass::TCollisionsRow TCollisionsRow;
- typedef typename Superclass::TCollisions TCollisions;
- typedef typename Superclass::TVertices TVertices;
-
- public:
- itkNewMacro( Self );
- itkTypeMacro(
- fpa::Image::MinimumSpanningTree,
- fpa::Base::MinimumSpanningTree
- );
-
- public:
- virtual TVertex GetParent( const TVertex& v ) const override
- {
- return( v + this->GetPixel( v ) );
- }
- virtual void SetParent( const TVertex& v, const TVertex& p ) override
- {
- this->SetPixel( v, p - v );
- }
-
- protected:
- MinimumSpanningTree( )
- : Superclass( )
- { }
- virtual ~MinimumSpanningTree( )
- { }
-
- private:
- MinimumSpanningTree( const Self& other );
- Self& operator=( const Self& other );
- };
-
- } // ecapseman
-
-} // ecapseman
-
-#endif // __fpa__Image__MinimumSpanningTree__h__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Image__MinimumSpanningTreeToImageFilter__h__
-#define __fpa__Image__MinimumSpanningTreeToImageFilter__h__
-
-#include <itkRGBAPixel.h>
-#include <itkImageToImageFilter.h>
-#include <vector>
-
-namespace fpa
-{
- namespace Image
- {
- /**
- */
- template< class _TMST, class _TOutputPixelValue >
- class MinimumSpanningTreeToImageFilter
- : public itk::ImageToImageFilter< _TMST, itk::Image< itk::RGBAPixel< _TOutputPixelValue >, _TMST::ImageDimension > >
- {
- public:
- typedef _TMST TMST;
- typedef _TOutputPixelValue TOutputPixelValue;
- typedef itk::RGBAPixel< TOutputPixelValue > TOutputPixel;
- typedef itk::Image< TOutputPixel, TMST::ImageDimension > TOutputImage;
-
- typedef MinimumSpanningTreeToImageFilter Self;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
- typedef itk::ImageToImageFilter< TMST, TOutputImage > Superclass;
-
- typedef typename TMST::IndexType TIndex;
- struct TPathData
- {
- TIndex Start;
- TIndex End;
- TOutputPixelValue Red;
- TOutputPixelValue Green;
- TOutputPixelValue Blue;
- };
- typedef std::vector< TPathData > TPaths;
-
- public:
- itkNewMacro( Self );
- itkTypeMacro(
- fpa::Image::MinimumSpanningTreeToImageFilter,
- itk::ImageToImageFilter
- );
-
- public:
- void AddPath(
- const TIndex& start, const TIndex& end,
- const TOutputPixelValue& r = TOutputPixelValue( 1 ),
- const TOutputPixelValue& g = TOutputPixelValue( 0 ),
- const TOutputPixelValue& b = TOutputPixelValue( 0 )
- );
-
- protected:
- MinimumSpanningTreeToImageFilter( );
- virtual ~MinimumSpanningTreeToImageFilter( );
-
- virtual void GenerateData( ) override;
-
- private:
- MinimumSpanningTreeToImageFilter( const Self& other );
- Self& operator=( const Self& other );
-
- protected:
- TPaths m_Paths;
- };
-
- } // ecapseman
-
-} // ecapseman
-
-#ifndef ITK_MANUAL_INSTANTIATION
-# include <fpa/Image/MinimumSpanningTreeToImageFilter.hxx>
-#endif // ITK_MANUAL_INSTANTIATION
-
-#endif // __fpa__Image__MinimumSpanningTreeToImageFilter__h__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Image__MinimumSpanningTreeToImageFilter__hxx__
-#define __fpa__Image__MinimumSpanningTreeToImageFilter__hxx__
-
-// -------------------------------------------------------------------------
-template< class _TMST, class _TOutputPixelValue >
-void fpa::Image::MinimumSpanningTreeToImageFilter< _TMST, _TOutputPixelValue >::
-AddPath(
- const TIndex& start, const TIndex& end,
- const TOutputPixelValue& r,
- const TOutputPixelValue& g,
- const TOutputPixelValue& b
- )
-{
- if( start != end )
- {
- TPathData d;
- d.Start = start;
- d.End = end;
- d.Red = r;
- d.Green = g;
- d.Blue = b;
- this->m_Paths.push_back( d );
- this->Modified( );
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-template< class _TMST, class _TOutputPixelValue >
-fpa::Image::MinimumSpanningTreeToImageFilter< _TMST, _TOutputPixelValue >::
-MinimumSpanningTreeToImageFilter( )
- : Superclass( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TMST, class _TOutputPixelValue >
-fpa::Image::MinimumSpanningTreeToImageFilter< _TMST, _TOutputPixelValue >::
-~MinimumSpanningTreeToImageFilter( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TMST, class _TOutputPixelValue >
-void fpa::Image::MinimumSpanningTreeToImageFilter< _TMST, _TOutputPixelValue >::
-GenerateData( )
-{
- TOutputPixel color;
- color.Fill( 0 );
-
- const TMST* mst = this->GetInput( );
- TOutputImage* output = this->GetOutput( );
- output->SetBufferedRegion( mst->GetBufferedRegion( ) );
- output->Allocate( );
- output->FillBuffer( color );
-
- typename TPaths::const_iterator d = this->m_Paths.begin( );
- for( ; d != this->m_Paths.end( ); ++d )
- {
- typename TMST::TVertices path = mst->GetPath( d->Start, d->End );
- color[ 0 ] = d->Red;
- color[ 1 ] = d->Green;
- color[ 2 ] = d->Blue;
- color[ 3 ] = std::numeric_limits< TOutputPixelValue >::max( );
- typename TMST::TVertices::const_iterator i = path.begin( );
- for( ; i != path.end( ); ++i )
- output->SetPixel( *i, color );
-
- } // rof
-}
-
-#endif // __fpa__Image__MinimumSpanningTreeToImageFilter__hxx__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Image__MoriRegionGrow__h__
-#define __fpa__Image__MoriRegionGrow__h__
-
-#include <fpa/Base/MoriRegionGrow.h>
-#include <fpa/Base/SeedsInterface.h>
-#include <fpa/Image/MarksInterface.h>
-#include <fpa/Image/Filter.h>
-
-namespace fpa
-{
- namespace Image
- {
- /**
- */
- template< class _TInputImage, class _TOutputImage >
- class MoriRegionGrow
- : public fpa::Base::MoriRegionGrow< fpa::Image::Filter< _TInputImage, _TOutputImage >, fpa::Image::MarksInterface< _TInputImage::ImageDimension >, fpa::Base::SeedsInterface< typename _TInputImage::IndexType, typename _TInputImage::IndexType::LexicographicCompare > >
- {
- public:
- // Interfaces
- typedef fpa::Image::Filter< _TInputImage, _TOutputImage > TFilter;
- typedef fpa::Image::MarksInterface< _TInputImage::ImageDimension > TMarksInterface;
- typedef fpa::Base::SeedsInterface< typename _TInputImage::IndexType, typename _TInputImage::IndexType::LexicographicCompare > TSeedsInterface;
-
- // Smart pointers
- typedef MoriRegionGrow Self;
- typedef fpa::Base::MoriRegionGrow< TFilter, TMarksInterface, TSeedsInterface > Superclass;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
-
- public:
- itkNewMacro( Self );
- itkTypeMacro( fpa::Image::MoriRegionGrow, fpa::Base::MoriRegionGrow );
-
- protected:
- MoriRegionGrow( ) : Superclass( ) { }
- virtual ~MoriRegionGrow( ) { }
-
- private:
- MoriRegionGrow( const Self& other );
- Self& operator=( const Self& other );
- };
-
- } // ecapseman
-
-} // ecapseman
-
-#endif // __fpa__Image__MoriRegionGrow__h__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Image__RegionGrow__h__
-#define __fpa__Image__RegionGrow__h__
-
-#include <fpa/Base/RegionGrow.h>
-#include <fpa/Base/SeedsInterface.h>
-#include <fpa/Image/MarksInterface.h>
-#include <fpa/Image/Filter.h>
-
-namespace fpa
-{
- namespace Image
- {
- /**
- */
- template< class _TInputImage, class _TOutputImage >
- class RegionGrow
- : public fpa::Base::RegionGrow< fpa::Image::Filter< _TInputImage, _TOutputImage >, fpa::Image::MarksInterface< _TInputImage::ImageDimension >, fpa::Base::SeedsInterface< typename _TInputImage::IndexType, typename _TInputImage::IndexType::LexicographicCompare > >
- {
- public:
- // Interfaces
- typedef fpa::Image::Filter< _TInputImage, _TOutputImage > TFilter;
- typedef fpa::Image::MarksInterface< _TInputImage::ImageDimension > TMarksInterface;
- typedef fpa::Base::SeedsInterface< typename _TInputImage::IndexType, typename _TInputImage::IndexType::LexicographicCompare > TSeedsInterface;
-
- // Smart pointers
- typedef RegionGrow Self;
- typedef fpa::Base::RegionGrow< TFilter, TMarksInterface, TSeedsInterface > Superclass;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
-
- public:
- itkNewMacro( Self );
- itkTypeMacro( fpa::Image::RegionGrow, fpa::Base::RegionGrow );
-
- protected:
- RegionGrow( ) : Superclass( ) { }
- virtual ~RegionGrow( ) { }
-
- private:
- RegionGrow( const Self& other );
- Self& operator=( const Self& other );
- };
-
- } // ecapseman
-
-} // ecapseman
-
-#endif // __fpa__Image__RegionGrow__h__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Image__SkeletonFilter__h__
-#define __fpa__Image__SkeletonFilter__h__
-
-#include <fpa/Image/Dijkstra.h>
-
-#include <map>
-#include <itkSignedMaurerDistanceMapImageFilter.h>
-#include <fpa/Base/Skeleton.h>
-
-namespace fpa
-{
- namespace Image
- {
- /**
- */
- template< class _TImage, class _TScalar = double >
- class SkeletonFilter
- : public fpa::Image::Dijkstra< itk::Image< _TScalar, _TImage::ImageDimension >, itk::Image< _TScalar, _TImage::ImageDimension > >
- {
- public:
- // Smart pointers
- typedef _TImage TImage;
- typedef _TScalar TScalar;
- typedef itk::Image< TScalar, TImage::ImageDimension > TScalarImage;
- typedef SkeletonFilter Self;
- typedef fpa::Image::Dijkstra< TScalarImage, TScalarImage > Superclass;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
-
- typedef typename Superclass::TMST TMST;
- typedef typename Superclass::TVertex TVertex;
- typedef typename Superclass::TOutputValue TOutputValue;
-
- typedef itk::SignedMaurerDistanceMapImageFilter< TImage, TScalarImage > TDistanceMap;
- typedef itk::Image< unsigned char, TImage::ImageDimension > TMarks;
- typedef fpa::Base::Skeleton< TImage::ImageDimension > TSkeleton;
-
- protected:
- typedef std::multimap< TScalar, TVertex, std::greater< TScalar > > _TSkeletonQueue;
- typedef std::map< TVertex, TVertex, typename TVertex::LexicographicCompare > _TAdjacencies;
-
- public:
- itkNewMacro( Self );
- itkTypeMacro( fpa::Image::SkeletonFilter, fpa::Image::Dijkstra );
-
- itkBooleanMacro( SeedFromMaximumDistance );
- itkGetConstMacro( SeedFromMaximumDistance, bool );
- itkSetMacro( SeedFromMaximumDistance, bool );
-
- public:
- virtual void SetInput( const TScalarImage* image ) override;
- void SetInput( const TImage* image );
- TImage* GetInput( );
- const TImage* GetInput( ) const;
-
- TSkeleton* GetSkeleton( );
- TMarks* GetMarks( );
-
- protected:
- SkeletonFilter( );
- virtual ~SkeletonFilter( );
-
- virtual void GenerateData( ) override;
- virtual void _SetOutputValue( const TVertex& vertex, const TOutputValue& value ) override;
-
- void _EndPoints( std::vector< TVertex >& end_points, _TAdjacencies& A );
- void _Skeleton( const std::vector< TVertex >& end_points, _TAdjacencies& A );
- void _MarkSphere( const TVertex& idx );
-
- private:
- SkeletonFilter( const Self& other );
- Self& operator=( const Self& other );
-
- protected:
- bool m_SeedFromMaximumDistance;
- typename TDistanceMap::Pointer m_DistanceMap;
- _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
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Image__SkeletonFilter__hxx__
-#define __fpa__Image__SkeletonFilter__hxx__
-
-#include <itkImageRegionIteratorWithIndex.h>
-#include <itkMinimumMaximumImageCalculator.h>
-
-#include <fpa/Image/Functors/VertexIdentity.h>
-#include <fpa/Base/Functors/InvertValue.h>
-
-// -------------------------------------------------------------------------
-template< class _TImage, class _TScalar >
-void fpa::Image::SkeletonFilter< _TImage, _TScalar >::
-SetInput( const TScalarImage* image )
-{
- // Do nothing
-}
-
-// -------------------------------------------------------------------------
-template< class _TImage, class _TScalar >
-void fpa::Image::SkeletonFilter< _TImage, _TScalar >::
-SetInput( const TImage* image )
-{
- this->m_DistanceMap->SetInput( image );
- this->Superclass::SetInput( this->m_DistanceMap->GetOutput( ) );
-}
-
-// -------------------------------------------------------------------------
-template< class _TImage, class _TScalar >
-_TImage* fpa::Image::SkeletonFilter< _TImage, _TScalar >::
-GetInput( )
-{
- return( this->m_DistanceMap->GetInput( ) );
-}
-
-// -------------------------------------------------------------------------
-template< class _TImage, class _TScalar >
-const _TImage* fpa::Image::SkeletonFilter< _TImage, _TScalar >::
-GetInput( ) const
-{
- return( this->m_DistanceMap->GetInput( ) );
-}
-
-// -------------------------------------------------------------------------
-template< class _TImage, class _TScalar >
-typename fpa::Image::SkeletonFilter< _TImage, _TScalar >::
-TSkeleton* fpa::Image::SkeletonFilter< _TImage, _TScalar >::
-GetSkeleton( )
-{
- return(
- dynamic_cast< TSkeleton* >(
- this->itk::ProcessObject::GetOutput( this->m_SkeletonIdx )
- )
- );
-}
-
-// -------------------------------------------------------------------------
-template< class _TImage, class _TScalar >
-typename fpa::Image::SkeletonFilter< _TImage, _TScalar >::
-TMarks* fpa::Image::SkeletonFilter< _TImage, _TScalar >::
-GetMarks( )
-{
- return(
- dynamic_cast< TMarks* >(
- this->itk::ProcessObject::GetOutput( this->m_MarksIdx )
- )
- );
-}
-
-// -------------------------------------------------------------------------
-template< class _TImage, class _TScalar >
-fpa::Image::SkeletonFilter< _TImage, _TScalar >::
-SkeletonFilter( )
- : Superclass( ),
- m_SeedFromMaximumDistance( false )
-{
- typedef fpa::Image::Functors::VertexIdentity< TScalarImage, _TScalar > _TVertexFunc;
- typedef fpa::Base::Functors::InvertValue< _TScalar, _TScalar > _TValueFunc;
-
- typename _TVertexFunc::Pointer vertex_func = _TVertexFunc::New( );
- typename _TValueFunc::Pointer value_func = _TValueFunc::New( );
- value_func->SetAlpha( 1 );
- value_func->SetBeta( 1 );
-
- this->SetFunctor( vertex_func );
- this->SetFunctor( value_func );
-
- this->m_DistanceMap = TDistanceMap::New( );
- this->m_DistanceMap->InsideIsPositiveOn( );
- this->m_DistanceMap->SquaredDistanceOff( );
- this->m_DistanceMap->UseImageSpacingOn( );
-
- 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( ) );
-}
-
-// -------------------------------------------------------------------------
-template< class _TImage, class _TScalar >
-fpa::Image::SkeletonFilter< _TImage, _TScalar >::
-~SkeletonFilter( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TImage, class _TScalar >
-void fpa::Image::SkeletonFilter< _TImage, _TScalar >::
-GenerateData( )
-{
- // Prepare distance map
- this->m_DistanceMap->Update( );
-
- // Update start seed
- TVertex seed;
- if( this->m_SeedFromMaximumDistance )
- {
- typedef itk::MinimumMaximumImageCalculator< TScalarImage > _TMinMax;
- typename _TMinMax::Pointer minmax = _TMinMax::New( );
- minmax->SetImage( this->m_DistanceMap->GetOutput( ) );
- minmax->Compute( );
- seed = minmax->GetIndexOfMaximum( );
- }
- else
- seed = *( this->BeginSeeds( ) );
- this->m_Seeds.clear( );
- this->m_Seeds.insert( seed );
-
- // Prepare skeleton candidates queue
- this->m_SkeletonQueue.clear( );
-
- // Go!
- this->Superclass::GenerateData( );
-
- // Backtracking
- _TAdjacencies A;
- std::vector< TVertex > end_points;
- this->_EndPoints( end_points, A );
- this->_Skeleton( end_points, A );
-}
-
-// -------------------------------------------------------------------------
-template< class _TImage, class _TScalar >
-void fpa::Image::SkeletonFilter< _TImage, _TScalar >::
-_SetOutputValue( const TVertex& vertex, const TOutputValue& value )
-{
- typedef typename _TSkeletonQueue::value_type _TSkeletonQueueValue;
-
- this->Superclass::_SetOutputValue( vertex, value );
- double d = double( this->m_DistanceMap->GetOutput( )->GetPixel( vertex ) );
- if( d >= double( 0 ) )
- {
- // Update skeleton candidates
- d += double( 1e-5 );
- double v = double( value ) / ( d * d );
- this->m_SkeletonQueue.insert( _TSkeletonQueueValue( v, vertex ) );
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-template< class _TImage, class _TScalar >
-void fpa::Image::SkeletonFilter< _TImage, _TScalar >::
-_EndPoints( std::vector< TVertex >& end_points, _TAdjacencies& A )
-{
- typedef typename _TSkeletonQueue::value_type _TSkeletonQueueValue;
-
- TMarks* marks = this->GetMarks( );
- TMST* mst = this->GetMinimumSpanningTree( );
- typename TImage::SpacingType 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
- typename _TSkeletonQueue::iterator nIt = this->m_SkeletonQueue.begin( );
- _TSkeletonQueueValue 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
- TVertex it = n.second;
- TVertex 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, class _TScalar >
-void fpa::Image::SkeletonFilter< _TImage, _TScalar >::
-_Skeleton( const std::vector< TVertex >& end_points, _TAdjacencies& A )
-{
- typedef typename TSkeleton::TPath _TPath;
- typedef itk::Image< unsigned long, TImage::ImageDimension > _TTagsImage;
-
- TMST* mst = this->GetMinimumSpanningTree( );
- TSkeleton* 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 );
- typename std::vector< TVertex >::const_iterator eIt = end_points.begin( );
- for( ; eIt != end_points.end( ); ++eIt )
- {
- TVertex it = *eIt;
- TVertex 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)
- eIt = end_points.begin( );
- for( ; eIt != end_points.end( ); ++eIt )
- {
- TVertex it = *eIt;
- TVertex p = mst->GetParent( it );
- TVertex sIdx = it;
- 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, class _TScalar >
-void fpa::Image::SkeletonFilter< _TImage, _TScalar >::
-_MarkSphere( const TVertex& idx )
-{
- typedef itk::ImageRegionIteratorWithIndex< TMarks > _TMarksIt;
-
- static const double _eps = std::sqrt( double( TImage::ImageDimension + 1 ) );
- const TScalarImage* dmap = this->m_DistanceMap->GetOutput( );
- TMarks* marks = this->GetMarks( );
- typename TImage::SpacingType spac = dmap->GetSpacing( );
- typename TImage::RegionType region = dmap->GetRequestedRegion( );
-
- typename TImage::PointType cnt;
- dmap->TransformIndexToPhysicalPoint( idx, cnt );
- double r = double( dmap->GetPixel( idx ) ) * _eps;
-
- TVertex i0, i1;
- for( unsigned int d = 0; d < TImage::ImageDimension; ++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 < TImage::ImageDimension; ++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 )
- {
- TVertex w = mIt.GetIndex( );
- typename TImage::PointType p;
- marks->TransformIndexToPhysicalPoint( w, p );
- mIt.Set( 1 );
-
- } // rof
-}
-
-#endif // __fpa__Image__SkeletonFilter__hxx__
-
-// eof - $RCSfile$
+++ /dev/null
-
-#include <fpa/fpa_export.h>
-#include <string>
-
-std::string FPA_EXPORT version( ) { return( "@prj_VERSION@" ); }
-
-// 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 "SkeletonFilter.h"
-#include <cpInstances/DataObjects/Image.h>
-#include <cpInstances/DataObjects/Skeleton.h>
-
-// -------------------------------------------------------------------------
-fpaPlugins_ImageAlgorithms::SkeletonFilter::
-SkeletonFilter( )
- : Superclass( )
-{
- typedef cpPlugins::Pipeline::DataObject _TData;
- typedef cpInstances::DataObjects::Image _TImage;
- typedef cpInstances::DataObjects::Skeleton _TSkeleton;
-
- this->_ConfigureInput< _TImage >( "Input", true, false );
- this->_ConfigureInput< _TData >( "Seeds", true, false );
- this->_ConfigureOutput< _TSkeleton >( "Output" );
-}
-
-// -------------------------------------------------------------------------
-fpaPlugins_ImageAlgorithms::SkeletonFilter::
-~SkeletonFilter( )
-{
-}
-
-// -------------------------------------------------------------------------
-void fpaPlugins_ImageAlgorithms::SkeletonFilter::
-_GenerateData( )
-{
- /* TODO
- 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 _TImage >
-void fpaPlugins_ImageAlgorithms::SkeletonFilter::
-_GD0( _TImage* image )
-{
- /* TODO
- 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__SkeletonFilter__h__
-#define __fpaPlugins_ImageAlgorithms__SkeletonFilter__h__
-
-#include <fpaPlugins_ImageAlgorithms_Export.h>
-#include <cpPlugins/Pipeline/ProcessObject.h>
-
-namespace fpaPlugins_ImageAlgorithms
-{
- /**
- */
- class fpaPlugins_ImageAlgorithms_EXPORT SkeletonFilter
- : public cpPlugins::Pipeline::ProcessObject
- {
- cpPluginsObject(
- SkeletonFilter,
- cpPlugins::Pipeline::ProcessObject,
- fpaImageAlgorithms
- );
-
- protected:
- template< class _TImage >
- inline void _GD0( _TImage* image );
- };
-
-} // ecapseman
-
-#endif // __fpaPlugins_ImageAlgorithms__SkeletonFilter__h__
-
-// eof - $RCSfile$