OTB  6.7.0
Orfeo Toolbox
otbStreamingMinMaxImageFilter.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 otbStreamingMinMaxImageFilter_h
23 #define otbStreamingMinMaxImageFilter_h
24 
25 #include <vector>
27 #include "itkNumericTraits.h"
30 
31 namespace otb
32 {
33 
51 template<class TInputImage>
52 class ITK_EXPORT PersistentMinMaxImageFilter :
53  public PersistentImageFilter<TInputImage, TInputImage>
54 {
55 public:
61 
63  itkNewMacro(Self);
64 
67 
69  typedef TInputImage ImageType;
70  typedef typename TInputImage::Pointer InputImagePointer;
71 
72  typedef typename TInputImage::RegionType RegionType;
73  typedef typename TInputImage::SizeType SizeType;
75  typedef typename TInputImage::PixelType PixelType;
76 
77  itkStaticConstMacro(InputImageDimension, unsigned int,
78  TInputImage::ImageDimension);
79 
81  itkStaticConstMacro(ImageDimension, unsigned int,
82  TInputImage::ImageDimension);
83 
87 
91 
94  {
95  return this->GetMinimumOutput()->Get();
96  }
97  PixelObjectType* GetMinimumOutput();
98  const PixelObjectType* GetMinimumOutput() const;
100 
103  {
104  return this->GetMaximumOutput()->Get();
105  }
106  PixelObjectType* GetMaximumOutput();
107  const PixelObjectType* GetMaximumOutput() const;
109 
112  {
113  return this->GetMinimumIndexOutput()->Get();
114  }
115  IndexObjectType* GetMinimumIndexOutput();
116  const IndexObjectType* GetMinimumIndexOutput() const;
118 
121  {
122  return this->GetMaximumIndexOutput()->Get();
123  }
124  IndexObjectType* GetMaximumIndexOutput();
125  const IndexObjectType* GetMaximumIndexOutput() const;
127 
128 
131  DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx) override;
132  using Superclass::MakeOutput;
133 
137  void AllocateOutputs() override;
138  void GenerateOutputInformation() override;
139  void Synthetize(void) override;
140  void Reset(void) override;
142 
143 protected:
146  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
147 
149  void ThreadedGenerateData(const RegionType&
150  outputRegionForThread,
151  itk::ThreadIdType threadId) override;
152 
153 private:
154  PersistentMinMaxImageFilter(const Self &) = delete;
155  void operator =(const Self&) = delete;
156 
157  std::vector<PixelType> m_ThreadMin;
158  std::vector<PixelType> m_ThreadMax;
159  std::vector<IndexType> m_ThreadMinIndex;
160  std::vector<IndexType> m_ThreadMaxIndex;
161 }; // end of class PersistentMinMaxImageFilter
162 
163 
196 template<class TInputImage>
197 class ITK_EXPORT StreamingMinMaxImageFilter :
198  public PersistentFilterStreamingDecorator<PersistentMinMaxImageFilter<TInputImage> >
199 {
200 public:
207 
209  itkNewMacro(Self);
210 
213 
214  typedef typename Superclass::FilterType StatFilterType;
215  typedef typename StatFilterType::PixelType PixelType;
217  typedef typename StatFilterType::PixelObjectType PixelObjectType;
218  typedef typename StatFilterType::IndexObjectType IndexObjectType;
219  typedef TInputImage InputImageType;
220 
221  using Superclass::SetInput;
222  void SetInput(InputImageType * input)
223  {
224  this->GetFilter()->SetInput(input);
225  }
227  {
228  return this->GetFilter()->GetInput();
229  }
230 
233  {
234  return this->GetFilter()->GetMinimumOutput()->Get();
235  }
237  {
238  return this->GetFilter()->GetMinimumOutput();
239  }
241  {
242  return this->GetFilter()->GetMinimumOutput();
243  }
244 
247  {
248  return this->GetFilter()->GetMaximumOutput()->Get();
249  }
251  {
252  return this->GetFilter()->GetMaximumOutput();
253  }
255  {
256  return this->GetFilter()->GetMaximumOutput();
257  }
259 
262  {
263  return this->GetFilter()->GetMinimumIndexOutput()->Get();
264  }
266  {
267  return this->GetFilter()->GetMinimumIndexOutput();
268  }
270  {
271  return this->GetFilter()->GetMinimumIndexOutput();
272  }
273 
276  {
277  return this->GetFilter()->GetMaximumIndexOutput()->Get();
278  }
280  {
281  return this->GetFilter()->GetMaximumIndexOutput();
282  }
284  {
285  return this->GetFilter()->GetMaximumIndexOutput();
286  }
287 protected:
288 
291 
294 
295 private:
296  StreamingMinMaxImageFilter(const Self &) = delete;
297  void operator =(const Self&) = delete;
298 };
299 
300 } // end namespace otb
301 
302 #ifndef OTB_MANUAL_INSTANTIATION
304 #endif
305 
306 #endif
itk::Size< Monteverdi_DIMENSION > SizeType
Definition: mvdTypes.h:137
StatFilterType::IndexObjectType IndexObjectType
itk::SimpleDataObjectDecorator< IndexType > IndexObjectType
itk::ProcessObject::DataObjectPointerArraySizeType DataObjectPointerArraySizeType
This class streams the whole input image through the PersistentMinMaxImageFilter. ...
const IndexObjectType * GetMinimumIndexOutput() const
const IndexObjectType * GetMaximumIndexOutput() const
itk::Index< Monteverdi_DIMENSION > IndexType
Definition: mvdTypes.h:133
const PixelObjectType * GetMinimumOutput() const
DataObjectPointerArray::size_type DataObjectPointerArraySizeType
itk::SmartPointer< const Self > ConstPointer
PersistentFilterStreamingDecorator< PersistentMinMaxImageFilter< TInputImage > > Superclass
unsigned int ThreadIdType
PersistentImageFilter< TInputImage, TInputImage > Superclass
itk::SimpleDataObjectDecorator< PixelType > PixelObjectType
Compute min. max of an image using the output requested region.
itk::SmartPointer< const Self > ConstPointer
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.
const PixelObjectType * GetMaximumOutput() const
This filter link a persistent filter with a StreamingImageVirtualWriter.
StatFilterType::PixelObjectType PixelObjectType