// ========================================================================= // @author Leonardo Florez Valencia // @email florez-l@javeriana.edu.co // ========================================================================= #ifndef __fpa__Filters__Image__Interface__hxx__ #define __fpa__Filters__Image__Interface__hxx__ // ------------------------------------------------------------------------- template< class _TTraits > fpa::Filters::Image::Interface< _TTraits >:: Interface( ) : Superclass( ), m_NeighborhoodOrder( 1 ) { fpaFilterOutputConfigureMacro( Marks, TMarksImage ); } // ------------------------------------------------------------------------- template< class _TTraits > fpa::Filters::Image::Interface< _TTraits >:: ~Interface( ) { } // ------------------------------------------------------------------------- template< class _TTraits > void fpa::Filters::Image::Interface< _TTraits >:: _AssignOutputValue( const TNode& n ) { this->GetOutput( )->SetPixel( n.Vertex, n.Value ); } // ------------------------------------------------------------------------- template< class _TTraits > void fpa::Filters::Image::Interface< _TTraits >:: _ConfigureOutputs( ) { const TInputImage* in = this->GetInput( ); TOutputImage* out = this->GetOutput( ); out->SetLargestPossibleRegion( in->GetLargestPossibleRegion( ) ); out->SetRequestedRegion( in->GetRequestedRegion( ) ); out->SetBufferedRegion( in->GetBufferedRegion( ) ); out->SetSpacing( in->GetSpacing( ) ); out->SetOrigin( in->GetOrigin( ) ); out->SetDirection( in->GetDirection( ) ); out->Allocate( ); out->FillBuffer( this->GetInitValue( ) ); TMarksImage* marks = this->GetMarks( ); marks->SetLargestPossibleRegion( in->GetLargestPossibleRegion( ) ); marks->SetRequestedRegion( in->GetRequestedRegion( ) ); marks->SetBufferedRegion( in->GetBufferedRegion( ) ); marks->SetSpacing( in->GetSpacing( ) ); marks->SetOrigin( in->GetOrigin( ) ); marks->SetDirection( in->GetDirection( ) ); marks->Allocate( ); marks->FillBuffer( TMark( 0 ) ); } // ------------------------------------------------------------------------- template< class _TTraits > typename fpa::Filters::Image::Interface< _TTraits >:: TInputValue fpa::Filters::Image::Interface< _TTraits >:: _GetInputValue( const TVertex& v ) const { return( this->GetInput( )->GetPixel( v ) ); } // ------------------------------------------------------------------------- template< class _TTraits > typename fpa::Filters::Image::Interface< _TTraits >:: TOutputValue fpa::Filters::Image::Interface< _TTraits >:: _GetOutputValue( const TVertex& v ) const { return( this->GetOutput( )->GetPixel( v ) ); } // ------------------------------------------------------------------------- template< class _TTraits > typename fpa::Filters::Image::Interface< _TTraits >:: TNeighborhood fpa::Filters::Image::Interface< _TTraits >:: _GetNeighbors( const TVertex& v ) const { typename TInputImage::RegionType region = this->GetInput( )->GetRequestedRegion( ); TNeighborhood neighborhood; if( this->m_NeighborhoodOrder == 1 ) { for( unsigned int d = 0; d < TTraits::Dimension; ++d ) { for( int s = -1; s <= 1; s += 2 ) { TVertex n = v; n[ d ] += s; if( region.IsInside( n ) ) neighborhood.push_back( n ); } // rof } // rof } else if( this->m_NeighborhoodOrder == 2 ) { // TODO } // fi return( neighborhood ); } // ------------------------------------------------------------------------- template< class _TTraits > unsigned long fpa::Filters::Image::Interface< _TTraits >:: _GetMark( const TVertex& v ) const { return( this->GetMarks( )->GetPixel( v ) ); } // ------------------------------------------------------------------------- template< class _TTraits > bool fpa::Filters::Image::Interface< _TTraits >:: _IsMarked( const TVertex& v ) const { return( this->GetMarks( )->GetPixel( v ) != TMark( 0 ) ); } // ------------------------------------------------------------------------- template< class _TTraits > void fpa::Filters::Image::Interface< _TTraits >:: _Mark( const TNode& n ) { this->GetMarks( )->SetPixel( n.Vertex, TMark( n.FrontId ) ); } #endif // __fpa__Filters__Image__Interface__hxx__ // eof - $RCSfile$