From 0732d0c2247c77d9c5a40c70985d5bfeb0533515 Mon Sep 17 00:00:00 2001
From: Julien Michel <julien.michel@c-s.fr>
Date: Fri, 7 Dec 2007 12:49:54 +0000
Subject: [PATCH] correction correlation

---
 Code/ChangeDetection/otbCorrelationChangeDetector.h | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/Code/ChangeDetection/otbCorrelationChangeDetector.h b/Code/ChangeDetection/otbCorrelationChangeDetector.h
index a87c8f11d4..b9c71dac0f 100755
--- a/Code/ChangeDetection/otbCorrelationChangeDetector.h
+++ b/Code/ChangeDetection/otbCorrelationChangeDetector.h
@@ -89,14 +89,17 @@ public:
 
     TOutput crossCorrel = 0.0;
 
-    for(unsigned long pos = 0; pos< itA.Size(); ++pos)
-      {
-	if(varA!=0 && varB!=0)
+    if(varA!=0 && varB!=0)
 	  {
-	    crossCorrel += (static_cast<TOutput>(itA.GetPixel(pos))-meanA)*(static_cast<TOutput>(itB.GetPixel(pos))-meanB)/(itA.Size()*vcl_sqrt(varA*varB));
+	    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)
+      {
+	crossCorrel = 1;	
       }
-
     return static_cast<TOutput>( 1.0-crossCorrel );
   }
 }; 
-- 
GitLab