From 17f052241f7ab67015e3a34f7564da17da8a0e07 Mon Sep 17 00:00:00 2001 From: Leonardo Florez-Valencia Date: Tue, 21 Jun 2016 17:09:33 -0500 Subject: [PATCH] New plugins added. --- .../RegionOfInterestImageCalculator.h | 73 ++++++ .../RegionOfInterestImageCalculator.hxx | 92 +++++++ .../Algorithms/UnaryThresholdImageFilter.h | 102 ++++++++ .../Algorithms/UnaryThresholdImageFilter.hxx | 245 ++++++++++++++++++ lib/cpPlugins_Instances/CMakeLists.txt | 4 + lib/cpPlugins_Instances/ExtractImageFilters.i | 18 ++ .../MorphologicalImageFilters.i | 21 ++ lib/cpPlugins_Instances/ThresholdFilters.i | 2 + .../BinaryDilateParaImageFilter.cxx | 53 ++++ .../BinaryDilateParaImageFilter.h | 44 ++++ .../BinaryErodeParaImageFilter.cxx | 53 ++++ .../BinaryErodeParaImageFilter.h | 44 ++++ .../cpPluginsImageFilters/CastImageFilter.h | 2 +- plugins/cpPluginsImageFilters/OrImageFilter.h | 2 +- .../RegionOfInterestImageFilter.cxx | 72 +++++ .../RegionOfInterestImageFilter.h | 44 ++++ .../UnaryThresholdImageFilter.cxx | 59 +++++ .../UnaryThresholdImageFilter.h | 44 ++++ .../cpPlugins_Install_ITK.sh | 1 + 19 files changed, 973 insertions(+), 2 deletions(-) create mode 100644 lib/cpExtensions/Algorithms/RegionOfInterestImageCalculator.h create mode 100644 lib/cpExtensions/Algorithms/RegionOfInterestImageCalculator.hxx create mode 100644 lib/cpExtensions/Algorithms/UnaryThresholdImageFilter.h create mode 100644 lib/cpExtensions/Algorithms/UnaryThresholdImageFilter.hxx create mode 100644 lib/cpPlugins_Instances/ExtractImageFilters.i create mode 100644 lib/cpPlugins_Instances/MorphologicalImageFilters.i create mode 100644 plugins/cpPluginsImageFilters/BinaryDilateParaImageFilter.cxx create mode 100644 plugins/cpPluginsImageFilters/BinaryDilateParaImageFilter.h create mode 100644 plugins/cpPluginsImageFilters/BinaryErodeParaImageFilter.cxx create mode 100644 plugins/cpPluginsImageFilters/BinaryErodeParaImageFilter.h create mode 100644 plugins/cpPluginsImageFilters/RegionOfInterestImageFilter.cxx create mode 100644 plugins/cpPluginsImageFilters/RegionOfInterestImageFilter.h create mode 100644 plugins/cpPluginsImageFilters/UnaryThresholdImageFilter.cxx create mode 100644 plugins/cpPluginsImageFilters/UnaryThresholdImageFilter.h diff --git a/lib/cpExtensions/Algorithms/RegionOfInterestImageCalculator.h b/lib/cpExtensions/Algorithms/RegionOfInterestImageCalculator.h new file mode 100644 index 0000000..84102ad --- /dev/null +++ b/lib/cpExtensions/Algorithms/RegionOfInterestImageCalculator.h @@ -0,0 +1,73 @@ +// ------------------------------------------------------------------------- +// @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co) +// ------------------------------------------------------------------------- + +#ifndef __CPEXTENSIONS__ALGORITHMS__REGIONOFINTERESTIMAGECALCULATOR__H__ +#define __CPEXTENSIONS__ALGORITHMS__REGIONOFINTERESTIMAGECALCULATOR__H__ + +#include +#include + +namespace cpExtensions +{ + namespace Algorithms + { + /** + */ + template< class _TImage > + class RegionOfInterestImageCalculator + : public itk::Object + { + public: + // Basic types + typedef RegionOfInterestImageCalculator Self; + typedef itk::Object Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; + + typedef _TImage TImage; + typedef typename _TImage::IndexType TIndex; + typedef typename _TImage::PixelType TPixel; + + public: + itkNewMacro( Self ); + itkTypeMacro( RegionOfInterestImageCalculator, itkObject ); + + itkGetConstObjectMacro( Image, _TImage ); + itkGetConstMacro( BackgroundValue, TPixel ); + itkGetConstMacro( Minimum, TIndex ); + itkGetConstMacro( Maximum, TIndex ); + + itkSetConstObjectMacro( Image, _TImage ); + itkSetMacro( BackgroundValue, TPixel ); + + public: + void Compute( ); + + protected: + RegionOfInterestImageCalculator( ); + virtual ~RegionOfInterestImageCalculator( ); + + private: + // Purposely not implemented + RegionOfInterestImageCalculator( const Self& ); + void operator=( const Self& ); + + protected: + typename _TImage::ConstPointer m_Image; + TPixel m_BackgroundValue; + TIndex m_Minimum; + TIndex m_Maximum; + }; + + } // ecapseman + +} // ecapseman + +#ifndef ITK_MANUAL_INSTANTIATION +# include +#endif // ITK_MANUAL_INSTANTIATION + +#endif // __CPEXTENSIONS__ALGORITHMS__REGIONOFINTERESTIMAGECALCULATOR__H__ + +// eof - $RCSfile$ diff --git a/lib/cpExtensions/Algorithms/RegionOfInterestImageCalculator.hxx b/lib/cpExtensions/Algorithms/RegionOfInterestImageCalculator.hxx new file mode 100644 index 0000000..fd7867f --- /dev/null +++ b/lib/cpExtensions/Algorithms/RegionOfInterestImageCalculator.hxx @@ -0,0 +1,92 @@ +// ------------------------------------------------------------------------- +// @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co) +// ------------------------------------------------------------------------- + +#ifndef __CPEXTENSIONS__ALGORITHMS__REGIONOFINTERESTIMAGECALCULATOR__HXX__ +#define __CPEXTENSIONS__ALGORITHMS__REGIONOFINTERESTIMAGECALCULATOR__HXX__ + +#include + +// ------------------------------------------------------------------------- +template< class _TImage > +void cpExtensions::Algorithms::RegionOfInterestImageCalculator< _TImage >:: +Compute( ) +{ + typedef itk::ImageRegionConstIteratorWithIndex< _TImage > _TIterator; + typedef typename _TImage::RegionType _TRegion; + + if( this->m_Image.IsNotNull( ) ) + { + _TRegion region = this->m_Image->GetRequestedRegion( ); + TIndex minidx = region.GetIndex( ); + TIndex maxidx = minidx + region.GetSize( ); + for( unsigned int d = 0; d < _TImage::ImageDimension; ++d ) + maxidx[ d ] -= 1; + + bool first = true; + _TIterator i( this->m_Image, region ); + for( i.GoToBegin( ); !i.IsAtEnd( ); ++i ) + { + if( i.Get( ) != this->m_BackgroundValue ) + { + TIndex idx = i.GetIndex( ); + if( !first ) + { + for( unsigned int d = 0; d < _TImage::ImageDimension; ++d ) + { + minidx[ d ] = ( idx[ d ] < minidx[ d ] )? idx[ d ]: minidx[ d ]; + maxidx[ d ] = ( idx[ d ] > maxidx[ d ] )? idx[ d ]: maxidx[ d ]; + + } // rof + } + else + { + minidx = maxidx = idx; + first = false; + + } // fi + + } // fi + + } // rof + this->m_Minimum = minidx; + this->m_Maximum = maxidx; + } + else + { + this->m_Minimum.Fill( 0 ); + this->m_Maximum.Fill( 0 ); + + } // fi +} + +// ------------------------------------------------------------------------- +template< class _TImage > +cpExtensions::Algorithms::RegionOfInterestImageCalculator< _TImage >:: +RegionOfInterestImageCalculator( ) + : Superclass( ), + m_BackgroundValue( TPixel( 0 ) ) +{ + this->m_Minimum.Fill( 0 ); + this->m_Maximum.Fill( 0 ); +} + +// ------------------------------------------------------------------------- +template< class _TImage > +cpExtensions::Algorithms::RegionOfInterestImageCalculator< _TImage >:: +~RegionOfInterestImageCalculator( ) +{ +} + + +/* TODO + typename _TImage::ConstPointer m_Image; + TPixel m_BackgroundValue; + TIndex m_Minimum; + TIndex m_Maximum; + }; +*/ + +#endif // __CPEXTENSIONS__ALGORITHMS__REGIONOFINTERESTIMAGECALCULATOR__HXX__ + +// eof - $RCSfile$ diff --git a/lib/cpExtensions/Algorithms/UnaryThresholdImageFilter.h b/lib/cpExtensions/Algorithms/UnaryThresholdImageFilter.h new file mode 100644 index 0000000..7de8b66 --- /dev/null +++ b/lib/cpExtensions/Algorithms/UnaryThresholdImageFilter.h @@ -0,0 +1,102 @@ +// ------------------------------------------------------------------------- +// @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co) +// ------------------------------------------------------------------------- + +#ifndef __CPEXTENSIONS__ALGORITHMS__UNARYTHRESHOLDIMAGEFILTER__H__ +#define __CPEXTENSIONS__ALGORITHMS__UNARYTHRESHOLDIMAGEFILTER__H__ + +#include + +namespace cpExtensions +{ + namespace Algorithms + { + namespace Functor + { + /** + */ + template< typename _TInput > + class UnaryThreshold + { + public: + UnaryThreshold( ); + virtual ~UnaryThreshold( ); + + const _TInput& GetThreshold( ) const; + const _TInput& GetInsideValue( ) const; + const _TInput& GetOutsideValue( ) const; + const bool& GetStrict( ) const; + + void StrictOn( ); + void StrictOff( ); + void SetStrict( bool s ); + void SetThreshold( const _TInput& thresh ); + void SetInsideValue( const _TInput& value ); + void SetOutsideValue( const _TInput& value ); + bool operator!=( const UnaryThreshold& other ) const; + bool operator==( const UnaryThreshold& other ) const; + _TInput operator()( const _TInput& A ) const; + + private: + _TInput m_Threshold; + _TInput m_InsideValue; + _TInput m_OutsideValue; + bool m_Strict; + }; + } + + /** + */ + template< class _TImage > + class UnaryThresholdImageFilter + : public itk::UnaryFunctorImageFilter< _TImage, _TImage, cpExtensions::Algorithms::Functor::UnaryThreshold< typename _TImage::PixelType > > + { + public: + // Basic types + typedef typename _TImage::PixelType TPixel; + typedef cpExtensions::Algorithms::Functor::UnaryThreshold< TPixel > TFunctor; + typedef itk::UnaryFunctorImageFilter< _TImage, _TImage, TFunctor > Superclass; + typedef UnaryThresholdImageFilter Self; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; + + typedef _TImage TImage; + + public: + itkNewMacro( Self ); + itkTypeMacro( UnaryThresholdImageFilter, itkUnaryFunctorImageFilter ); + + public: + const TPixel& GetThreshold( ) const; + const TPixel& GetInsideValue( ) const; + const TPixel& GetOutsideValue( ) const; + const bool& GetStrict( ) const; + + void StrictOn( ); + void StrictOff( ); + void SetStrict( bool s ); + void SetThreshold( const TPixel& thresh ); + void SetInsideValue( const TPixel& value ); + void SetOutsideValue( const TPixel& value ); + + protected: + UnaryThresholdImageFilter( ); + virtual ~UnaryThresholdImageFilter( ); + + private: + // Purposely not implemented + UnaryThresholdImageFilter( const Self& ); + void operator=( const Self& ); + }; + + } // ecapseman + +} // ecapseman + +#ifndef ITK_MANUAL_INSTANTIATION +# include +#endif // ITK_MANUAL_INSTANTIATION + +#endif // __CPEXTENSIONS__ALGORITHMS__UNARYTHRESHOLDIMAGEFILTER__H__ + +// eof - $RCSfile$ diff --git a/lib/cpExtensions/Algorithms/UnaryThresholdImageFilter.hxx b/lib/cpExtensions/Algorithms/UnaryThresholdImageFilter.hxx new file mode 100644 index 0000000..ff85edd --- /dev/null +++ b/lib/cpExtensions/Algorithms/UnaryThresholdImageFilter.hxx @@ -0,0 +1,245 @@ +// ------------------------------------------------------------------------- +// @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co) +// ------------------------------------------------------------------------- + +#ifndef __CPEXTENSIONS__ALGORITHMS__UNARYTHRESHOLDIMAGEFILTER__HXX__ +#define __CPEXTENSIONS__ALGORITHMS__UNARYTHRESHOLDIMAGEFILTER__HXX__ + +// ------------------------------------------------------------------------- +template< typename _TInput > +cpExtensions::Algorithms::Functor::UnaryThreshold< _TInput >:: +UnaryThreshold( ) + : m_Strict( false ) +{ + this->m_Threshold = itk::NumericTraits< _TInput >::NonpositiveMin( ); + this->m_OutsideValue = itk::NumericTraits< _TInput >::ZeroValue( ); + this->m_InsideValue = itk::NumericTraits< _TInput >::max( ); +} + +// ------------------------------------------------------------------------- +template< typename _TInput > +cpExtensions::Algorithms::Functor::UnaryThreshold< _TInput >:: +~UnaryThreshold( ) +{ +} + +// ------------------------------------------------------------------------- +template< typename _TInput > +const _TInput& cpExtensions::Algorithms::Functor::UnaryThreshold< _TInput >:: +GetThreshold( ) const +{ + return( this->m_Threshold ); +} + +// ------------------------------------------------------------------------- +template< typename _TInput > +const _TInput& cpExtensions::Algorithms::Functor::UnaryThreshold< _TInput >:: +GetInsideValue( ) const +{ + return( this->m_InsideValue ); +} + +// ------------------------------------------------------------------------- +template< typename _TInput > +const _TInput& cpExtensions::Algorithms::Functor::UnaryThreshold< _TInput >:: +GetOutsideValue( ) const +{ + return( this->m_OutsideValue ); +} + +// ------------------------------------------------------------------------- +template< typename _TInput > +const bool& cpExtensions::Algorithms::Functor::UnaryThreshold< _TInput >:: +GetStrict( ) const +{ + return( this->m_Strict ); +} + +// ------------------------------------------------------------------------- +template< typename _TInput > +void cpExtensions::Algorithms::Functor::UnaryThreshold< _TInput >:: +StrictOn( ) +{ + this->SetStrict( true ); +} + +// ------------------------------------------------------------------------- +template< typename _TInput > +void cpExtensions::Algorithms::Functor::UnaryThreshold< _TInput >:: +StrictOff( ) +{ + this->SetStrict( false ); +} + +// ------------------------------------------------------------------------- +template< typename _TInput > +void cpExtensions::Algorithms::Functor::UnaryThreshold< _TInput >:: +SetStrict( bool s ) +{ + this->m_Strict = s; +} + +// ------------------------------------------------------------------------- +template< typename _TInput > +void cpExtensions::Algorithms::Functor::UnaryThreshold< _TInput >:: +SetThreshold( const _TInput& thresh ) +{ + this->m_Threshold = thresh; +} + +// ------------------------------------------------------------------------- +template< typename _TInput > +void cpExtensions::Algorithms::Functor::UnaryThreshold< _TInput >:: +SetInsideValue( const _TInput& value ) +{ + this->m_InsideValue = value; +} + +// ------------------------------------------------------------------------- +template< typename _TInput > +void cpExtensions::Algorithms::Functor::UnaryThreshold< _TInput >:: +SetOutsideValue( const _TInput& value ) +{ + this->m_OutsideValue = value; +} + +// ------------------------------------------------------------------------- +template< typename _TInput > +bool cpExtensions::Algorithms::Functor::UnaryThreshold< _TInput >:: +operator!=( const UnaryThreshold& other ) const +{ + return( + this->m_Threshold != other.m_Threshold || + itk::Math::NotExactlyEquals( this->m_InsideValue, other.m_InsideValue ) || + itk::Math::NotExactlyEquals( this->m_OutsideValue, other.m_OutsideValue ) + ); +} + +// ------------------------------------------------------------------------- +template< typename _TInput > +bool cpExtensions::Algorithms::Functor::UnaryThreshold< _TInput >:: +operator==( const UnaryThreshold& other ) const +{ + return( !( *this != other ) ); +} + +// ------------------------------------------------------------------------- +template< typename _TInput > +_TInput cpExtensions::Algorithms::Functor::UnaryThreshold< _TInput >:: +operator()( const _TInput& A ) const +{ + if( this->m_Strict ) + { + if( this->m_Threshold < A ) + return( this->m_InsideValue ); + return( this->m_OutsideValue ); + } + else + { + if( this->m_Threshold <= A ) + return( this->m_InsideValue ); + return( this->m_OutsideValue ); + + } // fi +} + +// ------------------------------------------------------------------------- +template< class _TImage > +const typename cpExtensions::Algorithms::UnaryThresholdImageFilter< _TImage >:: +TPixel& cpExtensions::Algorithms::UnaryThresholdImageFilter< _TImage >:: +GetThreshold( ) const +{ + return( this->GetFunctor( ).GetThreshold( ) ); +} + +// ------------------------------------------------------------------------- +template< class _TImage > +const typename cpExtensions::Algorithms::UnaryThresholdImageFilter< _TImage >:: +TPixel& cpExtensions::Algorithms::UnaryThresholdImageFilter< _TImage >:: +GetInsideValue( ) const +{ + return( this->GetFunctor( ).GetInsideValue( ) ); +} + +// ------------------------------------------------------------------------- +template< class _TImage > +const typename cpExtensions::Algorithms::UnaryThresholdImageFilter< _TImage >:: +TPixel& cpExtensions::Algorithms::UnaryThresholdImageFilter< _TImage >:: +GetOutsideValue( ) const +{ + return( this->GetFunctor( ).GetOutsideValue( ) ); +} + +// ------------------------------------------------------------------------- +template< class _TImage > +const bool& cpExtensions::Algorithms::UnaryThresholdImageFilter< _TImage >:: +GetStrict( ) const +{ + return( this->GetFunctor( ).GetStrict( ) ); +} + +// ------------------------------------------------------------------------- +template< class _TImage > +void cpExtensions::Algorithms::UnaryThresholdImageFilter< _TImage >:: +StrictOn( ) +{ + this->GetFunctor( ).SetStrict( true ); +} + +// ------------------------------------------------------------------------- +template< class _TImage > +void cpExtensions::Algorithms::UnaryThresholdImageFilter< _TImage >:: +StrictOff( ) +{ + this->GetFunctor( ).SetStrict( false ); +} + +// ------------------------------------------------------------------------- +template< class _TImage > +void cpExtensions::Algorithms::UnaryThresholdImageFilter< _TImage >:: +SetStrict( bool s ) +{ + this->GetFunctor( ).SetStrict( s ); +} + +// ------------------------------------------------------------------------- +template< class _TImage > +void cpExtensions::Algorithms::UnaryThresholdImageFilter< _TImage >:: +SetThreshold( const TPixel& thresh ) +{ + this->GetFunctor( ).SetThreshold( thresh ); +} + +// ------------------------------------------------------------------------- +template< class _TImage > +void cpExtensions::Algorithms::UnaryThresholdImageFilter< _TImage >:: +SetInsideValue( const TPixel& value ) +{ + this->GetFunctor( ).SetInsideValue( value ); +} + +// ------------------------------------------------------------------------- +template< class _TImage > +void cpExtensions::Algorithms::UnaryThresholdImageFilter< _TImage >:: +SetOutsideValue( const TPixel& value ) +{ + this->GetFunctor( ).SetOutsideValue( value ); +} + +// ------------------------------------------------------------------------- +template< class _TImage > +cpExtensions::Algorithms::UnaryThresholdImageFilter< _TImage >:: +UnaryThresholdImageFilter( ) +{ +} + +// ------------------------------------------------------------------------- +template< class _TImage > +cpExtensions::Algorithms::UnaryThresholdImageFilter< _TImage >:: +~UnaryThresholdImageFilter( ) +{ +} + +#endif // __CPEXTENSIONS__ALGORITHMS__UNARYTHRESHOLDIMAGEFILTER__HXX__ + +// eof - $RCSfile$ diff --git a/lib/cpPlugins_Instances/CMakeLists.txt b/lib/cpPlugins_Instances/CMakeLists.txt index cece9b5..d248386 100644 --- a/lib/cpPlugins_Instances/CMakeLists.txt +++ b/lib/cpPlugins_Instances/CMakeLists.txt @@ -50,6 +50,8 @@ cpPlugins_WrapInstances( GaussianImageFilters ${arg} ${pfx}ScalarImagesBaseFilters ${pfx}ScalarVectorImagesBaseFilters ) +cpPlugins_WrapInstances(MorphologicalImageFilters ${arg} ${pfx}ScalarImagesBaseFilters) +cpPlugins_WrapInstances(ExtractImageFilters ${arg} ${pfx}ScalarImages) SET( cpPlugins_LIBRARIES @@ -73,6 +75,8 @@ SET( ${pfx}ResamplingFilters ${pfx}DistanceMapFilters ${pfx}GaussianImageFilters + ${pfx}MorphologicalImageFilters + ${pfx}ExtractImageFilters CACHE INTERNAL "All valid instances." FORCE ) diff --git a/lib/cpPlugins_Instances/ExtractImageFilters.i b/lib/cpPlugins_Instances/ExtractImageFilters.i new file mode 100644 index 0000000..4d0e548 --- /dev/null +++ b/lib/cpPlugins_Instances/ExtractImageFilters.i @@ -0,0 +1,18 @@ +d #ints=char;short;int;long +d #uints=unsigned #ints +d #floats=float;double +d #pixels=#ints;#uints;#floats +d #dims=2;3 + +i cpPlugins_Instances/ScalarImages.h +t cpExtensions/Algorithms/RegionOfInterestImageCalculator.h +t itkRegionOfInterestImageFilter.h + +* =========== +* = Filters = +* =========== + +c cpExtensions::Algorithms::RegionOfInterestImageCalculator< itk::Image< #pixels, #dims > > +c itk::RegionOfInterestImageFilter< itk::Image< #pixels, #dims >, itk::Image< #pixels, #dims > > + +* eof - $RCSfile$ diff --git a/lib/cpPlugins_Instances/MorphologicalImageFilters.i b/lib/cpPlugins_Instances/MorphologicalImageFilters.i new file mode 100644 index 0000000..f5d6c1e --- /dev/null +++ b/lib/cpPlugins_Instances/MorphologicalImageFilters.i @@ -0,0 +1,21 @@ +d #ints=char;short;int;long +d #uints=unsigned #ints +d #floats=float;double +d #pixels=#ints;#uints;#floats +d #dims=2;3 +d #itk_filters=BinaryDilateParaImage;BinaryErodeParaImage + +i cpPlugins_Instances/ScalarImagesBaseFilters.h +t itkParabolicErodeDilateImageFilter.h +t itk{#itk_filters}Filter.h +t itkUnaryFunctorImageFilter.h + +* =========== +* = Filters = +* =========== + +c itk::UnaryFunctorImageFilter< itk::Image< #pixels, #dims >, itk::Image< double, #dims >, itk::Functor::GEConst< #pixels, double > > +c itk::ParabolicErodeDilateImageFilter< itk::Image< double, #dims >, false, itk::Image< #pixels, #dims > > +c itk::{#itk_filters}Filter< itk::Image< #pixels, #dims > > + +* eof - $RCSfile$ diff --git a/lib/cpPlugins_Instances/ThresholdFilters.i b/lib/cpPlugins_Instances/ThresholdFilters.i index 9d1a884..99b860b 100644 --- a/lib/cpPlugins_Instances/ThresholdFilters.i +++ b/lib/cpPlugins_Instances/ThresholdFilters.i @@ -3,6 +3,7 @@ f cpPlugins_Instances/ScalarImagesBaseFilters.h t itkBinaryThresholdImageFilter.h t itkUnaryFunctorImageFilter.h t itkSimpleDataObjectDecorator.h +t cpExtensions/Algorithms/UnaryThresholdImageFilter.h d #dims=2;3 d #int=char;short;int;long @@ -11,3 +12,4 @@ d #scalar=#int;unsigned #int;#float d #output=#int;unsigned #int;#float c itk::BinaryThresholdImageFilter< itk::Image< #scalar, #dims >, itk::Image< #output, #dims > > +c cpExtensions::Algorithms::UnaryThresholdImageFilter< itk::Image< #scalar, #dims > > diff --git a/plugins/cpPluginsImageFilters/BinaryDilateParaImageFilter.cxx b/plugins/cpPluginsImageFilters/BinaryDilateParaImageFilter.cxx new file mode 100644 index 0000000..fe37f74 --- /dev/null +++ b/plugins/cpPluginsImageFilters/BinaryDilateParaImageFilter.cxx @@ -0,0 +1,53 @@ +#include +#include +#include + +// ------------------------------------------------------------------------- +cpPluginsImageFilters::BinaryDilateParaImageFilter:: +BinaryDilateParaImageFilter( ) + : Superclass( ) +{ + this->_AddInput( "Input" ); + this->_AddOutput< cpPlugins::Image >( "Output" ); + this->m_Parameters.ConfigureAsReal( "Radius" ); + this->m_Parameters.ConfigureAsBool( "Circular" ); + this->m_Parameters.ConfigureAsBool( "UseImageSpacing" ); + + this->m_Parameters.SetReal( "Radius", 3 ); + this->m_Parameters.SetBool( "Circular", true ); + this->m_Parameters.SetBool( "UseImageSpacing", false ); +} + +// ------------------------------------------------------------------------- +cpPluginsImageFilters::BinaryDilateParaImageFilter:: +~BinaryDilateParaImageFilter( ) +{ +} + +// ------------------------------------------------------------------------- +void cpPluginsImageFilters::BinaryDilateParaImageFilter:: +_GenerateData( ) +{ + auto image = this->GetInputData< itk::DataObject >( "Input" ); + cpPlugins_Image_Demangle_Pixel_AllScalars ( _GD0, image, 2 ); + else cpPlugins_Image_Demangle_Pixel_AllScalars( _GD0, image, 3 ); + else this->_Error( "No valid input image." ); +} + +// ------------------------------------------------------------------------- +template< class _TInputImage > +void cpPluginsImageFilters::BinaryDilateParaImageFilter:: +_GD0( _TInputImage* input_image ) +{ + typedef itk::BinaryDilateParaImageFilter< _TInputImage > _TFilter; + + auto filter = this->_CreateITK< _TFilter >( ); + filter->SetInput( input_image ); + filter->SetRadius( this->m_Parameters.GetReal( "Radius" ) ); + filter->SetCircular( this->m_Parameters.GetBool( "Circular" ) ); + filter->SetUseImageSpacing( this->m_Parameters.GetBool( "UseImageSpacing" ) ); + filter->Update( ); + this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) ); +} + +// eof - $RCSfile$ diff --git a/plugins/cpPluginsImageFilters/BinaryDilateParaImageFilter.h b/plugins/cpPluginsImageFilters/BinaryDilateParaImageFilter.h new file mode 100644 index 0000000..36f957a --- /dev/null +++ b/plugins/cpPluginsImageFilters/BinaryDilateParaImageFilter.h @@ -0,0 +1,44 @@ +#ifndef __CPPLUGINSIMAGEFILTERS__BINARYDILATEPARAIMAGEFILTER__H__ +#define __CPPLUGINSIMAGEFILTERS__BINARYDILATEPARAIMAGEFILTER__H__ + +#include +#include + +namespace cpPluginsImageFilters +{ + /** + */ + class cpPluginsImageFilters_EXPORT BinaryDilateParaImageFilter + : public cpPlugins::ProcessObject + { + public: + typedef BinaryDilateParaImageFilter Self; + typedef cpPlugins::ProcessObject Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; + + public: + itkNewMacro( Self ); + itkTypeMacro( BinaryDilateParaImageFilter, cpPlugins::ProcessObject ); + cpPlugins_Id_Macro( BinaryDilateParaImageFilter, ImageFilters ); + + protected: + BinaryDilateParaImageFilter( ); + virtual ~BinaryDilateParaImageFilter( ); + + virtual void _GenerateData( ) ITK_OVERRIDE; + + template< class _TInputImage > + inline void _GD0( _TInputImage* input_image ); + + private: + // Purposely not implemented + BinaryDilateParaImageFilter( const Self& ); + Self& operator=( const Self& ); + }; + +} // ecapseman + +#endif // __CPPLUGINSIMAGEFILTERS__BINARYDILATEPARAIMAGEFILTER__H__ + +// eof - $RCSfile$ diff --git a/plugins/cpPluginsImageFilters/BinaryErodeParaImageFilter.cxx b/plugins/cpPluginsImageFilters/BinaryErodeParaImageFilter.cxx new file mode 100644 index 0000000..7aad8cc --- /dev/null +++ b/plugins/cpPluginsImageFilters/BinaryErodeParaImageFilter.cxx @@ -0,0 +1,53 @@ +#include +#include +#include + +// ------------------------------------------------------------------------- +cpPluginsImageFilters::BinaryErodeParaImageFilter:: +BinaryErodeParaImageFilter( ) + : Superclass( ) +{ + this->_AddInput( "Input" ); + this->_AddOutput< cpPlugins::Image >( "Output" ); + this->m_Parameters.ConfigureAsReal( "Radius" ); + this->m_Parameters.ConfigureAsBool( "Circular" ); + this->m_Parameters.ConfigureAsBool( "UseImageSpacing" ); + + this->m_Parameters.SetReal( "Radius", 3 ); + this->m_Parameters.SetBool( "Circular", true ); + this->m_Parameters.SetBool( "UseImageSpacing", false ); +} + +// ------------------------------------------------------------------------- +cpPluginsImageFilters::BinaryErodeParaImageFilter:: +~BinaryErodeParaImageFilter( ) +{ +} + +// ------------------------------------------------------------------------- +void cpPluginsImageFilters::BinaryErodeParaImageFilter:: +_GenerateData( ) +{ + auto image = this->GetInputData< itk::DataObject >( "Input" ); + cpPlugins_Image_Demangle_Pixel_AllScalars ( _GD0, image, 2 ); + else cpPlugins_Image_Demangle_Pixel_AllScalars( _GD0, image, 3 ); + else this->_Error( "No valid input image." ); +} + +// ------------------------------------------------------------------------- +template< class _TInputImage > +void cpPluginsImageFilters::BinaryErodeParaImageFilter:: +_GD0( _TInputImage* input_image ) +{ + typedef itk::BinaryErodeParaImageFilter< _TInputImage > _TFilter; + + auto filter = this->_CreateITK< _TFilter >( ); + filter->SetInput( input_image ); + filter->SetRadius( this->m_Parameters.GetReal( "Radius" ) ); + filter->SetCircular( this->m_Parameters.GetBool( "Circular" ) ); + filter->SetUseImageSpacing( this->m_Parameters.GetBool( "UseImageSpacing" ) ); + filter->Update( ); + this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) ); +} + +// eof - $RCSfile$ diff --git a/plugins/cpPluginsImageFilters/BinaryErodeParaImageFilter.h b/plugins/cpPluginsImageFilters/BinaryErodeParaImageFilter.h new file mode 100644 index 0000000..a7c9c41 --- /dev/null +++ b/plugins/cpPluginsImageFilters/BinaryErodeParaImageFilter.h @@ -0,0 +1,44 @@ +#ifndef __CPPLUGINSIMAGEFILTERS__BINARYERODEPARAIMAGEFILTER__H__ +#define __CPPLUGINSIMAGEFILTERS__BINARYERODEPARAIMAGEFILTER__H__ + +#include +#include + +namespace cpPluginsImageFilters +{ + /** + */ + class cpPluginsImageFilters_EXPORT BinaryErodeParaImageFilter + : public cpPlugins::ProcessObject + { + public: + typedef BinaryErodeParaImageFilter Self; + typedef cpPlugins::ProcessObject Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; + + public: + itkNewMacro( Self ); + itkTypeMacro( BinaryErodeParaImageFilter, cpPlugins::ProcessObject ); + cpPlugins_Id_Macro( BinaryErodeParaImageFilter, ImageFilters ); + + protected: + BinaryErodeParaImageFilter( ); + virtual ~BinaryErodeParaImageFilter( ); + + virtual void _GenerateData( ) ITK_OVERRIDE; + + template< class _TInputImage > + inline void _GD0( _TInputImage* input_image ); + + private: + // Purposely not implemented + BinaryErodeParaImageFilter( const Self& ); + Self& operator=( const Self& ); + }; + +} // ecapseman + +#endif // __CPPLUGINSIMAGEFILTERS__BINARYERODEPARAIMAGEFILTER__H__ + +// eof - $RCSfile$ diff --git a/plugins/cpPluginsImageFilters/CastImageFilter.h b/plugins/cpPluginsImageFilters/CastImageFilter.h index d9760b0..e3b0eda 100644 --- a/plugins/cpPluginsImageFilters/CastImageFilter.h +++ b/plugins/cpPluginsImageFilters/CastImageFilter.h @@ -12,7 +12,7 @@ namespace cpPluginsImageFilters : public cpPlugins::ProcessObject { public: - typedef CastImageFilter Self; + typedef CastImageFilter Self; typedef cpPlugins::ProcessObject Superclass; typedef itk::SmartPointer< Self > Pointer; typedef itk::SmartPointer< const Self > ConstPointer; diff --git a/plugins/cpPluginsImageFilters/OrImageFilter.h b/plugins/cpPluginsImageFilters/OrImageFilter.h index a970d61..f7658b4 100644 --- a/plugins/cpPluginsImageFilters/OrImageFilter.h +++ b/plugins/cpPluginsImageFilters/OrImageFilter.h @@ -12,7 +12,7 @@ namespace cpPluginsImageFilters : public cpPlugins::ProcessObject { public: - typedef OrImageFilter Self; + typedef OrImageFilter Self; typedef cpPlugins::ProcessObject Superclass; typedef itk::SmartPointer< Self > Pointer; typedef itk::SmartPointer< const Self > ConstPointer; diff --git a/plugins/cpPluginsImageFilters/RegionOfInterestImageFilter.cxx b/plugins/cpPluginsImageFilters/RegionOfInterestImageFilter.cxx new file mode 100644 index 0000000..6a18098 --- /dev/null +++ b/plugins/cpPluginsImageFilters/RegionOfInterestImageFilter.cxx @@ -0,0 +1,72 @@ +#include +#include +#include + +// ------------------------------------------------------------------------- +cpPluginsImageFilters::RegionOfInterestImageFilter:: +RegionOfInterestImageFilter( ) + : Superclass( ) +{ + this->_AddInput( "Input" ); + this->_AddOutput< cpPlugins::Image >( "Output" ); + this->m_Parameters.ConfigureAsBool( "AutomaticRegion" ); + this->m_Parameters.ConfigureAsReal( "BackgroundValue" ); + this->m_Parameters.SetBool( "AutomaticRegion", true ); + this->m_Parameters.SetReal( "BackgroundValue", 0 ); +} + +// ------------------------------------------------------------------------- +cpPluginsImageFilters::RegionOfInterestImageFilter:: +~RegionOfInterestImageFilter( ) +{ +} + +// ------------------------------------------------------------------------- +void cpPluginsImageFilters::RegionOfInterestImageFilter:: +_GenerateData( ) +{ + auto image = this->GetInputData< itk::DataObject >( "Input" ); + cpPlugins_Image_Demangle_Pixel_AllScalars ( _GD0, image, 2 ); + else cpPlugins_Image_Demangle_Pixel_AllScalars( _GD0, image, 3 ); + else this->_Error( "No valid input image." ); +} + +// ------------------------------------------------------------------------- +template< class _TInputImage > +void cpPluginsImageFilters::RegionOfInterestImageFilter:: +_GD0( _TInputImage* image ) +{ + typedef + itk::RegionOfInterestImageFilter< _TInputImage, _TInputImage > + _TFilter; + typedef + cpExtensions::Algorithms::RegionOfInterestImageCalculator< _TInputImage > + _TCalculator; + + if( this->m_Parameters.GetBool( "AutomaticRegion" ) ) + { + typename _TCalculator::Pointer calculator = _TCalculator::New( ); + calculator->SetImage( image ); + calculator->Compute( ); + + auto minidx = calculator->GetMinimum( ); + auto maxidx = calculator->GetMaximum( ); + typename _TInputImage::SizeType size; + for( unsigned int d = 0; d < _TInputImage::ImageDimension; ++d ) + size[ d ] = maxidx[ d ] - minidx[ d ] + 1; + + typename _TInputImage::RegionType roi; + roi.SetIndex( minidx ); + roi.SetSize( size ); + + auto filter = this->_CreateITK< _TFilter >( ); + filter->SetInput( image ); + filter->SetRegionOfInterest( roi ); + filter->Update( ); + this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) ); + } + else + this->_Error( "Manual region not yet implemented." ); +} + +// eof - $RCSfile$ diff --git a/plugins/cpPluginsImageFilters/RegionOfInterestImageFilter.h b/plugins/cpPluginsImageFilters/RegionOfInterestImageFilter.h new file mode 100644 index 0000000..b1294b1 --- /dev/null +++ b/plugins/cpPluginsImageFilters/RegionOfInterestImageFilter.h @@ -0,0 +1,44 @@ +#ifndef __CPPLUGINSIMAGEFILTERS__REGIONOFINTERESTIMAGEFILTER__H__ +#define __CPPLUGINSIMAGEFILTERS__REGIONOFINTERESTIMAGEFILTER__H__ + +#include +#include + +namespace cpPluginsImageFilters +{ + /** + */ + class cpPluginsImageFilters_EXPORT RegionOfInterestImageFilter + : public cpPlugins::ProcessObject + { + public: + typedef RegionOfInterestImageFilter Self; + typedef cpPlugins::ProcessObject Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; + + public: + itkNewMacro( Self ); + itkTypeMacro( RegionOfInterestImageFilter, cpPlugins::ProcessObject ); + cpPlugins_Id_Macro( RegionOfInterestImageFilter, ImageFilters ); + + protected: + RegionOfInterestImageFilter( ); + virtual ~RegionOfInterestImageFilter( ); + + virtual void _GenerateData( ) ITK_OVERRIDE; + + template< class _TInputImage > + inline void _GD0( _TInputImage* image ); + + private: + // Purposely not implemented + RegionOfInterestImageFilter( const Self& ); + Self& operator=( const Self& ); + }; + +} // ecapseman + +#endif // __CPPLUGINSIMAGEFILTERS__REGIONOFINTERESTIMAGEFILTER__H__ + +// eof - $RCSfile$ diff --git a/plugins/cpPluginsImageFilters/UnaryThresholdImageFilter.cxx b/plugins/cpPluginsImageFilters/UnaryThresholdImageFilter.cxx new file mode 100644 index 0000000..e46ac82 --- /dev/null +++ b/plugins/cpPluginsImageFilters/UnaryThresholdImageFilter.cxx @@ -0,0 +1,59 @@ +#include +#include +#include + +// ------------------------------------------------------------------------- +cpPluginsImageFilters::UnaryThresholdImageFilter:: +UnaryThresholdImageFilter( ) + : Superclass( ) +{ + this->_AddInput( "Input" ); + this->_AddOutput< cpPlugins::Image >( "Output" ); + + this->m_Parameters.ConfigureAsReal( "Threshold" ); + this->m_Parameters.ConfigureAsReal( "InsideValue" ); + this->m_Parameters.ConfigureAsReal( "OutsideValue" ); + this->m_Parameters.ConfigureAsBool( "Strict" ); + + this->m_Parameters.SetReal( "Threshold", 0 ); + this->m_Parameters.SetReal( "InsideValue", 1 ); + this->m_Parameters.SetReal( "OutsideValue", 0 ); + this->m_Parameters.SetBool( "Strict", false ); +} + +// ------------------------------------------------------------------------- +cpPluginsImageFilters::UnaryThresholdImageFilter:: +~UnaryThresholdImageFilter( ) +{ +} + +// ------------------------------------------------------------------------- +void cpPluginsImageFilters::UnaryThresholdImageFilter:: +_GenerateData( ) +{ + auto image = this->GetInputData< itk::DataObject >( "Input" ); + cpPlugins_Image_Demangle_Pixel_AllScalars ( _GD0, image, 2 ); + else cpPlugins_Image_Demangle_Pixel_AllScalars( _GD0, image, 3 ); + else this->_Error( "No valid input image." ); +} + +// ------------------------------------------------------------------------- +template< class _TImage > +void cpPluginsImageFilters::UnaryThresholdImageFilter:: +_GD0( _TImage* image ) +{ + typedef + cpExtensions::Algorithms::UnaryThresholdImageFilter< _TImage > + _TFilter; + + _TFilter* filter = this->_CreateITK< _TFilter >( ); + filter->SetInput( image ); + filter->SetThreshold( this->m_Parameters.GetReal( "Threshold" ) ); + filter->SetInsideValue( this->m_Parameters.GetReal( "InsideValue" ) ); + filter->SetOutsideValue( this->m_Parameters.GetReal( "OutsideValue" ) ); + filter->SetStrict( this->m_Parameters.GetBool( "Strict" ) ); + filter->Update( ); + this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) ); +} + +// eof - $RCSfile$ diff --git a/plugins/cpPluginsImageFilters/UnaryThresholdImageFilter.h b/plugins/cpPluginsImageFilters/UnaryThresholdImageFilter.h new file mode 100644 index 0000000..533690a --- /dev/null +++ b/plugins/cpPluginsImageFilters/UnaryThresholdImageFilter.h @@ -0,0 +1,44 @@ +#ifndef __CPPLUGINSIMAGEFILTERS__UNARYTHRESHOLDIMAGEFILTER__H__ +#define __CPPLUGINSIMAGEFILTERS__UNARYTHRESHOLDIMAGEFILTER__H__ + +#include +#include + +namespace cpPluginsImageFilters +{ + /** + */ + class cpPluginsImageFilters_EXPORT UnaryThresholdImageFilter + : public cpPlugins::ProcessObject + { + public: + typedef UnaryThresholdImageFilter Self; + typedef cpPlugins::ProcessObject Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; + + public: + itkNewMacro( Self ); + itkTypeMacro( UnaryThresholdImageFilter, cpPlugins::ProcessObject ); + cpPlugins_Id_Macro( UnaryThresholdImageFilter, ImageFilters ); + + protected: + UnaryThresholdImageFilter( ); + virtual ~UnaryThresholdImageFilter( ); + + virtual void _GenerateData( ) ITK_OVERRIDE; + + template< class _TImage > + inline void _GD0( _TImage* image ); + + private: + // Purposely not implemented + UnaryThresholdImageFilter( const Self& ); + Self& operator=( const Self& ); + }; + +} // ecapseman + +#endif // __CPPLUGINSIMAGEFILTERS__UNARYTHRESHOLDIMAGEFILTER__H__ + +// eof - $RCSfile$ diff --git a/third_party_installers/cpPlugins_Install_ITK.sh b/third_party_installers/cpPlugins_Install_ITK.sh index 99dcd85..51e0ea0 100755 --- a/third_party_installers/cpPlugins_Install_ITK.sh +++ b/third_party_installers/cpPlugins_Install_ITK.sh @@ -194,6 +194,7 @@ $cmake_exec \ -DCMAKE_BUILD_TYPE:STRING=$build_type \ -DModule_ITKReview:BOOL=ON \ -DModule_ITKVtkGlue:BOOL=OFF \ + -DModule_ParabolicMorphology:BOOL=ON \ -DCMAKE_INSTALL_PREFIX:PATH=$prefix \ ${source_dir} echo "==> Configuring sources... done." -- 2.45.1