From: Leonardo Flórez-Valencia Date: Fri, 18 Aug 2017 03:16:14 +0000 (-0500) Subject: ... X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?p=FrontAlgorithms.git;a=commitdiff_plain;h=b6c80dbd5be1caf6cbdbfc21d2075021c57d7af2 ... --- diff --git a/appli/CTBronchi/MoriLabelling.h b/appli/CTBronchi/MoriLabelling.h index 0a9c586..caa96aa 100644 --- a/appli/CTBronchi/MoriLabelling.h +++ b/appli/CTBronchi/MoriLabelling.h @@ -6,6 +6,13 @@ #ifndef __CTBronchi__MoriLabelling__h__ #define __CTBronchi__MoriLabelling__h__ +#include +#include +#include +#include +#include +#include + /* TODO #include #include @@ -19,64 +26,63 @@ namespace CTBronchi { /** */ - /* 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 diff --git a/appli/CTBronchi/MoriLabelling.hxx b/appli/CTBronchi/MoriLabelling.hxx index 228ed2d..e654b09 100644 --- a/appli/CTBronchi/MoriLabelling.hxx +++ b/appli/CTBronchi/MoriLabelling.hxx @@ -6,191 +6,58 @@ #ifndef __CTBronchi__MoriLabelling__hxx__ #define __CTBronchi__MoriLabelling__hxx__ -/* TODO - #include - - // ------------------------------------------------------------------------- - 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__ diff --git a/appli/CTBronchi/Process.cxx b/appli/CTBronchi/Process.cxx index 4261a97..848a1f0 100644 --- a/appli/CTBronchi/Process.cxx +++ b/appli/CTBronchi/Process.cxx @@ -133,8 +133,25 @@ void Mori( _TOutputPtr& output, const _TInputPtr& input ) // ------------------------------------------------------------------------- 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( ); } // ------------------------------------------------------------------------- @@ -206,7 +223,7 @@ int main( int argc, char* argv[] ) // Create labels TLabelImage::Pointer labels; - Label( labels, mori ); + Label( labels, input_image, mori ); return( 0 ); diff --git a/lib/fpa/Filters/Image/LabelsSeedFilter.h b/lib/fpa/Filters/Image/LabelsSeedFilter.h new file mode 100644 index 0000000..b640fa7 --- /dev/null +++ b/lib/fpa/Filters/Image/LabelsSeedFilter.h @@ -0,0 +1,64 @@ +// ========================================================================= +// @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 +#endif // ITK_MANUAL_INSTANTIATION +#endif // __fpa__Filters__Image__LabelsSeedFilter__h__ +// eof - $RCSfile$ diff --git a/lib/fpa/Filters/Image/LabelsSeedFilter.hxx b/lib/fpa/Filters/Image/LabelsSeedFilter.hxx new file mode 100644 index 0000000..b23a4c3 --- /dev/null +++ b/lib/fpa/Filters/Image/LabelsSeedFilter.hxx @@ -0,0 +1,90 @@ +// ========================================================================= +// @author Leonardo Florez Valencia +// @email florez-l@javeriana.edu.co +// ========================================================================= +#ifndef __fpa__Filters__Image__LabelsSeedFilter__hxx__ +#define __fpa__Filters__Image__LabelsSeedFilter__hxx__ + +#include + +// ------------------------------------------------------------------------- +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$ diff --git a/lib/fpa/Filters/Image/RandomWalker.h b/lib/fpa/Filters/Image/RandomWalker.h index 41fba2c..bf5af11 100644 --- a/lib/fpa/Filters/Image/RandomWalker.h +++ b/lib/fpa/Filters/Image/RandomWalker.h @@ -10,6 +10,7 @@ #include #include #include +#include #include namespace fpa @@ -40,7 +41,7 @@ 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; @@ -50,11 +51,11 @@ namespace fpa 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: @@ -63,8 +64,6 @@ namespace fpa fpa::Filters::Image::RandomWalker, fpa::Filters::Image::Algorithm ); - fpaFilterInputMacro( InputLabels, TInputLabels ); - public: TCostsImage* GetOutputCosts( ); const TCostsImage* GetOutputCosts( ) const; @@ -80,16 +79,10 @@ namespace fpa 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 diff --git a/lib/fpa/Filters/Image/RandomWalker.hxx b/lib/fpa/Filters/Image/RandomWalker.hxx index ef858b5..12543a3 100644 --- a/lib/fpa/Filters/Image/RandomWalker.hxx +++ b/lib/fpa/Filters/Image/RandomWalker.hxx @@ -5,8 +5,6 @@ #ifndef __fpa__Filters__Image__RandomWalker__hxx__ #define __fpa__Filters__Image__RandomWalker__hxx__ -#include - // ------------------------------------------------------------------------- template< class _TInputImage, class _TInputLabels, class _TCostsImage, class _TTraits > typename @@ -88,7 +86,6 @@ fpa::Filters::Image::RandomWalker< _TInputImage, _TInputLabels, _TCostsImage, _T RandomWalker( ) : Superclass( ) { - fpaFilterInputConfigureMacro( InputLabels, TInputLabels ); } // ------------------------------------------------------------------------- @@ -98,69 +95,5 @@ fpa::Filters::Image::RandomWalker< _TInputImage, _TInputLabels, _TCostsImage, _T { } -// ------------------------------------------------------------------------- -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$