22 #ifndef otbVectorImageToMatrixFilter_hxx
23 #define otbVectorImageToMatrixFilter_hxx
26 #include "itkImageRegionIterator.h"
27 #include "itkImageRegionConstIteratorWithIndex.h"
32 template <
class TInputImage>
40 this->DynamicMultiThreadingOn();
41 this->itk::ProcessObject::SetNthOutput(1, this->MakeOutput(1).GetPointer());
44 template <
class TInputImage>
50 return static_cast<itk::DataObject*
>(TInputImage::New().GetPointer());
53 return static_cast<itk::DataObject*
>(MatrixObjectType::New().GetPointer());
57 return static_cast<itk::DataObject*
>(TInputImage::New().GetPointer());
62 template <
class TInputImage>
65 return static_cast<MatrixObjectType*
>(this->itk::ProcessObject::GetOutput(1));
68 template <
class TInputImage>
71 return static_cast<const MatrixObjectType*
>(this->itk::ProcessObject::GetOutput(1));
74 template <
class TInputImage>
77 Superclass::GenerateOutputInformation();
80 this->GetOutput()->CopyInformation(this->GetInput());
81 this->GetOutput()->SetLargestPossibleRegion(this->GetInput()->GetLargestPossibleRegion());
83 if (this->GetOutput()->GetRequestedRegion().GetNumberOfPixels() == 0)
85 this->GetOutput()->SetRequestedRegion(this->GetOutput()->GetLargestPossibleRegion());
90 template <
class TInputImage>
100 template <
class TInputImage>
103 TInputImage* inputPtr =
const_cast<TInputImage*
>(this->GetInput());
104 inputPtr->UpdateOutputInformation();
106 this->GetMatrixOutput()->Get().set_size(inputPtr->GetNumberOfComponentsPerPixel(), inputPtr->GetLargestPossibleRegion().GetNumberOfPixels());
109 template <
class TInputImage>
114 template <
class TInputImage>
119 const unsigned int width = this->GetInput()->GetLargestPossibleRegion().GetSize()[0];
120 itk::ImageRegionConstIteratorWithIndex<TInputImage> it(inputPtr, outputRegionForThread);
122 for (it.GoToBegin(); !it.IsAtEnd(); ++it)
126 unsigned int col = idx[0] + idx[1] * width;
128 MatrixType& m = this->GetMatrixOutput()->Get();
129 for (
unsigned int r = 0; r < vectorValue.Size(); ++r)
131 m(r, col) = vectorValue[r];
136 template <
class TImage>
139 Superclass::PrintSelf(os, indent);
itk::ProcessObject::DataObjectPointerArraySizeType DataObjectPointerArraySizeType
MatrixObjectType * GetMatrixOutput()
TInputImage::PixelType PixelType
itk::SimpleDataObjectDecorator< MatrixType > MatrixObjectType
TInputImage::RegionType RegionType
void DynamicThreadedGenerateData(const RegionType &outputRegionForThread) override
void Synthetize(void) override
DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx) override
void PrintSelf(std::ostream &os, itk::Indent indent) const override
vnl_matrix< RealType > MatrixType
TInputImage::IndexType IndexType
void GenerateOutputInformation() override
void Reset(void) override
TInputImage::Pointer InputImagePointer
void AllocateOutputs() override
PersistentVectorImageToMatrixFilter()
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.