${LIB_NAME}
${${LIB_NAME}_LINK_LIBRARIES}
${ITK_LIBRARIES}
- ${VTK_LIBRARIES}
+ vtkInteractionWidgets
)
## eof - $RCSfile$
typedef typename TTraits::TFrontId _TFrontId;
typedef typename TTraits::TNode _TNode;
typedef typename TTraits::TNodes _TNodes;
-
- private:
- typedef std::queue< _TNode > _TQueue;
+ typedef std::queue< _TNode > _TQueue;
public:
- itkTypeMacro( RegionGrow, Base );
+ itkTypeMacro( RegionGrow, Algorithm );
protected:
RegionGrow( );
RegionGrow( const Self& ); // Not impl.
void operator=( const Self& ); // Not impl.
- private:
+ protected:
_TQueue m_Queue;
};
--- /dev/null
+#ifndef __FPA__BASE__REGIONGROWWITHMULTIPLECRITERIA__H__
+#define __FPA__BASE__REGIONGROWWITHMULTIPLECRITERIA__H__
+
+#include <vector>
+#include <itkFunctionBase.h>
+#include <fpa/Base/RegionGrow.h>
+
+namespace fpa
+{
+ namespace Base
+ {
+ /**
+ * Region grow is a front propagation with no costs.
+ */
+ template< class V, class R, class VV, class VC, class B >
+ class RegionGrowWithMultipleCriteria
+ : public RegionGrow< V, R, VV, VC, B >
+ {
+ public:
+ typedef V TVertex;
+ typedef R TResult;
+ typedef VV TVertexValue;
+ typedef B TBaseFilter;
+
+ /// Standard class typdedefs
+ typedef RegionGrowWithMultipleCriteria Self;
+ typedef RegionGrow< V, R, VV, VC, B > Superclass;
+ typedef itk::SmartPointer< Self > Pointer;
+ typedef itk::SmartPointer< const Self > ConstPointer;
+
+ typedef typename Superclass::TTraits TTraits;
+ typedef typename Superclass::TCost TCost;
+ typedef itk::FunctionBase< V, TCost > TMembershipFunction;
+ typedef
+ typename TMembershipFunction::Pointer
+ TMembershipFunctionPointer;
+ typedef std::vector< TMembershipFunctionPointer > TFunctions;
+
+ protected:
+ typedef typename Superclass::_TFrontId _TFrontId;
+ typedef typename Superclass::_TNode _TNode;
+ typedef typename Superclass::_TNodes _TNodes;
+ typedef typename Superclass::_TQueue _TQueue;
+
+ public:
+ itkTypeMacro( RegionGrowWithMultipleCriteria, RegionGrow );
+
+ public:
+ unsigned int GetNumberOfMembershipFunctions( ) const;
+ void ClearMembershipFunctions( );
+ void AddMembershipFunction( TMembershipFunction* function );
+
+ protected:
+ RegionGrowWithMultipleCriteria( );
+ virtual ~RegionGrowWithMultipleCriteria( );
+
+ virtual void _BeforeLoop( );
+ virtual _TNode _QueuePop( );
+ virtual bool _CheckMembership( const _TNode& n ) const;
+
+ private:
+ RegionGrowWithMultipleCriteria( const Self& ); // Not impl.
+ void operator=( const Self& ); // Not impl.
+
+ protected:
+ mutable _TQueue m_AuxiliaryQueue;
+ TFunctions m_Functions;
+ typename TFunctions::iterator m_ActualFunction;
+ };
+
+ } // ecapseman
+
+} // ecapseman
+
+#include <fpa/Base/RegionGrowWithMultipleCriteria.hxx>
+
+#endif // __FPA__BASE__REGIONGROWWITHMULTIPLECRITERIA__H__
+
+// eof - $RCSfile$
--- /dev/null
+#ifndef __FPA__BASE__REGIONGROWWITHMULTIPLECRITERIA__HXX__
+#define __FPA__BASE__REGIONGROWWITHMULTIPLECRITERIA__HXX__
+
+// -------------------------------------------------------------------------
+template< class V, class R, class VV, class VC, class B >
+unsigned int fpa::Base::RegionGrowWithMultipleCriteria< V, R, VV, VC, B >::
+GetNumberOfMembershipFunctions( ) const
+{
+ return( this->m_Functions.size( ) );
+}
+
+// -------------------------------------------------------------------------
+template< class V, class R, class VV, class VC, class B >
+void fpa::Base::RegionGrowWithMultipleCriteria< V, R, VV, VC, B >::
+ClearMembershipFunctions( )
+{
+ this->m_Functions.clear( );
+ this->Modified( );
+}
+
+// -------------------------------------------------------------------------
+template< class V, class R, class VV, class VC, class B >
+void fpa::Base::RegionGrowWithMultipleCriteria< V, R, VV, VC, B >::
+AddMembershipFunction( TMembershipFunction* function )
+{
+ this->m_Functions.push_back( function );
+ this->Modified( );
+}
+
+// -------------------------------------------------------------------------
+template< class V, class R, class VV, class VC, class B >
+fpa::Base::RegionGrowWithMultipleCriteria< V, R, VV, VC, B >::
+RegionGrowWithMultipleCriteria( )
+ : Superclass( )
+{
+}
+
+// -------------------------------------------------------------------------
+template< class V, class R, class VV, class VC, class B >
+fpa::Base::RegionGrowWithMultipleCriteria< V, R, VV, VC, B >::
+~RegionGrowWithMultipleCriteria( )
+{
+}
+
+// -------------------------------------------------------------------------
+template< class V, class R, class VV, class VC, class B >
+void fpa::Base::RegionGrowWithMultipleCriteria< V, R, VV, VC, B >::
+_BeforeLoop( )
+{
+ this->_BeforeLoop( );
+ this->m_ActualFunction = this->m_Functions.begin( );
+}
+
+// -------------------------------------------------------------------------
+template< class V, class R, class VV, class VC, class B >
+typename fpa::Base::RegionGrowWithMultipleCriteria< V, R, VV, VC, B >::
+_TNode fpa::Base::RegionGrowWithMultipleCriteria< V, R, VV, VC, B >::
+_QueuePop( )
+{
+ _TNode node = this->Superclass::_QueuePop( );
+ if( this->_IsQueueEmpty( ) )
+ {
+ std::cerr << "ERROR!!!!" << std::endl;
+
+ } // fi
+ return( node );
+}
+
+// -------------------------------------------------------------------------
+template< class V, class R, class VV, class VC, class B >
+bool fpa::Base::RegionGrowWithMultipleCriteria< V, R, VV, VC, B >::
+_CheckMembership( const _TNode& n ) const
+{
+ bool ret = ( *( this->m_ActualFunction ) )->Evaluate( n.Vertex );
+ if( !ret )
+ this->m_AuxiliaryQueue.push( n );
+ return( ret );
+}
+
+#endif // __FPA__BASE__REGIONGROWWITHMULTIPLECRITERIA__HXX__
+
+// eof - $RCSfile$
--- /dev/null
+#ifndef __FPA__IMAGE__FUNCTORS__IMAGEFUNCTION__H__
+#define __FPA__IMAGE__FUNCTORS__IMAGEFUNCTION__H__
+
+#include <itkFunctionBase.h>
+
+namespace fpa
+{
+ namespace Image
+ {
+ namespace Functors
+ {
+ /**
+ */
+ template< class I, class O >
+ class ImageFunction
+ : public itk::FunctionBase< typename I::IndexType, O >
+ {
+ public:
+ /// Type-related and pointers
+ typedef ImageFunction Self;
+ typedef itk::FunctionBase< typename I::IndexType, O > Superclass;
+ typedef itk::SmartPointer< Self > Pointer;
+ typedef itk::SmartPointer< const Self > ConstPointer;
+
+ typedef I TInputImage;
+ typedef O TOutputValue;
+ typedef typename I::IndexType TIndex;
+
+ public:
+ itkTypeMacro( ImageFunction, itkFunctionBase );
+
+ itkGetConstObjectMacro( InputImage, I );
+ itkSetConstObjectMacro( InputImage, I );
+
+ public:
+ virtual O Evaluate( const TIndex& idx ) const = 0;
+
+ protected:
+ ImageFunction( )
+ : Superclass( )
+ { }
+ virtual ~ImageFunction( )
+ { }
+
+ private:
+ // Purposely not implemented
+ ImageFunction( const Self& );
+ void operator=( const Self& );
+
+ protected:
+ typename I::ConstPointer m_InputImage;
+ };
+
+ } // ecapseman
+
+ } // ecapseman
+
+} // ecapseman
+
+#endif // __FPA__IMAGE__FUNCTORS__IMAGEFUNCTION__H__
+
+// eof - $RCSfile$
#ifndef __FPA__IMAGE__FUNCTORS__REGIONGROWALLBELONGSFUNCTION__H__
#define __FPA__IMAGE__FUNCTORS__REGIONGROWALLBELONGSFUNCTION__H__
-#include <itkImageFunction.h>
+#include <fpa/Image/Functors/ImageFunction.h>
namespace fpa
{
*/
template< class I >
class RegionGrowAllBelongsFunction
- : public itk::ImageFunction< I, bool >
+ : public fpa::Image::Functors::ImageFunction< I, bool >
{
public:
/// Type-related and pointers
- typedef RegionGrowAllBelongsFunction Self;
- typedef itk::ImageFunction< I, bool > Superclass;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
+ typedef RegionGrowAllBelongsFunction Self;
+ typedef fpa::Image::Functors::ImageFunction< I, bool > Superclass;
+ typedef itk::SmartPointer< Self > Pointer;
+ typedef itk::SmartPointer< const Self > ConstPointer;
// Superclass' types
- typedef typename Superclass::InputImageType InputImageType;
- typedef typename Superclass::InputPixelType InputPixelType;
- typedef typename Superclass::OutputType OutputType;
- typedef typename Superclass::CoordRepType CoordRepType;
- typedef typename Superclass::IndexType IndexType;
- typedef typename Superclass::IndexValueType IndexValueType;
- typedef typename Superclass::ContinuousIndexType ContinuousIndexType;
- typedef typename Superclass::PointType PointType;
+ typedef typename Superclass::TInputImage TInputImage;
+ typedef typename Superclass::TOutputValue TOutputValue;
+ typedef typename Superclass::TIndex TIndex;
public:
itkNewMacro( Self );
itkTypeMacro( RegionGrowAllBelongsFunction, itkImageFunction );
public:
- virtual OutputType Evaluate( const PointType& point ) const
- {
- IndexType index;
- this->ConvertPointToNearestIndex( point, index );
- return( this->EvaluateAtIndex( index ) );
- }
- virtual OutputType EvaluateAtContinuousIndex(
- const ContinuousIndexType& cindex
- ) const
- {
- IndexType index;
- this->ConvertContinuousIndexToNearestIndex( cindex, index );
- return( this->EvaluateAtIndex( index ) );
- }
- virtual OutputType EvaluateAtIndex( const IndexType& index ) const
+ virtual TOutputValue Evaluate( const TIndex& idx ) const
{ return( true ); }
protected:
typedef itk::SmartPointer< const Self > ConstPointer;
// Superclass' types
- typedef typename Superclass::InputImageType InputImageType;
- typedef typename Superclass::InputPixelType InputPixelType;
- typedef typename Superclass::OutputType OutputType;
- typedef typename Superclass::CoordRepType CoordRepType;
- typedef typename Superclass::IndexType IndexType;
- typedef typename Superclass::IndexValueType IndexValueType;
- typedef typename Superclass::ContinuousIndexType ContinuousIndexType;
- typedef typename Superclass::PointType PointType;
+ typedef typename Superclass::TInputImage TInputImage;
+ typedef typename Superclass::TOutputValue TOutputValue;
+ typedef typename Superclass::TIndex TIndex;
+ typedef typename I::PixelType TPixel;
public:
itkNewMacro( Self );
RegionGrowAllBelongsFunction
);
- itkGetConstMacro( LowerThreshold, InputPixelType );
- itkGetConstMacro( UpperThreshold, InputPixelType );
+ itkGetConstMacro( LowerThreshold, TPixel );
+ itkGetConstMacro( UpperThreshold, TPixel );
- itkSetMacro( LowerThreshold, InputPixelType );
- itkSetMacro( UpperThreshold, InputPixelType );
+ itkSetMacro( LowerThreshold, TPixel );
+ itkSetMacro( UpperThreshold, TPixel );
public:
- virtual OutputType EvaluateAtIndex( const IndexType& index ) const
+ virtual TOutputValue Evaluate( const TIndex& idx ) const
{
const I* img = this->GetInputImage( );
if( img != NULL )
{
- if( this->IsInsideBuffer( index ) )
- {
- InputPixelType v = img->GetPixel( index );
- return(
- this->m_LowerThreshold <= v &&
- v <= this->m_UpperThreshold
- );
-
- } // fi
+ /* TODO
+ if( this->IsInsideBuffer( idx ) )
+ {
+ */
+ TPixel v = img->GetPixel( idx );
+ return(
+ this->m_LowerThreshold <= v &&
+ v <= this->m_UpperThreshold
+ );
+
+ // TODO: } // fi
} // fi
return( false );
protected:
RegionGrowThresholdFunction( )
: Superclass( ),
- m_LowerThreshold( std::numeric_limits< InputPixelType >::min( ) ),
- m_UpperThreshold( std::numeric_limits< InputPixelType >::max( ) )
+ m_LowerThreshold( std::numeric_limits< TPixel >::min( ) ),
+ m_UpperThreshold( std::numeric_limits< TPixel >::max( ) )
{ }
virtual ~RegionGrowThresholdFunction( )
{ }
void operator=( const Self& );
protected:
- InputPixelType m_LowerThreshold;
- InputPixelType m_UpperThreshold;
+ TPixel m_LowerThreshold;
+ TPixel m_UpperThreshold;
};
} // ecapseman
--- /dev/null
+#ifndef __FPA__IMAGE__REGIONGROWWITHMULTIPLECRITERIA__H__
+#define __FPA__IMAGE__REGIONGROWWITHMULTIPLECRITERIA__H__
+
+#include <itkImageToImageFilter.h>
+#include <itkIndex.h>
+#include <fpa/Base/RegionGrowWithMultipleCriteria.h>
+#include <fpa/Image/Algorithm.h>
+#include <fpa/Image/Functors/ImageFunction.h>
+
+namespace fpa
+{
+ namespace Image
+ {
+ /**
+ * @param I Input image type
+ */
+ template< class I >
+ class RegionGrowWithMultipleCriteria
+ : public Algorithm< I, fpa::Base::RegionGrowWithMultipleCriteria< typename I::IndexType, typename I::PixelType, typename I::PixelType, itk::Functor::IndexLexicographicCompare< I::ImageDimension >, itk::ImageToImageFilter< I, I > > >
+ {
+ public:
+ // Standard class typdedefs
+ typedef typename I::IndexType TVertex;
+ typedef typename I::PixelType TResult;
+ typedef typename I::PixelType TVertexValue;
+ typedef itk::ImageToImageFilter< I, I > TBaseFilter;
+ typedef fpa::Base::RegionGrowWithMultipleCriteria< TVertex, TResult, TVertexValue, itk::Functor::IndexLexicographicCompare< I::ImageDimension >, TBaseFilter > TBaseAlgorithm;
+
+ typedef RegionGrowWithMultipleCriteria Self;
+ typedef Algorithm< I, TBaseAlgorithm > Superclass;
+ typedef itk::SmartPointer< Self > Pointer;
+ typedef itk::SmartPointer< const Self > ConstPointer;
+
+ typedef
+ fpa::Image::Functors::ImageFunction< I, bool >
+ TMembershipFunction;
+ typedef typename Superclass::TFunctions TFunctions;
+
+ public:
+ itkNewMacro( Self );
+ itkTypeMacro(
+ RegionGrowWithMultipleCriteria,
+ fpaBaseRegionGrowWithMultipleCriteria
+ );
+
+ protected:
+ RegionGrowWithMultipleCriteria( )
+ : Superclass( )
+ { }
+ virtual ~RegionGrowWithMultipleCriteria( )
+ { }
+
+ private:
+ // Purposely not implemented
+ RegionGrowWithMultipleCriteria( const Self& );
+ void operator=( const Self& );
+ };
+
+ } // ecapseman
+
+} // ecapseman
+
+#endif // __FPA__IMAGE__REGIONGROWWITHMULTIPLECRITERIA__H__
+
+// eof - $RCSfile$
#define __FPA__IMAGE__REGIONGROWWITHMULTIPLETHRESHOLDS__H__
#include <map>
-#include <fpa/Image/RegionGrow.h>
+#include <fpa/Image/RegionGrowWithMultipleCriteria.h>
namespace fpa
{
*/
template< class I >
class RegionGrowWithMultipleThresholds
- : public RegionGrow< I >
+ : public RegionGrowWithMultipleCriteria< I >
{
public:
- typedef RegionGrowWithMultipleThresholds Self;
- typedef RegionGrow< I > Superclass;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
+ typedef RegionGrowWithMultipleThresholds Self;
+ typedef RegionGrowWithMultipleCriteria< I > Superclass;
+ typedef itk::SmartPointer< Self > Pointer;
+ typedef itk::SmartPointer< const Self > ConstPointer;
typedef typename I::PixelType TPixel;
- typedef std::map< TPixel, unsigned long > THistogram;
- typedef typename Superclass::TBaseAlgorithm TBaseAlgorithm;
+ typedef std::map< TPixel, unsigned long > THistogram;
+ typedef typename Superclass::TBaseAlgorithm TBaseAlgorithm;
+ typedef typename Superclass::TMembershipFunction TMembershipFunction;
+ typedef typename Superclass::TFunctions TFunctions;
protected:
typedef typename TBaseAlgorithm::_TNode _TNode;
virtual ~RegionGrowWithMultipleThresholds( );
virtual bool _UpdateResult( _TNode& n );
+ virtual void _BeforeLoop( );
virtual void _AfterLoop( );
private:
#ifndef __FPA__IMAGE__REGIONGROWWITHMULTIPLETHRESHOLDS__HXX__
#define __FPA__IMAGE__REGIONGROWWITHMULTIPLETHRESHOLDS__HXX__
+#include <limits>
#include <fpa/Image/Functors/RegionGrowThresholdFunction.h>
// -------------------------------------------------------------------------
void fpa::Image::RegionGrowWithMultipleThresholds< I >::
AddThreshold( const TPixel& v )
{
- this->m_Histogram[ v ] = 0;
+ typedef
+ fpa::Image::Functors::RegionGrowThresholdFunction< I >
+ TFunction;
+ typename TFunction::Pointer function = TFunction::New( );
+
+ if( this->GetNumberOfMembershipFunctions( ) > 0 )
+ {
+ }
+ else
+ function->SetLowerThreshold( std::numeric_limits< TPixel >::min( ) );
+ std::cout
+ << typeid( TPixel ).name( ) << " "
+ << function->GetLowerThreshold( )
+ << std::endl;
+ function->SetUpperThreshold( v );
+ this->AddMembershipFunction( function );
/* TODO
- typedef
- fpa::Image::Functors::RegionGrowThresholdFunction< I >
- TFunction;
+ this->m_Histogram[ v ] = 0;
+
TFunction* function =
dynamic_cast< TFunction* >( this->GetMembershipFunction( ) );
if( function != NULL )
{
function->SetLowerThreshold( this->m_Histogram.begin( )->first );
- function->SetUpperThreshold( this->m_Histogram.rbegin( )->first );
} // fi
+ this->Modified( );
*/
- this->Modified( );
}
// -------------------------------------------------------------------------
: Superclass( ),
m_DerivativeThreshold( double( 3 ) )
{
- typedef
- fpa::Image::Functors::RegionGrowThresholdFunction< I >
- TFunction;
- typename TFunction::Pointer function = TFunction::New( );
- this->SetMembershipFunction( function );
+ /* TODO
+ typedef
+ fpa::Image::Functors::RegionGrowThresholdFunction< I >
+ TFunction;
+ typename TFunction::Pointer function = TFunction::New( );
+ this->SetMembershipFunction( function );
+ */
}
// -------------------------------------------------------------------------
{
bool ret = this->Superclass::_UpdateResult( n );
- if( ret )
- {
- TPixel v = TPixel( this->_Cost( n.Vertex, n.Vertex ) );
+ /* TODO
+ if( ret )
+ {
+ TPixel v = TPixel( this->_Cost( n.Vertex, n.Vertex ) );
- typename THistogram::reverse_iterator hIt = this->m_Histogram.rbegin( );
- while( hIt != this->m_Histogram.rend( ) )
- {
- if( v <= hIt->first )
- {
- hIt->second += 1;
- hIt++;
- }
- else
- hIt = this->m_Histogram.rend( );
-
- } // elihw
- this->GetOutput( )->SetPixel( n.Vertex, v );
-
- } // fi
+ typename THistogram::reverse_iterator hIt = this->m_Histogram.rbegin( );
+ while( hIt != this->m_Histogram.rend( ) )
+ {
+ if( v <= hIt->first )
+ {
+ hIt->second += 1;
+ hIt++;
+ }
+ else
+ hIt = this->m_Histogram.rend( );
+
+ } // elihw
+ this->GetOutput( )->SetPixel( n.Vertex, v );
+
+ } // fi
+ */
return( ret );
}
+// -------------------------------------------------------------------------
+template< class I >
+void fpa::Image::RegionGrowWithMultipleThresholds< I >::
+_BeforeLoop( )
+{
+ std::cout << "**1" << std::endl;
+ const I* img = this->GetInput( );
+ std::cout << "**2" << std::endl;
+ typename TFunctions::iterator fIt = this->m_Functions.begin( );
+ for( ; fIt != this->m_Functions.end( ); ++fIt )
+ {
+ TMembershipFunction* f =
+ dynamic_cast< TMembershipFunction* >( fIt->GetPointer( ) );
+ if( f != NULL )
+ f->SetInputImage( this->GetInput( ) );
+
+ } // rof
+ this->Superclass::_BeforeLoop( );
+}
+
// -------------------------------------------------------------------------
template< class I >
void fpa::Image::RegionGrowWithMultipleThresholds< I >::