OTB  9.0.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-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 otbStreamingStatisticsImageFilter_h
23 #define otbStreamingStatisticsImageFilter_h
24 
26 #include "itkNumericTraits.h"
27 #include "itkArray.h"
28 #include "itkSimpleDataObjectDecorator.h"
30 
31 namespace otb
32 {
33 
51 template <class TInputImage>
52 class ITK_EXPORT PersistentStatisticsImageFilter : public PersistentImageFilter<TInputImage, TInputImage>
53 {
54 public:
58  typedef itk::SmartPointer<Self> Pointer;
59  typedef itk::SmartPointer<const Self> ConstPointer;
60 
62  itkNewMacro(Self);
63 
66 
68  typedef TInputImage ImageType;
69  typedef typename TInputImage::Pointer InputImagePointer;
70 
71  typedef typename TInputImage::RegionType RegionType;
72  typedef typename TInputImage::SizeType SizeType;
73  typedef typename TInputImage::IndexType IndexType;
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::NumericTraits<PixelType>::RealType RealType;
83 
85  typedef typename itk::DataObject::Pointer DataObjectPointer;
86  typedef itk::ProcessObject::DataObjectPointerArraySizeType DataObjectPointerArraySizeType;
87 
89  typedef itk::SimpleDataObjectDecorator<RealType> RealObjectType;
90  typedef itk::SimpleDataObjectDecorator<PixelType> PixelObjectType;
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->GetMeanOutput()->Get();
114  }
115  RealObjectType* GetMeanOutput();
116  const RealObjectType* GetMeanOutput() const;
118 
121  {
122  return this->GetSigmaOutput()->Get();
123  }
124  RealObjectType* GetSigmaOutput();
125  const RealObjectType* GetSigmaOutput() const;
127 
130  {
131  return this->GetVarianceOutput()->Get();
132  }
133  RealObjectType* GetVarianceOutput();
134  const RealObjectType* GetVarianceOutput() const;
136 
138  RealType GetSum() const
139  {
140  return this->GetSumOutput()->Get();
141  }
142  RealObjectType* GetSumOutput();
143  const RealObjectType* GetSumOutput() const;
145 
148  DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx) override;
149  using Superclass::MakeOutput;
150 
154  void AllocateOutputs() override;
155  void GenerateOutputInformation() override;
156  void Synthetize(void) override;
157  void Reset(void) override;
159 
160  itkSetMacro(IgnoreInfiniteValues, bool);
161  itkGetMacro(IgnoreInfiniteValues, bool);
162 
163  itkSetMacro(IgnoreUserDefinedValue, bool);
164  itkGetMacro(IgnoreUserDefinedValue, bool);
165 
166  itkSetMacro(UserIgnoredValue, RealType);
167  itkGetMacro(UserIgnoredValue, RealType);
168 
169 protected:
172  {
173  }
174  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
175 
177  void ThreadedGenerateData(const RegionType& outputRegionForThread, itk::ThreadIdType threadId) override;
178 
179 private:
180  PersistentStatisticsImageFilter(const Self&) = delete;
181  void operator=(const Self&) = delete;
182 
183  itk::Array<RealType> m_ThreadSum;
184  itk::Array<RealType> m_SumOfSquares;
185  itk::Array<long> m_Count;
186  itk::Array<PixelType> m_ThreadMin;
187  itk::Array<PixelType> m_ThreadMax;
188 
189  /* Ignored values */
193  std::vector<unsigned int> m_IgnoredInfinitePixelCount;
194  std::vector<unsigned int> m_IgnoredUserPixelCount;
195 
196 
197 }; // end of class PersistentStatisticsImageFilter
198 
199 /*===========================================================================*/
200 
233 template <class TInputImage>
234 class ITK_EXPORT StreamingStatisticsImageFilter : public PersistentFilterStreamingDecorator<PersistentStatisticsImageFilter<TInputImage>>
235 {
236 public:
240  typedef itk::SmartPointer<Self> Pointer;
241  typedef itk::SmartPointer<const Self> ConstPointer;
242 
244  itkNewMacro(Self);
245 
248 
249  typedef typename Superclass::FilterType StatFilterType;
252  typedef TInputImage InputImageType;
253 
255  typedef itk::SimpleDataObjectDecorator<RealType> RealObjectType;
256  typedef itk::SimpleDataObjectDecorator<PixelType> PixelObjectType;
257 
258  using Superclass::SetInput;
260  {
261  this->GetFilter()->SetInput(input);
262  }
264  {
265  return this->GetFilter()->GetInput();
266  }
267 
270  {
271  return this->GetFilter()->GetMinimumOutput()->Get();
272  }
274  {
275  return this->GetFilter()->GetMinimumOutput();
276  }
278  {
279  return this->GetFilter()->GetMinimumOutput();
280  }
281 
284  {
285  return this->GetFilter()->GetMaximumOutput()->Get();
286  }
288  {
289  return this->GetFilter()->GetMaximumOutput();
290  }
292  {
293  return this->GetFilter()->GetMaximumOutput();
294  }
295 
298  {
299  return this->GetFilter()->GetMeanOutput()->Get();
300  }
302  {
303  return this->GetFilter()->GetMeanOutput();
304  }
306  {
307  return this->GetFilter()->GetMeanOutput();
308  }
310 
313  {
314  return this->GetSigmaOutput()->Get();
315  }
317  {
318  return this->GetFilter()->GetSigmaOutput();
319  }
321  {
322  return this->GetFilter()->GetSigmaOutput();
323  }
325 
328  {
329  return this->GetFilter()->GetVarianceOutput()->Get();
330  }
332  {
333  return this->GetFilter()->GetVarianceOutput();
334  }
336  {
337  return this->GetFilter()->GetVarianceOutput();
338  }
340 
342  RealType GetSum() const
343  {
344  return this->GetFilter()->GetSumOutput()->Get();
345  }
347  {
348  return this->GetFilter()->GetSumOutput();
349  }
351  {
352  return this->GetFilter()->GetSumOutput();
353  }
355 
356  otbSetObjectMemberMacro(Filter, IgnoreInfiniteValues, bool);
357  otbGetObjectMemberMacro(Filter, IgnoreInfiniteValues, bool);
358 
359  otbSetObjectMemberMacro(Filter, IgnoreUserDefinedValue, bool);
360  otbGetObjectMemberMacro(Filter, IgnoreUserDefinedValue, bool);
361 
362  otbSetObjectMemberMacro(Filter, UserIgnoredValue, RealType);
363  otbGetObjectMemberMacro(Filter, UserIgnoredValue, RealType);
364 
365 protected:
368 
371  {
372  }
373 
374 private:
375  StreamingStatisticsImageFilter(const Self&) = delete;
376  void operator=(const Self&) = delete;
377 };
378 
379 } // end namespace otb
380 
381 #ifndef OTB_MANUAL_INSTANTIATION
383 #endif
384 
385 #endif
otb::PersistentStatisticsImageFilter::m_ThreadMin
itk::Array< PixelType > m_ThreadMin
Definition: otbStreamingStatisticsImageFilter.h:186
otb::StreamingStatisticsImageFilter::PixelObjectType
itk::SimpleDataObjectDecorator< PixelType > PixelObjectType
Definition: otbStreamingStatisticsImageFilter.h:256
otb::PersistentStatisticsImageFilter::m_ThreadSum
itk::Array< RealType > m_ThreadSum
Definition: otbStreamingStatisticsImageFilter.h:183
otb::PersistentStatisticsImageFilter::IndexType
TInputImage::IndexType IndexType
Definition: otbStreamingStatisticsImageFilter.h:73
otbPersistentImageFilter.h
otb::StreamingStatisticsImageFilter::GetMinimumOutput
const PixelObjectType * GetMinimumOutput() const
Definition: otbStreamingStatisticsImageFilter.h:277
otb::StreamingStatisticsImageFilter::GetMean
RealType GetMean() const
Definition: otbStreamingStatisticsImageFilter.h:297
otb::PersistentStatisticsImageFilter::m_IgnoredUserPixelCount
std::vector< unsigned int > m_IgnoredUserPixelCount
Definition: otbStreamingStatisticsImageFilter.h:194
otb::PersistentStatisticsImageFilter::m_IgnoredInfinitePixelCount
std::vector< unsigned int > m_IgnoredInfinitePixelCount
Definition: otbStreamingStatisticsImageFilter.h:193
otb::PersistentStatisticsImageFilter::GetSigma
RealType GetSigma() const
Definition: otbStreamingStatisticsImageFilter.h:120
otb::PersistentImageFilter
This filter is the base class for all filter persisting data through multiple update....
Definition: otbPersistentImageFilter.h:47
otb::StreamingStatisticsImageFilter::GetMaximum
PixelType GetMaximum() const
Definition: otbStreamingStatisticsImageFilter.h:283
otb::PersistentStatisticsImageFilter::m_IgnoreUserDefinedValue
bool m_IgnoreUserDefinedValue
Definition: otbStreamingStatisticsImageFilter.h:191
otb::PersistentStatisticsImageFilter::m_Count
itk::Array< long > m_Count
Definition: otbStreamingStatisticsImageFilter.h:185
otb::StreamingStatisticsImageFilter::GetSumOutput
RealObjectType * GetSumOutput()
Definition: otbStreamingStatisticsImageFilter.h:346
otbPersistentFilterStreamingDecorator.h
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::PersistentStatisticsImageFilter::m_IgnoreInfiniteValues
bool m_IgnoreInfiniteValues
Definition: otbStreamingStatisticsImageFilter.h:190
otb::StreamingStatisticsImageFilter::StreamingStatisticsImageFilter
StreamingStatisticsImageFilter()
Definition: otbStreamingStatisticsImageFilter.h:367
otb::PersistentStatisticsImageFilter::DataObjectPointer
itk::DataObject::Pointer DataObjectPointer
Definition: otbStreamingStatisticsImageFilter.h:85
otb::PersistentStatisticsImageFilter::GetMean
RealType GetMean() const
Definition: otbStreamingStatisticsImageFilter.h:111
otb::PersistentStatisticsImageFilter::GetMaximum
PixelType GetMaximum() const
Definition: otbStreamingStatisticsImageFilter.h:102
otb::StreamingStatisticsImageFilter::GetMinimumOutput
PixelObjectType * GetMinimumOutput()
Definition: otbStreamingStatisticsImageFilter.h:273
otb::PersistentStatisticsImageFilter::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbStreamingStatisticsImageFilter.h:58
otb::PersistentStatisticsImageFilter::InputImagePointer
TInputImage::Pointer InputImagePointer
Definition: otbStreamingStatisticsImageFilter.h:69
otb::PersistentStatisticsImageFilter
Compute min. max, variance and mean of an image using the output requested region.
Definition: otbStreamingStatisticsImageFilter.h:52
otb::PersistentStatisticsImageFilter::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbStreamingStatisticsImageFilter.h:59
otb::StreamingStatisticsImageFilter::RealObjectType
itk::SimpleDataObjectDecorator< RealType > RealObjectType
Definition: otbStreamingStatisticsImageFilter.h:255
otb::PersistentStatisticsImageFilter::PixelType
TInputImage::PixelType PixelType
Definition: otbStreamingStatisticsImageFilter.h:74
otb::PersistentStatisticsImageFilter::PixelObjectType
itk::SimpleDataObjectDecorator< PixelType > PixelObjectType
Definition: otbStreamingStatisticsImageFilter.h:90
otb::StreamingStatisticsImageFilter::SetInput
void SetInput(InputImageType *input)
Definition: otbStreamingStatisticsImageFilter.h:259
otb::PersistentStatisticsImageFilter::GetSum
RealType GetSum() const
Definition: otbStreamingStatisticsImageFilter.h:138
otb::PersistentStatisticsImageFilter::m_ThreadMax
itk::Array< PixelType > m_ThreadMax
Definition: otbStreamingStatisticsImageFilter.h:187
otb::Wrapper::Tags::Filter
static const std::string Filter
Definition: otbWrapperTags.h:39
otb::PersistentStatisticsImageFilter::RealObjectType
itk::SimpleDataObjectDecorator< RealType > RealObjectType
Definition: otbStreamingStatisticsImageFilter.h:89
otb::PersistentStatisticsImageFilter::m_SumOfSquares
itk::Array< RealType > m_SumOfSquares
Definition: otbStreamingStatisticsImageFilter.h:184
otb::PersistentStatisticsImageFilter::SizeType
TInputImage::SizeType SizeType
Definition: otbStreamingStatisticsImageFilter.h:72
otb::StreamingStatisticsImageFilter::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbStreamingStatisticsImageFilter.h:240
otb::PersistentStatisticsImageFilter::~PersistentStatisticsImageFilter
~PersistentStatisticsImageFilter() override
Definition: otbStreamingStatisticsImageFilter.h:171
otb::StreamingStatisticsImageFilter::GetSigma
RealType GetSigma() const
Definition: otbStreamingStatisticsImageFilter.h:312
otb::PersistentStatisticsImageFilter::RealType
itk::NumericTraits< PixelType >::RealType RealType
Definition: otbStreamingStatisticsImageFilter.h:82
otb::StreamingStatisticsImageFilter::GetSumOutput
const RealObjectType * GetSumOutput() const
Definition: otbStreamingStatisticsImageFilter.h:350
otb::PersistentStatisticsImageFilter::RegionType
TInputImage::RegionType RegionType
Definition: otbStreamingStatisticsImageFilter.h:71
otb::StreamingStatisticsImageFilter::GetSum
RealType GetSum() const
Definition: otbStreamingStatisticsImageFilter.h:342
otb::PersistentFilterStreamingDecorator
This filter link a persistent filter with a StreamingImageVirtualWriter.
Definition: otbPersistentFilterStreamingDecorator.h:47
otb::StreamingStatisticsImageFilter
This class streams the whole input image through the PersistentStatisticsImageFilter.
Definition: otbStreamingStatisticsImageFilter.h:234
otb::StreamingStatisticsImageFilter::GetVarianceOutput
RealObjectType * GetVarianceOutput()
Definition: otbStreamingStatisticsImageFilter.h:331
otb::StreamingStatisticsImageFilter::InputImageType
TInputImage InputImageType
Definition: otbStreamingStatisticsImageFilter.h:252
otb::StreamingStatisticsImageFilter::GetSigmaOutput
RealObjectType * GetSigmaOutput()
Definition: otbStreamingStatisticsImageFilter.h:316
otb::StreamingStatisticsImageFilter::~StreamingStatisticsImageFilter
~StreamingStatisticsImageFilter() override
Definition: otbStreamingStatisticsImageFilter.h:370
otb::StreamingStatisticsImageFilter::GetMaximumOutput
PixelObjectType * GetMaximumOutput()
Definition: otbStreamingStatisticsImageFilter.h:287
otb::StreamingStatisticsImageFilter::GetMaximumOutput
const PixelObjectType * GetMaximumOutput() const
Definition: otbStreamingStatisticsImageFilter.h:291
otb::StreamingStatisticsImageFilter::GetMinimum
PixelType GetMinimum() const
Definition: otbStreamingStatisticsImageFilter.h:269
otb::StreamingStatisticsImageFilter::GetVariance
RealType GetVariance() const
Definition: otbStreamingStatisticsImageFilter.h:327
otb::StreamingStatisticsImageFilter::GetMeanOutput
RealObjectType * GetMeanOutput()
Definition: otbStreamingStatisticsImageFilter.h:301
otb::PersistentStatisticsImageFilter::Superclass
PersistentImageFilter< TInputImage, TInputImage > Superclass
Definition: otbStreamingStatisticsImageFilter.h:57
otb::StreamingStatisticsImageFilter::PixelType
StatFilterType::PixelType PixelType
Definition: otbStreamingStatisticsImageFilter.h:250
otb::PersistentStatisticsImageFilter::GetVariance
RealType GetVariance() const
Definition: otbStreamingStatisticsImageFilter.h:129
otb::PersistentStatisticsImageFilter::m_UserIgnoredValue
RealType m_UserIgnoredValue
Definition: otbStreamingStatisticsImageFilter.h:192
otb::PersistentStatisticsImageFilter::Self
PersistentStatisticsImageFilter Self
Definition: otbStreamingStatisticsImageFilter.h:56
otb::PersistentStatisticsImageFilter::GetMinimum
PixelType GetMinimum() const
Definition: otbStreamingStatisticsImageFilter.h:93
otb::StreamingStatisticsImageFilter::GetMeanOutput
const RealObjectType * GetMeanOutput() const
Definition: otbStreamingStatisticsImageFilter.h:305
otb::StreamingStatisticsImageFilter::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbStreamingStatisticsImageFilter.h:241
otbGetObjectMemberMacro
#define otbGetObjectMemberMacro(object, name, type)
Definition: otbMacro.h:89
otbSetObjectMemberMacro
#define otbSetObjectMemberMacro(object, name, type)
Definition: otbMacro.h:79
otb::StreamingStatisticsImageFilter::GetSigmaOutput
const RealObjectType * GetSigmaOutput() const
Definition: otbStreamingStatisticsImageFilter.h:320
otb::StreamingStatisticsImageFilter::GetInput
const InputImageType * GetInput()
Definition: otbStreamingStatisticsImageFilter.h:263
otb::StreamingStatisticsImageFilter::StatFilterType
Superclass::FilterType StatFilterType
Definition: otbStreamingStatisticsImageFilter.h:247
otb::StreamingStatisticsImageFilter::GetVarianceOutput
const RealObjectType * GetVarianceOutput() const
Definition: otbStreamingStatisticsImageFilter.h:335
otb::PersistentStatisticsImageFilter::ImageType
TInputImage ImageType
Definition: otbStreamingStatisticsImageFilter.h:65
otb::PersistentStatisticsImageFilter::DataObjectPointerArraySizeType
itk::ProcessObject::DataObjectPointerArraySizeType DataObjectPointerArraySizeType
Definition: otbStreamingStatisticsImageFilter.h:86
otbStreamingStatisticsImageFilter.hxx
otb::StreamingStatisticsImageFilter::Self
StreamingStatisticsImageFilter Self
Definition: otbStreamingStatisticsImageFilter.h:238
otb::StreamingStatisticsImageFilter::RealType
StatFilterType::RealType RealType
Definition: otbStreamingStatisticsImageFilter.h:251
otb::StreamingStatisticsImageFilter::Superclass
PersistentFilterStreamingDecorator< PersistentStatisticsImageFilter< TInputImage > > Superclass
Definition: otbStreamingStatisticsImageFilter.h:239