21 #ifndef otbVectorImageTo3DScalarImageFilter_hxx
22 #define otbVectorImageTo3DScalarImageFilter_hxx
25 #include "itkImageRegionConstIterator.h"
26 #include "itkImageSliceIteratorWithIndex.h"
33 template <
class TInputImage,
class TOutputImage>
39 template <
class TInputImage,
class TOutputImage>
43 const InputImageType* inputPtr = this->GetInput();
44 OutputImageType* outputPtr = this->GetOutput();
46 InputImageRegionType inputLargestRegion = this->GetInput()->GetLargestPossibleRegion();
47 OutputImageSizeType size;
48 OutputImageIndexType index;
49 for (
unsigned int i = 0; i < InputImageType::ImageDimension; ++i)
51 size[i] = inputLargestRegion.GetSize()[i];
52 index[i] = inputLargestRegion.GetIndex()[i];
54 size[OutputImageType::ImageDimension - 1] = inputPtr->GetNumberOfComponentsPerPixel();
55 index[OutputImageType::ImageDimension - 1] = 0;
57 OutputImageRegionType outputRegion;
58 outputRegion.SetSize(size);
59 outputRegion.SetIndex(index);
60 outputPtr->SetLargestPossibleRegion(outputRegion);
63 template <
class TInputImage,
class TOutputImage>
66 InputImageType* inputPtr =
const_cast<InputImageType*
>(this->GetInput());
67 OutputImageType* outputPtr = this->GetOutput();
70 OutputImageRegionType requestedRegion = outputPtr->GetRequestedRegion();
71 InputImageRegionType inputRequestedRegion;
72 InputImageSizeType size;
73 InputImageIndexType index;
75 for (
unsigned int i = 0; i < InputImageType::ImageDimension; ++i)
77 size[i] = requestedRegion.GetSize()[i];
78 index[i] = requestedRegion.GetIndex()[i];
80 inputRequestedRegion.SetSize(size);
81 inputRequestedRegion.SetIndex(index);
82 inputPtr->SetRequestedRegion(inputRequestedRegion);
84 template <
class TInputImage,
class TOutputImage>
86 itk::ThreadIdType itkNotUsed(threadId))
88 const InputImageType* inputPtr = this->GetInput();
89 OutputImageType* outputPtr = this->GetOutput();
91 typedef itk::ImageRegionConstIterator<InputImageType> InputIteratorType;
92 typedef itk::ImageSliceIteratorWithIndex<OutputImageType> OutputIteratorType;
94 InputImageRegionType inputRegion;
95 InputImageSizeType size;
96 InputImageIndexType index;
98 for (
unsigned int i = 0; i < InputImageType::ImageDimension; ++i)
100 size[i] = outputRegionForThread.GetSize()[i];
101 index[i] = outputRegionForThread.GetIndex()[i];
103 inputRegion.SetSize(size);
104 inputRegion.SetIndex(index);
106 InputIteratorType inIt(inputPtr, inputRegion);
108 OutputIteratorType outIt(outputPtr, outputRegionForThread);
109 outIt.SetFirstDirection(0);
110 outIt.SetSecondDirection(1);
115 while (!outIt.IsAtEnd())
117 outIt.Set(
static_cast<OutputPixelType
>(inIt.Get()[outIt.GetIndex()[InputImageType::ImageDimension]]));
124 if (outIt.IsAtEndOfLine())
128 if (outIt.IsAtEndOfSlice())