1 // =========================================================================
2 // @author Leonardo Florez Valencia
3 // @email florez-l@javeriana.edu.co
4 // =========================================================================
5 #ifndef __fpa__Filters__Image__Algorithm__hxx__
6 #define __fpa__Filters__Image__Algorithm__hxx__
8 // -------------------------------------------------------------------------
9 template< class _TBaseAlgorithm >
10 fpa::Filters::Image::Algorithm< _TBaseAlgorithm >::
13 m_NeighborhoodOrder( 1 )
15 fpaFilterOutputConfigureMacro( Marks, TMarksImage );
18 // -------------------------------------------------------------------------
19 template< class _TBaseAlgorithm >
20 fpa::Filters::Image::Algorithm< _TBaseAlgorithm >::
25 // -------------------------------------------------------------------------
26 template< class _TBaseAlgorithm >
27 void fpa::Filters::Image::Algorithm< _TBaseAlgorithm >::
30 const TInputImage* in = this->GetInput( );
32 TOutputImage* out = this->GetOutput( );
33 out->SetLargestPossibleRegion( in->GetLargestPossibleRegion( ) );
34 out->SetRequestedRegion( in->GetRequestedRegion( ) );
35 out->SetBufferedRegion( in->GetBufferedRegion( ) );
36 out->SetSpacing( in->GetSpacing( ) );
37 out->SetOrigin( in->GetOrigin( ) );
38 out->SetDirection( in->GetDirection( ) );
40 out->FillBuffer( this->GetInitValue( ) );
42 TMarksImage* marks = this->GetMarks( );
43 marks->SetLargestPossibleRegion( in->GetLargestPossibleRegion( ) );
44 marks->SetRequestedRegion( in->GetRequestedRegion( ) );
45 marks->SetBufferedRegion( in->GetBufferedRegion( ) );
46 marks->SetSpacing( in->GetSpacing( ) );
47 marks->SetOrigin( in->GetOrigin( ) );
48 marks->SetDirection( in->GetDirection( ) );
50 marks->FillBuffer( TMark( 0 ) );
53 // -------------------------------------------------------------------------
54 template< class _TBaseAlgorithm >
55 typename fpa::Filters::Image::Algorithm< _TBaseAlgorithm >::
56 TInputValue fpa::Filters::Image::Algorithm< _TBaseAlgorithm >::
57 _GetInputValue( const TVertex& v ) const
59 return( this->GetInput( )->GetPixel( v ) );
62 // -------------------------------------------------------------------------
63 template< class _TBaseAlgorithm >
64 typename fpa::Filters::Image::Algorithm< _TBaseAlgorithm >::
65 TOutputValue fpa::Filters::Image::Algorithm< _TBaseAlgorithm >::
66 _GetOutputValue( const TVertex& v ) const
68 return( this->GetOutput( )->GetPixel( v ) );
71 // -------------------------------------------------------------------------
72 template< class _TBaseAlgorithm >
73 typename fpa::Filters::Image::Algorithm< _TBaseAlgorithm >::
74 TNeighborhood fpa::Filters::Image::Algorithm< _TBaseAlgorithm >::
75 _GetNeighbors( const TVertex& v ) const
77 typename TInputImage::RegionType region =
78 this->GetInput( )->GetRequestedRegion( );
79 TNeighborhood neighborhood;
80 if( this->m_NeighborhoodOrder == 1 )
82 for( unsigned int d = 0; d < Self::Dimension; ++d )
84 for( int s = -1; s <= 1; s += 2 )
88 if( region.IsInside( n ) )
89 neighborhood.push_back( n );
95 else if( this->m_NeighborhoodOrder == 2 )
100 return( neighborhood );
103 // -------------------------------------------------------------------------
104 template< class _TBaseAlgorithm >
105 void fpa::Filters::Image::Algorithm< _TBaseAlgorithm >::
106 _UpdateOutputValue( TNode& n )
108 this->Superclass::_UpdateOutputValue( n );
109 this->GetOutput( )->SetPixel( n.Vertex, n.Value );
112 // -------------------------------------------------------------------------
113 template< class _TBaseAlgorithm >
114 unsigned long fpa::Filters::Image::Algorithm< _TBaseAlgorithm >::
115 _GetMark( const TVertex& v ) const
117 return( ( unsigned long )( this->GetMarks( )->GetPixel( v ) ) );
120 // -------------------------------------------------------------------------
121 template< class _TBaseAlgorithm >
122 bool fpa::Filters::Image::Algorithm< _TBaseAlgorithm >::
123 _IsMarked( const TVertex& v ) const
125 return( this->GetMarks( )->GetPixel( v ) != TMark( 0 ) );
128 // -------------------------------------------------------------------------
129 template< class _TBaseAlgorithm >
130 void fpa::Filters::Image::Algorithm< _TBaseAlgorithm >::
131 _Mark( const TVertex& v, unsigned long m )
133 this->GetMarks( )->SetPixel( v, TMark( m ) );
136 #endif // __fpa__Filters__Image__Algorithm__hxx__