OTB  6.7.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-2019 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 
28 #include "itkImageRegionSplitter.h"
29 #include "itkVariableSizeMatrix.h"
31 
32 namespace otb
33 {
34 
53 template<class TInputImage>
55  public PersistentImageFilter<TInputImage, TInputImage>
56 {
57 public:
63 
65  itkNewMacro(Self);
66 
69 
71  typedef TInputImage ImageType;
72  typedef typename TInputImage::Pointer InputImagePointer;
73  typedef typename TInputImage::RegionType RegionType;
74  typedef typename TInputImage::SizeType SizeType;
76  typedef typename TInputImage::PixelType PixelType;
77  typedef typename TInputImage::InternalPixelType InternalPixelType;
78 
79  itkStaticConstMacro(InputImageDimension, unsigned int, TInputImage::ImageDimension);
80 
82  itkStaticConstMacro(ImageDimension, unsigned int, TInputImage::ImageDimension);
83 
85  //typedef typename itk::NumericTraits<InternalPixelType>::RealType RealType;
88 
92 
94  typedef vnl_matrix<RealType> MatrixType;
96 
98  MatrixObjectType* GetMatrixOutput();
99  const MatrixObjectType* GetMatrixOutput() const;
101 
105  DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx) override;
106  using Superclass::MakeOutput;
107 
111  void AllocateOutputs() override;
112  void GenerateOutputInformation() override;
113  void Synthetize(void) override;
114  void Reset(void) override;
116 
117 protected:
120  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
121  void ThreadedGenerateData(const RegionType& outputRegionForThread, itk::ThreadIdType threadId) override;
122 
123 private:
124  PersistentVectorImageToMatrixFilter(const Self &) = delete;
125  void operator =(const Self&) = delete;
126 }; // end of class PersistentVectorImageToMatrixFilter
127 
150 template<class TInputImage>
152  public PersistentFilterStreamingDecorator<PersistentVectorImageToMatrixFilter<TInputImage> >
153 {
154 public:
161 
163  itkNewMacro(Self);
164 
167 
168  typedef TInputImage InputImageType;
169  typedef typename Superclass::FilterType PersistentFilterType;
170 
171  typedef typename PersistentFilterType::MatrixType MatrixType;
172  typedef typename PersistentFilterType::MatrixObjectType MatrixObjectType;
173 
174  using Superclass::SetInput;
175  void SetInput(InputImageType * input)
176  {
177  this->GetFilter()->SetInput(input);
178  }
180  {
181  return this->GetFilter()->GetInput();
182  }
183 
185  const MatrixType& GetMatrix() const
186  {
187  return this->GetMatrixOutput()->Get();
188  }
190  {
191  return this->GetFilter()->GetMatrixOutput();
192  }
194  {
195  return this->GetFilter()->GetMatrixOutput();
196  }
198 
199 protected:
202 
205 
206 private:
207  VectorImageToMatrixImageFilter(const Self &) = delete;
208  void operator =(const Self&) = delete;
209 };
210 
211 } // end namespace otb
212 
213 #ifndef OTB_MANUAL_INSTANTIATION
215 #endif
216 
217 #endif
itk::Size< Monteverdi_DIMENSION > SizeType
Definition: mvdTypes.h:137
Superclass::DataObjectPointerArraySizeType DataObjectPointerArraySizeType
itk::SimpleDataObjectDecorator< MatrixType > MatrixObjectType
itk::ProcessObject::DataObjectPointerArraySizeType DataObjectPointerArraySizeType
Compute covariance & correlation of a large image using streaming.
This class streams the whole input image through the PersistentStatisticsImageFilter.
itk::Index< Monteverdi_DIMENSION > IndexType
Definition: mvdTypes.h:133
PersistentFilterType::MatrixObjectType MatrixObjectType
DataObjectPointerArray::size_type DataObjectPointerArraySizeType
const MatrixObjectType * GetMatrixOutput() const
unsigned int ThreadIdType
PersistentImageFilter< TInputImage, TInputImage > Superclass
PersistentFilterStreamingDecorator< PersistentVectorImageToMatrixFilter< TInputImage > > Superclass
This filter is the base class for all filter persisting data through multiple update. For instance, a filter computing global statistics on an image with streaming capabilities will have to keep the temporary results for each streamed piece of the image in order to synthesize the global statistics at the end. This filter is an itk::ImageToImageFilter, providing two additional methods. The first one, Synthetize(), allows the user to synthesize temporary data produced by the multiple updates on different pieces of the image to the global result. The second one, Reset(), allows the user to reset the temporary data for a new input image for instance.
itk::VariableLengthVector< RealType > RealPixelType
This filter link a persistent filter with a StreamingImageVirtualWriter.