SET(prj_MAJOR_VERSION 0)
SET(prj_MINOR_VERSION 1)
SET(prj_RELEASE_VERSION 0)
-SET(_subdirs lib plugins)
+SET(_subdirs lib plugins examples)
SET(_policies CMP0015 CMP0020 CMP0042)
## ==========================
--- /dev/null
+OPTION(BUILD_Examples "Build simple examples?" OFF)
+
+IF(BUILD_Examples)
+ SET(
+ _examples
+ RegionGrow_00
+ )
+ INCLUDE_DIRECTORIES(
+ ${PROJECT_SOURCE_DIR}/lib
+ ${PROJECT_BINARY_DIR}/lib
+ )
+ FOREACH(_example ${_examples})
+ ADD_EXECUTABLE(fpa_example_${_example} ${_example}.cxx)
+ TARGET_LINK_LIBRARIES(fpa_example_${_example} ${ITK_LIBRARIES})
+ ENDFOREACH(_example)
+ENDIF(BUILD_Examples)
+
+## eof - $RCSfile$
--- /dev/null
+#include <itkCommand.h>
+#include <itkImage.h>
+#include <itkImageFileWriter.h>
+#include <fpa/Image/RegionGrow.h>
+
+// -------------------------------------------------------------------------
+typedef itk::Image< unsigned char, 2 > TImage;
+typedef fpa::Image::RegionGrow< TImage, TImage > TFilter;
+typedef itk::ImageFileWriter< TImage > TWriter;
+
+// -------------------------------------------------------------------------
+/**
+ */
+class MyObserver
+ : public itk::Command
+{
+public:
+ typedef TFilter::TStartEvent TStartEvent;
+ typedef TFilter::TEndEvent TEndEvent;
+ typedef TFilter::TStartLoopEvent TStartLoopEvent;
+ typedef TFilter::TEndLoopEvent TEndLoopEvent;
+ typedef TFilter::TPushEvent TPushEvent;
+ typedef TFilter::TPopEvent TPopEvent;
+ typedef TFilter::TMarkEvent TMarkEvent;
+
+public:
+ itkNewMacro( MyObserver );
+
+public:
+ virtual void Execute(
+ itk::Object* caller, const itk::EventObject& event
+ ) override
+ {
+ this->Execute( const_cast< const itk::Object* >( caller ), event );
+ }
+ virtual void Execute(
+ const itk::Object* object, const itk::EventObject& event
+ ) override
+ {
+ if( TStartEvent( ).CheckEvent( &event ) )
+ std::cout << "Start" << std::endl;
+ else if( TEndEvent( ).CheckEvent( &event ) )
+ std::cout << "End" << std::endl;
+ else if( TStartLoopEvent( ).CheckEvent( &event ) )
+ std::cout << "StartLoop" << std::endl;
+ else if( TEndLoopEvent( ).CheckEvent( &event ) )
+ std::cout << "EndLoop" << std::endl;
+ else if( TMarkEvent( ).CheckEvent( &event ) )
+ {
+ const TMarkEvent* mark = dynamic_cast< const TMarkEvent* >( &event );
+ std::cout << "Mark: " << mark->Vertex << std::endl;
+
+ } // fi
+ /* TODO
+ TPushEvent;
+ TPopEvent;
+ */
+ }
+};
+
+// -------------------------------------------------------------------------
+int main( int argc, char* argv[] )
+{
+ TImage::SizeType size;
+ size.Fill( 10 );
+
+ TImage::Pointer input = TImage::New( );
+ input->SetRegions( size );
+ input->Allocate( );
+ input->FillBuffer( 0 );
+
+ TImage::RegionType region = input->GetLargestPossibleRegion( );
+ TImage::PointType p0, p1, p2;
+ input->TransformIndexToPhysicalPoint( region.GetIndex( ), p0 );
+ input->TransformIndexToPhysicalPoint(
+ region.GetIndex( ) + region.GetSize( ), p1
+ );
+ p2 = ( p0.GetVectorFromOrigin( ) + p1.GetVectorFromOrigin( ) ) * 0.5;
+ TImage::IndexType seed;
+ input->TransformPhysicalPointToIndex( p2, seed );
+
+ TFilter::Pointer filter = TFilter::New( );
+ filter->SetInput( input );
+ filter->SetInsideValue( 255 );
+ filter->SetOutsideValue( 0 );
+ filter->AddSeed( seed, filter->GetInsideValue( ) );
+
+ MyObserver::Pointer obs = MyObserver::New( );
+ filter->AddObserver( itk::AnyEvent( ), obs );
+ filter->Update( );
+
+ TWriter::Pointer writer = TWriter::New( );
+ writer->SetInput( filter->GetOutput( ) );
+ writer->SetFileName( "RegionGrow_00.png" );
+ writer->Update( );
+
+ return( 0 );
+}
+
+// eof - $RCSfile$
virtual void GenerateData( ) fpa_OVERRIDE;
// Particular methods
+ virtual bool _ContinueGenerateData( );
virtual void _Loop( );
virtual void _BeforeGenerateData( );
this->_InitResults( this->m_InitResult );
// Main loop
- this->_Loop( );
+ do
+ this->_Loop( );
+ while( this->_ContinueGenerateData( ) );
} // fi
this->_AfterGenerateData( );
this->InvokeEvent( TEndEvent( ) );
}
+// -------------------------------------------------------------------------
+template < class _TFilter, class _TVertex, class _TOutput >
+bool fpa::Base::Algorithm< _TFilter, _TVertex, _TOutput >::
+_ContinueGenerateData( )
+{
+ return( false );
+}
+
// -------------------------------------------------------------------------
template < class _TFilter, class _TVertex, class _TOutput >
void fpa::Base::Algorithm< _TFilter, _TVertex, _TOutput >::
--- /dev/null
+#ifndef __fpa__Base__Functors__RegionGrow__Base__h__
+#define __fpa__Base__Functors__RegionGrow__Base__h__
+
+#include <itkObject.h>
+#include <itkObjectFactory.h>
+
+namespace fpa
+{
+ namespace Base
+ {
+ namespace Functors
+ {
+ namespace RegionGrow
+ {
+ /**
+ */
+ template< class _TVertex >
+ class Base
+ : public itk::Object
+ {
+ public:
+ typedef Base Self;
+ typedef itk::Object Superclass;
+ typedef itk::SmartPointer< Self > Pointer;
+ typedef itk::SmartPointer< const Self > ConstPointer;
+
+ typedef _TVertex TVertex;
+
+ public:
+ itkTypeMacro( Base, itk::Object );
+
+ public:
+ virtual bool Evaluate(
+ const TVertex& a, const TVertex& b
+ ) const = 0;
+
+ protected:
+ Base( )
+ : Superclass( )
+ { }
+ virtual ~Base( )
+ { }
+
+ private:
+ // Purposely not defined
+ Base( const Self& other );
+ Self& operator=( const Self& other );
+ };
+
+ } // ecapseman
+
+ } // ecapseman
+
+ } // ecapseman
+
+} // ecapseman
+
+#endif // __fpa__Base__Functors__RegionGrow__Base__h__
+
+// eof - $RCSfile$
--- /dev/null
+#ifndef __fpa__Base__Functors__RegionGrow__Tautology__h__
+#define __fpa__Base__Functors__RegionGrow__Tautology__h__
+
+#include <fpa/Base/Functors/RegionGrow/Base.h>
+
+namespace fpa
+{
+ namespace Base
+ {
+ namespace Functors
+ {
+ namespace RegionGrow
+ {
+ /**
+ */
+ template< class _TVertex >
+ class Tautology
+ : public Base< _TVertex >
+ {
+ public:
+ typedef Tautology Self;
+ typedef Base< _TVertex > Superclass;
+ typedef itk::SmartPointer< Self > Pointer;
+ typedef itk::SmartPointer< const Self > ConstPointer;
+
+ typedef typename Superclass::TVertex TVertex;
+
+ public:
+ itkNewMacro( Self );
+ itkTypeMacro( Tautology, Base );
+
+ public:
+ virtual bool Evaluate(
+ const TVertex& a, const TVertex& b
+ ) const override
+ {
+ return( true );
+ }
+
+ protected:
+ Tautology( )
+ : Superclass( )
+ { }
+ virtual ~Tautology( )
+ { }
+
+ private:
+ // Purposely not defined
+ Tautology( const Self& other );
+ Self& operator=( const Self& other );
+ };
+
+ } // ecapseman
+
+ } // ecapseman
+
+ } // ecapseman
+
+} // ecapseman
+
+#endif // __fpa__Base__Functors__RegionGrow__Tautology__h__
+
+// eof - $RCSfile$
--- /dev/null
+#ifndef __fpa__Base__MoriRegionGrow__h__
+#define __fpa__Base__MoriRegionGrow__h__
+
+#include <queue>
+#include <fpa/Config.h>
+#include <fpa/Base/RegionGrow.h>
+
+namespace fpa
+{
+ namespace Base
+ {
+ /**
+ */
+ template< class _TSuperclass >
+ class MoriRegionGrow
+ : public fpa::Base::RegionGrow< _TSuperclass >
+ {
+ public:
+ typedef MoriRegionGrow Self;
+ typedef fpa::Base::RegionGrow< _TSuperclass > Superclass;
+ typedef itk::SmartPointer< Self > Pointer;
+ typedef itk::SmartPointer< const Self > ConstPointer;
+
+ typedef typename Superclass::TOutput TOutput;
+ typedef typename Superclass::TVertex TVertex;
+
+ protected:
+ typedef typename Superclass::_TQueueNode _TQueueNode;
+ typedef typename Superclass::_TQueue _TQueue;
+
+ public:
+ itkTypeMacro( MoriRegionGrow, Algorithm );
+
+ protected:
+ MoriRegionGrow( );
+ virtual ~MoriRegionGrow( );
+
+ virtual bool _UpdateValue(
+ _TQueueNode& v, const _TQueueNode& p
+ ) override;
+
+ private:
+ // Purposely not defined
+ MoriRegionGrow( const Self& other );
+ Self& operator=( const Self& other );
+
+ protected:
+ _TQueue m_AuxilaryQueue;
+ };
+
+ } // ecapseman
+
+} // ecapseman
+
+#ifndef ITK_MANUAL_INSTANTIATION
+# include <fpa/Base/MoriRegionGrow.hxx>
+#endif // ITK_MANUAL_INSTANTIATION
+
+#endif // __fpa__Base__MoriRegionGrow__h__
+
+// eof - $RCSfile$
--- /dev/null
+#ifndef __fpa__Base__MoriRegionGrow__hxx__
+#define __fpa__Base__MoriRegionGrow__hxx__
+
+// -------------------------------------------------------------------------
+template< class _TSuperclass >
+fpa::Base::MoriRegionGrow< _TSuperclass >::
+MoriRegionGrow( )
+ : Superclass( )
+{
+}
+
+// -------------------------------------------------------------------------
+template< class _TSuperclass >
+fpa::Base::MoriRegionGrow< _TSuperclass >::
+~MoriRegionGrow( )
+{
+}
+
+// -------------------------------------------------------------------------
+template< class _TSuperclass >
+bool fpa::Base::MoriRegionGrow< _TSuperclass >::
+_UpdateValue( _TQueueNode& v, const _TQueueNode& p )
+{
+ bool ret = this->Superclass::_UpdateValue( v, p );
+ if( !ret )
+ this->m_AuxilaryQueue.push( v );
+ return( ret );
+}
+
+
+#endif // __fpa__Base__MoriRegionGrow__hxx__
+
+// eof - $RCSfile$
#include <queue>
#include <fpa/Config.h>
-#include <fpa/Base/RegionGrowFunctionBase.h>
+#include <fpa/Base/Functors/RegionGrow/Base.h>
namespace fpa
{
typedef typename Superclass::TOutput TOutput;
typedef typename Superclass::TVertex TVertex;
- typedef fpa::Base::RegionGrowFunctionBase< TVertex > TGrowFunction;
+ typedef fpa::Base::Functors::RegionGrow::Base< TVertex > TGrowFunction;
protected:
typedef typename Superclass::_TQueueNode _TQueueNode;
#ifndef __fpa__Base__RegionGrow__hxx__
#define __fpa__Base__RegionGrow__hxx__
+#include <fpa/Base/Functors/RegionGrow/Tautology.h>
+
// -------------------------------------------------------------------------
template< class _TSuperclass >
fpa::Base::RegionGrow< _TSuperclass >::
m_OutsideValue( TOutput( 0 ) )
{
this->m_InitResult = TOutput( 0 );
+ this->SetGrowFunction(
+ fpa::Base::Functors::RegionGrow::Tautology< TVertex >::New( )
+ );
}
// -------------------------------------------------------------------------
+++ /dev/null
-#ifndef __fpa__Base__RegionGrowFunctionBase__h__
-#define __fpa__Base__RegionGrowFunctionBase__h__
-
-#include <itkObject.h>
-#include <itkObjectFactory.h>
-
-namespace fpa
-{
- namespace Base
- {
- /**
- */
- template< class _TVertex >
- class RegionGrowFunctionBase
- : public itk::Object
- {
- public:
- typedef RegionGrowFunctionBase Self;
- typedef itk::Object Superclass;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
-
- typedef _TVertex TVertex;
-
- public:
- itkTypeMacro( RegionGrowFunctionBase, itk::Object );
-
- public:
- virtual bool Evaluate( const TVertex& a, const TVertex& b ) const = 0;
-
- protected:
- RegionGrowFunctionBase( )
- : Superclass( )
- { }
- virtual ~RegionGrowFunctionBase( )
- { }
-
- private:
- // Purposely not defined
- RegionGrowFunctionBase( const Self& other );
- Self& operator=( const Self& other );
- };
-
- } // ecapseman
-
-} // ecapseman
-
-#endif // __fpa__Base__RegionGrowFunctionBase__h__
-
-// eof - $RCSfile$
--- /dev/null
+#ifndef __fpa__Image__Functors__RegionGrow__BinaryThreshold__h__
+#define __fpa__Image__Functors__RegionGrow__BinaryThreshold__h__
+
+#include <fpa/Image/Functors/Base.h>
+#include <fpa/Base/Functors/RegionGrow/Base.h>
+
+namespace fpa
+{
+ namespace Image
+ {
+ namespace Functors
+ {
+ namespace RegionGrow
+ {
+ /**
+ */
+ template< class _TImage >
+ class BinaryThreshold
+ : public fpa::Image::Functors::Base< _TImage, fpa::Base::Functors::RegionGrow::Base< typename _TImage::IndexType > >
+ {
+ public:
+ typedef _TImage TImage;
+ typedef typename TImage::IndexType TIndex;
+ typedef typename TImage::PixelType TPixel;
+
+ typedef fpa::Base::Functors::RegionGrow::Base< TIndex > TBase;
+ typedef fpa::Image::Functors::Base< TImage, TBase > Superclass;
+ typedef BinaryThreshold Self;
+ typedef itk::SmartPointer< Self > Pointer;
+ typedef itk::SmartPointer< const Self > ConstPointer;
+
+ public:
+ itkNewMacro( Self );
+ itkTypeMacro( BinaryThreshold, Base );
+
+ itkGetConstMacro( Lower, TPixel );
+ itkGetConstMacro( Upper, TPixel );
+ itkSetMacro( Lower, TPixel );
+ itkSetMacro( Upper, TPixel );
+
+ public:
+ virtual bool Evaluate(
+ const TIndex& a, const TIndex& b
+ ) 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
+#ifndef __fpa__Image__Functors__RegionGrow__BinaryThreshold__hxx__
+#define __fpa__Image__Functors__RegionGrow__BinaryThreshold__hxx__
+
+#include <limits>
+
+// -------------------------------------------------------------------------
+template< class _TImage >
+bool fpa::Image::Functors::RegionGrow::BinaryThreshold< _TImage >::
+Evaluate( const TIndex& a, const TIndex& b ) const
+{
+ const _TImage* im =
+ dynamic_cast< const _TImage* >( this->m_Image.GetPointer( ) );
+ if( im != NULL )
+ {
+ TPixel v = im->GetPixel( b );
+ return( this->m_Lower <= v && v <= this->m_Upper );
+ }
+ else
+ return( false );
+}
+
+// -------------------------------------------------------------------------
+template< class _TImage >
+fpa::Image::Functors::RegionGrow::BinaryThreshold< _TImage >::
+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 _TImage >
+fpa::Image::Functors::RegionGrow::BinaryThreshold< _TImage >::
+~BinaryThreshold( )
+{
+}
+
+#endif // __fpa__Image__Functors__RegionGrow__BinaryThreshold__hxx__
+
+// eof - $RCSfile$
+++ /dev/null
-#ifndef __fpa__Image__Functors__RegionGrowBinaryThreshold__h__
-#define __fpa__Image__Functors__RegionGrowBinaryThreshold__h__
-
-#include <fpa/Image/Functors/Base.h>
-#include <fpa/Base/RegionGrowFunctionBase.h>
-
-namespace fpa
-{
- namespace Image
- {
- namespace Functors
- {
- /**
- */
- template< class _TImage >
- class RegionGrowBinaryThreshold
- : public fpa::Image::Functors::Base< _TImage, fpa::Base::RegionGrowFunctionBase< typename _TImage::IndexType > >
- {
- public:
- typedef _TImage TImage;
- typedef typename TImage::IndexType TIndex;
- typedef typename TImage::PixelType TPixel;
-
- typedef fpa::Base::RegionGrowFunctionBase< TIndex > TBaseFunctor;
- typedef fpa::Image::Functors::Base< TImage, TBaseFunctor > Superclass;
- typedef RegionGrowBinaryThreshold Self;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
-
- public:
- itkNewMacro( Self );
- itkTypeMacro( RegionGrowBinaryThreshold, Base );
-
- itkGetConstMacro( LowerThreshold, TPixel );
- itkGetConstMacro( UpperThreshold, TPixel );
- itkSetMacro( LowerThreshold, TPixel );
- itkSetMacro( UpperThreshold, TPixel );
-
- public:
- virtual bool Evaluate(
- const TIndex& a, const TIndex& b
- ) const fpa_OVERRIDE;
-
- protected:
- RegionGrowBinaryThreshold( );
- virtual ~RegionGrowBinaryThreshold( );
-
- private:
- // Purposely not implemented
- RegionGrowBinaryThreshold( const Self& other );
- Self& operator=( const Self& other );
-
- protected:
- TPixel m_LowerThreshold;
- TPixel m_UpperThreshold;
- };
-
- } // ecapseman
-
- } // ecapseman
-
-} // ecapseman
-
-#ifndef ITK_MANUAL_INSTANTIATION
-# include <fpa/Image/Functors/RegionGrowBinaryThreshold.hxx>
-#endif // ITK_MANUAL_INSTANTIATION
-
-#endif // __fpa__Image__Functors__RegionGrowBinaryThreshold__h__
-
-// eof - $RCSfile$
+++ /dev/null
-#ifndef __fpa__Image__Functors__RegionGrowBinaryThreshold__hxx__
-#define __fpa__Image__Functors__RegionGrowBinaryThreshold__hxx__
-
-// -------------------------------------------------------------------------
-template< class _TImage >
-bool fpa::Image::Functors::RegionGrowBinaryThreshold< _TImage >::
-Evaluate( const TIndex& a, const TIndex& b ) const
-{
- const _TImage* im =
- dynamic_cast< const _TImage* >( this->m_Image.GetPointer( ) );
- TPixel v = im->GetPixel( b );
- return( this->m_LowerThreshold <= v && v <= this->m_UpperThreshold );
-}
-
-// -------------------------------------------------------------------------
-template< class _TImage >
-fpa::Image::Functors::RegionGrowBinaryThreshold< _TImage >::
-RegionGrowBinaryThreshold( )
- : Superclass( ),
- m_LowerThreshold( TPixel( 0 ) ),
- m_UpperThreshold( std::numeric_limits< TPixel >::max( ) )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TImage >
-fpa::Image::Functors::RegionGrowBinaryThreshold< _TImage >::
-~RegionGrowBinaryThreshold( )
-{
-}
-
-#endif // __fpa__Image__Functors__RegionGrowBinaryThreshold__hxx__
-
-// eof - $RCSfile$
--- /dev/null
+#ifndef __fpa__Image__MoriRegionGrow__h__
+#define __fpa__Image__MoriRegionGrow__h__
+
+#include <fpa/Base/MoriRegionGrow.h>
+#include <fpa/Image/Algorithm.h>
+
+namespace fpa
+{
+ namespace Image
+ {
+ /**
+ */
+ template< class _TInputImage, class _TOutputImage >
+ class MoriRegionGrow
+ : public fpa::Base::MoriRegionGrow< fpa::Image::Algorithm< _TInputImage, _TOutputImage > >
+ {
+ public:
+ typedef fpa::Image::Algorithm< _TInputImage, _TOutputImage > TAlgorithm;
+ typedef MoriRegionGrow Self;
+ typedef fpa::Base::MoriRegionGrow< TAlgorithm > Superclass;
+ typedef itk::SmartPointer< Self > Pointer;
+ typedef itk::SmartPointer< const Self > ConstPointer;
+
+ typedef typename Superclass::TOutput TOutput;
+ typedef typename Superclass::TVertex TVertex;
+
+ typedef fpa::Image::Functors::Base< _TInputImage, typename Superclass::TGrowFunction > TGrowFunction;
+
+ public:
+ itkNewMacro( Self );
+ itkTypeMacro( fpa::Image::MoriRegionGrow, fpa::Base::MoriRegionGrow );
+
+ protected:
+ MoriRegionGrow( );
+ virtual ~MoriRegionGrow( );
+
+ virtual void _BeforeGenerateData( ) fpa_OVERRIDE;
+
+ private:
+ // Purposely not defined
+ MoriRegionGrow( const Self& other );
+ Self& operator=( const Self& other );
+ };
+
+ } // ecapseman
+
+} // ecapseman
+
+#ifndef ITK_MANUAL_INSTANTIATION
+# include <fpa/Image/MoriRegionGrow.hxx>
+#endif // ITK_MANUAL_INSTANTIATION
+
+#endif // __fpa__Image__MoriRegionGrow__h__
+
+// eof - $RCSfile$
--- /dev/null
+#ifndef __fpa__Image__MoriRegionGrow__hxx__
+#define __fpa__Image__MoriRegionGrow__hxx__
+
+// -------------------------------------------------------------------------
+template< class _TInputImage, class _TOutputImage >
+fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage >::
+MoriRegionGrow( )
+ : Superclass( )
+{
+}
+
+// -------------------------------------------------------------------------
+template< class _TInputImage, class _TOutputImage >
+fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage >::
+~MoriRegionGrow( )
+{
+}
+
+// -------------------------------------------------------------------------
+template< class _TInputImage, class _TOutputImage >
+void fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage >::
+_BeforeGenerateData( )
+{
+ this->Superclass::_BeforeGenerateData( );
+
+ TGrowFunction* grow =
+ dynamic_cast< TGrowFunction* >( this->GetGrowFunction( ) );
+ if( grow != NULL )
+ grow->SetImage( this->GetInput( ) );
+}
+
+#endif // __fpa__Image__MoriRegionGrow__hxx__
+
+// eof - $RCSfile$
instances fpa::Image::Functors::SimpleNeighborhood< itk::Image< #scalar_types#, #pdims# > >
cinclude fpa/Base/RegionGrow.hxx
+cinclude fpa/Base/MoriRegionGrow.hxx
define all_int_types=#int_types#;#uint_types#
tinclude fpa/Image/RegionGrow: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::MoriRegionGrow< itk::Image< #scalar_types#, #pdims# >, itk::Image< #all_int_types#, #pdims# > >
cinclude fpa/Base/Dijkstra.hxx
tinclude fpa/Image/Dijkstra:h|hxx
--- /dev/null
+#include <ImageAlgorithms/MoriRegionGrow.h>
+#include <cpInstances/DataObjects/Image.h>
+
+#include <fpa/Image/MoriRegionGrow.h>
+
+// -------------------------------------------------------------------------
+fpaPluginsImageAlgorithms::MoriRegionGrow::
+MoriRegionGrow( )
+ : Superclass( )
+{
+ typedef cpPlugins::Pipeline::DataObject _TData;
+
+ this->_ConfigureInput< _TData >( "GrowFunction", true, false );
+ this->m_Parameters.ConfigureAsInt( "InsideValue", 1 );
+ this->m_Parameters.ConfigureAsInt( "OutsideValue", 0 );
+ this->m_Parameters.ConfigureAsInt( "Step", 1 );
+ this->m_Parameters.ConfigureAsReal( "LowerThreshold", 1 );
+ this->m_Parameters.ConfigureAsReal( "UpperThreshold", 1 );
+ this->m_Parameters.ConfigureAsIntTypesChoices( "ResultType" );
+}
+
+// -------------------------------------------------------------------------
+fpaPluginsImageAlgorithms::MoriRegionGrow::
+~MoriRegionGrow( )
+{
+}
+
+// -------------------------------------------------------------------------
+void fpaPluginsImageAlgorithms::MoriRegionGrow::
+_GenerateData( )
+{
+ auto o = this->GetInputData( "Input" );
+ cpPlugins_Demangle_Image_ScalarPixels_AllDims_1( o, _GD0 )
+ this->_Error( "Invalid input image." );
+}
+
+// -------------------------------------------------------------------------
+template< class _TImage >
+void fpaPluginsImageAlgorithms::MoriRegionGrow::
+_GD0( _TImage* image )
+{
+ auto rtype = this->m_Parameters.GetSelectedChoice( "ResultType" );
+ if( rtype == "char" ) this->_GD1< _TImage, char >( image );
+ else if( rtype == "uchar" ) this->_GD1< _TImage, unsigned char >( image );
+ else if( rtype == "short" ) this->_GD1< _TImage, short >( image );
+ else if( rtype == "ushort" ) this->_GD1< _TImage, unsigned short >( image );
+ else if( rtype == "int" ) this->_GD1< _TImage, int >( image );
+ else if( rtype == "uint" ) this->_GD1< _TImage, unsigned int >( image );
+ else if( rtype == "long" ) this->_GD1< _TImage, long >( image );
+ else if( rtype == "ulong" ) this->_GD1< _TImage, unsigned long >( image );
+ else this->_GD1< _TImage, char >( image );
+}
+
+// -------------------------------------------------------------------------
+template< class _TInputImage, class _TOutputPixel >
+void fpaPluginsImageAlgorithms::MoriRegionGrow::
+_GD1( _TInputImage* image )
+{
+ typedef
+ itk::Image< _TOutputPixel, _TInputImage::ImageDimension >
+ _TOutputImage;
+ typedef fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage > _TFilter;
+ typedef typename _TFilter::TGrowFunction _TGrow;
+
+ auto filter = this->_CreateITK< _TFilter >( );
+ this->_ConfigureFilter( filter, image );
+ filter->SetGrowFunction( this->GetInputData< _TGrow >( "GrowFunction" ) );
+ filter->SetInsideValue( this->m_Parameters.GetInt( "InsideValue" ) );
+ filter->SetOutsideValue( this->m_Parameters.GetInt( "OutsideValue" ) );
+ filter->Update( );
+ this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) );
+}
+
+// eof - $RCSfile$
--- /dev/null
+#ifndef __fpaPluginsImageAlgorithms__MoriRegionGrow__h__
+#define __fpaPluginsImageAlgorithms__MoriRegionGrow__h__
+
+#include <ImageAlgorithms/BaseFilter.h>
+
+namespace fpaPluginsImageAlgorithms
+{
+ /**
+ */
+ class fpaPluginsImageAlgorithms_EXPORT MoriRegionGrow
+ : public BaseFilter
+ {
+ cpPluginsObject( MoriRegionGrow, BaseFilter, fpaImageAlgorithms );
+
+ protected:
+ template< class _TImage >
+ inline void _GD0( _TImage* image );
+
+ template< class _TInputImage, class _TOutputPixel >
+ inline void _GD1( _TInputImage* image );
+ };
+
+} // ecapseman
+
+#endif // __fpaPluginsImageAlgorithms__MoriRegionGrow__h__
+
+// eof - $RCSfile$
#include <RegionGrowFunctors/BinaryThreshold.h>
#include <cpInstances/DataObjects/Image.h>
-#include <fpa/Image/Functors/RegionGrowBinaryThreshold.h>
+#include <fpa/Image/Functors/RegionGrow/BinaryThreshold.h>
#include <itkConstNeighborhoodIterator.h>
#include <vtkPolyData.h>
this->_ConfigureOutput< _TData >( "Output" );
this->m_Parameters.ConfigureAsUint( "Radius", 1 );
- this->m_Parameters.ConfigureAsReal( "LowerThreshold", 0 );
- this->m_Parameters.ConfigureAsReal( "UpperThreshold", 0 );
+ this->m_Parameters.ConfigureAsReal( "Lower", 0 );
+ this->m_Parameters.ConfigureAsReal( "Upper", 0 );
}
// -------------------------------------------------------------------------
{
typedef itk::ConstNeighborhoodIterator< _TImage > _TInIt;
typedef
- fpa::Image::Functors::RegionGrowBinaryThreshold< _TImage >
+ fpa::Image::Functors::RegionGrow::BinaryThreshold< _TImage >
_TFunctor;
auto out = this->GetOutput( "Output" );
auto f = out->GetITK< _TFunctor >( );
s = std::sqrt( s );
v_min = m - s;
v_max = m + s;
- f->SetLowerThreshold( v_min );
- f->SetUpperThreshold( v_max );
- this->m_Parameters.SetReal( "LowerThreshold", f->GetLowerThreshold( ) );
- this->m_Parameters.SetReal( "UpperThreshold", f->GetUpperThreshold( ) );
+ f->SetLower( v_min );
+ f->SetUpper( v_max );
+ this->m_Parameters.SetReal( "Lower", f->GetLower( ) );
+ this->m_Parameters.SetReal( "Upper", f->GetUpper( ) );
}
else
{
- f->SetLowerThreshold( this->m_Parameters.GetReal( "LowerThreshold" ) );
- f->SetUpperThreshold( this->m_Parameters.GetReal( "UpperThreshold" ) );
+ f->SetLower( this->m_Parameters.GetReal( "Lower" ) );
+ f->SetUpper( this->m_Parameters.GetReal( "Upper" ) );
} // fi
}
header #define ITK_MANUAL_INSTANTIATION
cinclude itkImage.h
-tinclude fpa/Image/Functors/RegionGrowBinaryThreshold:h|hxx
-instances fpa::Image::Functors::RegionGrowBinaryThreshold< itk::Image< #scalar_types#, #pdims# > >
+tinclude fpa/Image/Functors/RegionGrow/BinaryThreshold:h|hxx
+instances fpa::Image::Functors::RegionGrow::BinaryThreshold< itk::Image< #scalar_types#, #pdims# > >
** eof - $RCSfile$