OTB  6.7.0
Orfeo Toolbox
otbStreamingStatisticsImageFilter.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 otbStreamingStatisticsImageFilter_h
23 #define otbStreamingStatisticsImageFilter_h
24 
26 #include "itkNumericTraits.h"
27 #include "itkArray.h"
30 
31 namespace otb
32 {
33 
51 template<class TInputImage>
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 
86 
90 
94 
97  {
98  return this->GetMinimumOutput()->Get();
99  }
100  PixelObjectType* GetMinimumOutput();
101  const PixelObjectType* GetMinimumOutput() const;
103 
106  {
107  return this->GetMaximumOutput()->Get();
108  }
109  PixelObjectType* GetMaximumOutput();
110  const PixelObjectType* GetMaximumOutput() const;
112 
115  {
116  return this->GetMeanOutput()->Get();
117  }
118  RealObjectType* GetMeanOutput();
119  const RealObjectType* GetMeanOutput() const;
121 
124  {
125  return this->GetSigmaOutput()->Get();
126  }
127  RealObjectType* GetSigmaOutput();
128  const RealObjectType* GetSigmaOutput() const;
130 
133  {
134  return this->GetVarianceOutput()->Get();
135  }
136  RealObjectType* GetVarianceOutput();
137  const RealObjectType* GetVarianceOutput() const;
139 
141  RealType GetSum() const
142  {
143  return this->GetSumOutput()->Get();
144  }
145  RealObjectType* GetSumOutput();
146  const RealObjectType* GetSumOutput() const;
148 
151  DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx) override;
152  using Superclass::MakeOutput;
153 
157  void AllocateOutputs() override;
158  void GenerateOutputInformation() override;
159  void Synthetize(void) override;
160  void Reset(void) override;
162 
163  itkSetMacro(IgnoreInfiniteValues, bool);
164  itkGetMacro(IgnoreInfiniteValues, bool);
165 
166  itkSetMacro(IgnoreUserDefinedValue, bool);
167  itkGetMacro(IgnoreUserDefinedValue, bool);
168 
169  itkSetMacro(UserIgnoredValue, RealType);
170  itkGetMacro(UserIgnoredValue, RealType);
171 
172 protected:
175  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
176 
178  void ThreadedGenerateData(const RegionType&
179  outputRegionForThread,
180  itk::ThreadIdType threadId) override;
181 
182 private:
183  PersistentStatisticsImageFilter(const Self &) = delete;
184  void operator =(const Self&) = delete;
185 
191 
192  /* Ignored values */
196  std::vector<unsigned int> m_IgnoredInfinitePixelCount;
197  std::vector<unsigned int> m_IgnoredUserPixelCount;
198 
199 
200 }; // end of class PersistentStatisticsImageFilter
201 
202 /*===========================================================================*/
203 
236 template<class TInputImage>
238  public PersistentFilterStreamingDecorator<PersistentStatisticsImageFilter<TInputImage> >
239 {
240 public:
247 
249  itkNewMacro(Self);
250 
253 
254  typedef typename Superclass::FilterType StatFilterType;
255  typedef typename StatFilterType::PixelType PixelType;
257  typedef TInputImage InputImageType;
258 
262 
263  using Superclass::SetInput;
264  void SetInput(InputImageType * input)
265  {
266  this->GetFilter()->SetInput(input);
267  }
269  {
270  return this->GetFilter()->GetInput();
271  }
272 
275  {
276  return this->GetFilter()->GetMinimumOutput()->Get();
277  }
279  {
280  return this->GetFilter()->GetMinimumOutput();
281  }
283  {
284  return this->GetFilter()->GetMinimumOutput();
285  }
286 
289  {
290  return this->GetFilter()->GetMaximumOutput()->Get();
291  }
293  {
294  return this->GetFilter()->GetMaximumOutput();
295  }
297  {
298  return this->GetFilter()->GetMaximumOutput();
299  }
300 
303  {
304  return this->GetFilter()->GetMeanOutput()->Get();
305  }
307  {
308  return this->GetFilter()->GetMeanOutput();
309  }
311  {
312  return this->GetFilter()->GetMeanOutput();
313  }
315 
318  {
319  return this->GetSigmaOutput()->Get();
320  }
322  {
323  return this->GetFilter()->GetSigmaOutput();
324  }
326  {
327  return this->GetFilter()->GetSigmaOutput();
328  }
330 
333  {
334  return this->GetFilter()->GetVarianceOutput()->Get();
335  }
337  {
338  return this->GetFilter()->GetVarianceOutput();
339  }
341  {
342  return this->GetFilter()->GetVarianceOutput();
343  }
345 
347  RealType GetSum() const
348  {
349  return this->GetFilter()->GetSumOutput()->Get();
350  }
352  {
353  return this->GetFilter()->GetSumOutput();
354  }
356  {
357  return this->GetFilter()->GetSumOutput();
358  }
360 
361  otbSetObjectMemberMacro(Filter, IgnoreInfiniteValues, bool);
362  otbGetObjectMemberMacro(Filter, IgnoreInfiniteValues, bool);
363 
364  otbSetObjectMemberMacro(Filter, IgnoreUserDefinedValue, bool);
365  otbGetObjectMemberMacro(Filter, IgnoreUserDefinedValue, bool);
366 
367  otbSetObjectMemberMacro(Filter, UserIgnoredValue, RealType);
368  otbGetObjectMemberMacro(Filter, UserIgnoredValue, RealType);
369 
370 protected:
373 
376 
377 private:
378  StreamingStatisticsImageFilter(const Self &) = delete;
379  void operator =(const Self&) = delete;
380 };
381 
382 } // end namespace otb
383 
384 #ifndef OTB_MANUAL_INSTANTIATION
386 #endif
387 
388 #endif
itk::Size< Monteverdi_DIMENSION > SizeType
Definition: mvdTypes.h:137
Compute min. max, variance and mean of an image using the output requested region.
itk::SimpleDataObjectDecorator< RealType > RealObjectType
#define otbGetObjectMemberMacro(object, name, type)
Definition: otbMacro.h:90
itk::SimpleDataObjectDecorator< RealType > RealObjectType
itk::ProcessObject::DataObjectPointerArraySizeType DataObjectPointerArraySizeType
static const std::string Filter
PersistentImageFilter< TInputImage, TInputImage > Superclass
itk::SimpleDataObjectDecorator< PixelType > PixelObjectType
itk::Index< Monteverdi_DIMENSION > IndexType
Definition: mvdTypes.h:133
DataObjectPointerArray::size_type DataObjectPointerArraySizeType
This class streams the whole input image through the PersistentStatisticsImageFilter.
Monteverdi_FLOATING_TYPE RealType
Definition: mvdTypes.h:84
itk::SimpleDataObjectDecorator< PixelType > PixelObjectType
unsigned int ThreadIdType
#define otbSetObjectMemberMacro(object, name, type)
Definition: otbMacro.h:80
PersistentFilterStreamingDecorator< PersistentStatisticsImageFilter< TInputImage > > Superclass
itk::NumericTraits< PixelType >::RealType RealType
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.