From a0baa0a5e6daa6136aeaee27d68b089913b6312c Mon Sep 17 00:00:00 2001 From: ctraizet <cedric.traizet@c-s.fr> Date: Mon, 18 Mar 2019 15:57:26 +0100 Subject: [PATCH] REFAC: replace LuminanceFunctor by a functorImageFilter --- .../app/otbContrastEnhancement.cxx | 28 +++++++++---------- .../AppFiltering/otb-module.cmake | 1 + 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/Modules/Applications/AppFiltering/app/otbContrastEnhancement.cxx b/Modules/Applications/AppFiltering/app/otbContrastEnhancement.cxx index d3843417a1..5cfe775105 100644 --- a/Modules/Applications/AppFiltering/app/otbContrastEnhancement.cxx +++ b/Modules/Applications/AppFiltering/app/otbContrastEnhancement.cxx @@ -25,7 +25,7 @@ #include "otbImageListToVectorImageFilter.h" #include "otbStreamingStatisticsVectorImageFilter.h" #include "otbStreamingStatisticsImageFilter.h" -#include "otbUnaryFunctorImageFilter.h" +#include "otbFunctorImageFilter.h" #include "itkStreamingImageFilter.h" #include "otbInPlacePassFilter.h" @@ -46,21 +46,21 @@ namespace Wrapper namespace Functor { +template<class TInput, class TOutput> class LuminanceOperator { -typedef FloatVectorImageType::PixelType OutPixel; -typedef FloatVectorImageType::PixelType InPixel; public: - LuminanceOperator() {} - unsigned int GetOutputSize() + LuminanceOperator() = default; + + size_t OutputSize(const std::array<size_t,1> & itkNotUsed(nbBands)) const { return 1; } - virtual ~LuminanceOperator() { } + virtual ~LuminanceOperator() = default; - OutPixel operator() ( InPixel input ) + TOutput operator() ( TInput input ) { - OutPixel out(1); + TOutput out(1); out[0] = m_LumCoef[0] * input[m_Rgb[0]] + m_LumCoef[1] * input[m_Rgb[1]] + m_LumCoef[2] * input[m_Rgb[2]] ; @@ -84,9 +84,9 @@ public: private: std::vector<unsigned int> m_Rgb; std::vector<float> m_LumCoef; -}; // end of functor class MultiplyOperator +}; // end of functor class LuminanceOperator -} // end of functor +} // namespace functor class ContrastEnhancement : public Application { @@ -127,8 +127,8 @@ public: typedef otb::StreamingStatisticsImageFilter < FloatImageType > StatsFilterType; - typedef otb::UnaryFunctorImageFilter < FloatVectorImageType , - FloatVectorImageType , Functor::LuminanceOperator > + typedef otb::FunctorImageFilter < Functor::LuminanceOperator + <FloatVectorImageType::PixelType, FloatVectorImageType::PixelType> > LuminanceFunctorType; typedef itk::StreamingImageFilter < LutType , LutType > @@ -705,8 +705,8 @@ private: lumCoef[i] /= sum; } m_LuminanceFunctor = LuminanceFunctorType::New() ; - m_LuminanceFunctor->GetFunctor().SetRgb( rgb ); - m_LuminanceFunctor->GetFunctor().SetLumCoef( lumCoef ); + m_LuminanceFunctor->GetModifiableFunctor().SetRgb( rgb ); + m_LuminanceFunctor->GetModifiableFunctor().SetLumCoef( lumCoef ); m_LuminanceFunctor->SetInput( inImage ); m_LuminanceFunctor->UpdateOutputInformation(); } diff --git a/Modules/Applications/AppFiltering/otb-module.cmake b/Modules/Applications/AppFiltering/otb-module.cmake index 7a1d6527ce..f70d3440c2 100644 --- a/Modules/Applications/AppFiltering/otb-module.cmake +++ b/Modules/Applications/AppFiltering/otb-module.cmake @@ -29,6 +29,7 @@ otb_module(OTBAppFiltering OTBContrast OTBStatistics OTBStreaming + OTBFunctor TEST_DEPENDS OTBTestKernel -- GitLab