From 5bd12737b3a5054d972501d15678d2a245753b77 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Leonardo=20Fl=C3=B3rez-Valencia?= Date: Thu, 13 Jul 2017 16:15:46 -0500 Subject: [PATCH] ... --- appli/CTBronchi/CTBronchi_process.sh | 2 -- appli/CTBronchi/RandomWalker.cxx | 8 ++---- cmake/fpaConfig.cmake.in | 5 +--- lib/fpa/Image/Functors/Dijkstra/Gaussian.h | 33 +++++++--------------- lib/fpa/Image/MinimumSpanningTree.h | 16 +++++++++++ tests/image/Dijkstra_Gaussian.cxx | 9 +++--- tests/image/RandomWalker.cxx | 8 ++---- 7 files changed, 38 insertions(+), 43 deletions(-) diff --git a/appli/CTBronchi/CTBronchi_process.sh b/appli/CTBronchi/CTBronchi_process.sh index 15bd591..26257be 100755 --- a/appli/CTBronchi/CTBronchi_process.sh +++ b/appli/CTBronchi/CTBronchi_process.sh @@ -36,7 +36,6 @@ label_inside=1 label_outside=2 random_walker_output_image="$base_name"_rw.mhd -random_walker_alpha=0 random_walker_beta=20 $mori_seg \ @@ -63,7 +62,6 @@ $mori_lab \ $random_walker \ $input_image $labels_output_image $random_walker_output_image \ $label_inside \ - $random_walker_alpha \ $random_walker_beta ## eof - $RCSfile$ diff --git a/appli/CTBronchi/RandomWalker.cxx b/appli/CTBronchi/RandomWalker.cxx index 5704558..561dd36 100644 --- a/appli/CTBronchi/RandomWalker.cxx +++ b/appli/CTBronchi/RandomWalker.cxx @@ -29,12 +29,12 @@ typedef ivq::ITK::ImageUnaryFunctionFilter< TLabelImage, TBinaryImage > TLabelEx int main( int argc, char* argv[] ) { // Get arguments - if( argc < 7 ) + if( argc < 6 ) { std::cerr << "Usage: " << argv[ 0 ] << std::endl << " input_image label_image output_image" << std::endl - << " label alpha(0) beta(100)" + << " label beta(100)" << std::endl; return( 1 ); @@ -43,8 +43,7 @@ int main( int argc, char* argv[] ) std::string label_image_filename = argv[ 2 ]; std::string output_image_filename = argv[ 3 ]; TLabel label = TLabel( std::atoi( argv[ 4 ] ) ); - double alpha = std::atof( argv[ 5 ] ); - double beta = std::atof( argv[ 6 ] ); + double beta = std::atof( argv[ 5 ] ); // Read images itk::ImageFileReader< TInputImage >::Pointer input_image_reader = @@ -57,7 +56,6 @@ int main( int argc, char* argv[] ) // Prepare weight TWeight::Pointer weight = TWeight::New( ); - weight->SetAlpha( alpha ); weight->SetBeta( beta ); // Prepare filter diff --git a/cmake/fpaConfig.cmake.in b/cmake/fpaConfig.cmake.in index 62a9a8c..f019632 100644 --- a/cmake/fpaConfig.cmake.in +++ b/cmake/fpaConfig.cmake.in @@ -7,9 +7,6 @@ check_required_components("@PROJECT_NAME@") ## == Find needed packages and dependencies == ## =========================================== -set(ITK_DIR @ITK_DIR@) - -find_package(ITK CONFIG REQUIRED) -include(${ITK_USE_FILE}) +find_package(ivq CONFIG REQUIRED) ## eof - $RCSfile$ diff --git a/lib/fpa/Image/Functors/Dijkstra/Gaussian.h b/lib/fpa/Image/Functors/Dijkstra/Gaussian.h index 5187312..d06d84d 100644 --- a/lib/fpa/Image/Functors/Dijkstra/Gaussian.h +++ b/lib/fpa/Image/Functors/Dijkstra/Gaussian.h @@ -18,6 +18,7 @@ namespace fpa namespace Dijkstra { /** + * w_{i,j}=\left(\exp\left(\left(\frac{w_{i}-w_{j}}{\beta}\right)^{2}\right)-1\right)^{\alpha} */ template< class _TInputImage, class _TOutputValue > class Gaussian @@ -38,36 +39,22 @@ namespace fpa fpa::Image::Functors::Dijkstra::Function ); - public: - double GetAlpha( ) const - { - return( double( 1 ) - this->m_Alpha ); - } - double GetBeta( ) const - { - return( std::sqrt( this->m_Beta ) ); - } - void SetAlpha( const double& v ) - { - this->m_Alpha = double( 1 ) - v; - this->Modified( ); - } - void SetBeta( const double& v ) - { - this->m_Beta = v * v; - this->Modified( ); - } + itkGetConstMacro( Alpha, double ); + itkSetMacro( Alpha, double ); + itkGetConstMacro( Beta, double ); + itkSetMacro( Beta, double ); + + public: virtual _TOutputValue Evaluate( const TVertex& v, const TVertex& p ) const override { double d = double( this->m_Image->GetPixel( v ) ); d -= double( this->m_Image->GetPixel( p ) ); - d = ( d * d ) / this->m_Beta; - return( - _TOutputValue( double( 1 ) - ( this->m_Alpha * std::exp( -d ) ) ) - ); + d /= this->m_Beta; + d = std::exp( d * d ) - double( 1 ); + return( _TOutputValue( std::pow( d, this->m_Alpha ) ) ); } protected: diff --git a/lib/fpa/Image/MinimumSpanningTree.h b/lib/fpa/Image/MinimumSpanningTree.h index a93157c..46d2231 100644 --- a/lib/fpa/Image/MinimumSpanningTree.h +++ b/lib/fpa/Image/MinimumSpanningTree.h @@ -8,6 +8,7 @@ #include #include +#include namespace fpa { @@ -33,6 +34,8 @@ namespace fpa typedef typename Superclass::TCollisions TCollisions; typedef typename Superclass::TVertices TVertices; + typedef fpa::Image::PolyLineParametricPath< _VDim > TPolyLineParametricPath; + public: itkNewMacro( Self ); itkTypeMacro( @@ -50,6 +53,15 @@ namespace fpa this->SetPixel( v, p - v ); } + void GetPath( + typename TPolyLineParametricPath::Pointer& path, + const TVertex& a + ) const; + void GetPath( + typename TPolyLineParametricPath::Pointer& path, + const TVertex& a, const TVertex& b + ) const; + protected: MinimumSpanningTree( ) : Superclass( ) @@ -66,6 +78,10 @@ namespace fpa } // ecapseman +#ifndef ITK_MANUAL_INSTANTIATION +# include +#endif // ITK_MANUAL_INSTANTIATION + #endif // __fpa__Image__MinimumSpanningTree__h__ // eof - $RCSfile$ diff --git a/tests/image/Dijkstra_Gaussian.cxx b/tests/image/Dijkstra_Gaussian.cxx index 1e147c6..5622e7f 100644 --- a/tests/image/Dijkstra_Gaussian.cxx +++ b/tests/image/Dijkstra_Gaussian.cxx @@ -4,9 +4,9 @@ #include // ------------------------------------------------------------------------- -const unsigned int Dim = 2; -typedef unsigned char TPixel; -typedef float TScalar; +const unsigned int Dim = 3; +typedef short TPixel; +typedef float TScalar; typedef itk::Image< TPixel, Dim > TInputImage; typedef itk::Image< TScalar, Dim > TScalarImage; @@ -56,13 +56,14 @@ int main( int argc, char* argv[] ) filter->SetStopAtOneFront( stop_at_one_front ); // Get all seeds - for( int i = 7; i < argc; i += 2 ) + for( int i = 7; i < argc; i += 3 ) { if( i + 1 < argc ) { TInputImage::IndexType seed; seed[ 0 ] = std::atoi( argv[ i ] ); seed[ 1 ] = std::atoi( argv[ i + 1 ] ); + seed[ 2 ] = std::atoi( argv[ i + 2 ] ); filter->AddSeed( seed ); } // fi diff --git a/tests/image/RandomWalker.cxx b/tests/image/RandomWalker.cxx index 45a15c1..6bdca1c 100644 --- a/tests/image/RandomWalker.cxx +++ b/tests/image/RandomWalker.cxx @@ -18,12 +18,12 @@ typedef fpa::Image::Functors::Dijkstra::Gaussian< TInputImage, TScalar > TWeight int main( int argc, char* argv[] ) { // Get arguments - if( argc < 7 ) + if( argc < 6 ) { std::cerr << "Usage: " << argv[ 0 ] << " input_image labels_image output_image output_costs" - << " alpha beta" + << " beta" << std::endl; return( 1 ); @@ -32,8 +32,7 @@ int main( int argc, char* argv[] ) std::string labels_image_filename = argv[ 2 ]; std::string output_image_filename = argv[ 3 ]; std::string output_costs_filename = argv[ 4 ]; - double alpha = std::atof( argv[ 5 ] ); - double beta = std::atof( argv[ 6 ] ); + double beta = std::atof( argv[ 5 ] ); // Read image TInputImage::Pointer image; @@ -57,7 +56,6 @@ int main( int argc, char* argv[] ) // Prepare weight TWeight::Pointer weight = TWeight::New( ); - weight->SetAlpha( alpha ); weight->SetBeta( beta ); // Prepare filter -- 2.45.1