// ========================================================================= // @author Leonardo Florez Valencia // @email florez-l@javeriana.edu.co // ========================================================================= #ifndef __fpa__Image__Functors__GaussianWeight__h__ #define __fpa__Image__Functors__GaussianWeight__h__ #include #include namespace fpa { namespace Image { namespace Functors { /** */ template< class _TInputImage, class _TOutputValue > class GaussianWeight : public fpa::Image::Functors::VertexParentBase< _TInputImage, _TOutputValue > { public: typedef _TInputImage TInputImage; typedef _TOutputValue TOutputValue; typedef GaussianWeight Self; typedef itk::SmartPointer< Self > Pointer; typedef itk::SmartPointer< const Self > ConstPointer; typedef fpa::Image::Functors::VertexParentBase< TInputImage, TOutputValue > Superclass; typedef typename Superclass::TVertex TVertex; public: itkNewMacro( Self ); itkTypeMacro( fpa::Image::Functors::GaussianWeight, fpa::Image::Functors::VertexParentBase ); itkBooleanMacro( Invert ); itkGetConstMacro( Beta, double ); itkGetConstMacro( Invert, bool ); itkSetMacro( Beta, double ); itkSetMacro( Invert, bool ); public: virtual TOutputValue Evaluate( const TVertex& a, const TVertex& p ) const override { double va = double( this->m_Image->GetPixel( a ) ); double vp = double( this->m_Image->GetPixel( p ) ); double d = va - vp; d = ( d * d ) / this->m_Beta; if( this->m_Invert ) return( TOutputValue( double( 1 ) - std::exp( -d ) ) ); else return( TOutputValue( std::exp( -d ) ) ); } protected: GaussianWeight( ) : Superclass( ), m_Invert( false ), m_Beta( double( 1 ) ) { } virtual ~GaussianWeight( ) { } private: GaussianWeight( const Self& other ); Self& operator=( const Self& other ); protected: bool m_Invert; double m_Beta; }; } // ecapseman } // ecapseman } // ecapseman #endif // __fpa__Image__Functors__GaussianWeight__h__ // eof - $RCSfile$