]> Creatis software - FrontAlgorithms.git/blobdiff - lib/fpa/Image/Functors/RegionGrowThresholdFunction.h
...
[FrontAlgorithms.git] / lib / fpa / Image / Functors / RegionGrowThresholdFunction.h
index 00a813f682a1694b756ca5d0d7238052a6d5df27..55a5d53b7fc63b53f88b59a8442b5b38e109607e 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef __FPA__IMAGE__FUNCTORS__REGIONGROWTHRESHOLDFUNCTION__H__
 #define __FPA__IMAGE__FUNCTORS__REGIONGROWTHRESHOLDFUNCTION__H__
 
-#include <limits>
+#include <itkNumericTraits.h>
 #include <fpa/Image/Functors/RegionGrowAllBelongsFunction.h>
 
 namespace fpa
@@ -24,14 +24,9 @@ namespace fpa
         typedef itk::SmartPointer< const Self >   ConstPointer;
 
         // Superclass' types
-        typedef typename Superclass::InputImageType      InputImageType;
-        typedef typename Superclass::InputPixelType      InputPixelType;
-        typedef typename Superclass::OutputType          OutputType;
-        typedef typename Superclass::CoordRepType        CoordRepType;
-        typedef typename Superclass::IndexType           IndexType;
-        typedef typename Superclass::IndexValueType      IndexValueType;
-        typedef typename Superclass::ContinuousIndexType ContinuousIndexType;
-        typedef typename Superclass::PointType           PointType;
+        typedef I                     TInputImage;
+        typedef typename I::IndexType TIndex;
+        typedef typename I::PixelType TPixel;
 
       public:
         itkNewMacro( Self );
@@ -40,27 +35,23 @@ namespace fpa
           RegionGrowAllBelongsFunction
           );
 
-        itkGetConstMacro( LowerThreshold, InputPixelType );
-        itkGetConstMacro( UpperThreshold, InputPixelType );
+        itkGetConstMacro( LowerThreshold, TPixel );
+        itkGetConstMacro( UpperThreshold, TPixel );
 
-        itkSetMacro( LowerThreshold, InputPixelType );
-        itkSetMacro( UpperThreshold, InputPixelType );
+        itkSetMacro( LowerThreshold, TPixel );
+        itkSetMacro( UpperThreshold, TPixel );
 
       public:
-        virtual OutputType EvaluateAtIndex( const IndexType& index ) const
+        virtual bool Evaluate( const TIndex& idx ) const
           {
-            const I* img = this->GetInputImage( );
+            const I* img = this->GetSpace( );
+
             if( img != NULL )
             {
-              if( this->IsInsideBuffer( index ) )
-              {
-                InputPixelType v = img->GetPixel( index );
-                return(
-                  this->m_LowerThreshold <= v &&
-                  v <= this->m_UpperThreshold
-                  );
-
-              } // fi
+              TPixel v = img->GetPixel( idx );
+              return(
+                !( v < this->m_LowerThreshold || this->m_UpperThreshold < v )
+                );
 
             } // fi
             return( false );
@@ -68,10 +59,11 @@ namespace fpa
 
       protected:
         RegionGrowThresholdFunction( )
-          : Superclass( ),
-            m_LowerThreshold( std::numeric_limits< InputPixelType >::min( ) ),
-            m_UpperThreshold( std::numeric_limits< InputPixelType >::max( ) )
-          { }
+          : Superclass( )
+          {
+            itk::NumericTraits< TPixel >::min( this->m_LowerThreshold );
+            itk::NumericTraits< TPixel >::max( this->m_UpperThreshold );
+          }
         virtual ~RegionGrowThresholdFunction( )
           { }
 
@@ -81,8 +73,8 @@ namespace fpa
         void operator=( const Self& );
 
       protected:
-        InputPixelType m_LowerThreshold;
-        InputPixelType m_UpperThreshold;
+        TPixel m_LowerThreshold;
+        TPixel m_UpperThreshold;
       };
 
     } // ecapseman