OTB  10.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-2024 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:
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 
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:
297  void operator=(const Self&) = delete;
298 };
299 
300 } // end namespace otb
301 
302 #ifndef OTB_MANUAL_INSTANTIATION
304 #endif
305 
306 #endif
This filter link a persistent filter with a StreamingImageVirtualWriter.
This filter is the base class for all filter persisting data through multiple update....
Compute min. max of an image using the output requested region.
PersistentMinMaxImageFilter(const Self &)=delete
PersistentImageFilter< TInputImage, TInputImage > Superclass
itk::ProcessObject::DataObjectPointerArraySizeType DataObjectPointerArraySizeType
itk::SimpleDataObjectDecorator< PixelType > PixelObjectType
itk::SimpleDataObjectDecorator< IndexType > IndexObjectType
itk::SmartPointer< const Self > ConstPointer
void operator=(const Self &)=delete
This class streams the whole input image through the PersistentMinMaxImageFilter.
const IndexObjectType * GetMinimumIndexOutput() const
itk::SmartPointer< const Self > ConstPointer
const PixelObjectType * GetMinimumOutput() const
const IndexObjectType * GetMaximumIndexOutput() const
void operator=(const Self &)=delete
const PixelObjectType * GetMaximumOutput() const
StreamingMinMaxImageFilter(const Self &)=delete
StatFilterType::IndexObjectType IndexObjectType
StatFilterType::PixelObjectType PixelObjectType
PersistentFilterStreamingDecorator< PersistentMinMaxImageFilter< TInputImage > > Superclass
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.