#ifndef __CTBronchi__MoriLabelling__h__
#define __CTBronchi__MoriLabelling__h__
+#include <fpa/Filters/Image/DefaultTraits.h>
+#include <fpa/Filters/MarksInterface.h>
+#include <fpa/Filters/Image/LabelsSeedFilter.h>
+#include <fpa/Filters/Image/LabelsSeedInterface.h>
+#include <fpa/Filters/Image/RegionGrow.h>
+#include <fpa/Functors/RegionGrow/BinaryThreshold.h>
+
/* TODO
#include <fpa/Base/RegionGrow.h>
#include <fpa/Base/MarksInterface.h>
{
/**
*/
- /* TODO
- template< class _TInputImage, class _TLabelImage, class _TTraits = fpa::Image::DefaultTraits< _TInputImage, _TLabelImage, typename _TLabelImage::PixelType > >
- class MoriLabelling
- : public fpa::Base::RegionGrow< fpa::Image::Algorithm< _TTraits, fpa::Base::MarksInterface< _TTraits >, fpa::Image::LabelledSeedsInterface< _TTraits > > >
- {
- public:
- typedef _TInputImage TInputImage;
- typedef _TLabelImage TLabelImage;
- typedef _TTraits TTraits;
- fpa_Base_TraitTypes( typename TTraits );
-
- typedef fpa::Base::MarksInterface< TTraits > TMarksInterface;
- typedef fpa::Image::LabelledSeedsInterface< TTraits > TSeedsInterface;
- typedef fpa::Image::Algorithm< TTraits, TMarksInterface, TSeedsInterface > TAlgorithm;
-
- typedef MoriLabelling Self;
- typedef fpa::Base::RegionGrow< TAlgorithm > Superclass;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
-
- typedef fpa::Base::Functors::RegionGrow::BinaryThreshold< TInputValue > TThresholdFunction;
-
- public:
- itkNewMacro( Self );
- itkTypeMacro( MoriLabelling, fpa::Base::RegionGrow );
-
- itkGetConstMacro( InsideLabel, TOutputValue );
- itkSetMacro( InsideLabel, TOutputValue );
-
- public:
- const TLabelImage* GetInputLabelImage( ) const;
- void SetInputLabelImage( TLabelImage* image );
-
- const TInputImage* GetInputRawImage( ) const;
- void SetInputRawImage( TInputImage* image );
-
- TInputValue GetUpperThreshold( ) const;
- void SetUpperThreshold( TInputValue t );
-
- TOutputValue GetOutsideValue( ) const;
- void SetOutsideLabel( TOutputValue o );
-
- protected:
- MoriLabelling( );
- virtual ~MoriLabelling( );
-
- virtual TNodes _UnifySeeds( ) override;
- virtual void _UpdateOutputValue( TNode& n ) override;
-
- private:
- // Purposely not implemented.
- MoriLabelling( const Self& other );
- Self& operator=( const Self& other );
-
- protected:
- TOutputValue m_InsideLabel;
- };
- */
+ template< class _TInputImage, class _TLabelImage >
+ class MoriLabellingTraits
+ : public fpa::Filters::Image::DefaultTraits< _TInputImage, _TLabelImage, typename _TLabelImage::PixelType >
+ {
+ public:
+ typedef _TInputImage TInputImage;
+ typedef _TLabelImage TLabelImage;
+ typedef fpa::Filters::Image::DefaultTraits< TInputImage, TLabelImage, typename TLabelImage::PixelType > Superclass;
+
+ typedef typename Superclass::TInternalTraits TInternalTraits;
+ typedef typename Superclass::TFilter TFilter;
+ typedef fpa::Filters::MarksInterface< TInternalTraits > TMarksInterface;
+ typedef fpa::Filters::Image::LabelsSeedInterface< TInternalTraits > TSeedsInterface;
+ };
+
+ /**
+ */
+ template< class _TInputImage, class _TLabelImage >
+ class MoriLabelling
+ : public fpa::Filters::Image::LabelsSeedFilter< fpa::Filters::Image::Algorithm< fpa::Filters::RegionGrow< CTBronchi::MoriLabellingTraits< _TInputImage, _TLabelImage > > >, _TLabelImage >
+ {
+ public:
+ typedef _TInputImage TInputImage;
+ typedef _TLabelImage TLabelImage;
+ typedef CTBronchi::MoriLabellingTraits< TInputImage, TLabelImage > TTraits;
+ fpaTraitsMacro( typename, TTraits );
+
+ typedef fpa::Filters::Image::Algorithm< fpa::Filters::RegionGrow< TTraits > > TAlgorithm;
+ typedef fpa::Filters::Image::LabelsSeedFilter< TAlgorithm, _TLabelImage > Superclass;
+ typedef MoriLabelling Self;
+ typedef itk::SmartPointer< Self > Pointer;
+ typedef itk::SmartPointer< const Self > ConstPointer;
+
+ typedef fpa::Functors::RegionGrow::BinaryThreshold< TInputValue > TLabelFunctor;
+
+ public:
+ itkNewMacro( Self );
+ itkTypeMacro( CTBronchi::MoriLabelling, fpa::Filters::Image::RegionGrow );
+
+ public:
+ TInputValue GetUpperThreshold( ) const;
+ void SetUpperThreshold( TInputValue t );
+
+ protected:
+ MoriLabelling( );
+ virtual ~MoriLabelling( );
+
+ virtual void _UpdateOutputValue( TNode& n ) override;
+
+ private:
+ // Purposely not implemented.
+ MoriLabelling( const Self& other );
+ Self& operator=( const Self& other );
+
+ protected:
+ typename TLabelFunctor::Pointer m_LabelFunctor;
+ };
} // ecapseman
#ifndef __CTBronchi__MoriLabelling__hxx__
#define __CTBronchi__MoriLabelling__hxx__
-/* TODO
- #include <itkImageRegionConstIteratorWithIndex.h>
-
- // -------------------------------------------------------------------------
- template< class _TInputImage, class _TLabelImage, class _TTraits >
- const typename CTBronchi::MoriLabelling< _TInputImage, _TLabelImage, _TTraits >::
- TLabelImage* CTBronchi::MoriLabelling< _TInputImage, _TLabelImage, _TTraits >::
- GetInputLabelImage( ) const
- {
- return( this->GetLabels( ) );
- }
-
- // -------------------------------------------------------------------------
- template< class _TInputImage, class _TLabelImage, class _TTraits >
- void CTBronchi::MoriLabelling< _TInputImage, _TLabelImage, _TTraits >::
- SetInputLabelImage( TLabelImage* image )
- {
- this->SetLabels( image );
- }
-
- // -------------------------------------------------------------------------
- template< class _TInputImage, class _TLabelImage, class _TTraits >
- const typename CTBronchi::MoriLabelling< _TInputImage, _TLabelImage, _TTraits >::
- TInputImage* CTBronchi::MoriLabelling< _TInputImage, _TLabelImage, _TTraits >::
- GetInputRawImage( ) const
- {
- return( this->GetInput( ) );
- }
-
- // -------------------------------------------------------------------------
- template< class _TInputImage, class _TLabelImage, class _TTraits >
- void CTBronchi::MoriLabelling< _TInputImage, _TLabelImage, _TTraits >::
- SetInputRawImage( TInputImage* image )
- {
- this->SetInput( image );
- }
-
- // -------------------------------------------------------------------------
- template< class _TInputImage, class _TLabelImage, class _TTraits >
- typename CTBronchi::MoriLabelling< _TInputImage, _TLabelImage, _TTraits >::
- TInputValue CTBronchi::MoriLabelling< _TInputImage, _TLabelImage, _TTraits >::
- GetUpperThreshold( ) const
- {
- const TThresholdFunction* func =
- dynamic_cast< const TThresholdFunction* >( this->GetValuePredicate( ) );
- if( func != NULL )
- return( func->GetUpper( ) );
- else
- return( TInputValue( 0 ) );
- }
-
- // -------------------------------------------------------------------------
- template< class _TInputImage, class _TLabelImage, class _TTraits >
- void CTBronchi::MoriLabelling< _TInputImage, _TLabelImage, _TTraits >::
- SetUpperThreshold( TInputValue t )
- {
- TThresholdFunction* func =
- dynamic_cast< TThresholdFunction* >( this->GetValuePredicate( ) );
- if( func != NULL )
- func->SetUpper( t );
- }
-
- // -------------------------------------------------------------------------
- template< class _TInputImage, class _TLabelImage, class _TTraits >
- typename CTBronchi::MoriLabelling< _TInputImage, _TLabelImage, _TTraits >::
- TOutputValue CTBronchi::MoriLabelling< _TInputImage, _TLabelImage, _TTraits >::
- GetOutsideValue( ) const
- {
- return( this->GetInitValue( ) );
- }
-
- // -------------------------------------------------------------------------
- template< class _TInputImage, class _TLabelImage, class _TTraits >
- void CTBronchi::MoriLabelling< _TInputImage, _TLabelImage, _TTraits >::
- SetOutsideLabel( TOutputValue o )
- {
- this->SetInitValue( o );
- }
-
- // -------------------------------------------------------------------------
- template< class _TInputImage, class _TLabelImage, class _TTraits >
- CTBronchi::MoriLabelling< _TInputImage, _TLabelImage, _TTraits >::
- MoriLabelling( )
- : Superclass( ),
- m_InsideLabel( TOutputValue( 0 ) )
- {
- typename TThresholdFunction::Pointer func = TThresholdFunction::New( );
- this->SetPredicate( func );
- }
-
- // -------------------------------------------------------------------------
- template< class _TInputImage, class _TLabelImage, class _TTraits >
- CTBronchi::MoriLabelling< _TInputImage, _TLabelImage, _TTraits >::
- ~MoriLabelling( )
- {
- }
-
- // -------------------------------------------------------------------------
- template< class _TInputImage, class _TLabelImage, class _TTraits >
- typename CTBronchi::MoriLabelling< _TInputImage, _TLabelImage, _TTraits >::
- TNodes CTBronchi::MoriLabelling< _TInputImage, _TLabelImage, _TTraits >::
- _UnifySeeds( )
- {
- this->m_Seeds.clear( );
- const TLabelImage* lbl = this->GetLabels( );
- if( lbl == NULL )
- {
- std::ostringstream msg;
- msg << "itk::ERROR: CTBronchi::MoriLabelling (" << this
- << "): Labelled image not defined.";
- ::itk::ExceptionObject e(
- __FILE__, __LINE__, msg.str( ).c_str( ), ITK_LOCATION
- );
- throw e;
-
- } // fi
-
- // Iterate over labels
- typename TLabelImage::RegionType reg = lbl->GetRequestedRegion( );
- itk::ImageRegionConstIteratorWithIndex< TLabelImage > lIt( lbl, reg );
- for( lIt.GoToBegin( ); !lIt.IsAtEnd( ); ++lIt )
- {
- if( lIt.Get( ) > 0 )
- {
- bool is_seed = false;
- for( unsigned int d = 0; d < TLabelImage::ImageDimension; ++d )
- {
- for( int s = -1; s <= 1; s += 2 )
- {
- TVertex neigh = lIt.GetIndex( );
- neigh[ d ] += s;
- if( reg.IsInside( neigh ) )
- is_seed |= ( lbl->GetPixel( neigh ) == 0 );
-
- } // rof
-
- } // rof
-
- if( !is_seed )
- {
- typename TSeedsInterface::TNode node;
- node.Vertex = lIt.GetIndex( );
- node.Parent = lIt.GetIndex( );
- node.FrontId = lIt.Get( );
- node.Value = this->m_InsideLabel;
- this->_Mark( node.Vertex, node.FrontId );
- this->_UpdateOutputValue( node );
- }
- else
- {
- typename TSeedsInterface::TSeed seed;
- seed.Vertex = lIt.GetIndex( );
- seed.IsPoint = false;
- seed.FrontId = lIt.Get( );
- this->m_Seeds.push_back( seed );
-
- } // fi
-
- } // fi
-
- } // rof
-
- // Ok, finish initialization
- return( this->Superclass::_UnifySeeds( ) );
- }
-
- // -------------------------------------------------------------------------
- template< class _TInputImage, class _TLabelImage, class _TTraits >
- void CTBronchi::MoriLabelling< _TInputImage, _TLabelImage, _TTraits >::
- _UpdateOutputValue( TNode& n )
- {
- const TLabelImage* input_labels = this->GetInputLabelImage( );
-
- this->Superclass::_UpdateOutputValue( n );
- if( n.FrontId != 0 )
- {
- if( input_labels->GetPixel( n.Vertex ) == this->GetInsideValue( ) )
- n.Value = this->GetInsideLabel( );
- else
- n.Value = TOutputValue( 0 );
- this->TAlgorithm::_UpdateOutputValue( n );
-
- } // fi
- }
-*/
+// -------------------------------------------------------------------------
+template< class _TInputImage, class _TLabelImage >
+typename CTBronchi::MoriLabelling< _TInputImage, _TLabelImage >::
+TInputValue CTBronchi::MoriLabelling< _TInputImage, _TLabelImage >::
+GetUpperThreshold( ) const
+{
+ return( this->m_LabelFunctor->GetUpperThreshold( ) );
+}
+
+// -------------------------------------------------------------------------
+template< class _TInputImage, class _TLabelImage >
+void CTBronchi::MoriLabelling< _TInputImage, _TLabelImage >::
+SetUpperThreshold( TInputValue t )
+{
+ this->m_LabelFunctor->SetUpperThreshold( t );
+}
+
+// -------------------------------------------------------------------------
+template< class _TInputImage, class _TLabelImage >
+CTBronchi::MoriLabelling< _TInputImage, _TLabelImage >::
+MoriLabelling( )
+ : Superclass( )
+{
+ this->m_LabelFunctor = TLabelFunctor::New( );
+ this->SetPredicate( this->m_LabelFunctor );
+}
+
+// -------------------------------------------------------------------------
+template< class _TInputImage, class _TLabelImage >
+CTBronchi::MoriLabelling< _TInputImage, _TLabelImage >::
+~MoriLabelling( )
+{
+}
+
+// -------------------------------------------------------------------------
+template< class _TInputImage, class _TLabelImage >
+void CTBronchi::MoriLabelling< _TInputImage, _TLabelImage >::
+_UpdateOutputValue( TNode& n )
+{
+ this->Superclass::_UpdateOutputValue( n );
+ if( n.FrontId != 0 )
+ {
+ const TLabelImage* input_labels = this->GetInputLabels( );
+ if( input_labels->GetPixel( n.Vertex ) == this->GetInsideValue( ) )
+ n.Value = TOutputValue( 1 ); // this->GetInsideLabel( );
+ else
+ n.Value = TOutputValue( 0 );
+ /* TODO
+ if( input_labels->GetPixel( n.Vertex ) == this->GetInsideValue( ) )
+ */
+ } // fi
+}
#endif // __CTBronchi__MoriLabelling__hxx__
// -------------------------------------------------------------------------
template< class _TInputPtr, class _TOutputPtr >
-void Label( _TOutputPtr& output, const _TInputPtr& input )
+void Label( _TOutputPtr& output, const _TInputPtr& input, const _TOutputPtr& labels )
{
+ typedef typename _TInputPtr::ObjectType _TInput;
+ typedef typename _TOutputPtr::ObjectType _TOutput;
+ typedef CTBronchi::MoriLabelling< _TInput, _TOutput > _TLabelling;
+
+ typename _TLabelling::Pointer labelling = _TLabelling::New( );
+ labelling->SetInput( input );
+ labelling->SetInputLabels( labels );
+ // TODO: labelling->SetOutsideValue( ); // out label
+ // TODO: labelling->SetInsideValue( ); // inside label
+ // TODO: labelling->SetUpperThreshold( );
+ double t = MeasureTime( labelling );
+ std::cout << "Labelling executed in " << t << " s" << std::endl;
+ output = labelling->GetOutput( );
+ TMap::const_iterator i = Args.find( "out_labels" );
+ if( i != Args.end( ) )
+ WriteImage( output, i->second );
+ output->DisconnectPipeline( );
}
// -------------------------------------------------------------------------
// Create labels
TLabelImage::Pointer labels;
- Label( labels, mori );
+ Label( labels, input_image, mori );
return( 0 );
--- /dev/null
+// =========================================================================
+// @author Leonardo Florez Valencia
+// @email florez-l@javeriana.edu.co
+// =========================================================================
+#ifndef __fpa__Filters__Image__LabelsSeedFilter__h__
+#define __fpa__Filters__Image__LabelsSeedFilter__h__
+
+namespace fpa
+{
+ namespace Filters
+ {
+ namespace Image
+ {
+ /**
+ */
+ template< class _TFilter, class _TInputLabels >
+ class LabelsSeedFilter
+ : public _TFilter
+ {
+ public:
+ typedef _TInputLabels TInputLabels;
+ typedef typename _TFilter::TTraits TTraits;
+ fpaTraitsMacro( typename, TTraits );
+
+ typedef _TFilter Superclass;
+ typedef LabelsSeedFilter Self;
+ typedef itk::SmartPointer< Self > Pointer;
+ typedef itk::SmartPointer< const Self > ConstPointer;
+
+ public:
+ itkNewMacro( Self );
+ itkTypeMacro(
+ fpa::Filters::Image::LabelsSeedFilter, TFilter
+ );
+
+ fpaFilterInputMacro( InputLabels, TInputLabels );
+
+ protected:
+ LabelsSeedFilter( );
+ virtual ~LabelsSeedFilter( );
+
+ virtual const itk::DataObject* _GetReferenceInput( ) const override;
+ virtual void _PrepareSeeds( const itk::DataObject* input ) override;
+
+ private:
+ // Purposely not implemented.
+ LabelsSeedFilter( const Self& other );
+ Self& operator=( const Self& other );
+
+ protected:
+ unsigned int m_InputLabelsIdx;
+ };
+
+ } // ecapseman
+
+ } // ecapseman
+
+} // ecapseman
+
+#ifndef ITK_MANUAL_INSTANTIATION
+# include <fpa/Filters/Image/LabelsSeedFilter.hxx>
+#endif // ITK_MANUAL_INSTANTIATION
+#endif // __fpa__Filters__Image__LabelsSeedFilter__h__
+// eof - $RCSfile$
--- /dev/null
+// =========================================================================
+// @author Leonardo Florez Valencia
+// @email florez-l@javeriana.edu.co
+// =========================================================================
+#ifndef __fpa__Filters__Image__LabelsSeedFilter__hxx__
+#define __fpa__Filters__Image__LabelsSeedFilter__hxx__
+
+#include <itkImageRegionConstIteratorWithIndex.h>
+
+// -------------------------------------------------------------------------
+template< class _TFilter, class _TInputLabels >
+fpa::Filters::Image::LabelsSeedFilter< _TFilter, _TInputLabels >::
+LabelsSeedFilter( )
+ : Superclass( )
+{
+ fpaFilterInputConfigureMacro( InputLabels, TInputLabels );
+}
+
+// -------------------------------------------------------------------------
+template< class _TFilter, class _TInputLabels >
+fpa::Filters::Image::LabelsSeedFilter< _TFilter, _TInputLabels >::
+~LabelsSeedFilter( )
+{
+}
+
+// -------------------------------------------------------------------------
+template< class _TFilter, class _TInputLabels >
+const itk::DataObject*
+fpa::Filters::Image::LabelsSeedFilter< _TFilter, _TInputLabels >::
+_GetReferenceInput( ) const
+{
+ return( this->GetInputLabels( ) );
+}
+
+// -------------------------------------------------------------------------
+template< class _TFilter, class _TInputLabels >
+void fpa::Filters::Image::LabelsSeedFilter< _TFilter, _TInputLabels >::
+_PrepareSeeds( const itk::DataObject* input )
+{
+ // Input object is a labelled image?
+ const TInputLabels* labels = dynamic_cast< const TInputLabels* >( input );
+ if( labels != NULL )
+ {
+ this->m_UnifiedSeeds.clear( );
+
+ // Iterate over labels
+ typedef itk::ImageRegionConstIteratorWithIndex< TInputLabels > _TIt;
+ typename TInputLabels::RegionType reg = labels->GetRequestedRegion( );
+ _TIt lIt( labels, reg );
+ for( lIt.GoToBegin( ); !lIt.IsAtEnd( ); ++lIt )
+ {
+ if( lIt.Get( ) > 0 )
+ {
+ bool is_seed = false;
+ for( unsigned int d = 0; d < Self::Dimension; ++d )
+ {
+ for( int s = -1; s <= 1; s += 2 )
+ {
+ TVertex neigh = lIt.GetIndex( );
+ neigh[ d ] += s;
+ if( reg.IsInside( neigh ) )
+ is_seed |= ( labels->GetPixel( neigh ) == 0 );
+
+ } // rof
+
+ } // rof
+
+ // Add pixel as seed or already marked
+ TNode node;
+ node.Vertex = lIt.GetIndex( );
+ node.Parent = lIt.GetIndex( );
+ node.FrontId = lIt.Get( );
+ node.Value = TOutputValue( 0 );
+ if( !is_seed )
+ {
+ this->_Mark( node.Vertex, node.FrontId );
+ this->_UpdateOutputValue( node );
+ }
+ else
+ this->m_UnifiedSeeds.insert( node );
+
+ } // fi
+
+ } // rof
+
+ } // fi
+}
+
+#endif // __fpa__Filters__Image__LabelsSeedFilter__hxx__
+// eof - $RCSfile$
#include <fpa/Filters/Image/Algorithm.h>
#include <fpa/Filters/Image/DefaultTraits.h>
#include <fpa/Filters/MarksInterface.h>
+#include <fpa/Filters/Image/LabelsSeedFilter.h>
#include <fpa/Filters/Image/LabelsSeedInterface.h>
namespace fpa
*/
template< class _TInputImage, class _TInputLabels, class _TCostsImage = itk::Image< float, _TInputImage::ImageDimension >, class _TTraits = fpa::Filters::Image::RandomWalkerTraits< _TInputImage, _TInputLabels, _TCostsImage > >
class RandomWalker
- : public fpa::Filters::Image::Algorithm< fpa::Filters::DijkstraBase< _TTraits > >
+ : public fpa::Filters::Image::LabelsSeedFilter< fpa::Filters::Image::Algorithm< fpa::Filters::DijkstraBase< _TTraits > >, _TInputLabels >
{
public:
typedef _TInputImage TInputImage;
fpaTraitsMacro( typename, TTraits );
typedef fpa::Filters::DijkstraBase< TTraits > TAlgorithm;
- typedef fpa::Filters::Image::Algorithm< TAlgorithm > Superclass;
- typedef RandomWalker Self;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
-
+ typedef fpa::Filters::Image::Algorithm< TAlgorithm > TBase;
+ typedef fpa::Filters::Image::LabelsSeedFilter< TBase, TInputLabels > Superclass;
+ typedef RandomWalker Self;
+ typedef itk::SmartPointer< Self > Pointer;
+ typedef itk::SmartPointer< const Self > ConstPointer;
typedef typename Superclass::TMarksImage TOutputLabels;
public:
fpa::Filters::Image::RandomWalker, fpa::Filters::Image::Algorithm
);
- fpaFilterInputMacro( InputLabels, TInputLabels );
-
public:
TCostsImage* GetOutputCosts( );
const TCostsImage* GetOutputCosts( ) const;
RandomWalker( );
virtual ~RandomWalker( );
- virtual const itk::DataObject* _GetReferenceInput( ) const override;
- virtual void _PrepareSeeds( const itk::DataObject* input ) override;
-
private:
// Purposely not implemented.
RandomWalker( const Self& other );
Self& operator=( const Self& other );
-
- protected:
- unsigned int m_InputLabelsIdx;
};
} // ecapseman
#ifndef __fpa__Filters__Image__RandomWalker__hxx__
#define __fpa__Filters__Image__RandomWalker__hxx__
-#include <itkImageRegionConstIteratorWithIndex.h>
-
// -------------------------------------------------------------------------
template< class _TInputImage, class _TInputLabels, class _TCostsImage, class _TTraits >
typename
RandomWalker( )
: Superclass( )
{
- fpaFilterInputConfigureMacro( InputLabels, TInputLabels );
}
// -------------------------------------------------------------------------
{
}
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TInputLabels, class _TCostsImage, class _TTraits >
-const itk::DataObject*
-fpa::Filters::Image::RandomWalker< _TInputImage, _TInputLabels, _TCostsImage, _TTraits >::
-_GetReferenceInput( ) const
-{
- return( this->GetInputLabels( ) );
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TInputLabels, class _TCostsImage, class _TTraits >
-void
-fpa::Filters::Image::RandomWalker< _TInputImage, _TInputLabels, _TCostsImage, _TTraits >::
-_PrepareSeeds( const itk::DataObject* input )
-{
- // Input object is a labelled image?
- const TInputLabels* labels = dynamic_cast< const TInputLabels* >( input );
- if( labels != NULL )
- {
- this->m_UnifiedSeeds.clear( );
-
- // Iterate over labels
- typedef itk::ImageRegionConstIteratorWithIndex< TInputLabels > _TIt;
- typename TInputLabels::RegionType reg = labels->GetRequestedRegion( );
- _TIt lIt( labels, reg );
- for( lIt.GoToBegin( ); !lIt.IsAtEnd( ); ++lIt )
- {
- if( lIt.Get( ) > 0 )
- {
- bool is_seed = false;
- for( unsigned int d = 0; d < Self::Dimension; ++d )
- {
- for( int s = -1; s <= 1; s += 2 )
- {
- TVertex neigh = lIt.GetIndex( );
- neigh[ d ] += s;
- if( reg.IsInside( neigh ) )
- is_seed |= ( labels->GetPixel( neigh ) == 0 );
-
- } // rof
-
- } // rof
-
- // Add pixel as seed or already marked
- TNode node;
- node.Vertex = lIt.GetIndex( );
- node.Parent = lIt.GetIndex( );
- node.FrontId = lIt.Get( );
- node.Value = TOutputValue( 0 );
- if( !is_seed )
- {
- this->_Mark( node.Vertex, node.FrontId );
- this->_UpdateOutputValue( node );
- }
- else
- this->m_UnifiedSeeds.insert( node );
-
- } // fi
-
- } // rof
-
- } // fi
-}
-
#endif // __fpa__Filters__Image__RandomWalker__hxx__
// eof - $RCSfile$