21 #ifndef otbUnaryImageFunctorWithVectorImageFilter_hxx
22 #define otbUnaryImageFunctorWithVectorImageFilter_hxx
25 #include "itkImageRegionIterator.h"
26 #include "itkProgressReporter.h"
34 template <
class TInputImage,
class TOutputImage,
class TFunction>
37 this->SetNumberOfRequiredInputs(1);
39 this->DynamicMultiThreadingOn();
52 template <
class TInputImage,
class TOutputImage,
class TFunction>
55 Superclass::GenerateOutputInformation();
58 typename Superclass::OutputImagePointer outputPtr = this->GetOutput();
59 typename Superclass::InputImageConstPointer inputPtr = this->GetInput();
61 if (!outputPtr || !inputPtr)
65 outputPtr->SetNumberOfComponentsPerPixel(
66 inputPtr->GetNumberOfComponentsPerPixel());
70 for (
unsigned int i = 0; i < inputPtr->GetNumberOfComponentsPerPixel(); ++i)
73 m_FunctorVector.push_back(functor);
80 template <
class TInputImage,
class TOutputImage,
class TFunction>
83 typename Superclass::OutputImagePointer outputPtr = this->GetOutput();
84 typename Superclass::InputImageConstPointer inputPtr = this->GetInput();
88 itk::ImageRegionConstIterator<InputImageType> inputIt(inputPtr, outputRegionForThread);
89 itk::ImageRegionIterator<OutputImageType> outputIt(outputPtr, outputRegionForThread);
96 nullPixel.SetSize(inputPtr->GetNumberOfComponentsPerPixel());
97 nullPixel.Fill(itk::NumericTraits<OutputInternalPixelType>::Zero);
99 while (!inputIt.IsAtEnd())
103 outPixel.SetSize(inputPtr->GetNumberOfComponentsPerPixel());
104 outPixel.Fill(itk::NumericTraits<OutputInternalPixelType>::Zero);
106 if (inPixel != nullPixel)
108 for (
unsigned int j = 0; j < inputPtr->GetNumberOfComponentsPerPixel(); ++j)
110 outPixel[j] = m_FunctorVector[j](inPixel[j]);
113 outputIt.Set(outPixel);
119 template <
class TInputImage,
class TOutputImage,
class TFunction>
122 this->Superclass::PrintSelf(os, indent);
void DynamicThreadedGenerateData(const OutputImageRegionType &outputRegionForThread) override
void GenerateOutputInformation() override
UnaryImageFunctorWithVectorImageFilter()
OutputImageType::PixelType OutputPixelType
void PrintSelf(std::ostream &os, itk::Indent indent) const override
OutputImageType::RegionType OutputImageRegionType
InputImageType::PixelType InputPixelType
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.