22 #ifndef otbFunctionToImageFilter_hxx
23 #define otbFunctionToImageFilter_hxx
26 #include "itkImageRegionConstIterator.h"
27 #include "itkProgressReporter.h"
35 template <
class TInputImage,
class TOutputImage,
class TFunction>
39 m_PixelFunction = FunctionType::New();
58 template <
class TInputImage,
class TOutputImage,
class TFunction>
61 InputImagePointer inputPtr =
dynamic_cast<const TInputImage*
>((itk::ProcessObject::GetInput(0)));
62 if (inputPtr.IsNull())
64 itkExceptionMacro(<<
"At least one input is missing."
65 <<
" Input is missing :" << inputPtr.GetPointer();)
67 m_PixelFunction->SetInputImage(inputPtr);
74 template <
class TInputImage,
class TOutputImage,
class TFunction>
76 itk::ThreadIdType threadId)
80 InputImagePointer inputPtr =
dynamic_cast<const TInputImage*
>((itk::ProcessObject::GetInput(0)));
84 itk::ImageRegionConstIterator<TInputImage> inputIt(inputPtr, outputRegionForThread);
85 itk::ImageRegionIterator<TOutputImage> outputIt(outputPtr, outputRegionForThread);
87 itk::ProgressReporter progress(
this, threadId, outputRegionForThread.GetNumberOfPixels());
93 while (!inputIt.IsAtEnd())
95 outputIt.Set(
static_cast<OutputImagePixelType>(m_PixelFunction->EvaluateAtIndex(inputIt.GetIndex())));
98 progress.CompletedPixel();