From 1b83bb346b8416eab760148e7ec92eb8b4a9024c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Leonardo=20Fl=C3=B3rez-Valencia?= Date: Mon, 13 Mar 2017 20:07:34 -0500 Subject: [PATCH] ... --- examples/CMakeLists.txt | 4 ++ .../Image/{MoriRegionGrow.h => MoriFilter.h} | 28 ++++---- .../{MoriRegionGrow.hxx => MoriFilter.hxx} | 68 +++++++++++-------- ...iRegionGrowHelper.h => MoriFilterHelper.h} | 20 +++--- ...ionGrowHelper.hxx => MoriFilterHelper.hxx} | 29 ++++---- 5 files changed, 85 insertions(+), 64 deletions(-) rename libs/fpa/Image/{MoriRegionGrow.h => MoriFilter.h} (77%) rename libs/fpa/Image/{MoriRegionGrow.hxx => MoriFilter.hxx} (64%) rename libs/fpa/Image/{MoriRegionGrowHelper.h => MoriFilterHelper.h} (82%) rename libs/fpa/Image/{MoriRegionGrowHelper.hxx => MoriFilterHelper.hxx} (81%) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index ddaadf3..8205f49 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -4,6 +4,10 @@ IF(BUILD_EXAMPLES) _examples BronchiiInitialSegmentationWithMori ) + INCLUDE_DIRECTORIES( + ${PROJECT_SOURCE_DIR}/libs + ${PROJECT_BINARY_DIR}/libs + ) FOREACH(_e ${_examples}) ADD_EXECUTABLE(fpa_example_${_e} ${_e}.cxx) TARGET_LINK_LIBRARIES(fpa_example_${_e} ${ITK_LIBRARIES}) diff --git a/libs/fpa/Image/MoriRegionGrow.h b/libs/fpa/Image/MoriFilter.h similarity index 77% rename from libs/fpa/Image/MoriRegionGrow.h rename to libs/fpa/Image/MoriFilter.h index 41c122e..0707ff5 100644 --- a/libs/fpa/Image/MoriRegionGrow.h +++ b/libs/fpa/Image/MoriFilter.h @@ -1,9 +1,9 @@ -#ifndef __fpa__Image__MoriRegionGrow__h__ -#define __fpa__Image__MoriRegionGrow__h__ +#ifndef __fpa__Image__MoriFilter__h__ +#define __fpa__Image__MoriFilter__h__ #include #include -#include +#include namespace fpa { @@ -12,17 +12,17 @@ namespace fpa /** */ template< class _TInputImage, class _TOutputImage, class _TAuxPixel = unsigned short > - class MoriRegionGrow + class MoriFilter : public itk::ImageToImageFilter< _TInputImage, _TOutputImage > { public: - typedef MoriRegionGrow Self; + typedef MoriFilter Self; typedef itk::ImageToImageFilter< _TInputImage, _TOutputImage > Superclass; typedef itk::SmartPointer< Self > Pointer; typedef itk::SmartPointer< const Self > ConstPointer; typedef itk::Image< _TAuxPixel, _TInputImage::ImageDimension > TAuxImage; - typedef fpa::Image::MoriRegionGrowHelper< _TInputImage, TAuxImage > THelper; + typedef fpa::Image::MoriFilterHelper< _TInputImage, TAuxImage > THelper; typedef itk::BinaryThresholdImageFilter< TAuxImage, _TOutputImage > TThreshold; typedef typename _TInputImage::IndexType TIndex; @@ -31,7 +31,7 @@ namespace fpa public: itkNewMacro( Self ); - itkTypeMacro( fpa::Image::MoriRegionGrow, itk::ImageToImageFilter ); + itkTypeMacro( fpa::Image::MoriFilter, itk::ImageToImageFilter ); itkGetConstMacro( Seed, TIndex ); itkSetMacro( Seed, TIndex ); @@ -49,6 +49,10 @@ namespace fpa void SetLower( const TInputPixel& v ); void SetUpper( const TInputPixel& v ); void SetStep( const TInputPixel& v ); + void SetThresholdRange( + const TInputPixel& l, const TInputPixel& u, + const TInputPixel& s = TInputPixel( 1 ) + ); void SetInsideValue( const TOutputPixel& v ); void SetOutsideValue( const TOutputPixel& v ); @@ -65,14 +69,14 @@ namespace fpa */ protected: - MoriRegionGrow( ); - virtual ~MoriRegionGrow( ); + MoriFilter( ); + virtual ~MoriFilter( ); virtual void GenerateData( ) override; private: // Purposely not defined - MoriRegionGrow( const Self& other ); + MoriFilter( const Self& other ); Self& operator=( const Self& other ); protected: @@ -86,9 +90,9 @@ namespace fpa } // ecapseman #ifndef ITK_MANUAL_INSTANTIATION -# include +# include #endif // ITK_MANUAL_INSTANTIATION -#endif // __fpa__Image__MoriRegionGrow__h__ +#endif // __fpa__Image__MoriFilter__h__ // eof - $RCSfile$ diff --git a/libs/fpa/Image/MoriRegionGrow.hxx b/libs/fpa/Image/MoriFilter.hxx similarity index 64% rename from libs/fpa/Image/MoriRegionGrow.hxx rename to libs/fpa/Image/MoriFilter.hxx index 737bf1f..9f822c9 100644 --- a/libs/fpa/Image/MoriRegionGrow.hxx +++ b/libs/fpa/Image/MoriFilter.hxx @@ -1,12 +1,12 @@ -#ifndef __fpa__Image__MoriRegionGrow__hxx__ -#define __fpa__Image__MoriRegionGrow__hxx__ +#ifndef __fpa__Image__MoriFilter__hxx__ +#define __fpa__Image__MoriFilter__hxx__ // ------------------------------------------------------------------------- template< class _TInputImage, class _TOutputImage, class _TAuxPixel > typename -fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage, _TAuxPixel >:: +fpa::Image::MoriFilter< _TInputImage, _TOutputImage, _TAuxPixel >:: TAuxImage* -fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage, _TAuxPixel >:: +fpa::Image::MoriFilter< _TInputImage, _TOutputImage, _TAuxPixel >:: GetAuxiliaryImage( ) { return( this->m_Helper->GetOutput( ) ); @@ -15,9 +15,9 @@ GetAuxiliaryImage( ) // ------------------------------------------------------------------------- template< class _TInputImage, class _TOutputImage, class _TAuxPixel > const typename -fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage, _TAuxPixel >:: +fpa::Image::MoriFilter< _TInputImage, _TOutputImage, _TAuxPixel >:: TAuxImage* -fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage, _TAuxPixel >:: +fpa::Image::MoriFilter< _TInputImage, _TOutputImage, _TAuxPixel >:: GetAuxiliaryImage( ) const { return( this->m_Helper->GetOutput( ) ); @@ -26,9 +26,9 @@ GetAuxiliaryImage( ) const // ------------------------------------------------------------------------- template< class _TInputImage, class _TOutputImage, class _TAuxPixel > typename -fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage, _TAuxPixel >:: +fpa::Image::MoriFilter< _TInputImage, _TOutputImage, _TAuxPixel >:: TInputPixel -fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage, _TAuxPixel >:: +fpa::Image::MoriFilter< _TInputImage, _TOutputImage, _TAuxPixel >:: GetLower( ) const { return( this->m_Helper->GetLower( ) ); @@ -37,9 +37,9 @@ GetLower( ) const // ------------------------------------------------------------------------- template< class _TInputImage, class _TOutputImage, class _TAuxPixel > typename -fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage, _TAuxPixel >:: +fpa::Image::MoriFilter< _TInputImage, _TOutputImage, _TAuxPixel >:: TInputPixel -fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage, _TAuxPixel >:: +fpa::Image::MoriFilter< _TInputImage, _TOutputImage, _TAuxPixel >:: GetUpper( ) const { return( this->m_Helper->GetUpper( ) ); @@ -48,9 +48,9 @@ GetUpper( ) const // ------------------------------------------------------------------------- template< class _TInputImage, class _TOutputImage, class _TAuxPixel > typename -fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage, _TAuxPixel >:: +fpa::Image::MoriFilter< _TInputImage, _TOutputImage, _TAuxPixel >:: TInputPixel -fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage, _TAuxPixel >:: +fpa::Image::MoriFilter< _TInputImage, _TOutputImage, _TAuxPixel >:: GetStep( ) const { return( this->m_Helper->GetStep( ) ); @@ -59,9 +59,9 @@ GetStep( ) const // ------------------------------------------------------------------------- template< class _TInputImage, class _TOutputImage, class _TAuxPixel > typename -fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage, _TAuxPixel >:: +fpa::Image::MoriFilter< _TInputImage, _TOutputImage, _TAuxPixel >:: TOutputPixel -fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage, _TAuxPixel >:: +fpa::Image::MoriFilter< _TInputImage, _TOutputImage, _TAuxPixel >:: GetInsideValue( ) const { return( this->m_Threshold->GetInsideValue( ) ); @@ -70,9 +70,9 @@ GetInsideValue( ) const // ------------------------------------------------------------------------- template< class _TInputImage, class _TOutputImage, class _TAuxPixel > typename -fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage, _TAuxPixel >:: +fpa::Image::MoriFilter< _TInputImage, _TOutputImage, _TAuxPixel >:: TOutputPixel -fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage, _TAuxPixel >:: +fpa::Image::MoriFilter< _TInputImage, _TOutputImage, _TAuxPixel >:: GetOutsideValue( ) const { return( this->m_Threshold->GetInsideValue( ) ); @@ -80,7 +80,7 @@ GetOutsideValue( ) const // ------------------------------------------------------------------------- template< class _TInputImage, class _TOutputImage, class _TAuxPixel > -void fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage, _TAuxPixel >:: +void fpa::Image::MoriFilter< _TInputImage, _TOutputImage, _TAuxPixel >:: SetLower( const TInputPixel& v ) { this->m_Helper->SetLower( v ); @@ -89,7 +89,7 @@ SetLower( const TInputPixel& v ) // ------------------------------------------------------------------------- template< class _TInputImage, class _TOutputImage, class _TAuxPixel > -void fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage, _TAuxPixel >:: +void fpa::Image::MoriFilter< _TInputImage, _TOutputImage, _TAuxPixel >:: SetUpper( const TInputPixel& v ) { this->m_Helper->SetUpper( v ); @@ -98,7 +98,7 @@ SetUpper( const TInputPixel& v ) // ------------------------------------------------------------------------- template< class _TInputImage, class _TOutputImage, class _TAuxPixel > -void fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage, _TAuxPixel >:: +void fpa::Image::MoriFilter< _TInputImage, _TOutputImage, _TAuxPixel >:: SetStep( const TInputPixel& v ) { this->m_Helper->SetStep( v ); @@ -107,7 +107,19 @@ SetStep( const TInputPixel& v ) // ------------------------------------------------------------------------- template< class _TInputImage, class _TOutputImage, class _TAuxPixel > -void fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage, _TAuxPixel >:: +void fpa::Image::MoriFilter< _TInputImage, _TOutputImage, _TAuxPixel >:: +SetThresholdRange( + const TInputPixel& l, const TInputPixel& u, const TInputPixel& s + ) +{ + this->SetLower( l ); + this->SetUpper( u ); + this->SetStep( s ); +} + +// ------------------------------------------------------------------------- +template< class _TInputImage, class _TOutputImage, class _TAuxPixel > +void fpa::Image::MoriFilter< _TInputImage, _TOutputImage, _TAuxPixel >:: SetInsideValue( const TOutputPixel& v ) { this->m_Threshold->SetInsideValue( v ); @@ -116,7 +128,7 @@ SetInsideValue( const TOutputPixel& v ) // ------------------------------------------------------------------------- template< class _TInputImage, class _TOutputImage, class _TAuxPixel > -void fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage, _TAuxPixel >:: +void fpa::Image::MoriFilter< _TInputImage, _TOutputImage, _TAuxPixel >:: SetOutsideValue( const TOutputPixel& v ) { this->m_Threshold->SetOutsideValue( v ); @@ -125,8 +137,8 @@ SetOutsideValue( const TOutputPixel& v ) // ------------------------------------------------------------------------- template< class _TInputImage, class _TOutputImage, class _TAuxPixel > -fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage, _TAuxPixel >:: -MoriRegionGrow( ) +fpa::Image::MoriFilter< _TInputImage, _TOutputImage, _TAuxPixel >:: +MoriFilter( ) : Superclass( ) { this->m_Helper = THelper::New( ); @@ -135,18 +147,18 @@ MoriRegionGrow( ) // ------------------------------------------------------------------------- template< class _TInputImage, class _TOutputImage, class _TAuxPixel > -fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage, _TAuxPixel >:: -~MoriRegionGrow( ) +fpa::Image::MoriFilter< _TInputImage, _TOutputImage, _TAuxPixel >:: +~MoriFilter( ) { } // ------------------------------------------------------------------------- template< class _TInputImage, class _TOutputImage, class _TAuxPixel > -void fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage, _TAuxPixel >:: +void fpa::Image::MoriFilter< _TInputImage, _TOutputImage, _TAuxPixel >:: GenerateData( ) { this->m_Helper->ClearSeeds( ); - this->m_Helper->AddSeed( this->m_Seed, 0 ); + this->m_Helper->AddSeed( this->m_Seed, this->GetOutsideValue( ) ); this->m_Helper->SetInput( this->GetInput( ) ); this->m_Helper->Update( ); @@ -157,6 +169,6 @@ GenerateData( ) this->GetOutput( )->Graft( this->m_Threshold->GetOutput( ) ); } -#endif // __fpa__Image__MoriRegionGrow__hxx__ +#endif // __fpa__Image__MoriFilter__hxx__ // eof - $RCSfile$ diff --git a/libs/fpa/Image/MoriRegionGrowHelper.h b/libs/fpa/Image/MoriFilterHelper.h similarity index 82% rename from libs/fpa/Image/MoriRegionGrowHelper.h rename to libs/fpa/Image/MoriFilterHelper.h index 02f51b6..6d55ec7 100644 --- a/libs/fpa/Image/MoriRegionGrowHelper.h +++ b/libs/fpa/Image/MoriFilterHelper.h @@ -1,5 +1,5 @@ -#ifndef __fpa__Image__MoriRegionGrowHelper__h__ -#define __fpa__Image__MoriRegionGrowHelper__h__ +#ifndef __fpa__Image__MoriFilterHelper__h__ +#define __fpa__Image__MoriFilterHelper__h__ #include #include @@ -13,11 +13,11 @@ namespace fpa /** */ template< class _TInputImage, class _TOutputImage > - class MoriRegionGrowHelper + class MoriFilterHelper : public fpa::Image::RegionGrow< _TInputImage, _TOutputImage > { public: - typedef MoriRegionGrowHelper Self; + typedef MoriFilterHelper Self; typedef fpa::Image::RegionGrow< _TInputImage, _TOutputImage > Superclass; typedef itk::SmartPointer< Self > Pointer; typedef itk::SmartPointer< const Self > ConstPointer; @@ -37,7 +37,7 @@ namespace fpa public: itkNewMacro( Self ); - itkTypeMacro( fpa::Image::MoriRegionGrowHelper, fpa::Image::RegionGrow ); + itkTypeMacro( fpa::Image::MoriFilterHelper, fpa::Image::RegionGrow ); itkGetConstMacro( Lower, TPixel ); itkGetConstMacro( Upper, TPixel ); @@ -50,8 +50,8 @@ namespace fpa protected: - MoriRegionGrowHelper( ); - virtual ~MoriRegionGrowHelper( ); + MoriFilterHelper( ); + virtual ~MoriFilterHelper( ); virtual bool _ContinueGenerateData( ) override; virtual void _BeforeGenerateData( ) override; @@ -63,7 +63,7 @@ namespace fpa private: // Purposely not defined - MoriRegionGrowHelper( const Self& other ); + MoriFilterHelper( const Self& other ); Self& operator=( const Self& other ); protected: @@ -82,9 +82,9 @@ namespace fpa } // ecapseman #ifndef ITK_MANUAL_INSTANTIATION -# include +# include #endif // ITK_MANUAL_INSTANTIATION -#endif // __fpa__Image__MoriRegionGrowHelper__h__ +#endif // __fpa__Image__MoriFilterHelper__h__ // eof - $RCSfile$ diff --git a/libs/fpa/Image/MoriRegionGrowHelper.hxx b/libs/fpa/Image/MoriFilterHelper.hxx similarity index 81% rename from libs/fpa/Image/MoriRegionGrowHelper.hxx rename to libs/fpa/Image/MoriFilterHelper.hxx index 9dc1df3..4ddb234 100644 --- a/libs/fpa/Image/MoriRegionGrowHelper.hxx +++ b/libs/fpa/Image/MoriFilterHelper.hxx @@ -1,10 +1,10 @@ -#ifndef __fpa__Image__MoriRegionGrowHelper__hxx__ -#define __fpa__Image__MoriRegionGrowHelper__hxx__ +#ifndef __fpa__Image__MoriFilterHelper__hxx__ +#define __fpa__Image__MoriFilterHelper__hxx__ // ------------------------------------------------------------------------- template< class _TInputImage, class _TOutputImage > -fpa::Image::MoriRegionGrowHelper< _TInputImage, _TOutputImage >:: -MoriRegionGrowHelper( ) +fpa::Image::MoriFilterHelper< _TInputImage, _TOutputImage >:: +MoriFilterHelper( ) : Superclass( ), m_Step( TPixel( 1 ) ) { @@ -20,14 +20,14 @@ MoriRegionGrowHelper( ) // ------------------------------------------------------------------------- template< class _TInputImage, class _TOutputImage > -fpa::Image::MoriRegionGrowHelper< _TInputImage, _TOutputImage >:: -~MoriRegionGrowHelper( ) +fpa::Image::MoriFilterHelper< _TInputImage, _TOutputImage >:: +~MoriFilterHelper( ) { } // ------------------------------------------------------------------------- template< class _TInputImage, class _TOutputImage > -bool fpa::Image::MoriRegionGrowHelper< _TInputImage, _TOutputImage >:: +bool fpa::Image::MoriFilterHelper< _TInputImage, _TOutputImage >:: _ContinueGenerateData( ) { TBinThresholdFunction* functor = @@ -36,6 +36,7 @@ _ContinueGenerateData( ) // Update flooding data this->m_Curve.push_back( TCurveData( u, this->m_ActualCount ) ); + std::cout << u << " " << this->m_ActualCount << std::endl; // Update thresholds if( u < this->m_Upper ) @@ -55,7 +56,7 @@ _ContinueGenerateData( ) // ------------------------------------------------------------------------- template< class _TInputImage, class _TOutputImage > -void fpa::Image::MoriRegionGrowHelper< _TInputImage, _TOutputImage >:: +void fpa::Image::MoriFilterHelper< _TInputImage, _TOutputImage >:: _BeforeGenerateData( ) { this->Superclass::_BeforeGenerateData( ); @@ -73,7 +74,7 @@ _BeforeGenerateData( ) // ------------------------------------------------------------------------- template< class _TInputImage, class _TOutputImage > -void fpa::Image::MoriRegionGrowHelper< _TInputImage, _TOutputImage >:: +void fpa::Image::MoriFilterHelper< _TInputImage, _TOutputImage >:: _AfterGenerateData( ) { typedef typename _TOutputImage::PixelType _TOut; @@ -102,7 +103,7 @@ _AfterGenerateData( ) // ------------------------------------------------------------------------- template< class _TInputImage, class _TOutputImage > -void fpa::Image::MoriRegionGrowHelper< _TInputImage, _TOutputImage >:: +void fpa::Image::MoriFilterHelper< _TInputImage, _TOutputImage >:: _BeforeLoop( ) { this->Superclass::_BeforeLoop( ); @@ -110,7 +111,7 @@ _BeforeLoop( ) // ------------------------------------------------------------------------- template< class _TInputImage, class _TOutputImage > -void fpa::Image::MoriRegionGrowHelper< _TInputImage, _TOutputImage >:: +void fpa::Image::MoriFilterHelper< _TInputImage, _TOutputImage >:: _AfterLoop( ) { this->Superclass::_AfterLoop( ); @@ -118,7 +119,7 @@ _AfterLoop( ) // ------------------------------------------------------------------------- template< class _TInputImage, class _TOutputImage > -bool fpa::Image::MoriRegionGrowHelper< _TInputImage, _TOutputImage >:: +bool fpa::Image::MoriFilterHelper< _TInputImage, _TOutputImage >:: _UpdateValue( _TQueueNode& v, const _TQueueNode& p ) { typedef typename _TOutputImage::PixelType _TOut; @@ -132,13 +133,13 @@ _UpdateValue( _TQueueNode& v, const _TQueueNode& p ) // ------------------------------------------------------------------------- template< class _TInputImage, class _TOutputImage > -void fpa::Image::MoriRegionGrowHelper< _TInputImage, _TOutputImage >:: +void fpa::Image::MoriFilterHelper< _TInputImage, _TOutputImage >:: _UpdateResult( const _TQueueNode& n ) { this->Superclass::_UpdateResult( n ); this->m_ActualCount += 1; } -#endif // __fpa__Image__MoriRegionGrowHelper__hxx__ +#endif // __fpa__Image__MoriFilterHelper__hxx__ // eof - $RCSfile$ -- 2.45.0