OTB  6.1.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-2017 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 
28 #include "itkImageRegionSplitter.h"
29 #include "itkVariableSizeMatrix.h"
31 #include "vnl/vnl_matrix.h"
32 
33 namespace otb
34 {
35 
54 template<class TInputImage>
56  public PersistentImageFilter<TInputImage, TInputImage>
57 {
58 public:
64 
66  itkNewMacro(Self);
67 
70 
72  typedef TInputImage ImageType;
73  typedef typename TInputImage::Pointer InputImagePointer;
74  typedef typename TInputImage::RegionType RegionType;
75  typedef typename TInputImage::PixelType PixelType;
76 
77  itkStaticConstMacro(InputImageDimension, unsigned int, TInputImage::ImageDimension);
78 
80  itkStaticConstMacro(ImageDimension, unsigned int, TInputImage::ImageDimension);
81 
85 
87  typedef vnl_matrix<double> MatrixType;
88  typedef typename std::vector<MatrixType> ArrayMatrixType;
89 
92 
96  {
97  return this->GetInnerProductOutput()->Get();
98  }
99  MatrixObjectType* GetInnerProductOutput();
100  const MatrixObjectType* GetInnerProductOutput() const;
101 
105  DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx) ITK_OVERRIDE;
106  using Superclass::MakeOutput;
107 
111  void AllocateOutputs() ITK_OVERRIDE;
112  void GenerateOutputInformation() ITK_OVERRIDE;
113  void Synthetize(void) ITK_OVERRIDE;
114  void Reset(void) ITK_OVERRIDE;
116 
118  itkSetMacro(CenterData, bool);
119  itkGetMacro(CenterData, bool);
120  itkBooleanMacro(CenterData);
122 
123 protected:
125  ~PersistentInnerProductVectorImageFilter() ITK_OVERRIDE {}
126  void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE;
128  void ThreadedGenerateData(const RegionType& outputRegionForThread, itk::ThreadIdType threadId) ITK_OVERRIDE;
129 
130 private:
131  PersistentInnerProductVectorImageFilter(const Self &); //purposely not implemented
132  void operator =(const Self&); //purposely not implemented
133 
135 
138 
139 }; // end of class PersistentStatisticsVectorImageFilter
140 
163 template<class TInputImage>
165  public PersistentFilterStreamingDecorator<PersistentInnerProductVectorImageFilter<TInputImage> >
166 {
167 public:
174 
176  itkNewMacro(Self);
177 
180 
181  typedef TInputImage InputImageType;
183  typedef typename StatFilterType::MatrixType MatrixType;
184 
186  typedef typename StatFilterType::MatrixObjectType MatrixObjectType;
187 
188  using Superclass::SetInput;
189  void SetInput(TInputImage * input)
190  {
191  this->GetFilter()->SetInput(input);
192  }
193  TInputImage * GetInput()
194  {
195  return this->GetFilter()->GetInput();
196  }
197 
200  {
201  return this->GetFilter()->GetInnerProductOutput()->Get();
202  }
204  {
205  return this->GetFilter()->GetInnerProductOutput();
206  }
208  {
209  return this->GetFilter()->GetInnerProductOutput();
210  }
212 
214  void SetCenterData(bool centerdata)
215  {
216  this->GetFilter()->SetCenterData(centerdata);
217  }
218 
219 protected:
222 
225 
226 private:
227  StreamingInnerProductVectorImageFilter(const Self &); //purposely not implemented
228  void operator =(const Self&); //purposely not implemented
229 
230 };
231 
232 } // end namespace otb
233 
234 #ifndef OTB_MANUAL_INSTANTIATION
236 #endif
237 
238 #endif
PersistentFilterStreamingDecorator< PersistentInnerProductVectorImageFilter< TInputImage > > Superclass
This class streams the whole input image through the PersistentStatisticsImageFilter.
itk::ProcessObject::DataObjectPointerArraySizeType DataObjectPointerArraySizeType
Compute the inner product of a large image using streaming.
itk::SimpleDataObjectDecorator< MatrixType > MatrixObjectType
DataObjectPointerArray::size_type DataObjectPointerArraySizeType
unsigned int ThreadIdType
PersistentImageFilter< TInputImage, 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.
This filter link a persistent filter with a StreamingImageVirtualWriter.