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();
152 itk::ThreadIdType threadId)
override
154 using ImageScanlineConstIteratorType = itk::ImageScanlineConstIterator<InputImageType const>;
156 using OutputIterator = itk::ImageScanlineIterator<OutputImageType>;
159 auto const regSizeY = outputRegionForThread.GetSize()[1];
160 itk::ProgressReporter progress(
this, threadId, outputRegionForThread.GetNumberOfPixels() / regSizeY );
162 InputIterator inputIterator(this->
GetInputs(), outputRegionForThread);
163 OutputIterator outputIterator(this->GetOutput(), outputRegionForThread);
165 inputIterator.GoToBegin();
166 outputIterator.GoToBegin();
168 ; !inputIterator.IsAtEnd()
169 ; inputIterator.NextLine(), outputIterator.NextLine())
171 assert(! outputIterator.IsAtEnd());
175 ; !inputIterator.IsAtEndOfLine()
176 ; ++inputIterator, ++outputIterator)
178 assert(!outputIterator.IsAtEndOfLine());
180 outputIterator.Set(
m_functor(inputIterator.Get()));
182 progress.CompletedPixel();
191 auto const nbInputImages = this->GetNumberOfInputs();
192 auto const& inputSize = this->GetInput(0)->GetLargestPossibleRegion().GetSize();
194 for (
auto p = 1U; p < nbInputImages; ++p)
196 auto const& regionSize = this->GetInput(p)->GetLargestPossibleRegion().GetSize();
197 if (inputSize != regionSize)
199 itkExceptionMacro(<<
"Input images must have the same dimensions.\n"
200 <<
"band #1 is [" << inputSize[0] <<
";" << inputSize[1] <<
"]\n"
201 <<
"band #" << p + 1 <<
" is [" << this->GetInput(p)->GetLargestPossibleRegion().GetSize(0) <<
";"
202 << regionSize <<
"]");
229 template <
typename TInputImage,
typename TOutputImage,
typename TFunctor>
239 #ifndef OTB_MANUAL_INSTANTIATION
243 #endif // otbSynthetizeFilter_h