From 51ae8d3dbf1d72c87fefd6a3561ae9841930c435 Mon Sep 17 00:00:00 2001
From: Jonathan Guinet <jonathan.guinet@c-s.fr>
Date: Wed, 18 Apr 2012 16:57:30 +0200
Subject: [PATCH] BUG: convergence threshold calculus is wrong.

---
 Code/BasicFilters/otbMeanShiftImageFilter2.txx | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/Code/BasicFilters/otbMeanShiftImageFilter2.txx b/Code/BasicFilters/otbMeanShiftImageFilter2.txx
index 6ccb5405bc..6c9a333a0b 100644
--- a/Code/BasicFilters/otbMeanShiftImageFilter2.txx
+++ b/Code/BasicFilters/otbMeanShiftImageFilter2.txx
@@ -681,6 +681,7 @@ MeanShiftImageFilter2<TInputImage,TOutputMetricImage, TOutputImage, TKernel>
     // TODO change the maximum value;
 
     bool hasConverged = false;
+
     while ((iteration < m_MaxIterationNumber) && (!hasConverged))
       {
 
@@ -720,7 +721,7 @@ MeanShiftImageFilter2<TInputImage,TOutputMetricImage, TOutputImage, TKernel>
         rangePixel[comp] += meanShiftVector[spatialNumberOfComponents + comp];
         metricPixel[spatialNumberOfComponents + comp] = meanShiftVector[spatialNumberOfComponents + comp]
             * meanShiftVector[spatialNumberOfComponents + comp];
-        sum += metricPixel[comp];
+        sum += metricPixel[spatialNumberOfComponents+comp];
         }
 
       //TODO replace SSD Test with templated metric
-- 
GitLab