1 #ifndef __FPA__IMAGE__ALGORITHM__HXX__
2 #define __FPA__IMAGE__ALGORITHM__HXX__
4 #include <itkConstNeighborhoodIterator.h>
6 // -------------------------------------------------------------------------
7 template< class _TInputImage, class _TOutputImage >
8 fpa::Image::Algorithm< _TInputImage, _TOutputImage >::
11 m_NeighborhoodOrder( 1 )
15 // -------------------------------------------------------------------------
16 template< class _TInputImage, class _TOutputImage >
17 fpa::Image::Algorithm< _TInputImage, _TOutputImage >::
22 // -------------------------------------------------------------------------
23 template< class _TInputImage, class _TOutputImage >
24 void fpa::Image::Algorithm< _TInputImage, _TOutputImage >::
25 _BeforeGenerateData( )
27 this->Superclass::_BeforeGenerateData( );
28 this->AllocateOutputs( );
31 // -------------------------------------------------------------------------
32 template< class _TInputImage, class _TOutputImage >
33 void fpa::Image::Algorithm< _TInputImage, _TOutputImage >::
36 TOutputImage* out = this->GetOutput( );
37 this->m_Marks = TMarkImage::New( );
38 this->m_Marks->CopyInformation( out );
39 this->m_Marks->SetRequestedRegion( out->GetRequestedRegion( ) );
40 this->m_Marks->SetBufferedRegion( out->GetBufferedRegion( ) );
41 this->m_Marks->Allocate( );
42 this->m_Marks->FillBuffer( 0 );
45 // -------------------------------------------------------------------------
46 template< class _TInputImage, class _TOutputImage >
47 void fpa::Image::Algorithm< _TInputImage, _TOutputImage >::
50 this->GetOutput( )->FillBuffer( TScalar( 0 ) );
53 // -------------------------------------------------------------------------
54 template< class _TInputImage, class _TOutputImage >
55 void fpa::Image::Algorithm< _TInputImage, _TOutputImage >::
56 _DeallocateAuxiliary( )
61 // -------------------------------------------------------------------------
62 template< class _TInputImage, class _TOutputImage >
63 typename fpa::Image::Algorithm< _TInputImage, _TOutputImage >::
64 TFrontId fpa::Image::Algorithm< _TInputImage, _TOutputImage >::
65 _GetMark( const TVertex& v )
67 if( this->m_Marks->GetRequestedRegion( ).IsInside( v ) )
68 return( this->m_Marks->GetPixel( v ) );
73 // -------------------------------------------------------------------------
74 template< class _TInputImage, class _TOutputImage >
75 void fpa::Image::Algorithm< _TInputImage, _TOutputImage >::
76 _Visit( const TNode& n )
78 if( this->m_Marks->GetRequestedRegion( ).IsInside( n.Vertex ) )
80 this->m_Marks->SetPixel( n.Vertex, n.FrontId );
81 this->GetOutput( )->SetPixel( n.Vertex, n.Result );
86 // -------------------------------------------------------------------------
87 template< class _TInputImage, class _TOutputImage >
88 typename fpa::Image::Algorithm< _TInputImage, _TOutputImage >::
89 TVertices fpa::Image::Algorithm< _TInputImage, _TOutputImage >::
90 _GetNeighborhood( const TVertex& v ) const
93 auto reg = this->GetInput( )->GetRequestedRegion( );
94 if( this->m_NeighborhoodOrder == 1 )
96 for( unsigned int d = 0; d < _TInputImage::ImageDimension; d++ )
98 for( int i = -1; i <= 1; i += 2 )
102 if( reg.IsInside( n ) )
103 neighs.push_back( n );
111 typedef itk::ConstNeighborhoodIterator< _TInputImage > _TNeighIt;
112 typename _TInputImage::SizeType nSize;
115 _TNeighIt nIt( nSize, this->GetInput( ), reg );
116 nIt.SetLocation( v );
117 for( unsigned int i = 0; i < nIt.Size( ); i++ )
119 TVertex n = nIt.GetIndex( i );
122 if( reg.IsInside( n ) )
123 neighs.push_back( n );
131 #endif // __FPA__IMAGE__ALGORITHM__HXX__