--- /dev/null
+// =========================================================================
+// @author Leonardo Florez Valencia
+// @email florez-l@javeriana.edu.co
+// =========================================================================
+
+#ifndef __fpa__Base__SeedsInterface__h__
+#define __fpa__Base__SeedsInterface__h__
+
+#include <itkProcessObject.h>
+#include <set>
+
+namespace fpa
+{
+ namespace Base
+ {
+ /**
+ */
+ template< class _TVertex, class _TCompare >
+ class SeedsInterface
+ {
+ public:
+ typedef _TVertex TVertex;
+ typedef _TCompare TCompare;
+ typedef SeedsInterface Self;
+ typedef std::set< TVertex, TCompare > TSeeds;
+
+ public:
+ unsigned int GetNumberOfSeeds( ) const;
+ const TSeeds& GetSeeds( ) const;
+ typename TSeeds::const_iterator BeginSeeds( ) const;
+ typename TSeeds::const_iterator EndSeeds( ) const;
+
+ void AddSeed( const TVertex& seed );
+ void RemoveSeed( const TVertex& seed );
+ void ClearSeeds( );
+
+ protected:
+ SeedsInterface( itk::ProcessObject* filter );
+ virtual ~SeedsInterface( );
+
+ private:
+ TSeeds m_Seeds;
+ itk::ProcessObject* m_Filter;
+ };
+
+ } // ecapseman
+
+} // ecapseman
+
+#ifndef ITK_MANUAL_INSTANTIATION
+# include <fpa/Base/SeedsInterface.hxx>
+#endif // ITK_MANUAL_INSTANTIATION
+
+#endif // __fpa__Base__SeedsInterface__h__
+
+// eof - $RCSfile$
--- /dev/null
+// =========================================================================
+// @author Leonardo Florez Valencia
+// @email florez-l@javeriana.edu.co
+// =========================================================================
+
+#ifndef __fpa__Base__SeedsInterface__hxx__
+#define __fpa__Base__SeedsInterface__hxx__
+
+// -------------------------------------------------------------------------
+template< class _TVertex, class _TCompare >
+unsigned int fpa::Base::SeedsInterface< _TVertex, _TCompare >::
+GetNumberOfSeeds( ) const
+{
+ return( this->m_Seeds.size( ) );
+}
+
+// -------------------------------------------------------------------------
+template< class _TVertex, class _TCompare >
+const typename fpa::Base::SeedsInterface< _TVertex, _TCompare >::
+TSeeds& fpa::Base::SeedsInterface< _TVertex, _TCompare >::
+GetSeeds( ) const
+{
+ return( this->m_Seeds );
+}
+
+// -------------------------------------------------------------------------
+template< class _TVertex, class _TCompare >
+typename fpa::Base::SeedsInterface< _TVertex, _TCompare >::
+TSeeds::const_iterator fpa::Base::SeedsInterface< _TVertex, _TCompare >::
+BeginSeeds( ) const
+{
+ return( this->m_Seeds.begin( ) );
+}
+
+// -------------------------------------------------------------------------
+template< class _TVertex, class _TCompare >
+typename fpa::Base::SeedsInterface< _TVertex, _TCompare >::
+TSeeds::const_iterator fpa::Base::SeedsInterface< _TVertex, _TCompare >::
+EndSeeds( ) const
+{
+ return( this->m_Seeds.end( ) );
+}
+
+// -------------------------------------------------------------------------
+template< class _TVertex, class _TCompare >
+void fpa::Base::SeedsInterface< _TVertex, _TCompare >::
+AddSeed( const TVertex& seed )
+{
+ if( this->m_Seeds.insert( seed ).second && this->m_Filter != NULL )
+ this->m_Filter->Modified( );
+}
+
+// -------------------------------------------------------------------------
+template< class _TVertex, class _TCompare >
+void fpa::Base::SeedsInterface< _TVertex, _TCompare >::
+RemoveSeed( const TVertex& seed )
+{
+ typename TSeeds::const_iterator i = this->m_Seeds.find( seed );
+ if( i != this->m_Seeds.end( ) )
+ {
+ this->m_Seeds.erase( i );
+ if( this->m_Filter != NULL )
+ this->m_Filter->Modified( );
+
+ } // fi
+}
+
+// -------------------------------------------------------------------------
+template< class _TVertex, class _TCompare >
+void fpa::Base::SeedsInterface< _TVertex, _TCompare >::
+ClearSeeds( )
+{
+ if( this->m_Seeds.size( ) > 0 )
+ {
+ this->m_Seeds.clear( );
+ if( this->m_Filter != NULL )
+ this->m_Filter->Modified( );
+
+ } // fi
+}
+
+// -------------------------------------------------------------------------
+template< class _TVertex, class _TCompare >
+fpa::Base::SeedsInterface< _TVertex, _TCompare >::
+SeedsInterface( itk::ProcessObject* filter )
+ : m_Filter( filter )
+{
+}
+
+// -------------------------------------------------------------------------
+template< class _TVertex, class _TCompare >
+fpa::Base::SeedsInterface< _TVertex, _TCompare >::
+~SeedsInterface( )
+{
+ this->m_Seeds.clear( );
+}
+
+#endif // __fpa__Base__SeedsInterface__hxx__
+
+// eof - $RCSfile$
#include <itkImageToImageFilter.h>
#include <itkFunctionBase.h>
-#include <set>
+#include <fpa/Base/SeedsInterface.h>
namespace fpa
{
*/
template< class _TInputImage, class _TOutputImage >
class RegionGrow
- : public itk::ImageToImageFilter< _TInputImage, _TOutputImage >
+ : public itk::ImageToImageFilter< _TInputImage, _TOutputImage >,
+ public fpa::Base::SeedsInterface< typename _TInputImage::IndexType, typename _TInputImage::IndexType::LexicographicCompare >
{
public:
typedef _TInputImage TInputImage;
typedef _TOutputImage TOutputImage;
+ typedef typename TInputImage::IndexType TIndex;
+ typedef typename TInputImage::RegionType TRegion;
+ typedef typename TInputImage::PixelType TInputPixel;
+ typedef typename TOutputImage::PixelType TOutputPixel;
+ typedef typename TIndex::LexicographicCompare TIndexCompare;
typedef RegionGrow Self;
typedef itk::ImageToImageFilter< TInputImage, TOutputImage > Superclass;
typedef itk::SmartPointer< Self > Pointer;
typedef itk::SmartPointer< const Self > ConstPointer;
- typedef typename TInputImage::IndexType TIndex;
- typedef typename TInputImage::RegionType TRegion;
- typedef typename TInputImage::PixelType TInputPixel;
- typedef typename TOutputImage::PixelType TOutputPixel;
-
+ typedef fpa::Base::SeedsInterface< TIndex, TIndexCompare > TSeedsInterface;
typedef itk::FunctionBase< TInputPixel, bool > TIntensityFunctor;
- typedef std::set< TIndex, typename TIndex::LexicographicCompare > TSeeds;
-
public:
itkNewMacro( Self );
itkTypeMacro( fpa::Image::RegionGrow, itk::ImageToImageFilter );
public:
void SetPredicate( TIntensityFunctor* functor );
- void AddSeed( const TIndex& seed );
-
protected:
RegionGrow( );
virtual ~RegionGrow( );
protected:
typename TIntensityFunctor::Pointer m_IntensityFunctor;
- TSeeds m_Seeds;
+ /* TODO
+ TSeeds m_Seeds;
+ */
TOutputPixel m_InsideValue;
TOutputPixel m_OutsideValue;
};
} // fi
}
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage >
-void fpa::Image::RegionGrow< _TInputImage, _TOutputImage >::
-AddSeed( const TIndex& seed )
-{
- if( this->m_Seeds.insert( seed ).second )
- this->Modified( );
-}
-
// -------------------------------------------------------------------------
template< class _TInputImage, class _TOutputImage >
fpa::Image::RegionGrow< _TInputImage, _TOutputImage >::
RegionGrow( )
: Superclass( ),
+ TSeedsInterface( this ),
m_InsideValue( TInputPixel( 0 ) ),
m_OutsideValue( TInputPixel( 0 ) )
{
// Init queue
std::queue< TIndex > q;
- for( TIndex seed: this->m_Seeds )
+ for( TIndex seed: this->GetSeeds( ) )
q.push( seed );
// Main loop