OTB  9.0.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-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 otbStreamingMinMaxImageFilter_h
23 #define otbStreamingMinMaxImageFilter_h
24 
25 #include <vector>
27 #include "itkNumericTraits.h"
28 #include "itkSimpleDataObjectDecorator.h"
30 
31 namespace otb
32 {
33 
51 template <class TInputImage>
52 class ITK_EXPORT PersistentMinMaxImageFilter : 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::DataObject::Pointer DataObjectPointer;
83  typedef itk::ProcessObject::DataObjectPointerArraySizeType DataObjectPointerArraySizeType;
84 
86  typedef itk::SimpleDataObjectDecorator<PixelType> PixelObjectType;
87  typedef itk::SimpleDataObjectDecorator<IndexType> IndexObjectType;
88 
91  {
92  return this->GetMinimumOutput()->Get();
93  }
94  PixelObjectType* GetMinimumOutput();
95  const PixelObjectType* GetMinimumOutput() const;
97 
100  {
101  return this->GetMaximumOutput()->Get();
102  }
103  PixelObjectType* GetMaximumOutput();
104  const PixelObjectType* GetMaximumOutput() const;
106 
109  {
110  return this->GetMinimumIndexOutput()->Get();
111  }
112  IndexObjectType* GetMinimumIndexOutput();
113  const IndexObjectType* GetMinimumIndexOutput() const;
115 
118  {
119  return this->GetMaximumIndexOutput()->Get();
120  }
121  IndexObjectType* GetMaximumIndexOutput();
122  const IndexObjectType* GetMaximumIndexOutput() const;
124 
125 
128  DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx) override;
129  using Superclass::MakeOutput;
130 
134  void AllocateOutputs() override;
135  void GenerateOutputInformation() override;
136  void Synthetize(void) override;
137  void Reset(void) override;
139 
140 protected:
143  {
144  }
145  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
146 
148  void ThreadedGenerateData(const RegionType& outputRegionForThread, itk::ThreadIdType threadId) override;
149 
150 private:
151  PersistentMinMaxImageFilter(const Self&) = delete;
152  void operator=(const Self&) = delete;
153 
154  std::vector<PixelType> m_ThreadMin;
155  std::vector<PixelType> m_ThreadMax;
156  std::vector<IndexType> m_ThreadMinIndex;
157  std::vector<IndexType> m_ThreadMaxIndex;
158 }; // end of class PersistentMinMaxImageFilter
159 
160 
193 template <class TInputImage>
194 class ITK_EXPORT StreamingMinMaxImageFilter : public PersistentFilterStreamingDecorator<PersistentMinMaxImageFilter<TInputImage>>
195 {
196 public:
200  typedef itk::SmartPointer<Self> Pointer;
201  typedef itk::SmartPointer<const Self> ConstPointer;
202 
204  itkNewMacro(Self);
205 
208 
209  typedef typename Superclass::FilterType StatFilterType;
214  typedef TInputImage InputImageType;
215 
216  using Superclass::SetInput;
218  {
219  this->GetFilter()->SetInput(input);
220  }
222  {
223  return this->GetFilter()->GetInput();
224  }
225 
228  {
229  return this->GetFilter()->GetMinimumOutput()->Get();
230  }
232  {
233  return this->GetFilter()->GetMinimumOutput();
234  }
236  {
237  return this->GetFilter()->GetMinimumOutput();
238  }
239 
242  {
243  return this->GetFilter()->GetMaximumOutput()->Get();
244  }
246  {
247  return this->GetFilter()->GetMaximumOutput();
248  }
250  {
251  return this->GetFilter()->GetMaximumOutput();
252  }
254 
257  {
258  return this->GetFilter()->GetMinimumIndexOutput()->Get();
259  }
261  {
262  return this->GetFilter()->GetMinimumIndexOutput();
263  }
265  {
266  return this->GetFilter()->GetMinimumIndexOutput();
267  }
268 
271  {
272  return this->GetFilter()->GetMaximumIndexOutput()->Get();
273  }
275  {
276  return this->GetFilter()->GetMaximumIndexOutput();
277  }
279  {
280  return this->GetFilter()->GetMaximumIndexOutput();
281  }
283 
284 protected:
287  {
288  }
289 
292  {
293  }
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
otb::StreamingMinMaxImageFilter::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbStreamingMinMaxImageFilter.h:200
otb::StreamingMinMaxImageFilter::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbStreamingMinMaxImageFilter.h:201
otb::PersistentMinMaxImageFilter::Self
PersistentMinMaxImageFilter Self
Definition: otbStreamingMinMaxImageFilter.h:56
otb::StreamingMinMaxImageFilter::SetInput
void SetInput(InputImageType *input)
Definition: otbStreamingMinMaxImageFilter.h:217
otb::PersistentMinMaxImageFilter::PixelType
TInputImage::PixelType PixelType
Definition: otbStreamingMinMaxImageFilter.h:74
otb::PersistentMinMaxImageFilter::PixelObjectType
itk::SimpleDataObjectDecorator< PixelType > PixelObjectType
Definition: otbStreamingMinMaxImageFilter.h:86
otb::PersistentMinMaxImageFilter::~PersistentMinMaxImageFilter
~PersistentMinMaxImageFilter() override
Definition: otbStreamingMinMaxImageFilter.h:142
otb::PersistentMinMaxImageFilter::IndexObjectType
itk::SimpleDataObjectDecorator< IndexType > IndexObjectType
Definition: otbStreamingMinMaxImageFilter.h:87
otb::StreamingMinMaxImageFilter::GetMaximumOutput
const PixelObjectType * GetMaximumOutput() const
Definition: otbStreamingMinMaxImageFilter.h:249
otbPersistentImageFilter.h
otb::StreamingMinMaxImageFilter::PixelType
StatFilterType::PixelType PixelType
Definition: otbStreamingMinMaxImageFilter.h:210
otb::StreamingMinMaxImageFilter::GetMinimumIndexOutput
const IndexObjectType * GetMinimumIndexOutput() const
Definition: otbStreamingMinMaxImageFilter.h:264
otb::PersistentImageFilter
This filter is the base class for all filter persisting data through multiple update....
Definition: otbPersistentImageFilter.h:47
otb::PersistentMinMaxImageFilter::SizeType
TInputImage::SizeType SizeType
Definition: otbStreamingMinMaxImageFilter.h:72
otb::StreamingMinMaxImageFilter::GetMaximumIndex
IndexType GetMaximumIndex() const
Definition: otbStreamingMinMaxImageFilter.h:270
otbPersistentFilterStreamingDecorator.h
otb::StreamingMinMaxImageFilter::GetMinimumOutput
PixelObjectType * GetMinimumOutput()
Definition: otbStreamingMinMaxImageFilter.h:231
otbStreamingMinMaxImageFilter.hxx
otb::StreamingMinMaxImageFilter::StreamingMinMaxImageFilter
StreamingMinMaxImageFilter()
Definition: otbStreamingMinMaxImageFilter.h:286
otb::PersistentMinMaxImageFilter::m_ThreadMin
std::vector< PixelType > m_ThreadMin
Definition: otbStreamingMinMaxImageFilter.h:154
otb::PersistentMinMaxImageFilter::m_ThreadMax
std::vector< PixelType > m_ThreadMax
Definition: otbStreamingMinMaxImageFilter.h:155
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::StreamingMinMaxImageFilter::GetMaximum
PixelType GetMaximum() const
Definition: otbStreamingMinMaxImageFilter.h:241
otb::StreamingMinMaxImageFilter::GetMinimum
PixelType GetMinimum() const
Definition: otbStreamingMinMaxImageFilter.h:227
otb::StreamingMinMaxImageFilter::Superclass
PersistentFilterStreamingDecorator< PersistentMinMaxImageFilter< TInputImage > > Superclass
Definition: otbStreamingMinMaxImageFilter.h:199
otb::StreamingMinMaxImageFilter::InputImageType
TInputImage InputImageType
Definition: otbStreamingMinMaxImageFilter.h:214
otb::PersistentMinMaxImageFilter::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbStreamingMinMaxImageFilter.h:58
otb::StreamingMinMaxImageFilter::GetMaximumIndexOutput
const IndexObjectType * GetMaximumIndexOutput() const
Definition: otbStreamingMinMaxImageFilter.h:278
otb::StreamingMinMaxImageFilter::IndexObjectType
StatFilterType::IndexObjectType IndexObjectType
Definition: otbStreamingMinMaxImageFilter.h:213
otb::PersistentMinMaxImageFilter::m_ThreadMaxIndex
std::vector< IndexType > m_ThreadMaxIndex
Definition: otbStreamingMinMaxImageFilter.h:157
otb::PersistentMinMaxImageFilter::GetMaximumIndex
IndexType GetMaximumIndex() const
Definition: otbStreamingMinMaxImageFilter.h:117
otb::PersistentMinMaxImageFilter::RegionType
TInputImage::RegionType RegionType
Definition: otbStreamingMinMaxImageFilter.h:71
otb::StreamingMinMaxImageFilter::StatFilterType
Superclass::FilterType StatFilterType
Definition: otbStreamingMinMaxImageFilter.h:207
otb::PersistentFilterStreamingDecorator
This filter link a persistent filter with a StreamingImageVirtualWriter.
Definition: otbPersistentFilterStreamingDecorator.h:47
otb::PersistentMinMaxImageFilter::ImageType
TInputImage ImageType
Definition: otbStreamingMinMaxImageFilter.h:65
otb::PersistentMinMaxImageFilter::DataObjectPointerArraySizeType
itk::ProcessObject::DataObjectPointerArraySizeType DataObjectPointerArraySizeType
Definition: otbStreamingMinMaxImageFilter.h:83
otb::PersistentMinMaxImageFilter::m_ThreadMinIndex
std::vector< IndexType > m_ThreadMinIndex
Definition: otbStreamingMinMaxImageFilter.h:156
otb::StreamingMinMaxImageFilter::GetMaximumOutput
PixelObjectType * GetMaximumOutput()
Definition: otbStreamingMinMaxImageFilter.h:245
otb::StreamingMinMaxImageFilter
This class streams the whole input image through the PersistentMinMaxImageFilter.
Definition: otbStreamingMinMaxImageFilter.h:194
otb::StreamingMinMaxImageFilter::PixelObjectType
StatFilterType::PixelObjectType PixelObjectType
Definition: otbStreamingMinMaxImageFilter.h:212
otb::StreamingMinMaxImageFilter::GetMinimumIndexOutput
IndexObjectType * GetMinimumIndexOutput()
Definition: otbStreamingMinMaxImageFilter.h:260
otb::PersistentMinMaxImageFilter::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbStreamingMinMaxImageFilter.h:59
otb::PersistentMinMaxImageFilter::GetMinimum
PixelType GetMinimum() const
Definition: otbStreamingMinMaxImageFilter.h:90
otb::PersistentMinMaxImageFilter::GetMaximum
PixelType GetMaximum() const
Definition: otbStreamingMinMaxImageFilter.h:99
otb::StreamingMinMaxImageFilter::IndexType
StatFilterType::IndexType IndexType
Definition: otbStreamingMinMaxImageFilter.h:211
otb::StreamingMinMaxImageFilter::Self
StreamingMinMaxImageFilter Self
Definition: otbStreamingMinMaxImageFilter.h:198
otb::StreamingMinMaxImageFilter::~StreamingMinMaxImageFilter
~StreamingMinMaxImageFilter() override
Definition: otbStreamingMinMaxImageFilter.h:291
otb::StreamingMinMaxImageFilter::GetInput
const InputImageType * GetInput()
Definition: otbStreamingMinMaxImageFilter.h:221
otb::StreamingMinMaxImageFilter::GetMaximumIndexOutput
IndexObjectType * GetMaximumIndexOutput()
Definition: otbStreamingMinMaxImageFilter.h:274
otb::PersistentMinMaxImageFilter::DataObjectPointer
itk::DataObject::Pointer DataObjectPointer
Definition: otbStreamingMinMaxImageFilter.h:82
otb::PersistentMinMaxImageFilter::IndexType
TInputImage::IndexType IndexType
Definition: otbStreamingMinMaxImageFilter.h:73
otb::PersistentMinMaxImageFilter::GetMinimumIndex
IndexType GetMinimumIndex() const
Definition: otbStreamingMinMaxImageFilter.h:108
otb::PersistentMinMaxImageFilter::InputImagePointer
TInputImage::Pointer InputImagePointer
Definition: otbStreamingMinMaxImageFilter.h:69
otb::PersistentMinMaxImageFilter::Superclass
PersistentImageFilter< TInputImage, TInputImage > Superclass
Definition: otbStreamingMinMaxImageFilter.h:57
otb::StreamingMinMaxImageFilter::GetMinimumIndex
IndexType GetMinimumIndex() const
Definition: otbStreamingMinMaxImageFilter.h:256
otb::PersistentMinMaxImageFilter
Compute min. max of an image using the output requested region.
Definition: otbStreamingMinMaxImageFilter.h:52
otb::StreamingMinMaxImageFilter::GetMinimumOutput
const PixelObjectType * GetMinimumOutput() const
Definition: otbStreamingMinMaxImageFilter.h:235