22 #ifndef otbVectorImageToMatrixFilter_hxx
23 #define otbVectorImageToMatrixFilter_hxx
26 #include "itkImageRegionIterator.h"
27 #include "itkImageRegionConstIteratorWithIndex.h"
28 #include "itkProgressReporter.h"
34 template <
class TInputImage>
42 this->itk::ProcessObject::SetNthOutput(1, this->MakeOutput(1).GetPointer());
45 template <
class TInputImage>
51 return static_cast<itk::DataObject*
>(TInputImage::New().GetPointer());
54 return static_cast<itk::DataObject*
>(MatrixObjectType::New().GetPointer());
58 return static_cast<itk::DataObject*
>(TInputImage::New().GetPointer());
63 template <
class TInputImage>
66 return static_cast<MatrixObjectType*
>(this->itk::ProcessObject::GetOutput(1));
69 template <
class TInputImage>
72 return static_cast<const MatrixObjectType*
>(this->itk::ProcessObject::GetOutput(1));
75 template <
class TInputImage>
78 Superclass::GenerateOutputInformation();
81 this->GetOutput()->CopyInformation(this->GetInput());
82 this->GetOutput()->SetLargestPossibleRegion(this->GetInput()->GetLargestPossibleRegion());
84 if (this->GetOutput()->GetRequestedRegion().GetNumberOfPixels() == 0)
86 this->GetOutput()->SetRequestedRegion(this->GetOutput()->GetLargestPossibleRegion());
91 template <
class TInputImage>
101 template <
class TInputImage>
104 TInputImage* inputPtr =
const_cast<TInputImage*
>(this->GetInput());
105 inputPtr->UpdateOutputInformation();
107 this->GetMatrixOutput()->Get().set_size(inputPtr->GetNumberOfComponentsPerPixel(), inputPtr->GetLargestPossibleRegion().GetNumberOfPixels());
110 template <
class TInputImage>
115 template <
class TInputImage>
119 itk::ProgressReporter progress(
this, threadId, outputRegionForThread.GetNumberOfPixels());
123 const unsigned int width = this->GetInput()->GetLargestPossibleRegion().GetSize()[0];
124 itk::ImageRegionConstIteratorWithIndex<TInputImage> it(inputPtr, outputRegionForThread);
126 for (it.GoToBegin(); !it.IsAtEnd(); ++it, progress.CompletedPixel())
130 unsigned int col = idx[0] + idx[1] * width;
132 MatrixType& m = this->GetMatrixOutput()->Get();
133 for (
unsigned int r = 0; r < vectorValue.Size(); ++r)
135 m(r, col) = vectorValue[r];
140 template <
class TImage>
143 Superclass::PrintSelf(os, indent);