21 #ifndef otbSynthetizeFilter_h
22 #define otbSynthetizeFilter_h
25 #include "itkImageToImageFilter.h"
26 #include "itkImageScanlineConstIterator.h"
27 #include "itkImageScanlineIterator.h"
28 #include "itkProgressReporter.h"
46 template <
typename TInputImage,
typename TOutputImage,
typename TFunctor>
67 using Superclass = itk::ImageToImageFilter<InputImageType, OutputImageType>;
76 smartPtr->UnRegister();
88 using InputRealType =
typename itk::NumericTraits<InputPixelType>::RealType;
106 using Superclass::SetNthInput;
107 using Superclass::GetInput;
118 std::vector<InputImageType const*> res;
119 auto const nbInputImages = this->GetNumberOfInputs();
120 res.reserve(nbInputImages);
121 for (std::size_t i = 0 ; i != nbInputImages ; ++i)
122 res.push_back(this->GetInput(i));
137 Superclass::GenerateOutputInformation();
153 using ImageScanlineConstIteratorType = itk::ImageScanlineConstIterator<InputImageType const>;
155 using OutputIterator = itk::ImageScanlineIterator<OutputImageType>;
158 InputIterator inputIterator(this->
GetInputs(), outputRegionForThread);
159 OutputIterator outputIterator(this->GetOutput(), outputRegionForThread);
161 inputIterator.GoToBegin();
162 outputIterator.GoToBegin();
164 ; !inputIterator.IsAtEnd()
165 ; inputIterator.NextLine(), outputIterator.NextLine())
167 assert(! outputIterator.IsAtEnd());
171 ; !inputIterator.IsAtEndOfLine()
172 ; ++inputIterator, ++outputIterator)
174 assert(!outputIterator.IsAtEndOfLine());
176 outputIterator.Set(
m_functor(inputIterator.Get()));
186 auto const nbInputImages = this->GetNumberOfInputs();
187 auto const& inputSize = this->GetInput(0)->GetLargestPossibleRegion().GetSize();
189 for (
auto p = 1U; p < nbInputImages; ++p)
191 auto const& regionSize = this->GetInput(p)->GetLargestPossibleRegion().GetSize();
192 if (inputSize != regionSize)
194 itkExceptionMacro(<<
"Input images must have the same dimensions.\n"
195 <<
"band #1 is [" << inputSize[0] <<
";" << inputSize[1] <<
"]\n"
196 <<
"band #" << p + 1 <<
" is [" << this->GetInput(p)->GetLargestPossibleRegion().GetSize(0) <<
";"
197 << regionSize <<
"]");
224 template <
typename TInputImage,
typename TOutputImage,
typename TFunctor>
234 #ifndef OTB_MANUAL_INSTANTIATION
void CheckInputImageDimensions()
typename OutputImageType::IndexType OutputIndexType
TOutputImage OutputImageType
typename InputImageType::PixelType InputPixelType
itk::ProcessObject::DataObjectPointerArraySizeType DataObjectPointerArraySizeType
std::vector< InputImageType const * > GetInputs() const
typename OutputImageType::PixelType OutputPixelType
static const unsigned int OutputImageDimension
InputImageType * GetNthInput(DataObjectPointerArraySizeType idx)
TInputImage InputImageType
itk::SmartPointer< Self > Pointer
typename InputImageType::SizeType InputSizeType
void DynamicThreadedGenerateData(OutputImageRegionType const &outputRegionForThread) override
typename OutputImageType::SizeType OutputSizeType
typename OutputImageType::RegionType OutputImageRegionType
SynthetizeFilter(FunctorType functor)
typename InputImageType::RegionType InputImageRegionType
~SynthetizeFilter()=default
static Pointer New(FunctorType functor)
itk::ImageToImageFilter< InputImageType, OutputImageType > Superclass
void GenerateOutputInformation() override
static const unsigned int InputImageDimension
typename itk::NumericTraits< InputPixelType >::RealType InputRealType
itk::SmartPointer< const Self > ConstPointer
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
auto MakeSynthetizeFilter(TFunctor functor)