22 #ifndef otbQuaternaryFunctorImageFilter_hxx
23 #define otbQuaternaryFunctorImageFilter_hxx
26 #include "itkImageRegionIterator.h"
27 #include "itkProgressReporter.h"
35 template <
class TInputImage1,
class TInputImage2,
class TInputImage3,
class TInputImage4,
class TOutputImage,
class TFunction>
44 template <
class TInputImage1,
class TInputImage2,
class TInputImage3,
class TInputImage4,
class TOutputImage,
class TFunction>
48 this->SetNthInput(0,
const_cast<TInputImage1*
>(image1));
54 template <
class TInputImage1,
class TInputImage2,
class TInputImage3,
class TInputImage4,
class TOutputImage,
class TFunction>
58 this->SetNthInput(1,
const_cast<TInputImage2*
>(image2));
64 template <
class TInputImage1,
class TInputImage2,
class TInputImage3,
class TInputImage4,
class TOutputImage,
class TFunction>
68 this->SetNthInput(2,
const_cast<TInputImage3*
>(image3));
74 template <
class TInputImage1,
class TInputImage2,
class TInputImage3,
class TInputImage4,
class TOutputImage,
class TFunction>
78 this->SetNthInput(3,
const_cast<TInputImage4*
>(image4));
84 template <
class TInputImage1,
class TInputImage2,
class TInputImage3,
class TInputImage4,
class TOutputImage,
class TFunction>
87 Input1ImagePointer inputPtr1 =
dynamic_cast<const TInputImage1*
>((itk::ProcessObject::GetInput(0)));
88 Input2ImagePointer inputPtr2 =
dynamic_cast<const TInputImage2*
>((itk::ProcessObject::GetInput(1)));
89 Input3ImagePointer inputPtr3 =
dynamic_cast<const TInputImage3*
>((itk::ProcessObject::GetInput(2)));
90 Input4ImagePointer inputPtr4 =
dynamic_cast<const TInputImage4*
>((itk::ProcessObject::GetInput(3)));
91 if (inputPtr1.IsNull() || inputPtr2.IsNull() || inputPtr3.IsNull() || inputPtr4.IsNull())
93 itkExceptionMacro(<<
"At least one input is missing."
94 <<
" Input1 is " << inputPtr1.GetPointer() <<
", "
95 <<
" Input2 is " << inputPtr2.GetPointer() <<
", "
96 <<
" Input3 is " << inputPtr3.GetPointer() <<
", "
97 <<
" Input4 is " << inputPtr4.GetPointer());
105 template <
class TInputImage1,
class TInputImage2,
class TInputImage3,
class TInputImage4,
class TOutputImage,
class TFunction>
112 Input1ImagePointer inputPtr1 =
dynamic_cast<const TInputImage1*
>((itk::ProcessObject::GetInput(0)));
113 Input2ImagePointer inputPtr2 =
dynamic_cast<const TInputImage2*
>((itk::ProcessObject::GetInput(1)));
114 Input3ImagePointer inputPtr3 =
dynamic_cast<const TInputImage3*
>((itk::ProcessObject::GetInput(2)));
115 Input4ImagePointer inputPtr4 =
dynamic_cast<const TInputImage4*
>((itk::ProcessObject::GetInput(3)));
119 itk::ImageRegionConstIterator<TInputImage1> inputIt1(inputPtr1, outputRegionForThread);
120 itk::ImageRegionConstIterator<TInputImage2> inputIt2(inputPtr2, outputRegionForThread);
121 itk::ImageRegionConstIterator<TInputImage3> inputIt3(inputPtr3, outputRegionForThread);
122 itk::ImageRegionConstIterator<TInputImage4> inputIt4(inputPtr4, outputRegionForThread);
123 itk::ImageRegionIterator<TOutputImage> outputIt(outputPtr, outputRegionForThread);
125 itk::ProgressReporter progress(
this, threadId, outputRegionForThread.GetNumberOfPixels());
127 inputIt1.GoToBegin();
128 inputIt2.GoToBegin();
129 inputIt3.GoToBegin();
130 outputIt.GoToBegin();
132 while (!inputIt1.IsAtEnd())
134 outputIt.Set(m_Functor(inputIt1.Get(), inputIt2.Get(), inputIt3.Get(), inputIt4.Get()));
140 progress.CompletedPixel();