OTB  6.7.0
Orfeo Toolbox
otbStreamingHistogramVectorImageFilter.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 otbStreamingHistogramVectorImageFilter_h
23 #define otbStreamingHistogramVectorImageFilter_h
24 
27 
28 #include "otbObjectList.h"
29 #include "itkStatisticsAlgorithm.h"
30 #include "itkNumericTraits.h"
31 #include "itkHistogram.h"
32 
33 namespace otb
34 {
35 
54 template<class TInputImage>
56  public PersistentImageFilter<TInputImage, TInputImage>
57 {
58 public:
64 
66  itkNewMacro(Self);
67 
70 
72  typedef TInputImage ImageType;
73  typedef typename TInputImage::Pointer InputImagePointer;
74  typedef typename TInputImage::RegionType RegionType;
75  typedef typename TInputImage::SizeType SizeType;
77  typedef typename TInputImage::PixelType PixelType;
78  typedef typename TInputImage::InternalPixelType InternalPixelType;
79 
80  itkStaticConstMacro(InputImageDimension, unsigned int, TInputImage::ImageDimension);
81 
83  itkStaticConstMacro(ImageDimension, unsigned int, TInputImage::ImageDimension);
84 
88 
92 
95 
96  typedef
99 
100  typedef
103 
105 
109  typedef typename std::vector<HistogramListPointerType> ArrayHistogramListType;
110 
111 
115  itkSetMacro(NoDataValue, InternalPixelType);
116 
120  itkGetConstReferenceMacro(NoDataValue, InternalPixelType);
121 
125  itkSetMacro(NoDataFlag, bool);
126 
130  itkGetMacro(NoDataFlag, bool);
131 
135  itkBooleanMacro(NoDataFlag);
136 
137  inline void SetNumberOfBins( unsigned int i, CountVectorType::ValueType size )
138  {
139  m_Size[ i ] = size;
140  }
141 
142  inline void SetNumberOfBins( const CountVectorType& size )
143  {
144  m_Size = size;
145  }
146 
148  HistogramListType* GetHistogramListOutput();
149  const HistogramListType* GetHistogramListOutput() const;
151 
153  itkGetConstReferenceMacro(HistogramMin,MeasurementVectorType);
154 
156  itkSetMacro(HistogramMin,MeasurementVectorType);
157 
159  itkGetConstReferenceMacro(HistogramMax,MeasurementVectorType);
160 
162  itkSetMacro(HistogramMax,MeasurementVectorType);
163 
165  itkSetMacro(SubSamplingRate, unsigned int);
166 
168  itkGetMacro(SubSamplingRate, unsigned int);
169 
173  DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx) override;
174  using Superclass::MakeOutput;
175 
179  void AllocateOutputs() override;
180  void GenerateOutputInformation() override;
181  void Synthetize(void) override;
182  void Reset(void) override;
184 
185 protected:
188  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
190  void ThreadedGenerateData(const RegionType& outputRegionForThread, itk::ThreadIdType threadId) override;
191 
192 private:
193  PersistentHistogramVectorImageFilter(const Self &) = delete;
194  void operator =(const Self&) = delete;
195 
202 
204  unsigned int m_SubSamplingRate;
205 
206 }; // end of class PersistentStatisticsVectorImageFilter
207 
230 template<class TInputImage>
232  public PersistentFilterStreamingDecorator<PersistentHistogramVectorImageFilter<TInputImage> >
233 {
234 public:
241 
243  itkNewMacro(Self);
244 
247 
248  typedef TInputImage InputImageType;
249  typedef typename Superclass::FilterType InternalFilterType;
250 
252  typedef typename InternalFilterType::HistogramType HistogramType;
253  typedef typename InternalFilterType::HistogramListType HistogramListType;
254 
255  using Superclass::SetInput;
256  void SetInput(InputImageType * input)
257  {
258  this->GetFilter()->SetInput(input);
259  }
261  {
262  return this->GetFilter()->GetInput();
263  }
264 
267  {
268  return this->GetFilter()->GetHistogramListOutput();
269  }
270 
271 
272 protected:
275 
278 
279 private:
280  StreamingHistogramVectorImageFilter(const Self &) = delete;
281  void operator =(const Self&) = delete;
282 };
283 
284 } // end namespace otb
285 
286 #ifndef OTB_MANUAL_INSTANTIATION
288 #endif
289 
290 #endif
itk::Size< Monteverdi_DIMENSION > SizeType
Definition: mvdTypes.h:137
itk::Statistics::Histogram< HistogramMeasurementRealType, DFContainerType > HistogramType
itk::Statistics::DenseFrequencyContainer2 DFContainerType
OTBOSSIMAdapters_EXPORT char const * NoDataValue
This class streams the whole input image through the PersistentHistogramVectorImageFilter.
itk::VariableLengthVector< unsigned int > CountVectorType
std::vector< HistogramListPointerType > ArrayHistogramListType
itk::Index< Monteverdi_DIMENSION > IndexType
Definition: mvdTypes.h:133
This class is a generic all-purpose wrapping around an std::vector<itk::SmartPointer<ObjectType> >...
Definition: otbObjectList.h:40
DataObjectPointerArray::size_type DataObjectPointerArraySizeType
itk::NumericTraits< InternalPixelType >::RealType HistogramMeasurementRealType
unsigned int ThreadIdType
PersistentImageFilter< TInputImage, TInputImage > Superclass
itk::ProcessObject::DataObjectPointerArraySizeType DataObjectPointerArraySizeType
void SetNumberOfBins(unsigned int i, CountVectorType::ValueType size)
PersistentFilterStreamingDecorator< PersistentHistogramVectorImageFilter< TInputImage > > Superclass
itk::NumericTraits< InternalPixelType >::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.
Compute the histogram of a large image using streaming.
This filter link a persistent filter with a StreamingImageVirtualWriter.