From 1256a0131728279e2a85a9e24b1a69ea69a4f516 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Leonardo=20Fl=C3=B3rez-Valencia?= Date: Tue, 29 Nov 2016 18:16:43 -0500 Subject: [PATCH] ... --- CMakeLists.txt | 2 +- appli/CMakeLists.txt | 5 ++ appli/experiments/CMakeLists.txt | 8 +++ appli/experiments/Skeleton_00.cxx | 91 ++++++++++++++++++++++++++++ plugins/ImageAlgorithms/BaseFilter.h | 6 +- 5 files changed, 109 insertions(+), 3 deletions(-) create mode 100644 appli/experiments/CMakeLists.txt create mode 100644 appli/experiments/Skeleton_00.cxx diff --git a/CMakeLists.txt b/CMakeLists.txt index a5fba66..2c06df5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,6 +55,6 @@ INCLUDE(cmake/Functions.cmake) ## == Build different parts == ## =========================== -SUBDIRS(lib plugins) +SUBDIRS(appli lib plugins) ## eof - $RCSfile$ diff --git a/appli/CMakeLists.txt b/appli/CMakeLists.txt index a5a2028..6380a79 100644 --- a/appli/CMakeLists.txt +++ b/appli/CMakeLists.txt @@ -3,4 +3,9 @@ IF(BUILD_EXAMPLES) SUBDIRS(examples) ENDIF(BUILD_EXAMPLES) +OPTION(BUILD_EXPERIMENTS "Build experiments" OFF) +IF(BUILD_EXPERIMENTS) + SUBDIRS(experiments) +ENDIF(BUILD_EXPERIMENTS) + ## eof - $RCSfile$ diff --git a/appli/experiments/CMakeLists.txt b/appli/experiments/CMakeLists.txt new file mode 100644 index 0000000..3be8e1c --- /dev/null +++ b/appli/experiments/CMakeLists.txt @@ -0,0 +1,8 @@ +INCLUDE_DIRECTORIES( + ${PROJECT_SOURCE_DIR}/lib + ${PROJECT_BINARY_DIR}/lib + ) +ADD_EXECUTABLE(fpa_experiments_Skeleton_00 Skeleton_00.cxx) +TARGET_LINK_LIBRARIES(fpa_experiments_Skeleton_00 ${ITK_LIBRARIES} ${VTK_LIBRARIES}) + +## eof - $RCSfile$ diff --git a/appli/experiments/Skeleton_00.cxx b/appli/experiments/Skeleton_00.cxx new file mode 100644 index 0000000..11b49f2 --- /dev/null +++ b/appli/experiments/Skeleton_00.cxx @@ -0,0 +1,91 @@ +#include +#include +#include +#include +#include +#include +#include + +typedef double TScalar; +typedef itk::Image< TScalar, 3 > TImage; +typedef itk::MinimumMaximumImageCalculator< TImage > TMinMax; +typedef itk::SignedMaurerDistanceMapImageFilter< TImage, TImage > TDMap; +typedef fpa::Image::SkeletonFilter< TImage > TSkeletonFilter; +typedef TSkeletonFilter::TSkeleton TSkeleton; +typedef cpExtensions::Algorithms::SkeletonToImageFilter< TSkeleton, TImage > TSkeletonToImage; +typedef itk::ImageFileReader< TImage > TReader; +typedef itk::ImageFileWriter< TImage > TWriter; + +int main( int argc, char* argv[] ) +{ + if( argc < 4 ) + { + std::cerr + << "Usage: " << argv[ 0 ] + << " image prefix number_of_samples [seed_x seed_y seed_z]" + << std::endl; + return( 1 ); + + } // fi + std::string image_name = argv[ 1 ]; + + TReader::Pointer reader = TReader::New( ); + reader->SetFileName( image_name ); + reader->Update( ); + + TDMap::Pointer dmap = TDMap::New( ); + dmap->SetInput( reader->GetOutput( ) ); + dmap->InsideIsPositiveOn( ); + dmap->Update( ); + const TImage* image = dmap->GetOutput( ); + + std::string prefix = argv[ 2 ]; + std::istringstream str( argv[ 3 ] ); + unsigned int number_of_samples; + str >> number_of_samples; + TImage::IndexType seed; + if( argc < 7 ) + { + TMinMax::Pointer minmax = TMinMax::New( ); + minmax->SetImage( image ); + minmax->Compute( ); + seed = minmax->GetIndexOfMaximum( ); + } + else + { + std::istringstream str_x( argv[ 4 ] ); + std::istringstream str_y( argv[ 5 ] ); + std::istringstream str_z( argv[ 6 ] ); + TImage::PointType pnt; + str_x >> pnt[ 0 ]; + str_y >> pnt[ 1 ]; + str_z >> pnt[ 2 ]; + image->TransformPhysicalPointToIndex( pnt, seed ); + + } // fi + + for( unsigned int i = 0; i < number_of_samples; ++i ) + { + std::cout << i << std::endl; + TSkeletonFilter::Pointer skeleton = TSkeletonFilter::New( ); + skeleton->SetInput( image ); + skeleton->AddSeed( seed, 0 ); + skeleton->Update( ); + + TSkeletonToImage::Pointer sk2im = TSkeletonToImage::New( ); + sk2im->SetTemplateImage( image ); + sk2im->SetSkeleton( skeleton->GetSkeleton( ) ); + sk2im->SetOutsideValue( 0 ); + sk2im->SetInsideValue( 1 ); + sk2im->Update( ); + + TWriter::Pointer writer = TWriter::New( ); + writer->SetInput( sk2im->GetOutput( ) ); + writer->SetFileName( "skeleton.mhd" ); + writer->Update( ); + + } // rof + return( 0 ); +} + +// eof - $RCSfile$ diff --git a/plugins/ImageAlgorithms/BaseFilter.h b/plugins/ImageAlgorithms/BaseFilter.h index 11c97ca..9808e46 100644 --- a/plugins/ImageAlgorithms/BaseFilter.h +++ b/plugins/ImageAlgorithms/BaseFilter.h @@ -51,12 +51,14 @@ namespace fpaPluginsImageAlgorithms } // ecapseman // ------------------------------------------------------------------------- - template< class _TFilter, class _TImage > +template< class _TFilter, class _TImage > void fpaPluginsImageAlgorithms::BaseFilter:: _ConfigureFilter( _TFilter* filter, _TImage* image ) { typedef typename _TFilter::TNeighborhoodFunction _TNeighborhood; - typedef fpa::Image::Functors::SimpleNeighborhood< _TImage > _TSimpleNeigh; + typedef + fpa::Image::Functors::SimpleNeighborhood< typename _TImage::Superclass > + _TSimpleNeigh; // Simple configuration filter->SetInput( image ); -- 2.47.1