diff --git a/Modules/Applications/AppDomainTransform/app/otbDomainTransform.cxx b/Modules/Applications/AppDomainTransform/app/otbDomainTransform.cxx index 34905e71732644a6edb9a86b2caff9d6cffb1bd3..b63d0c093501f11cb530080324b2b87abbfd5f58 100644 --- a/Modules/Applications/AppDomainTransform/app/otbDomainTransform.cxx +++ b/Modules/Applications/AppDomainTransform/app/otbDomainTransform.cxx @@ -28,38 +28,17 @@ #include <itkConfigure.h> #include <itkForwardFFTImageFilter.h> #include <itkInverseFFTImageFilter.h> -#include <itkUnaryFunctorImageFilter.h> #include <itkFFTShiftImageFilter.h> #include <itkFFTWGlobalConfiguration.h> +#include "otbFunctorImageFilter.h" + #include "otbComplexToVectorImageCastFilter.h" namespace otb { namespace Wrapper { -template< class TInput, class TOutput> -class ToComplexPixel -{ -public: - ToComplexPixel ( ) { }; - - ~ToComplexPixel( ) { }; - - bool operator!=( const ToComplexPixel & ) const - { - return false; - } - bool operator==( const ToComplexPixel & other ) const - { - return !(*this != other); - } - inline TOutput operator( )( const TInput & A ) const - { - return TOutput( static_cast<typename TOutput::value_type> ( A[0] ), - static_cast<typename TOutput::value_type> ( A[1] ) ); - } -}; class DomainTransform : public Application { @@ -282,7 +261,7 @@ private: fwdFilter->SetInput( inImage ); - //typedef VectorImage for output of UnaryFunctorImageFilter + // typedef VectorImage for output typedef otb::VectorImage<OutputPixelType> TOutputImage; typedef otb::ComplexToVectorImageCastFilter< @@ -330,16 +309,12 @@ private: //typedef TOutputImage for InverseFFTImageFilter output typedef otb::Image< OutputPixelType > TOutputImage; - // a unary functor to convert vectorimage to complex image - typedef itk::UnaryFunctorImageFilter - <TInputImage, - TComplexImage, - ToComplexPixel - <TInputImage::PixelType, - TComplexImage::PixelType> > UnaryFunctorImageFilter; + auto toComplex = [](const typename TInputImage::PixelType& A){ + return typename TComplexImage::PixelType( static_cast<typename TComplexImage::PixelType::value_type> ( A[0] ), + static_cast<typename TComplexImage::PixelType::value_type> ( A[1] ) ); + }; - UnaryFunctorImageFilter::Pointer - unaryFunctorImageFilter = UnaryFunctorImageFilter::New(); + auto toComplexFilter = NewFunctorFilter( toComplex ); if( shift) { @@ -353,21 +328,21 @@ private: fftShiftFilter->Update(); - unaryFunctorImageFilter->SetInput(fftShiftFilter->GetOutput() ); + toComplexFilter->SetVariadicInputs( fftShiftFilter->GetOutput() ); } else { - unaryFunctorImageFilter->SetInput(inImage); + toComplexFilter->SetVariadicInputs( inImage ); } - unaryFunctorImageFilter->Update(); + toComplexFilter->Update(); //typedef itk::::InverseFFTImageFilter over TComplexImage typedef itk::InverseFFTImageFilter < TComplexImage, TOutputImage > FFTFilter; FFTFilter::Pointer invFilter = FFTFilter::New(); - invFilter->SetInput( unaryFunctorImageFilter->GetOutput() ); + invFilter->SetInput( toComplexFilter->GetOutput() ); invFilter->Update(); //set output image diff --git a/Modules/Applications/AppDomainTransform/otb-module.cmake b/Modules/Applications/AppDomainTransform/otb-module.cmake index c5d362d94cf42f9a7aaf4f8f4d6f86ed8b8e9631..17412de4d016e1de0fbf70a8dd7cca0dc133c780 100644 --- a/Modules/Applications/AppDomainTransform/otb-module.cmake +++ b/Modules/Applications/AppDomainTransform/otb-module.cmake @@ -24,6 +24,7 @@ otb_module(OTBAppDomainTransform DEPENDS OTBWavelet OTBApplicationEngine + OTBFunctor TEST_DEPENDS OTBTestKernel