From 89a76190321c3e1f8d5dcd6500c567313a79072e Mon Sep 17 00:00:00 2001
From: Thomas Feuvrier <thomas.feuvrier@c-s.fr>
Date: Thu, 30 Nov 2006 11:35:01 +0000
Subject: [PATCH] =?UTF-8?q?Correction=20FA=2038=20:=20ajout=20d'un=20param?=
 =?UTF-8?q?etre=20Template=20de=20classe=20permettant=20de=20d=C3=A9finir?=
 =?UTF-8?q?=20le=20type=20utilis=C3=A9=20pour=20la=20pr=C3=A9cision=20des?=
 =?UTF-8?q?=20calculs.=20Modification=20des=20classes=20(dans=20FeatureExt?=
 =?UTF-8?q?raction)=20des=20MomentImageFunction=20et=20MomentPathFunction?=
 =?UTF-8?q?=20(complex,=20real,=20Flusser,=20Hu,=20etc...)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../otbComplexMomentImageFunction.h           | 14 +++--
 .../otbComplexMomentImageFunction.txx         | 34 +++++------
 .../otbComplexMomentPathFunction.h            | 23 ++++---
 .../otbComplexMomentPathFunction.txx          | 61 +++++++++----------
 .../otbFlusserImageFunction.h                 | 15 +++--
 .../otbFlusserImageFunction.txx               | 14 ++---
 .../otbFlusserPathFunction.h                  | 12 ++--
 .../otbFlusserPathFunction.txx                | 22 +++----
 .../otbGeometricMomentImageFunction.h         |  6 +-
 .../otbGeometricMomentPathFunction.h          |  6 +-
 Code/FeatureExtraction/otbHuImageFunction.h   | 14 +++--
 Code/FeatureExtraction/otbHuImageFunction.txx | 14 ++---
 Code/FeatureExtraction/otbHuPathFunction.h    | 10 ++-
 Code/FeatureExtraction/otbHuPathFunction.txx  | 22 +++----
 .../otbRealMomentImageFunction.h              | 12 ++--
 .../otbRealMomentPathFunction.h               | 10 ++-
 16 files changed, 165 insertions(+), 124 deletions(-)

diff --git a/Code/FeatureExtraction/otbComplexMomentImageFunction.h b/Code/FeatureExtraction/otbComplexMomentImageFunction.h
index 30967cb947..662e4b6d9c 100644
--- a/Code/FeatureExtraction/otbComplexMomentImageFunction.h
+++ b/Code/FeatureExtraction/otbComplexMomentImageFunction.h
@@ -46,15 +46,16 @@ namespace otb
  * \ingroup ImageFunctions
  */
 template < class TInput, 
-           class TOutput = std::complex<double >,
+           class TOutput = std::complex<double>,
+           class TPrecision = double,
 	   class TCoordRep = float >
 class ITK_EXPORT ComplexMomentImageFunction :
-    public GeometricMomentImageFunction<TInput, TOutput,TCoordRep>
+    public GeometricMomentImageFunction<TInput, TOutput, TPrecision, TCoordRep>
 {
 public:
   /** Standard class typedefs. */
   typedef ComplexMomentImageFunction                                 Self;
-  typedef GeometricMomentImageFunction<TInput, TOutput,TCoordRep>    Superclass;
+  typedef GeometricMomentImageFunction<TInput, TOutput, TPrecision, TCoordRep>    Superclass;
   typedef itk::SmartPointer<Self>                                    Pointer;
   typedef itk::SmartPointer<const Self>                              ConstPointer;
   
@@ -70,8 +71,13 @@ public:
   typedef typename Superclass::ContinuousIndexType  ContinuousIndexType;
   typedef typename Superclass::PointType            PointType;
  
-  typedef TOutput                                   ComplexType;
+  typedef typename Superclass::OutputType           ComplexType;
 
+  /** Type for calculation precision */
+  typedef typename Superclass::PrecisionType        PrecisionType;
+  			 
+  /** ComplexType for calculation precision */
+  typedef std::complex<PrecisionType>               ComplexPrecisionType;
   			 
   /** Evalulate the function at specified index */
   virtual ComplexType EvaluateAtIndex( const IndexType& index ) const;
diff --git a/Code/FeatureExtraction/otbComplexMomentImageFunction.txx b/Code/FeatureExtraction/otbComplexMomentImageFunction.txx
index b1469cd231..c5e570fb72 100644
--- a/Code/FeatureExtraction/otbComplexMomentImageFunction.txx
+++ b/Code/FeatureExtraction/otbComplexMomentImageFunction.txx
@@ -31,8 +31,8 @@ namespace otb
 /**
    * Constructor
    */
-template < class TInput, class TOutput, class TCoordRep>
-ComplexMomentImageFunction<TInput,TOutput,TCoordRep>
+template < class TInput, class TOutput, class TPrecision, class TCoordRep>
+ComplexMomentImageFunction<TInput,TOutput,TPrecision,TCoordRep>
 ::ComplexMomentImageFunction()
 {
   m_P = 0;
@@ -42,9 +42,9 @@ ComplexMomentImageFunction<TInput,TOutput,TCoordRep>
 /**
    *
    */
-template < class TInput, class TOutput, class TCoordRep>
+template < class TInput, class TOutput, class TPrecision, class TCoordRep>
 void
-ComplexMomentImageFunction<TInput,TOutput,TCoordRep>
+ComplexMomentImageFunction<TInput,TOutput,TPrecision,TCoordRep>
 ::PrintSelf(std::ostream& os, itk::Indent indent) const
 {
   this->Superclass::PrintSelf(os,indent);
@@ -53,15 +53,15 @@ ComplexMomentImageFunction<TInput,TOutput,TCoordRep>
 }
 
 
-template < class TInput, class TOutput, class TCoordRep>
-typename ComplexMomentImageFunction<TInput,TOutput,TCoordRep>::ComplexType
-ComplexMomentImageFunction<TInput,TOutput,TCoordRep>
+template < class TInput, class TOutput, class TPrecision, class TCoordRep>
+typename ComplexMomentImageFunction<TInput,TOutput,TPrecision,TCoordRep>::ComplexType
+ComplexMomentImageFunction<TInput,TOutput,TPrecision,TCoordRep>
 ::EvaluateAtIndex(const IndexType& index) const
 {  
   typename TInput::SizeType           ImageSize;
-  ComplexType                         Sum;
-  ComplexType                         ValP;
-  ComplexType                         ValQ;
+  ComplexPrecisionType                Sum;
+  ComplexPrecisionType                ValP;
+  ComplexPrecisionType                ValQ;
   IndexType                           IndexValue;
   IndexType                           indexPos = index;
   typename TInput::SizeType           kernelSize;
@@ -69,7 +69,7 @@ ComplexMomentImageFunction<TInput,TOutput,TCoordRep>
   if( !this->GetInputImage() )
     {
     otbMsgDevMacro( << "Pb with GetInputImage" );
-    return ( std::complex<float>( itk::NumericTraits<float>::max(), itk::NumericTraits<float>::max() ) );
+    return ( static_cast<ComplexType>( itk::NumericTraits<PrecisionType>::max(), itk::NumericTraits<PrecisionType>::max() ) );
     }
 
    if(this->GetNeighborhoodRadius()<0)
@@ -93,28 +93,28 @@ ComplexMomentImageFunction<TInput,TOutput,TCoordRep>
 
   // Set the iterator at the desired location
   it.SetLocation(indexPos);
-  Sum = std::complex<float>(0.0,0.0); 
+  Sum = ComplexPrecisionType(0.0,0.0); 
 
   const unsigned int size = it.Size();
   for (unsigned int i = 0; i < size; ++i)
   {
     IndexValue = it.GetIndex(i);
-    ValP = std::complex<float>(1.0,0.0);
-    ValQ = std::complex<float>(1.0,0.0);
+    ValP = ComplexPrecisionType(1.0,0.0);
+    ValQ = ComplexPrecisionType(1.0,0.0);
     unsigned int p  = m_P;
     while(p>0)
      {
-      ValP *= std::complex<float>(IndexValue[0], IndexValue[1]);
+      ValP *= ComplexPrecisionType(IndexValue[0], IndexValue[1]);
       --p; 
      }
     unsigned int q  = m_Q;
     while(q>0)
      {
-      ValQ *= std::complex<float>(IndexValue[0], -IndexValue[1]);
+      ValQ *= ComplexPrecisionType(IndexValue[0], -IndexValue[1]);
       --q; 
      }
           
-    Sum += ( ValP * ValQ * std::complex<float>(static_cast<float>(it.GetPixel(i)),0.0) );
+    Sum += ( ValP * ValQ * ComplexPrecisionType(static_cast<PrecisionType>(it.GetPixel(i)),0.0) );
 
   }
 
diff --git a/Code/FeatureExtraction/otbComplexMomentPathFunction.h b/Code/FeatureExtraction/otbComplexMomentPathFunction.h
index 32bb336efe..8218df2703 100644
--- a/Code/FeatureExtraction/otbComplexMomentPathFunction.h
+++ b/Code/FeatureExtraction/otbComplexMomentPathFunction.h
@@ -46,15 +46,17 @@ namespace otb
  * \ingroup ImageFunctions
  */
 template < class TInputPath, 
-           class TOutput = std::complex<double> >
+           class TOutput = std::complex<double>,
+           class TPrecision = double>
 class ITK_EXPORT ComplexMomentPathFunction :
     public GeometricMomentPathFunction< TInputPath, 
-					TOutput >
+					TOutput,
+                                        TPrecision >
 {
 public:
   /** Standard class typedefs. */
   typedef ComplexMomentPathFunction                                  Self;
-  typedef GeometricMomentPathFunction<TInputPath, TOutput >          Superclass;
+  typedef GeometricMomentPathFunction<TInputPath, TOutput, TPrecision>  Superclass;
   typedef itk::SmartPointer<Self>                                    Pointer;
   typedef itk::SmartPointer<const Self>                              ConstPointer;
   
@@ -72,11 +74,18 @@ public:
   typedef itk::VectorContainer< unsigned,VertexType >   VertexListType;
   typedef typename VertexListType::ConstPointer         VertexListPointer;
 
-//  typedef typename Superclass::OutputType               ComplexType;
-  typedef std::complex<double>                          ComplexType;
-  typedef TOutput                                       OutputType;
-  typedef float                                         RealType;
+  /** Complex Type */
+  typedef typename Superclass::OutputType               ComplexType;
 
+  typedef typename Superclass::OutputType               OutputType;
+
+  typedef double                                        RealType;
+ 
+  /** Type for calculation precision */
+  typedef typename Superclass::PrecisionType            PrecisionType;
+  			 
+  /** ComplexType for calculation precision */
+  typedef std::complex<PrecisionType>                   ComplexPrecisionType;
   			 
   /** Evalulate the function */
   virtual OutputType Evaluate(const PathType& path) const;
diff --git a/Code/FeatureExtraction/otbComplexMomentPathFunction.txx b/Code/FeatureExtraction/otbComplexMomentPathFunction.txx
index 62bab30ed3..968932a4a5 100644
--- a/Code/FeatureExtraction/otbComplexMomentPathFunction.txx
+++ b/Code/FeatureExtraction/otbComplexMomentPathFunction.txx
@@ -31,8 +31,8 @@ namespace otb
 /**
    * Constructor
    */
-template < class TInputPath, class TOutput>
-ComplexMomentPathFunction<TInputPath,TOutput>
+template < class TInputPath, class TOutput, class TPrecision>
+ComplexMomentPathFunction<TInputPath,TOutput,TPrecision>
 ::ComplexMomentPathFunction()
 {
   m_P    = 0;
@@ -43,9 +43,9 @@ ComplexMomentPathFunction<TInputPath,TOutput>
 /**
    *
    */
-template < class TInputPath, class TOutput>
+template < class TInputPath, class TOutput, class TPrecision>
 void
-ComplexMomentPathFunction<TInputPath,TOutput>
+ComplexMomentPathFunction<TInputPath,TOutput,TPrecision>
 ::PrintSelf(std::ostream& os, itk::Indent indent) const
 {
   this->Superclass::PrintSelf(os,indent);
@@ -54,44 +54,42 @@ ComplexMomentPathFunction<TInputPath,TOutput>
 }
 
 
-template < class TInputPath, class TOutput>
-typename ComplexMomentPathFunction<TInputPath,TOutput>::ComplexType 
-ComplexMomentPathFunction<TInputPath,TOutput>
+template < class TInputPath, class TOutput, class TPrecision>
+typename ComplexMomentPathFunction<TInputPath,TOutput,TPrecision>::ComplexType 
+ComplexMomentPathFunction<TInputPath,TOutput,TPrecision>
 ::EvaluateComplexMomentAtIndex(VertexType index) const
 {
-    ComplexType                         ValP;
-    ComplexType                         ValQ;
-    ComplexType                         Result;
-    double                              PixelValue = 1.0;
+    ComplexPrecisionType                         ValP;
+    ComplexPrecisionType                         ValQ;
+    ComplexPrecisionType                         Result;
+    PrecisionType                                PixelValue(1.0);
 
-    ValP = std::complex<double>(1.0,0.0);
-    ValQ = std::complex<double>(1.0,0.0);
+    ValP = ComplexPrecisionType(1.0,0.0);
+    ValQ = ComplexPrecisionType(1.0,0.0);
     unsigned int p  = m_P;
     while(p>0)
      {
-      ValP *= std::complex<double>(index[0], index[1]);
+      ValP *= ComplexPrecisionType(index[0], index[1]);
       --p; 
      }
     unsigned int q  = m_Q;
     while(q>0)
      {
-      ValQ *= std::complex<double>(index[0], -index[1]);
+      ValQ *= ComplexPrecisionType(index[0], -index[1]);
       --q; 
      }
 
-    Result = ValP * ValQ * std::complex<double>( static_cast<double>(PixelValue), 0.0); 
+    Result = ValP * ValQ * ComplexPrecisionType( static_cast<PrecisionType>(PixelValue), 0.0); 
     return ( static_cast<ComplexType>(Result) );
 }
 
 
-template < class TInputPath, class TOutput>
+template < class TInputPath, class TOutput, class TPrecision>
 typename ComplexMomentPathFunction<TInputPath,
-                                   TOutput>::OutputType
-ComplexMomentPathFunction<TInputPath,TOutput>
+                                   TOutput,TPrecision>::OutputType
+ComplexMomentPathFunction<TInputPath,TOutput,TPrecision>
 ::Evaluate(const PathType& path) const
 {
-  typedef float                       RealType;
-
   PathConstPointer                    Path;
   VertexListPointer                   vertexList;
   VertexType                          cindex;
@@ -99,7 +97,6 @@ ComplexMomentPathFunction<TInputPath,TOutput>
   int                                 nbPath;
   ComplexType  	     		      Value;
 
-
   Value = static_cast<ComplexType>(0.0);
   
   vertexList = path.GetVertexList();
@@ -110,14 +107,14 @@ ComplexMomentPathFunction<TInputPath,TOutput>
      for(int i =0 ; i<nbPath-1 ;i++)
        {
        cindex = vertexList->GetElement(i);
-       RealType x1 = cindex[0];
-       RealType y1 = cindex[1];
+       PrecisionType x1 = cindex[0];
+       PrecisionType y1 = cindex[1];
        cindex = vertexList->GetElement(i+1);
-       RealType x2 = cindex[0];
-       RealType y2 = cindex[1];
+       PrecisionType x2 = cindex[0];
+       PrecisionType y2 = cindex[1];
        
-       RealType Theta;
-       RealType Norm;
+       PrecisionType Theta;
+       PrecisionType Norm;
        
        Theta = atan2(y2-y1,x2-x1);
        Norm  = sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1) );
@@ -135,16 +132,16 @@ ComplexMomentPathFunction<TInputPath,TOutput>
 
 }
 
-template < class TInputPath, class TOutput>
+template < class TInputPath, class TOutput, class TPrecision>
 typename ComplexMomentPathFunction<TInputPath,
-                                   TOutput>::OutputType
-ComplexMomentPathFunction<TInputPath,TOutput>
+                                   TOutput,TPrecision>::OutputType
+ComplexMomentPathFunction<TInputPath,TOutput,TPrecision>
 ::Evaluate() const
 {
   if( !this->GetInputPath() )
     {
     otbMsgDevMacro( << "Pb with GetInputPath" );
-    return static_cast<OutputType>(std::complex<float>( itk::NumericTraits<float>::max(), itk::NumericTraits<float>::max() ) );
+    return static_cast<OutputType>(ComplexPrecisionType( itk::NumericTraits<PrecisionType>::max(), itk::NumericTraits<PrecisionType>::max() ) );
     }
 
   OutputType Result =  Evaluate( *(this->GetInputPath()) );
diff --git a/Code/FeatureExtraction/otbFlusserImageFunction.h b/Code/FeatureExtraction/otbFlusserImageFunction.h
index 7875863543..4cad09d3fd 100644
--- a/Code/FeatureExtraction/otbFlusserImageFunction.h
+++ b/Code/FeatureExtraction/otbFlusserImageFunction.h
@@ -60,15 +60,16 @@ namespace otb
  */
 
 template < class TInput, 
-           class TOutput   = double,
-	   class TCoordRep = float >
+           class TOutput    = double,
+           class TPrecision = double,
+	   class TCoordRep  = float >
 class ITK_EXPORT FlusserImageFunction :
-  public RealMomentImageFunction< TInput, TOutput,TCoordRep >
+  public RealMomentImageFunction< TInput, TOutput, TPrecision, TCoordRep >
 {
 public:
   /** Standard class typedefs. */
   typedef FlusserImageFunction                                      Self;
-  typedef RealMomentImageFunction< TInput, TOutput,TCoordRep >      Superclass;
+  typedef RealMomentImageFunction< TInput, TOutput, TPrecision, TCoordRep >      Superclass;
   typedef itk::SmartPointer<Self>                                   Pointer;
   typedef itk::SmartPointer<const Self>                             ConstPointer;
   
@@ -84,8 +85,12 @@ public:
   typedef typename Superclass::ContinuousIndexType  ContinuousIndexType;
   typedef typename Superclass::PointType            PointType;
 
-  typedef TOutput                                   RealType;
+  typedef typename Superclass::RealType             RealType;
   typedef typename std::complex<RealType>           ComplexType;
+
+  /** Type for calculation precision */
+  typedef typename Superclass::PrecisionType        PrecisionType;
+
    
   /** Dimension of the underlying image. */
   itkStaticConstMacro(ImageDimension, unsigned int,
diff --git a/Code/FeatureExtraction/otbFlusserImageFunction.txx b/Code/FeatureExtraction/otbFlusserImageFunction.txx
index b41e05f932..bbc6cc9f07 100644
--- a/Code/FeatureExtraction/otbFlusserImageFunction.txx
+++ b/Code/FeatureExtraction/otbFlusserImageFunction.txx
@@ -30,8 +30,8 @@ namespace otb
 /**
    * Constructor
    */
-template < class TInput, class TOutput, class TCoordRep>
-FlusserImageFunction<TInput,TOutput,TCoordRep>
+template < class TInput, class TOutput, class TPrecision, class TCoordRep>
+FlusserImageFunction<TInput,TOutput,TPrecision,TCoordRep>
 ::FlusserImageFunction()
 {
   m_MomentNumber =-1; 
@@ -40,9 +40,9 @@ FlusserImageFunction<TInput,TOutput,TCoordRep>
 /**
    *
    */
-template < class TInput, class TOutput, class TCoordRep>
+template < class TInput, class TOutput, class TPrecision, class TCoordRep>
 void
-FlusserImageFunction<TInput,TOutput,TCoordRep>
+FlusserImageFunction<TInput,TOutput,TPrecision,TCoordRep>
 ::PrintSelf(std::ostream& os, itk::Indent indent) const
 {
   this->Superclass::PrintSelf(os,indent);
@@ -50,9 +50,9 @@ FlusserImageFunction<TInput,TOutput,TCoordRep>
 }
 
 
-template < class TInput, class TOutput, class TCoordRep>
-typename FlusserImageFunction<TInput,TOutput,TCoordRep>::RealType
-FlusserImageFunction<TInput,TOutput,TCoordRep>
+template < class TInput, class TOutput, class TPrecision, class TCoordRep>
+typename FlusserImageFunction<TInput,TOutput,TPrecision,TCoordRep>::RealType
+FlusserImageFunction<TInput,TOutput,TPrecision,TCoordRep>
 ::EvaluateAtIndex(const IndexType& index) const
 {
   
diff --git a/Code/FeatureExtraction/otbFlusserPathFunction.h b/Code/FeatureExtraction/otbFlusserPathFunction.h
index 7ead224744..95f60979c4 100644
--- a/Code/FeatureExtraction/otbFlusserPathFunction.h
+++ b/Code/FeatureExtraction/otbFlusserPathFunction.h
@@ -57,14 +57,15 @@ namespace otb
  */
 
 template < class TInputPath,    
-           class TOutput      = double>
+           class TOutput      = double,
+       	   class TPrecision   = double>
 class ITK_EXPORT FlusserPathFunction :
-  public RealMomentPathFunction< TInputPath, TOutput >
+  public RealMomentPathFunction< TInputPath, TOutput, TPrecision >
 {
 public:
   /** Standard class typedefs. */
   typedef FlusserPathFunction                           Self;
-  typedef RealMomentPathFunction<TInputPath, TOutput>   Superclass;
+  typedef RealMomentPathFunction<TInputPath, TOutput, TPrecision>   Superclass;
   typedef itk::SmartPointer<Self>                       Pointer;
   typedef itk::SmartPointer<const Self>                 ConstPointer;
   
@@ -82,8 +83,9 @@ public:
   typedef typename VertexListType::ConstPointer         VertexListPointer;
 
   typedef typename Superclass::RealType                 RealType;
-   
-  			 
+ 
+  /** Type for calculation precision */
+  typedef typename Superclass::PrecisionType            PrecisionType;
 
   /** Evaluate the function at non-integer positions */
   virtual RealType Evaluate( const PathType& path) const;
diff --git a/Code/FeatureExtraction/otbFlusserPathFunction.txx b/Code/FeatureExtraction/otbFlusserPathFunction.txx
index 731d4985be..895d2e0273 100644
--- a/Code/FeatureExtraction/otbFlusserPathFunction.txx
+++ b/Code/FeatureExtraction/otbFlusserPathFunction.txx
@@ -29,8 +29,8 @@ namespace otb
 /**
    * Constructor
    */
-template < class TInputPath, class TOutput>
-FlusserPathFunction<TInputPath, TOutput >
+template < class TInputPath, class TOutput, class TPrecision>
+FlusserPathFunction<TInputPath, TOutput, TPrecision >
 ::FlusserPathFunction()
 {
   m_MomentNumber =-1; 
@@ -39,9 +39,9 @@ FlusserPathFunction<TInputPath, TOutput >
 /**
    *
    */
-template < class TInputPath, class TOutput>
+template < class TInputPath, class TOutput, class TPrecision>
 void
-FlusserPathFunction< TInputPath, TOutput >
+FlusserPathFunction< TInputPath, TOutput, TPrecision >
 ::PrintSelf(std::ostream& os, itk::Indent indent) const
 {
   this->Superclass::PrintSelf(os,indent);
@@ -49,9 +49,9 @@ FlusserPathFunction< TInputPath, TOutput >
 }
 
 
-template < class TInputPath, class TOutput>
-typename FlusserPathFunction<TInputPath, TOutput>::RealType
-FlusserPathFunction<TInputPath, TOutput >
+template < class TInputPath, class TOutput, class TPrecision>
+typename FlusserPathFunction<TInputPath, TOutput, TPrecision>::RealType
+FlusserPathFunction<TInputPath, TOutput, TPrecision >
 ::Evaluate( const PathType& path) const
 {
   typedef ComplexMomentPathFunction<PathType>     FunctionType;
@@ -214,15 +214,15 @@ FlusserPathFunction<TInputPath, TOutput >
 
 }
 
-template < class TInputPath, class TOutput>
-typename FlusserPathFunction<TInputPath, TOutput>::RealType
-FlusserPathFunction<TInputPath, TOutput >
+template < class TInputPath, class TOutput, class TPrecision>
+typename FlusserPathFunction<TInputPath, TOutput, TPrecision>::RealType
+FlusserPathFunction<TInputPath, TOutput, TPrecision >
 ::Evaluate() const
 {
   if( !this->GetInputPath() )
     {
     otbMsgDevMacro( << "Pb with GetInputPath" );
-    return static_cast<RealType>( itk::NumericTraits<float>::max());
+    return static_cast<RealType>( itk::NumericTraits<PrecisionType>::max());
     }
 
   RealType Result =  Evaluate( *(this->GetInputPath()) );
diff --git a/Code/FeatureExtraction/otbGeometricMomentImageFunction.h b/Code/FeatureExtraction/otbGeometricMomentImageFunction.h
index 3c1e1ec261..237d5a321e 100644
--- a/Code/FeatureExtraction/otbGeometricMomentImageFunction.h
+++ b/Code/FeatureExtraction/otbGeometricMomentImageFunction.h
@@ -33,7 +33,8 @@ namespace otb
 
 template < class TInput, 
            class TOutput = float,
-	   class TCoordRep = float >
+	   class TPrecision = double,
+           class TCoordRep = float >
 class ITK_EXPORT GeometricMomentImageFunction :
   public itk::ImageFunction<TInput, TOutput,TCoordRep >
 {
@@ -55,7 +56,8 @@ public:
   typedef typename Superclass::PointType            PointType;
  
   typedef TOutput                                   OutputType;
-
+  /** Type for calculation precision */
+  typedef TPrecision                                PrecisionType;
 
   /** Get/Set the radius of the neighborhood over which the
       statistics are evaluated */
diff --git a/Code/FeatureExtraction/otbGeometricMomentPathFunction.h b/Code/FeatureExtraction/otbGeometricMomentPathFunction.h
index a1fcc7d20b..e0dc4d9d7a 100644
--- a/Code/FeatureExtraction/otbGeometricMomentPathFunction.h
+++ b/Code/FeatureExtraction/otbGeometricMomentPathFunction.h
@@ -32,7 +32,8 @@ namespace otb
  */
 
 template < class TInputPath,    
-           class TOutput >
+           class TOutput,
+       	   class TPrecision = double>
 class ITK_EXPORT GeometricMomentPathFunction :
   public PathFunction< TInputPath, TOutput>
 {
@@ -54,6 +55,9 @@ public:
   /** OutputPathType typedef support. */
   typedef typename Superclass::OutputType            OutputType;
 
+  /** Type for calculation precision */
+  typedef TPrecision                                 PrecisionType;
+
 
 protected:
   GeometricMomentPathFunction() {};
diff --git a/Code/FeatureExtraction/otbHuImageFunction.h b/Code/FeatureExtraction/otbHuImageFunction.h
index b5bf0e55e3..049ea7bd84 100644
--- a/Code/FeatureExtraction/otbHuImageFunction.h
+++ b/Code/FeatureExtraction/otbHuImageFunction.h
@@ -54,15 +54,16 @@ namespace otb
 //  public itk::ImageFunction< TInput, TOutput,TCoordRep >
 
 template < class TInput, 
-           class TOutput   = double,
-	   class TCoordRep = float >
+           class TOutput    = double,
+           class TPrecision = double,
+	   class TCoordRep  = float >
 class ITK_EXPORT HuImageFunction :
-  public RealMomentImageFunction< TInput, TOutput,TCoordRep >
+  public RealMomentImageFunction< TInput, TOutput, TPrecision, TCoordRep >
 {
 public:
   /** Standard class typedefs. */
   typedef HuImageFunction                                           Self;
-  typedef RealMomentImageFunction< TInput, TOutput,TCoordRep >      Superclass;
+  typedef RealMomentImageFunction< TInput, TOutput, TPrecision, TCoordRep >      Superclass;
   typedef itk::SmartPointer<Self>                                   Pointer;
   typedef itk::SmartPointer<const Self>                             ConstPointer;
   
@@ -78,8 +79,11 @@ public:
   typedef typename Superclass::ContinuousIndexType  ContinuousIndexType;
   typedef typename Superclass::PointType            PointType;
 
-  typedef TOutput                                   RealType;
+  typedef typename Superclass::RealType             RealType;
   typedef typename std::complex<RealType>           ComplexType;
+
+  /** Type for calculation precision */
+  typedef typename Superclass::PrecisionType        PrecisionType;
    
   /** Dimension of the underlying image. */
   itkStaticConstMacro(ImageDimension, unsigned int,
diff --git a/Code/FeatureExtraction/otbHuImageFunction.txx b/Code/FeatureExtraction/otbHuImageFunction.txx
index 42f60aa541..3ff339b9ba 100644
--- a/Code/FeatureExtraction/otbHuImageFunction.txx
+++ b/Code/FeatureExtraction/otbHuImageFunction.txx
@@ -30,8 +30,8 @@ namespace otb
 /**
    * Constructor
    */
-template < class TInput, class TOutput, class TCoordRep>
-HuImageFunction<TInput,TOutput,TCoordRep>
+template < class TInput, class TOutput, class TPrecision, class TCoordRep>
+HuImageFunction<TInput,TOutput,TPrecision,TCoordRep>
 ::HuImageFunction()
 {
   m_MomentNumber =-1; 
@@ -40,9 +40,9 @@ HuImageFunction<TInput,TOutput,TCoordRep>
 /**
    *
    */
-template < class TInput, class TOutput, class TCoordRep>
+template < class TInput, class TOutput, class TPrecision, class TCoordRep>
 void
-HuImageFunction<TInput,TOutput,TCoordRep>
+HuImageFunction<TInput,TOutput,TPrecision,TCoordRep>
 ::PrintSelf(std::ostream& os, itk::Indent indent) const
 {
   this->Superclass::PrintSelf(os,indent);
@@ -50,9 +50,9 @@ HuImageFunction<TInput,TOutput,TCoordRep>
 }
 
 
-template < class TInput, class TOutput, class TCoordRep>
-typename HuImageFunction<TInput,TOutput,TCoordRep>::RealType
-HuImageFunction<TInput,TOutput,TCoordRep>
+template < class TInput, class TOutput, class TPrecision, class TCoordRep>
+typename HuImageFunction<TInput,TOutput,TPrecision,TCoordRep>::RealType
+HuImageFunction<TInput,TOutput,TPrecision,TCoordRep>
 ::EvaluateAtIndex(const IndexType& index) const
 {
   //typename InputType::SizeType        ImageSize;
diff --git a/Code/FeatureExtraction/otbHuPathFunction.h b/Code/FeatureExtraction/otbHuPathFunction.h
index 94f2fed743..f25044c451 100644
--- a/Code/FeatureExtraction/otbHuPathFunction.h
+++ b/Code/FeatureExtraction/otbHuPathFunction.h
@@ -53,14 +53,15 @@ namespace otb
  */
 
 template < class TInputPath,    
-           class TOutput      = double>
+           class TOutput    = double,
+           class TPrecision = double>
 class ITK_EXPORT HuPathFunction :
-  public RealMomentPathFunction< TInputPath, TOutput >
+  public RealMomentPathFunction< TInputPath, TOutput, TPrecision >
 {
 public:
   /** Standard class typedefs. */
   typedef HuPathFunction                                Self;
-  typedef RealMomentPathFunction<TInputPath, TOutput>   Superclass;
+  typedef RealMomentPathFunction<TInputPath, TOutput, TPrecision>   Superclass;
   typedef itk::SmartPointer<Self>                       Pointer;
   typedef itk::SmartPointer<const Self>                 ConstPointer;
   
@@ -79,6 +80,9 @@ public:
 
   /** OutputType typedef support. */
   typedef typename Superclass::RealType                 RealType;  			 
+ 
+  /** Type for calculation precision */
+  typedef typename Superclass::PrecisionType            PrecisionType;
 
   /** Evaluate the function at non-integer positions */
   virtual RealType Evaluate( const PathType& path) const;
diff --git a/Code/FeatureExtraction/otbHuPathFunction.txx b/Code/FeatureExtraction/otbHuPathFunction.txx
index f010b4bb88..7d30d36f16 100644
--- a/Code/FeatureExtraction/otbHuPathFunction.txx
+++ b/Code/FeatureExtraction/otbHuPathFunction.txx
@@ -30,8 +30,8 @@ namespace otb
 /**
    * Constructor
    */
-template < class TInputPath, class TOutput>
-HuPathFunction< TInputPath, TOutput >
+template < class TInputPath, class TOutput, class TPrecision>
+HuPathFunction< TInputPath, TOutput, TPrecision  >
 ::HuPathFunction()
 {
   m_MomentNumber =-1; 
@@ -40,9 +40,9 @@ HuPathFunction< TInputPath, TOutput >
 /**
    *
    */
-template < class TInputPath, class TOutput>
+template < class TInputPath, class TOutput, class TPrecision>
 void
-HuPathFunction< TInputPath, TOutput >
+HuPathFunction< TInputPath, TOutput, TPrecision  >
 ::PrintSelf(std::ostream& os, itk::Indent indent) const
 {
   this->Superclass::PrintSelf(os,indent);
@@ -50,9 +50,9 @@ HuPathFunction< TInputPath, TOutput >
 }
 
 
-template < class TInputPath, class TOutput>
-typename HuPathFunction<TInputPath, TOutput >::RealType
-HuPathFunction<TInputPath, TOutput >
+template < class TInputPath, class TOutput, class TPrecision>
+typename HuPathFunction<TInputPath, TOutput, TPrecision  >::RealType
+HuPathFunction<TInputPath, TOutput, TPrecision  >
 ::Evaluate( const PathType& path) const
 {
   typedef ComplexMomentPathFunction<PathType>   FunctionType;
@@ -171,15 +171,15 @@ HuPathFunction<TInputPath, TOutput >
 
 }
 
-template < class TInputPath, class TOutput>
-typename HuPathFunction<TInputPath, TOutput >::RealType
-HuPathFunction<TInputPath, TOutput >
+template < class TInputPath, class TOutput, class TPrecision>
+typename HuPathFunction<TInputPath, TOutput, TPrecision >::RealType
+HuPathFunction<TInputPath, TOutput, TPrecision >
 ::Evaluate( ) const
 {
   if( !this->GetInputPath() )
     {
     otbMsgDevMacro( << "Pb with GetInputPath" );
-    return static_cast<RealType>( itk::NumericTraits<float>::max());
+    return static_cast<RealType>( itk::NumericTraits<PrecisionType>::max());
     }
 
   RealType Result =  Evaluate( *(this->GetInputPath()) );
diff --git a/Code/FeatureExtraction/otbRealMomentImageFunction.h b/Code/FeatureExtraction/otbRealMomentImageFunction.h
index 7dbd6e8603..5709ac2339 100644
--- a/Code/FeatureExtraction/otbRealMomentImageFunction.h
+++ b/Code/FeatureExtraction/otbRealMomentImageFunction.h
@@ -33,14 +33,15 @@ namespace otb
 
 template < class TInput, 
            class TOutput = float,
+           class TPrecision = double,
 	   class TCoordRep = float >
 class ITK_EXPORT RealMomentImageFunction :
-  public GeometricMomentImageFunction<TInput, TOutput,TCoordRep >
+  public GeometricMomentImageFunction<TInput, TOutput, TPrecision, TCoordRep >
 {
 public:
   /** Standard class typedefs. */
   typedef RealMomentImageFunction                                     Self;
-  typedef GeometricMomentImageFunction< TInput, TOutput,TCoordRep >   Superclass;
+  typedef GeometricMomentImageFunction< TInput, TOutput, TPrecision, TCoordRep >   Superclass;
   typedef itk::SmartPointer<Self>                                     Pointer;
   typedef itk::SmartPointer<const Self>                               ConstPointer;
   
@@ -54,8 +55,11 @@ public:
   typedef typename Superclass::ContinuousIndexType  ContinuousIndexType;
   typedef typename Superclass::PointType            PointType;
  
-  typedef TOutput                                   OutputType;
-  typedef TOutput                                   RealType;
+  /** Type for calculation precision */
+  typedef typename Superclass::PrecisionType        PrecisionType;
+
+  typedef typename Superclass::OutputType           OutputType;
+  typedef OutputType                                RealType;
 
 
   
diff --git a/Code/FeatureExtraction/otbRealMomentPathFunction.h b/Code/FeatureExtraction/otbRealMomentPathFunction.h
index 6756263acc..b8d62d6b35 100644
--- a/Code/FeatureExtraction/otbRealMomentPathFunction.h
+++ b/Code/FeatureExtraction/otbRealMomentPathFunction.h
@@ -33,14 +33,15 @@ namespace otb
  */
 
 template < class TInputPath,    
-           class TOutput      = double>
+           class TOutput      = double,
+       	   class TPrecision   = double>
 class ITK_EXPORT RealMomentPathFunction :
-  public GeometricMomentPathFunction< TInputPath, TOutput>
+  public GeometricMomentPathFunction< TInputPath, TOutput, TPrecision>
 {
 public:
   /** Standard class typedefs. */
   typedef RealMomentPathFunction                                      Self;
-  typedef GeometricMomentPathFunction< TInputPath, TOutput>           Superclass;
+  typedef GeometricMomentPathFunction< TInputPath, TOutput, TPrecision> Superclass;
   typedef itk::SmartPointer<Self>                                     Pointer;
   typedef itk::SmartPointer<const Self>                               ConstPointer;
   
@@ -54,6 +55,9 @@ public:
   typedef itk::VectorContainer< unsigned,VertexType >   VertexListType;
   typedef typename VertexListType::ConstPointer         VertexListPointer;
  
+  /** Type for calculation precision */
+  typedef typename Superclass::PrecisionType            PrecisionType;
+   
   /** OutputType typedef support. */
   typedef typename Superclass::OutputType               RealType;
 
-- 
GitLab