X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2Ffpa%2FFilters%2FImage%2FInterface.hxx;fp=lib%2Ffpa%2FFilters%2FImage%2FInterface.hxx;h=2ea6e03e732e9ab82fdf31c013d7b3fb4310f71a;hb=bd89a1af0c14ed2ac0afeca923103de54283cbaf;hp=0000000000000000000000000000000000000000;hpb=a8ac405fe1422bc0792a810f7f0693096a22c20e;p=FrontAlgorithms.git diff --git a/lib/fpa/Filters/Image/Interface.hxx b/lib/fpa/Filters/Image/Interface.hxx new file mode 100644 index 0000000..2ea6e03 --- /dev/null +++ b/lib/fpa/Filters/Image/Interface.hxx @@ -0,0 +1,136 @@ +// ========================================================================= +// @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$