Commit a0baa0a5 authored by ctraizet's avatar ctraizet
Browse files

REFAC: replace LuminanceFunctor by a functorImageFilter

No related merge requests found
Showing with 15 additions and 14 deletions
+15 -14
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
#include "otbImageListToVectorImageFilter.h" #include "otbImageListToVectorImageFilter.h"
#include "otbStreamingStatisticsVectorImageFilter.h" #include "otbStreamingStatisticsVectorImageFilter.h"
#include "otbStreamingStatisticsImageFilter.h" #include "otbStreamingStatisticsImageFilter.h"
#include "otbUnaryFunctorImageFilter.h" #include "otbFunctorImageFilter.h"
#include "itkStreamingImageFilter.h" #include "itkStreamingImageFilter.h"
#include "otbInPlacePassFilter.h" #include "otbInPlacePassFilter.h"
...@@ -46,21 +46,21 @@ namespace Wrapper ...@@ -46,21 +46,21 @@ namespace Wrapper
namespace Functor namespace Functor
{ {
template<class TInput, class TOutput>
class LuminanceOperator class LuminanceOperator
{ {
typedef FloatVectorImageType::PixelType OutPixel;
typedef FloatVectorImageType::PixelType InPixel;
public: public:
LuminanceOperator() {} LuminanceOperator() = default;
unsigned int GetOutputSize()
size_t OutputSize(const std::array<size_t,1> & itkNotUsed(nbBands)) const
{ {
return 1; 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]] + out[0] = m_LumCoef[0] * input[m_Rgb[0]] +
m_LumCoef[1] * input[m_Rgb[1]] + m_LumCoef[1] * input[m_Rgb[1]] +
m_LumCoef[2] * input[m_Rgb[2]] ; m_LumCoef[2] * input[m_Rgb[2]] ;
...@@ -84,9 +84,9 @@ public: ...@@ -84,9 +84,9 @@ public:
private: private:
std::vector<unsigned int> m_Rgb; std::vector<unsigned int> m_Rgb;
std::vector<float> m_LumCoef; std::vector<float> m_LumCoef;
}; // end of functor class MultiplyOperator }; // end of functor class LuminanceOperator
} // end of functor } // namespace functor
class ContrastEnhancement : public Application class ContrastEnhancement : public Application
{ {
...@@ -127,8 +127,8 @@ public: ...@@ -127,8 +127,8 @@ public:
typedef otb::StreamingStatisticsImageFilter < FloatImageType > typedef otb::StreamingStatisticsImageFilter < FloatImageType >
StatsFilterType; StatsFilterType;
typedef otb::UnaryFunctorImageFilter < FloatVectorImageType , typedef otb::FunctorImageFilter < Functor::LuminanceOperator
FloatVectorImageType , Functor::LuminanceOperator > <FloatVectorImageType::PixelType, FloatVectorImageType::PixelType> >
LuminanceFunctorType; LuminanceFunctorType;
typedef itk::StreamingImageFilter < LutType , LutType > typedef itk::StreamingImageFilter < LutType , LutType >
...@@ -705,8 +705,8 @@ private: ...@@ -705,8 +705,8 @@ private:
lumCoef[i] /= sum; lumCoef[i] /= sum;
} }
m_LuminanceFunctor = LuminanceFunctorType::New() ; m_LuminanceFunctor = LuminanceFunctorType::New() ;
m_LuminanceFunctor->GetFunctor().SetRgb( rgb ); m_LuminanceFunctor->GetModifiableFunctor().SetRgb( rgb );
m_LuminanceFunctor->GetFunctor().SetLumCoef( lumCoef ); m_LuminanceFunctor->GetModifiableFunctor().SetLumCoef( lumCoef );
m_LuminanceFunctor->SetInput( inImage ); m_LuminanceFunctor->SetInput( inImage );
m_LuminanceFunctor->UpdateOutputInformation(); m_LuminanceFunctor->UpdateOutputInformation();
} }
......
...@@ -29,6 +29,7 @@ otb_module(OTBAppFiltering ...@@ -29,6 +29,7 @@ otb_module(OTBAppFiltering
OTBContrast OTBContrast
OTBStatistics OTBStatistics
OTBStreaming OTBStreaming
OTBFunctor
TEST_DEPENDS TEST_DEPENDS
OTBTestKernel OTBTestKernel
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment