Skip to content
Snippets Groups Projects
Commit 5ef33657 authored by Julien Michel's avatar Julien Michel
Browse files

Merge branch 'use_FunctorImagefilter_in_DomainTransform' into 'develop'

REFAC: use FunctorFilter in DomainTransform

See merge request orfeotoolbox/otb!309
parents 89359fb0 1d449a94
No related branches found
No related tags found
No related merge requests found
...@@ -28,38 +28,17 @@ ...@@ -28,38 +28,17 @@
#include <itkConfigure.h> #include <itkConfigure.h>
#include <itkForwardFFTImageFilter.h> #include <itkForwardFFTImageFilter.h>
#include <itkInverseFFTImageFilter.h> #include <itkInverseFFTImageFilter.h>
#include <itkUnaryFunctorImageFilter.h>
#include <itkFFTShiftImageFilter.h> #include <itkFFTShiftImageFilter.h>
#include <itkFFTWGlobalConfiguration.h> #include <itkFFTWGlobalConfiguration.h>
#include "otbFunctorImageFilter.h"
#include "otbComplexToVectorImageCastFilter.h" #include "otbComplexToVectorImageCastFilter.h"
namespace otb namespace otb
{ {
namespace Wrapper 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 class DomainTransform : public Application
{ {
...@@ -282,7 +261,7 @@ private: ...@@ -282,7 +261,7 @@ private:
fwdFilter->SetInput( inImage ); fwdFilter->SetInput( inImage );
//typedef VectorImage for output of UnaryFunctorImageFilter // typedef VectorImage for output
typedef otb::VectorImage<OutputPixelType> TOutputImage; typedef otb::VectorImage<OutputPixelType> TOutputImage;
typedef otb::ComplexToVectorImageCastFilter< typedef otb::ComplexToVectorImageCastFilter<
...@@ -330,16 +309,12 @@ private: ...@@ -330,16 +309,12 @@ private:
//typedef TOutputImage for InverseFFTImageFilter output //typedef TOutputImage for InverseFFTImageFilter output
typedef otb::Image< OutputPixelType > TOutputImage; typedef otb::Image< OutputPixelType > TOutputImage;
// a unary functor to convert vectorimage to complex image auto toComplex = [](const typename TInputImage::PixelType& A){
typedef itk::UnaryFunctorImageFilter return typename TComplexImage::PixelType( static_cast<typename TComplexImage::PixelType::value_type> ( A[0] ),
<TInputImage, static_cast<typename TComplexImage::PixelType::value_type> ( A[1] ) );
TComplexImage, };
ToComplexPixel
<TInputImage::PixelType,
TComplexImage::PixelType> > UnaryFunctorImageFilter;
UnaryFunctorImageFilter::Pointer auto toComplexFilter = NewFunctorFilter( toComplex );
unaryFunctorImageFilter = UnaryFunctorImageFilter::New();
if( shift) if( shift)
{ {
...@@ -353,21 +328,21 @@ private: ...@@ -353,21 +328,21 @@ private:
fftShiftFilter->Update(); fftShiftFilter->Update();
unaryFunctorImageFilter->SetInput(fftShiftFilter->GetOutput() ); toComplexFilter->SetVariadicInputs( fftShiftFilter->GetOutput() );
} }
else else
{ {
unaryFunctorImageFilter->SetInput(inImage); toComplexFilter->SetVariadicInputs( inImage );
} }
unaryFunctorImageFilter->Update(); toComplexFilter->Update();
//typedef itk::::InverseFFTImageFilter over TComplexImage //typedef itk::::InverseFFTImageFilter over TComplexImage
typedef itk::InverseFFTImageFilter typedef itk::InverseFFTImageFilter
< TComplexImage, < TComplexImage,
TOutputImage > FFTFilter; TOutputImage > FFTFilter;
FFTFilter::Pointer invFilter = FFTFilter::New(); FFTFilter::Pointer invFilter = FFTFilter::New();
invFilter->SetInput( unaryFunctorImageFilter->GetOutput() ); invFilter->SetInput( toComplexFilter->GetOutput() );
invFilter->Update(); invFilter->Update();
//set output image //set output image
......
...@@ -24,6 +24,7 @@ otb_module(OTBAppDomainTransform ...@@ -24,6 +24,7 @@ otb_module(OTBAppDomainTransform
DEPENDS DEPENDS
OTBWavelet OTBWavelet
OTBApplicationEngine OTBApplicationEngine
OTBFunctor
TEST_DEPENDS TEST_DEPENDS
OTBTestKernel OTBTestKernel
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment