From b049629d95536d6c53a415327b34665f49934b12 Mon Sep 17 00:00:00 2001
From: Julien Malik <julien.malik@c-s.fr>
Date: Thu, 12 May 2011 17:26:28 +0200
Subject: [PATCH] BUG: use itk::VectorIndexSelectionCastImageFilter in place of
 otb::MultiToMonoChannelExtractROI due to bug when LargestRegion has a
 non-null origin

---
 .../OBIA/otbBandsStatisticsAttributesLabelMapFilter.h |  5 -----
 .../otbBandsStatisticsAttributesLabelMapFilter.txx    | 11 ++++++++---
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/Code/OBIA/otbBandsStatisticsAttributesLabelMapFilter.h b/Code/OBIA/otbBandsStatisticsAttributesLabelMapFilter.h
index 840709338c..eb510a4de3 100644
--- a/Code/OBIA/otbBandsStatisticsAttributesLabelMapFilter.h
+++ b/Code/OBIA/otbBandsStatisticsAttributesLabelMapFilter.h
@@ -164,11 +164,6 @@ public:
   /** Runtime information support. */
   itkTypeMacro(BandsStatisticsAttributesLabelMapFilter, LabelMapFeaturesFunctorImageFilter);
 
-  // Channels
-  typedef MultiToMonoChannelExtractROI
-  <FeatureInternalPixelType, InternalPrecisionType>       ChannelFilterType;
-  typedef typename ChannelFilterType::Pointer ChannelFilterPointerType;
-
   /** Set the feature image */
   void SetFeatureImage(const TFeatureImage *input);
 
diff --git a/Code/OBIA/otbBandsStatisticsAttributesLabelMapFilter.txx b/Code/OBIA/otbBandsStatisticsAttributesLabelMapFilter.txx
index 224bbd7f90..77fe216133 100644
--- a/Code/OBIA/otbBandsStatisticsAttributesLabelMapFilter.txx
+++ b/Code/OBIA/otbBandsStatisticsAttributesLabelMapFilter.txx
@@ -19,6 +19,7 @@
 #define __otbBandsStatisticsAttributesLabelMapFilter_txx
 
 #include "otbBandsStatisticsAttributesLabelMapFilter.h"
+#include "itkVectorIndexSelectionCastImageFilter.h"
 
 namespace otb
 {
@@ -225,16 +226,20 @@ BandsStatisticsAttributesLabelMapFilter<TImage, TFeatureImage>
   // Add each band of the feature image to the statistics functor
   for (unsigned int i = 0; i < nbComponents; ++i)
     {
-    ChannelFilterPointerType band = ChannelFilterType::New();
-    band->SetChannel(i + 1);
+    typedef itk::VectorIndexSelectionCastImageFilter<FeatureImageType, InternalImageType>
+      VectorIndexSelectionCastImageFilterType;
+
+    typename VectorIndexSelectionCastImageFilterType::Pointer band = VectorIndexSelectionCastImageFilterType::New();
     band->SetInput(this->GetFeatureImage());
+    band->SetIndex(i);
+    band->UpdateOutputInformation();
     band->GetOutput()->SetRequestedRegion(this->GetOutput()->GetRequestedRegion());
     band->Update();
     std::ostringstream oss;
     oss << "Band" << i + 1; // [1..N] convention in feature naming
     this->GetFunctor().AddFeature(oss.str(), band->GetOutput());
-    }
 
+    }
 }
 
 template <class TImage, class TFeatureImage>
-- 
GitLab