OTB  9.0.0
Orfeo Toolbox
otbStreamingInnerProductVectorImageFilter.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 otbStreamingInnerProductVectorImageFilter_h
23 #define otbStreamingInnerProductVectorImageFilter_h
24 
27 #include "itkSimpleDataObjectDecorator.h"
28 #include "itkImageRegionSplitter.h"
29 #include "itkVariableSizeMatrix.h"
30 #include "itkVariableLengthVector.h"
31 #include "vnl/vnl_matrix.h"
32 
33 namespace otb
34 {
35 
54 template <class TInputImage>
55 class ITK_EXPORT PersistentInnerProductVectorImageFilter : public PersistentImageFilter<TInputImage, TInputImage>
56 {
57 public:
61  typedef itk::SmartPointer<Self> Pointer;
62  typedef itk::SmartPointer<const Self> ConstPointer;
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::PixelType PixelType;
75 
76  itkStaticConstMacro(InputImageDimension, unsigned int, TInputImage::ImageDimension);
77 
79  itkStaticConstMacro(ImageDimension, unsigned int, TInputImage::ImageDimension);
80 
82  typedef typename itk::DataObject::Pointer DataObjectPointer;
83  typedef itk::ProcessObject::DataObjectPointerArraySizeType DataObjectPointerArraySizeType;
84 
86  typedef vnl_matrix<double> MatrixType;
87  typedef typename std::vector<MatrixType> ArrayMatrixType;
88 
90  typedef itk::SimpleDataObjectDecorator<MatrixType> MatrixObjectType;
91 
95  {
96  return this->GetInnerProductOutput()->Get();
97  }
98  MatrixObjectType* GetInnerProductOutput();
99  const MatrixObjectType* GetInnerProductOutput() 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 
117  itkSetMacro(CenterData, bool);
118  itkGetMacro(CenterData, bool);
119  itkBooleanMacro(CenterData);
121 
122 protected:
125  {
126  }
127  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
129  void ThreadedGenerateData(const RegionType& outputRegionForThread, itk::ThreadIdType threadId) override;
130 
131 private:
132  PersistentInnerProductVectorImageFilter(const Self&) = delete;
133  void operator=(const Self&) = delete;
134 
136 
139 
140 }; // end of class PersistentStatisticsVectorImageFilter
141 
164 template <class TInputImage>
165 class ITK_EXPORT StreamingInnerProductVectorImageFilter : public PersistentFilterStreamingDecorator<PersistentInnerProductVectorImageFilter<TInputImage>>
166 {
167 public:
171  typedef itk::SmartPointer<Self> Pointer;
172  typedef itk::SmartPointer<const Self> ConstPointer;
173 
175  itkNewMacro(Self);
176 
179 
180  typedef TInputImage InputImageType;
182  typedef typename StatFilterType::MatrixType MatrixType;
183 
186 
187  using Superclass::SetInput;
188  void SetInput(TInputImage* input)
189  {
190  this->GetFilter()->SetInput(input);
191  }
192  TInputImage* GetInput()
193  {
194  return this->GetFilter()->GetInput();
195  }
196 
199  {
200  return this->GetFilter()->GetInnerProductOutput()->Get();
201  }
203  {
204  return this->GetFilter()->GetInnerProductOutput();
205  }
207  {
208  return this->GetFilter()->GetInnerProductOutput();
209  }
211 
213  void SetCenterData(bool centerdata)
214  {
215  this->GetFilter()->SetCenterData(centerdata);
216  }
217 
218 protected:
221 
224  {
225  }
226 
227 private:
228  StreamingInnerProductVectorImageFilter(const Self&) = delete;
229  void operator=(const Self&) = delete;
230 };
231 
232 } // end namespace otb
233 
234 #ifndef OTB_MANUAL_INSTANTIATION
236 #endif
237 
238 #endif
otb::PersistentInnerProductVectorImageFilter::RegionType
TInputImage::RegionType RegionType
Definition: otbStreamingInnerProductVectorImageFilter.h:73
otb::PersistentInnerProductVectorImageFilter::ArrayMatrixType
std::vector< MatrixType > ArrayMatrixType
Definition: otbStreamingInnerProductVectorImageFilter.h:87
otb::PersistentInnerProductVectorImageFilter::~PersistentInnerProductVectorImageFilter
~PersistentInnerProductVectorImageFilter() override
Definition: otbStreamingInnerProductVectorImageFilter.h:124
otbPersistentImageFilter.h
otb::StreamingInnerProductVectorImageFilter::MatrixType
StatFilterType::MatrixType MatrixType
Definition: otbStreamingInnerProductVectorImageFilter.h:182
otb::PersistentImageFilter
This filter is the base class for all filter persisting data through multiple update....
Definition: otbPersistentImageFilter.h:47
otb::PersistentInnerProductVectorImageFilter::m_ThreadInnerProduct
ArrayMatrixType m_ThreadInnerProduct
Definition: otbStreamingInnerProductVectorImageFilter.h:135
otb::StreamingInnerProductVectorImageFilter::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbStreamingInnerProductVectorImageFilter.h:172
otbPersistentFilterStreamingDecorator.h
otb::PersistentInnerProductVectorImageFilter
Compute the inner product of a large image using streaming.
Definition: otbStreamingInnerProductVectorImageFilter.h:55
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::PersistentInnerProductVectorImageFilter::DataObjectPointer
itk::DataObject::Pointer DataObjectPointer
Definition: otbStreamingInnerProductVectorImageFilter.h:82
otb::PersistentInnerProductVectorImageFilter::Superclass
PersistentImageFilter< TInputImage, TInputImage > Superclass
Definition: otbStreamingInnerProductVectorImageFilter.h:60
otb::StreamingInnerProductVectorImageFilter::GetInnerProductOutput
const MatrixObjectType * GetInnerProductOutput() const
Definition: otbStreamingInnerProductVectorImageFilter.h:206
otb::PersistentInnerProductVectorImageFilter::Self
PersistentInnerProductVectorImageFilter Self
Definition: otbStreamingInnerProductVectorImageFilter.h:59
otb::PersistentInnerProductVectorImageFilter::GetInnerProduct
MatrixType GetInnerProduct() const
Definition: otbStreamingInnerProductVectorImageFilter.h:94
otb::StreamingInnerProductVectorImageFilter::InputImageType
TInputImage InputImageType
Definition: otbStreamingInnerProductVectorImageFilter.h:178
otb::StreamingInnerProductVectorImageFilter::GetInnerProduct
MatrixType GetInnerProduct() const
Definition: otbStreamingInnerProductVectorImageFilter.h:198
otb::PersistentInnerProductVectorImageFilter::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbStreamingInnerProductVectorImageFilter.h:62
otb::StreamingInnerProductVectorImageFilter::Self
StreamingInnerProductVectorImageFilter Self
Definition: otbStreamingInnerProductVectorImageFilter.h:169
otb::StreamingInnerProductVectorImageFilter::SetInput
void SetInput(TInputImage *input)
Definition: otbStreamingInnerProductVectorImageFilter.h:188
otbStreamingInnerProductVectorImageFilter.hxx
otb::PersistentFilterStreamingDecorator
This filter link a persistent filter with a StreamingImageVirtualWriter.
Definition: otbPersistentFilterStreamingDecorator.h:47
otb::StreamingInnerProductVectorImageFilter::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbStreamingInnerProductVectorImageFilter.h:171
otb::PersistentInnerProductVectorImageFilter::MatrixType
vnl_matrix< double > MatrixType
Definition: otbStreamingInnerProductVectorImageFilter.h:86
otb::PersistentInnerProductVectorImageFilter::MatrixObjectType
itk::SimpleDataObjectDecorator< MatrixType > MatrixObjectType
Definition: otbStreamingInnerProductVectorImageFilter.h:90
otb::StreamingInnerProductVectorImageFilter::SetCenterData
void SetCenterData(bool centerdata)
Definition: otbStreamingInnerProductVectorImageFilter.h:213
otb::StreamingInnerProductVectorImageFilter::GetInput
TInputImage * GetInput()
Definition: otbStreamingInnerProductVectorImageFilter.h:192
otb::StreamingInnerProductVectorImageFilter::StatFilterType
Superclass::FilterType StatFilterType
Definition: otbStreamingInnerProductVectorImageFilter.h:181
otb::StreamingInnerProductVectorImageFilter
This class streams the whole input image through the PersistentStatisticsImageFilter.
Definition: otbStreamingInnerProductVectorImageFilter.h:165
otb::StreamingInnerProductVectorImageFilter::Superclass
PersistentFilterStreamingDecorator< PersistentInnerProductVectorImageFilter< TInputImage > > Superclass
Definition: otbStreamingInnerProductVectorImageFilter.h:170
otb::PersistentInnerProductVectorImageFilter::m_CenterData
bool m_CenterData
Definition: otbStreamingInnerProductVectorImageFilter.h:138
otb::PersistentInnerProductVectorImageFilter::ImageType
TInputImage ImageType
Definition: otbStreamingInnerProductVectorImageFilter.h:68
otb::StreamingInnerProductVectorImageFilter::~StreamingInnerProductVectorImageFilter
~StreamingInnerProductVectorImageFilter() override
Definition: otbStreamingInnerProductVectorImageFilter.h:223
otb::StreamingInnerProductVectorImageFilter::MatrixObjectType
StatFilterType::MatrixObjectType MatrixObjectType
Definition: otbStreamingInnerProductVectorImageFilter.h:185
otb::PersistentInnerProductVectorImageFilter::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbStreamingInnerProductVectorImageFilter.h:61
otb::PersistentInnerProductVectorImageFilter::DataObjectPointerArraySizeType
itk::ProcessObject::DataObjectPointerArraySizeType DataObjectPointerArraySizeType
Definition: otbStreamingInnerProductVectorImageFilter.h:83
otb::StreamingInnerProductVectorImageFilter::StreamingInnerProductVectorImageFilter
StreamingInnerProductVectorImageFilter()
Definition: otbStreamingInnerProductVectorImageFilter.h:220
otb::StreamingInnerProductVectorImageFilter::GetInnerProductOutput
MatrixObjectType * GetInnerProductOutput()
Definition: otbStreamingInnerProductVectorImageFilter.h:202
otb::PersistentInnerProductVectorImageFilter::InputImagePointer
TInputImage::Pointer InputImagePointer
Definition: otbStreamingInnerProductVectorImageFilter.h:72
otb::PersistentInnerProductVectorImageFilter::PixelType
TInputImage::PixelType PixelType
Definition: otbStreamingInnerProductVectorImageFilter.h:74