diff --git a/Code/OBIA/otbBandsStatisticsAttributesLabelMapFilter.h b/Code/OBIA/otbBandsStatisticsAttributesLabelMapFilter.h index 840709338c850c185c51d4e3f2c9137d6cf13158..eb510a4de333a52776af39260f0114ad49ddc316 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 224bbd7f904177924ddb1a121b9a885389309117..77fe21613308af4178861d6e71b373f9f25976a3 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>