X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2Ffpa%2FFunctors%2FDijkstra%2FImage%2FGaussian.h;h=8fa04be63d9b7180bfc0b2d432a6584ffa596754;hb=ae0e1b8916a0fb2188080b9134c1c2781c6c200f;hp=e917e95bff25897eacb45e78019ca1b15a6628ae;hpb=bd89a1af0c14ed2ac0afeca923103de54283cbaf;p=FrontAlgorithms.git diff --git a/lib/fpa/Functors/Dijkstra/Image/Gaussian.h b/lib/fpa/Functors/Dijkstra/Image/Gaussian.h index e917e95..8fa04be 100644 --- a/lib/fpa/Functors/Dijkstra/Image/Gaussian.h +++ b/lib/fpa/Functors/Dijkstra/Image/Gaussian.h @@ -38,14 +38,20 @@ namespace fpa fpa::Functors::VertexFunction ); - itkGetConstMacro( Alpha, double ); - itkSetMacro( Alpha, double ); + itkGetConstMacro( Beta, TValue ); + itkSetMacro( Beta, TValue ); - itkGetConstMacro( Beta, double ); - itkSetMacro( Beta, double ); + 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 + virtual TValue Evaluate( + const TVertex& v, const TVertex& p + ) const override { const TImage* image = dynamic_cast< const TImage* >( @@ -53,11 +59,14 @@ namespace fpa ); if( image != NULL ) { - double d = double( image->GetPixel( v ) ); - d -= double( image->GetPixel( p ) ); + TValue d = TValue( image->GetPixel( v ) ); + d -= TValue( image->GetPixel( p ) ); d /= this->m_Beta; - d = std::exp( d * d ) - double( 1 ); - return( TValue( std::pow( d, this->m_Alpha ) ) ); + if( this->m_TreatAsWeight ) d = std::exp( d * d ) - TValue( 1 ); + else d = std::exp( -std::fabs( d ) ); + + if( d < this->m_Epsilon ) return( this->m_Epsilon ); + else return( d ); } else return( TValue( -1 ) ); @@ -66,8 +75,9 @@ namespace fpa protected: Gaussian( ) : Superclass( ), - m_Alpha( double( 1 ) ), - m_Beta( double( 1 ) ) + m_Beta( TValue( 1 ) ), + m_Epsilon( TValue( 1e-5 ) ), + m_TreatAsWeight( true ) { } virtual ~Gaussian( ) @@ -80,8 +90,9 @@ namespace fpa Self& operator=( const Self& other ); protected: - double m_Alpha; - double m_Beta; + TValue m_Beta; + TValue m_Epsilon; + bool m_TreatAsWeight; }; } // ecapseman