From 762c1359d66d33b892a0ba5a8c780d09ba6d394f Mon Sep 17 00:00:00 2001
From: Emmanuel Christophe <emmanuel.christophe@orfeo-toolbox.org>
Date: Fri, 20 Jun 2008 09:28:41 +0000
Subject: [PATCH] Numeric traits pour genericite

---
 .../otbCorrelationChangeDetector.h             | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/Code/ChangeDetection/otbCorrelationChangeDetector.h b/Code/ChangeDetection/otbCorrelationChangeDetector.h
index b9c71dac0f..c526262f95 100755
--- a/Code/ChangeDetection/otbCorrelationChangeDetector.h
+++ b/Code/ChangeDetection/otbCorrelationChangeDetector.h
@@ -58,8 +58,8 @@ public:
                              const TInput2 & itB)
   {
     
-    TOutput meanA = 0.0;
-    TOutput meanB = 0.0;
+    TOutput meanA = itk::NumericTraits<TOutput>::Zero;
+    TOutput meanB = itk::NumericTraits<TOutput>::Zero;
 
     for(unsigned long pos = 0; pos< itA.Size(); ++pos)
       {
@@ -73,8 +73,8 @@ public:
     meanA /= itA.Size();
     meanB /= itB.Size();
 
-    TOutput varA = 0.0;
-    TOutput varB = 0.0;
+    TOutput varA = itk::NumericTraits<TOutput>::Zero;
+    TOutput varB = itk::NumericTraits<TOutput>::Zero;
 
     for(unsigned long pos = 0; pos< itA.Size(); ++pos)
       {
@@ -87,20 +87,20 @@ public:
     varA /= itA.Size();
     varB /= itB.Size();
 
-    TOutput crossCorrel = 0.0;
+    TOutput crossCorrel = itk::NumericTraits<TOutput>::Zero;
 
-    if(varA!=0 && varB!=0)
+    if(varA!= itk::NumericTraits<TOutput>::Zero && varB!= itk::NumericTraits<TOutput>::Zero)
 	  {
 	    for(unsigned long pos = 0; pos< itA.Size(); ++pos)
 	      {
 		crossCorrel += (static_cast<TOutput>(itA.GetPixel(pos))-meanA)*(static_cast<TOutput>(itB.GetPixel(pos))-meanB)/(itA.Size()*vcl_sqrt(varA*varB));
 	      }
 	  }
-    else if(varA==0 && varB==0)
+    else if(varA==itk::NumericTraits<TOutput>::Zero && varB==itk::NumericTraits<TOutput>::Zero)
       {
-	crossCorrel = 1;	
+	crossCorrel = itk::NumericTraits<TOutput>::One;	
       }
-    return static_cast<TOutput>( 1.0-crossCorrel );
+    return static_cast<TOutput>( itk::NumericTraits<TOutput>::One - crossCorrel );
   }
 }; 
 }
-- 
GitLab