// ========================================================================= // @author Leonardo Florez Valencia // @email florez-l@javeriana.edu.co // ========================================================================= #ifndef __fpa__Functors__Dijkstra__Image__Gaussian__h__ #define __fpa__Functors__Dijkstra__Image__Gaussian__h__ #include #include namespace fpa { namespace Functors { namespace Dijkstra { namespace Image { /** */ template< class _TImage, class _TValue > class Gaussian : public fpa::Functors::VertexFunction< typename _TImage::IndexType, _TValue > { public: typedef _TImage TImage; typedef _TValue TValue; typedef typename TImage::IndexType TVertex; typedef fpa::Functors::VertexFunction< TVertex, TValue > Superclass; typedef Gaussian Self; typedef itk::SmartPointer< Self > Pointer; typedef itk::SmartPointer< const Self > ConstPointer; public: itkNewMacro( Self ); itkTypeMacro( fpa::Functors::Dijkstra::Image::Gaussian, fpa::Functors::VertexFunction ); itkGetConstMacro( Beta, TValue ); itkSetMacro( Beta, TValue ); itkGetConstMacro( Epsilon, TValue ); itkSetMacro( Epsilon, TValue ); itkBooleanMacro( TreatAsWeight ); itkGetConstMacro( TreatAsWeight, bool ); itkSetMacro( TreatAsWeight, bool ); public: virtual TValue Evaluate( const TVertex& v, const TVertex& p ) const override { const TImage* image = dynamic_cast< const TImage* >( this->m_DataObject.GetPointer( ) ); if( image != NULL ) { TValue d = TValue( image->GetPixel( v ) ); d -= TValue( image->GetPixel( p ) ); d /= this->m_Beta; d *= d; if( this->m_TreatAsWeight ) d = std::exp( d ); else d = std::exp( -d ); if( d < this->m_Epsilon ) return( this->m_Epsilon ); else return( d ); } else return( TValue( -1 ) ); } protected: Gaussian( ) : Superclass( ), m_Beta( TValue( 1 ) ), m_Epsilon( TValue( 1e-5 ) ), m_TreatAsWeight( true ) { } virtual ~Gaussian( ) { } private: // Purposely not implemented. Gaussian( const Self& other ); Self& operator=( const Self& other ); protected: TValue m_Beta; TValue m_Epsilon; bool m_TreatAsWeight; }; } // ecapseman } // ecapseman } // ecapseman } // ecapseman #endif // __fpa__Functors__Dijkstra__Gaussian__h__ // eof - $RCSfile$