diff --git a/Modules/Applications/AppFiltering/app/otbContrastEnhancement.cxx b/Modules/Applications/AppFiltering/app/otbContrastEnhancement.cxx index d3843417a1988ae1fa1cb1e8ffeddf57b2414c54..5cfe775105574eef2a8ed44f89d9b61f2ac358bf 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 7a1d6527cec9e8e0b603d73591c155ddcb70acc0..f70d3440c2869c99c1a8ca26018994d8be60e98c 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