From bc9106ae516e78fdd5eeef428996723f26e332d0 Mon Sep 17 00:00:00 2001
From: Guillaume Pasero <guillaume.pasero@c-s.fr>
Date: Mon, 24 Apr 2017 19:08:40 +0200
Subject: [PATCH] BUG: Mantis-1389: use uint32 for label type

---
 .../Applications/AppImageUtils/app/otbColorMapping.cxx   | 9 +++++----
 Modules/Applications/AppImageUtils/otb-module.cmake      | 1 +
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/Modules/Applications/AppImageUtils/app/otbColorMapping.cxx b/Modules/Applications/AppImageUtils/app/otbColorMapping.cxx
index e3f43b81dc..2bfbceb715 100644
--- a/Modules/Applications/AppImageUtils/app/otbColorMapping.cxx
+++ b/Modules/Applications/AppImageUtils/app/otbColorMapping.cxx
@@ -46,6 +46,7 @@
 #include "otbStreamingStatisticsMapFromLabelImageFilter.h"
 
 #include "otbMacro.h"
+#include "otbStringUtils.h"
 
 namespace otb
 {
@@ -178,14 +179,14 @@ public:
   itkTypeMacro(ColorMapping, otb::Application);
 
   typedef FloatImageType::PixelType   PixelType;
-  typedef UInt16ImageType             LabelImageType;
+  typedef UInt32ImageType             LabelImageType;
   typedef LabelImageType::PixelType   LabelType;
   typedef UInt8VectorImageType        VectorImageType;
   typedef VectorImageType::PixelType  VectorPixelType;
   typedef UInt8RGBImageType           RGBImageType;
   typedef RGBImageType::PixelType     RGBPixelType;
 
-  typedef UInt16VectorImageType                       LabelVectorImageType;
+  typedef UInt32VectorImageType                       LabelVectorImageType;
   typedef LabelVectorImageType::PixelType             LabelVectorType;
 
   typedef itk::NumericTraits
@@ -196,7 +197,7 @@ public:
   typedef itk::ImageRegionConstIterator
     <FloatVectorImageType>                            IteratorType;
   typedef itk::ImageRegionConstIterator
-    <UInt16ImageType>                                 LabelIteratorType;
+    <LabelImageType>                                 LabelIteratorType;
 
   // Manual label LUT
   typedef otb::ChangeLabelImageFilter
@@ -783,7 +784,7 @@ private:
         if (nextpos == std::string::npos)
           continue;
         length = nextpos - pos;
-        LabelType clabel = atoi(line.substr(pos, length).c_str());
+        LabelType clabel = boost::lexical_cast<LabelType>(line.substr(pos, length).c_str());
         // Retrieve the color
         VectorPixelType color(3);
         color.Fill(0);
diff --git a/Modules/Applications/AppImageUtils/otb-module.cmake b/Modules/Applications/AppImageUtils/otb-module.cmake
index b817effaab..72e63db6e8 100644
--- a/Modules/Applications/AppImageUtils/otb-module.cmake
+++ b/Modules/Applications/AppImageUtils/otb-module.cmake
@@ -23,6 +23,7 @@ set(DOCUMENTATION "Image utils and handling application.")
 otb_module(OTBAppImageUtils
   DEPENDS
     OTBApplicationEngine
+    OTBBoostAdapters
     OTBCarto
     OTBColorMap
     OTBCommon
-- 
GitLab