From 72dfd7599c674b02ae3589f90a11174923335d45 Mon Sep 17 00:00:00 2001
From: Guillaume Pasero <guillaume.pasero@c-s.fr>
Date: Fri, 23 Nov 2012 10:29:58 +0100
Subject: [PATCH] BUG: fix colormapping with support image (clamping)

---
 Applications/Utils/otbColorMapping.cxx | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/Applications/Utils/otbColorMapping.cxx b/Applications/Utils/otbColorMapping.cxx
index 7ee40000b0..adff0e99af 100644
--- a/Applications/Utils/otbColorMapping.cxx
+++ b/Applications/Utils/otbColorMapping.cxx
@@ -628,11 +628,11 @@ private:
 
             // Convert the radiometric value to [0, 255]
             // using the clamping from histogram cut
-            color[RGB] = NumericTraitsType::Clamp( meanValue[dispIndex]
-                                                   , minVal[dispIndex]
-                                                   , maxVal[dispIndex] )
-                         / (maxVal[dispIndex] - minVal[dispIndex])
-                         * 255.0;
+            color[RGB] = NumericTraitsType::Clamp( (meanValue[dispIndex] - minVal[dispIndex])
+                                                      / (maxVal[dispIndex] - minVal[dispIndex])
+                                                      * 255.0
+                                                   , 0.0
+                                                   , 255.0);
             }
           }
         otbAppLogINFO("Adding color mapping " << clabel << " -> [" << (int) color[0] << " " << (int) color[1] << " "<< (int) color[2] << " ]" << std::endl);
-- 
GitLab