1 // =========================================================================
2 // @author Leonardo Florez Valencia
3 // @email florez-l@javeriana.edu.co
4 // =========================================================================
5 #ifndef __fpa__Filters__Image__Interface__hxx__
6 #define __fpa__Filters__Image__Interface__hxx__
8 // -------------------------------------------------------------------------
9 template< class _TTraits >
10 fpa::Filters::Image::Interface< _TTraits >::
13 m_NeighborhoodOrder( 1 )
15 fpaFilterOutputConfigureMacro( Marks, TMarksImage );
18 // -------------------------------------------------------------------------
19 template< class _TTraits >
20 fpa::Filters::Image::Interface< _TTraits >::
25 // -------------------------------------------------------------------------
26 template< class _TTraits >
27 void fpa::Filters::Image::Interface< _TTraits >::
28 _AssignOutputValue( const TNode& n )
30 this->GetOutput( )->SetPixel( n.Vertex, n.Value );
33 // -------------------------------------------------------------------------
34 template< class _TTraits >
35 void fpa::Filters::Image::Interface< _TTraits >::
38 const TInputImage* in = this->GetInput( );
40 TOutputImage* out = this->GetOutput( );
41 out->SetLargestPossibleRegion( in->GetLargestPossibleRegion( ) );
42 out->SetRequestedRegion( in->GetRequestedRegion( ) );
43 out->SetBufferedRegion( in->GetBufferedRegion( ) );
44 out->SetSpacing( in->GetSpacing( ) );
45 out->SetOrigin( in->GetOrigin( ) );
46 out->SetDirection( in->GetDirection( ) );
48 out->FillBuffer( this->GetInitValue( ) );
50 TMarksImage* marks = this->GetMarks( );
51 marks->SetLargestPossibleRegion( in->GetLargestPossibleRegion( ) );
52 marks->SetRequestedRegion( in->GetRequestedRegion( ) );
53 marks->SetBufferedRegion( in->GetBufferedRegion( ) );
54 marks->SetSpacing( in->GetSpacing( ) );
55 marks->SetOrigin( in->GetOrigin( ) );
56 marks->SetDirection( in->GetDirection( ) );
58 marks->FillBuffer( TMark( 0 ) );
61 // -------------------------------------------------------------------------
62 template< class _TTraits >
63 typename fpa::Filters::Image::Interface< _TTraits >::
64 TInputValue fpa::Filters::Image::Interface< _TTraits >::
65 _GetInputValue( const TVertex& v ) const
67 return( this->GetInput( )->GetPixel( v ) );
70 // -------------------------------------------------------------------------
71 template< class _TTraits >
72 typename fpa::Filters::Image::Interface< _TTraits >::
73 TOutputValue fpa::Filters::Image::Interface< _TTraits >::
74 _GetOutputValue( const TVertex& v ) const
76 return( this->GetOutput( )->GetPixel( v ) );
79 // -------------------------------------------------------------------------
80 template< class _TTraits >
81 typename fpa::Filters::Image::Interface< _TTraits >::
82 TNeighborhood fpa::Filters::Image::Interface< _TTraits >::
83 _GetNeighbors( const TVertex& v ) const
85 typename TInputImage::RegionType region =
86 this->GetInput( )->GetRequestedRegion( );
87 TNeighborhood neighborhood;
88 if( this->m_NeighborhoodOrder == 1 )
90 for( unsigned int d = 0; d < TTraits::Dimension; ++d )
92 for( int s = -1; s <= 1; s += 2 )
96 if( region.IsInside( n ) )
97 neighborhood.push_back( n );
103 else if( this->m_NeighborhoodOrder == 2 )
108 return( neighborhood );
111 // -------------------------------------------------------------------------
112 template< class _TTraits >
113 unsigned long fpa::Filters::Image::Interface< _TTraits >::
114 _GetMark( const TVertex& v ) const
116 return( this->GetMarks( )->GetPixel( v ) );
119 // -------------------------------------------------------------------------
120 template< class _TTraits >
121 bool fpa::Filters::Image::Interface< _TTraits >::
122 _IsMarked( const TVertex& v ) const
124 return( this->GetMarks( )->GetPixel( v ) != TMark( 0 ) );
127 // -------------------------------------------------------------------------
128 template< class _TTraits >
129 void fpa::Filters::Image::Interface< _TTraits >::
130 _Mark( const TNode& n )
132 this->GetMarks( )->SetPixel( n.Vertex, TMark( n.FrontId ) );
135 #endif // __fpa__Filters__Image__Interface__hxx__