OTB  9.0.0
Orfeo Toolbox
otbVectorImageToMatrixImageFilter.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1999-2011 Insight Software Consortium
3  * Copyright (C) 2005-2022 Centre National d'Etudes Spatiales (CNES)
4  *
5  * This file is part of Orfeo Toolbox
6  *
7  * https://www.orfeo-toolbox.org/
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  */
21 
22 #ifndef otbVectorImageToMatrixFilter_h
23 #define otbVectorImageToMatrixFilter_h
24 
27 #include "itkSimpleDataObjectDecorator.h"
28 #include "itkImageRegionSplitter.h"
29 #include "itkVariableSizeMatrix.h"
30 #include "itkVariableLengthVector.h"
31 
32 namespace otb
33 {
34 
53 template <class TInputImage>
54 class ITK_EXPORT PersistentVectorImageToMatrixFilter : public PersistentImageFilter<TInputImage, TInputImage>
55 {
56 public:
60  typedef itk::SmartPointer<Self> Pointer;
61  typedef itk::SmartPointer<const Self> ConstPointer;
62 
64  itkNewMacro(Self);
65 
68 
70  typedef TInputImage ImageType;
71  typedef typename TInputImage::Pointer InputImagePointer;
72  typedef typename TInputImage::RegionType RegionType;
73  typedef typename TInputImage::SizeType SizeType;
74  typedef typename TInputImage::IndexType IndexType;
75  typedef typename TInputImage::PixelType PixelType;
76  typedef typename TInputImage::InternalPixelType InternalPixelType;
77 
78  itkStaticConstMacro(InputImageDimension, unsigned int, TInputImage::ImageDimension);
79 
81  itkStaticConstMacro(ImageDimension, unsigned int, TInputImage::ImageDimension);
82 
84  // typedef typename itk::NumericTraits<InternalPixelType>::RealType RealType;
86  typedef itk::VariableLengthVector<RealType> RealPixelType;
87 
89  typedef typename itk::DataObject::Pointer DataObjectPointer;
90  typedef itk::ProcessObject::DataObjectPointerArraySizeType DataObjectPointerArraySizeType;
91 
93  typedef vnl_matrix<RealType> MatrixType;
94  typedef itk::SimpleDataObjectDecorator<MatrixType> MatrixObjectType;
95 
97  MatrixObjectType* GetMatrixOutput();
98  const MatrixObjectType* GetMatrixOutput() const;
100 
104  DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx) override;
105  using Superclass::MakeOutput;
106 
110  void AllocateOutputs() override;
111  void GenerateOutputInformation() override;
112  void Synthetize(void) override;
113  void Reset(void) override;
115 
116 protected:
119  {
120  }
121  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
122  void ThreadedGenerateData(const RegionType& outputRegionForThread, itk::ThreadIdType threadId) override;
123 
124 private:
125  PersistentVectorImageToMatrixFilter(const Self&) = delete;
126  void operator=(const Self&) = delete;
127 }; // end of class PersistentVectorImageToMatrixFilter
128 
151 template <class TInputImage>
152 class ITK_EXPORT VectorImageToMatrixImageFilter : public PersistentFilterStreamingDecorator<PersistentVectorImageToMatrixFilter<TInputImage>>
153 {
154 public:
158  typedef itk::SmartPointer<Self> Pointer;
159  typedef itk::SmartPointer<const Self> ConstPointer;
160 
162  itkNewMacro(Self);
163 
166 
167  typedef TInputImage InputImageType;
169 
172 
173  using Superclass::SetInput;
175  {
176  this->GetFilter()->SetInput(input);
177  }
179  {
180  return this->GetFilter()->GetInput();
181  }
182 
184  const MatrixType& GetMatrix() const
185  {
186  return this->GetMatrixOutput()->Get();
187  }
189  {
190  return this->GetFilter()->GetMatrixOutput();
191  }
193  {
194  return this->GetFilter()->GetMatrixOutput();
195  }
197 
198 protected:
201 
204  {
205  }
206 
207 private:
208  VectorImageToMatrixImageFilter(const Self&) = delete;
209  void operator=(const Self&) = delete;
210 };
211 
212 } // end namespace otb
213 
214 #ifndef OTB_MANUAL_INSTANTIATION
216 #endif
217 
218 #endif
otb::PersistentVectorImageToMatrixFilter::InputImagePointer
TInputImage::Pointer InputImagePointer
Definition: otbVectorImageToMatrixImageFilter.h:71
otb::PersistentVectorImageToMatrixFilter::RegionType
TInputImage::RegionType RegionType
Definition: otbVectorImageToMatrixImageFilter.h:72
otb::PersistentVectorImageToMatrixFilter::~PersistentVectorImageToMatrixFilter
~PersistentVectorImageToMatrixFilter() override
Definition: otbVectorImageToMatrixImageFilter.h:118
otb::VectorImageToMatrixImageFilter::MatrixObjectType
PersistentFilterType::MatrixObjectType MatrixObjectType
Definition: otbVectorImageToMatrixImageFilter.h:171
otb::PersistentVectorImageToMatrixFilter::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbVectorImageToMatrixImageFilter.h:60
otb::VectorImageToMatrixImageFilter::Superclass
PersistentFilterStreamingDecorator< PersistentVectorImageToMatrixFilter< TInputImage > > Superclass
Definition: otbVectorImageToMatrixImageFilter.h:157
otb::PersistentVectorImageToMatrixFilter::MatrixType
vnl_matrix< RealType > MatrixType
Definition: otbVectorImageToMatrixImageFilter.h:93
otbPersistentImageFilter.h
otb::PersistentVectorImageToMatrixFilter::PixelType
TInputImage::PixelType PixelType
Definition: otbVectorImageToMatrixImageFilter.h:75
otb::VectorImageToMatrixImageFilter::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbVectorImageToMatrixImageFilter.h:158
otb::PersistentImageFilter
This filter is the base class for all filter persisting data through multiple update....
Definition: otbPersistentImageFilter.h:47
otb::PersistentVectorImageToMatrixFilter::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbVectorImageToMatrixImageFilter.h:61
otb::VectorImageToMatrixImageFilter::Self
VectorImageToMatrixImageFilter Self
Definition: otbVectorImageToMatrixImageFilter.h:156
otb::PersistentVectorImageToMatrixFilter::Superclass
PersistentImageFilter< TInputImage, TInputImage > Superclass
Definition: otbVectorImageToMatrixImageFilter.h:59
otb::PersistentVectorImageToMatrixFilter::SizeType
TInputImage::SizeType SizeType
Definition: otbVectorImageToMatrixImageFilter.h:73
otbPersistentFilterStreamingDecorator.h
otb::VectorImageToMatrixImageFilter::GetMatrix
const MatrixType & GetMatrix() const
Definition: otbVectorImageToMatrixImageFilter.h:184
otb::PersistentVectorImageToMatrixFilter::DataObjectPointerArraySizeType
itk::ProcessObject::DataObjectPointerArraySizeType DataObjectPointerArraySizeType
Definition: otbVectorImageToMatrixImageFilter.h:90
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::PersistentVectorImageToMatrixFilter::DataObjectPointer
itk::DataObject::Pointer DataObjectPointer
Definition: otbVectorImageToMatrixImageFilter.h:89
otb::VectorImageToMatrixImageFilter::SetInput
void SetInput(InputImageType *input)
Definition: otbVectorImageToMatrixImageFilter.h:174
otb::PersistentVectorImageToMatrixFilter::RealPixelType
itk::VariableLengthVector< RealType > RealPixelType
Definition: otbVectorImageToMatrixImageFilter.h:86
otb::PersistentVectorImageToMatrixFilter::Self
PersistentVectorImageToMatrixFilter Self
Definition: otbVectorImageToMatrixImageFilter.h:58
otb::VectorImageToMatrixImageFilter::GetInput
const InputImageType * GetInput()
Definition: otbVectorImageToMatrixImageFilter.h:178
otb::VectorImageToMatrixImageFilter::InputImageType
TInputImage InputImageType
Definition: otbVectorImageToMatrixImageFilter.h:165
otb::VectorImageToMatrixImageFilter::GetMatrixOutput
MatrixObjectType * GetMatrixOutput()
Definition: otbVectorImageToMatrixImageFilter.h:188
otb::PersistentVectorImageToMatrixFilter::RealType
InternalPixelType RealType
Definition: otbVectorImageToMatrixImageFilter.h:85
otb::PersistentFilterStreamingDecorator
This filter link a persistent filter with a StreamingImageVirtualWriter.
Definition: otbPersistentFilterStreamingDecorator.h:47
otb::PersistentVectorImageToMatrixFilter::IndexType
TInputImage::IndexType IndexType
Definition: otbVectorImageToMatrixImageFilter.h:74
otb::VectorImageToMatrixImageFilter::PersistentFilterType
Superclass::FilterType PersistentFilterType
Definition: otbVectorImageToMatrixImageFilter.h:168
otb::PersistentVectorImageToMatrixFilter
Compute covariance & correlation of a large image using streaming.
Definition: otbVectorImageToMatrixImageFilter.h:54
otb::VectorImageToMatrixImageFilter::GetMatrixOutput
const MatrixObjectType * GetMatrixOutput() const
Definition: otbVectorImageToMatrixImageFilter.h:192
otbVectorImageToMatrixImageFilter.hxx
otb::PersistentVectorImageToMatrixFilter::MatrixObjectType
itk::SimpleDataObjectDecorator< MatrixType > MatrixObjectType
Definition: otbVectorImageToMatrixImageFilter.h:94
otb::VectorImageToMatrixImageFilter
This class streams the whole input image through the PersistentStatisticsImageFilter.
Definition: otbVectorImageToMatrixImageFilter.h:152
otb::VectorImageToMatrixImageFilter::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbVectorImageToMatrixImageFilter.h:159
otb::VectorImageToMatrixImageFilter::MatrixType
PersistentFilterType::MatrixType MatrixType
Definition: otbVectorImageToMatrixImageFilter.h:170
otb::PersistentVectorImageToMatrixFilter::InternalPixelType
TInputImage::InternalPixelType InternalPixelType
Definition: otbVectorImageToMatrixImageFilter.h:76
otb::VectorImageToMatrixImageFilter::~VectorImageToMatrixImageFilter
~VectorImageToMatrixImageFilter() override
Definition: otbVectorImageToMatrixImageFilter.h:203
otb::VectorImageToMatrixImageFilter::VectorImageToMatrixImageFilter
VectorImageToMatrixImageFilter()
Definition: otbVectorImageToMatrixImageFilter.h:200
otb::PersistentVectorImageToMatrixFilter::ImageType
TInputImage ImageType
Definition: otbVectorImageToMatrixImageFilter.h:67