OTB  9.0.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-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 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>
55 class ITK_EXPORT PersistentHistogramVectorImageFilter : public PersistentImageFilter<TInputImage, TInputImage>
56 {
57 public:
61  typedef itk::SmartPointer<Self> Pointer;
62  typedef itk::SmartPointer<const Self> ConstPointer;
63 
65  itkNewMacro(Self);
66 
69 
71  typedef TInputImage ImageType;
72  typedef typename TInputImage::Pointer InputImagePointer;
73  typedef typename TInputImage::RegionType RegionType;
74  typedef typename TInputImage::SizeType SizeType;
75  typedef typename TInputImage::IndexType IndexType;
76  typedef typename TInputImage::PixelType PixelType;
77  typedef typename TInputImage::InternalPixelType InternalPixelType;
78 
79  itkStaticConstMacro(InputImageDimension, unsigned int, TInputImage::ImageDimension);
80 
82  itkStaticConstMacro(ImageDimension, unsigned int, TInputImage::ImageDimension);
83 
85  typedef typename itk::NumericTraits<InternalPixelType>::RealType RealType;
86  typedef itk::VariableLengthVector<RealType> RealPixelType;
87 
89  typedef typename itk::DataObject::Pointer DataObjectPointer;
90  typedef itk::ProcessObject::DataObjectPointerArraySizeType DataObjectPointerArraySizeType;
91 
93  typedef itk::Statistics::DenseFrequencyContainer2 DFContainerType;
94 
95  typedef typename itk::NumericTraits<InternalPixelType>::RealType HistogramMeasurementRealType;
96 
97  typedef itk::Statistics::Histogram<HistogramMeasurementRealType, DFContainerType> HistogramType;
98 
99  typedef itk::VariableLengthVector<unsigned int> CountVectorType;
100 
104  typedef typename std::vector<HistogramListPointerType> ArrayHistogramListType;
105 
106 
110  itkSetMacro(NoDataValue, InternalPixelType);
111 
115  itkGetConstReferenceMacro(NoDataValue, InternalPixelType);
116 
120  itkSetMacro(NoDataFlag, bool);
121 
125  itkGetMacro(NoDataFlag, bool);
126 
130  itkBooleanMacro(NoDataFlag);
131 
132  inline void SetNumberOfBins(unsigned int i, CountVectorType::ValueType size)
133  {
134  m_Size[i] = size;
135  }
136 
137  inline void SetNumberOfBins(const CountVectorType& size)
138  {
139  m_Size = size;
140  }
141 
143  HistogramListType* GetHistogramListOutput();
144  const HistogramListType* GetHistogramListOutput() const;
146 
148  itkGetConstReferenceMacro(HistogramMin, MeasurementVectorType);
149 
151  itkSetMacro(HistogramMin, MeasurementVectorType);
152 
154  itkGetConstReferenceMacro(HistogramMax, MeasurementVectorType);
155 
157  itkSetMacro(HistogramMax, MeasurementVectorType);
158 
160  itkSetMacro(SubSamplingRate, unsigned int);
161 
163  itkGetMacro(SubSamplingRate, unsigned int);
164 
168  DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx) override;
169  using Superclass::MakeOutput;
170 
174  void AllocateOutputs() override;
175  void GenerateOutputInformation() override;
176  void Synthetize(void) override;
177  void Reset(void) override;
179 
180 protected:
183  {
184  }
185  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
187  void ThreadedGenerateData(const RegionType& outputRegionForThread, itk::ThreadIdType threadId) override;
188 
189 private:
190  PersistentHistogramVectorImageFilter(const Self&) = delete;
191  void operator=(const Self&) = delete;
192 
199 
201  unsigned int m_SubSamplingRate;
202 
203 }; // end of class PersistentStatisticsVectorImageFilter
204 
227 template <class TInputImage>
228 class ITK_EXPORT StreamingHistogramVectorImageFilter : public PersistentFilterStreamingDecorator<PersistentHistogramVectorImageFilter<TInputImage>>
229 {
230 public:
234  typedef itk::SmartPointer<Self> Pointer;
235  typedef itk::SmartPointer<const Self> ConstPointer;
236 
238  itkNewMacro(Self);
239 
242 
243  typedef TInputImage InputImageType;
245 
249 
250  using Superclass::SetInput;
252  {
253  this->GetFilter()->SetInput(input);
254  }
256  {
257  return this->GetFilter()->GetInput();
258  }
259 
262  {
263  return this->GetFilter()->GetHistogramListOutput();
264  }
265 
266 
267 protected:
270 
273  {
274  }
275 
276 private:
277  StreamingHistogramVectorImageFilter(const Self&) = delete;
278  void operator=(const Self&) = delete;
279 };
280 
281 } // end namespace otb
282 
283 #ifndef OTB_MANUAL_INSTANTIATION
285 #endif
286 
287 #endif
otb::PersistentHistogramVectorImageFilter::SetNumberOfBins
void SetNumberOfBins(unsigned int i, CountVectorType::ValueType size)
Definition: otbStreamingHistogramVectorImageFilter.h:132
otb::StreamingHistogramVectorImageFilter
This class streams the whole input image through the PersistentHistogramVectorImageFilter.
Definition: otbStreamingHistogramVectorImageFilter.h:228
otb::PersistentHistogramVectorImageFilter::HistogramMeasurementRealType
itk::NumericTraits< InternalPixelType >::RealType HistogramMeasurementRealType
Definition: otbStreamingHistogramVectorImageFilter.h:95
otb::PersistentHistogramVectorImageFilter::Superclass
PersistentImageFilter< TInputImage, TInputImage > Superclass
Definition: otbStreamingHistogramVectorImageFilter.h:60
otb::PersistentHistogramVectorImageFilter::m_Size
CountVectorType m_Size
Definition: otbStreamingHistogramVectorImageFilter.h:194
otbPersistentImageFilter.h
otb::StreamingHistogramVectorImageFilter::HistogramType
InternalFilterType::HistogramType HistogramType
Definition: otbStreamingHistogramVectorImageFilter.h:247
otb::PersistentHistogramVectorImageFilter::m_HistogramMax
MeasurementVectorType m_HistogramMax
Definition: otbStreamingHistogramVectorImageFilter.h:196
otb::PersistentImageFilter
This filter is the base class for all filter persisting data through multiple update....
Definition: otbPersistentImageFilter.h:47
otb::StreamingHistogramVectorImageFilter::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbStreamingHistogramVectorImageFilter.h:234
otb::PersistentHistogramVectorImageFilter::m_HistogramMin
MeasurementVectorType m_HistogramMin
Definition: otbStreamingHistogramVectorImageFilter.h:195
otb::StreamingHistogramVectorImageFilter::InternalFilterType
Superclass::FilterType InternalFilterType
Definition: otbStreamingHistogramVectorImageFilter.h:244
otbPersistentFilterStreamingDecorator.h
otb::PersistentHistogramVectorImageFilter::IndexType
TInputImage::IndexType IndexType
Definition: otbStreamingHistogramVectorImageFilter.h:75
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::PersistentHistogramVectorImageFilter::SetNumberOfBins
void SetNumberOfBins(const CountVectorType &size)
Definition: otbStreamingHistogramVectorImageFilter.h:137
otb::PersistentHistogramVectorImageFilter::RegionType
TInputImage::RegionType RegionType
Definition: otbStreamingHistogramVectorImageFilter.h:73
otb::PersistentHistogramVectorImageFilter::HistogramListPointerType
HistogramListType::Pointer HistogramListPointerType
Definition: otbStreamingHistogramVectorImageFilter.h:103
otb::ObjectList::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbObjectList.h:46
otb::StreamingHistogramVectorImageFilter::HistogramListType
InternalFilterType::HistogramListType HistogramListType
Definition: otbStreamingHistogramVectorImageFilter.h:248
otb::PersistentHistogramVectorImageFilter::DataObjectPointer
itk::DataObject::Pointer DataObjectPointer
Definition: otbStreamingHistogramVectorImageFilter.h:89
otb::PersistentHistogramVectorImageFilter::Self
PersistentHistogramVectorImageFilter Self
Definition: otbStreamingHistogramVectorImageFilter.h:59
otb::StreamingHistogramVectorImageFilter::~StreamingHistogramVectorImageFilter
~StreamingHistogramVectorImageFilter() override
Definition: otbStreamingHistogramVectorImageFilter.h:272
otb::PersistentHistogramVectorImageFilter::DataObjectPointerArraySizeType
itk::ProcessObject::DataObjectPointerArraySizeType DataObjectPointerArraySizeType
Definition: otbStreamingHistogramVectorImageFilter.h:90
otb::StreamingHistogramVectorImageFilter::Superclass
PersistentFilterStreamingDecorator< PersistentHistogramVectorImageFilter< TInputImage > > Superclass
Definition: otbStreamingHistogramVectorImageFilter.h:233
otb::PersistentHistogramVectorImageFilter::CountVectorType
itk::VariableLengthVector< unsigned int > CountVectorType
Definition: otbStreamingHistogramVectorImageFilter.h:99
otb::StreamingHistogramVectorImageFilter::StreamingHistogramVectorImageFilter
StreamingHistogramVectorImageFilter()
Definition: otbStreamingHistogramVectorImageFilter.h:269
otbStreamingHistogramVectorImageFilter.hxx
otb::StreamingHistogramVectorImageFilter::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbStreamingHistogramVectorImageFilter.h:235
otb::MetaDataKey::NoDataValue
OTBMetadata_EXPORT char const * NoDataValue
otb::PersistentHistogramVectorImageFilter::RealType
itk::NumericTraits< InternalPixelType >::RealType RealType
Definition: otbStreamingHistogramVectorImageFilter.h:85
otb::PersistentHistogramVectorImageFilter::RealPixelType
itk::VariableLengthVector< RealType > RealPixelType
Definition: otbStreamingHistogramVectorImageFilter.h:86
otb::PersistentHistogramVectorImageFilter::m_NoDataFlag
bool m_NoDataFlag
Definition: otbStreamingHistogramVectorImageFilter.h:197
otb::StreamingHistogramVectorImageFilter::SetInput
void SetInput(InputImageType *input)
Definition: otbStreamingHistogramVectorImageFilter.h:251
otb::PersistentHistogramVectorImageFilter::~PersistentHistogramVectorImageFilter
~PersistentHistogramVectorImageFilter() override
Definition: otbStreamingHistogramVectorImageFilter.h:182
otbObjectList.h
otb::PersistentHistogramVectorImageFilter::SizeType
TInputImage::SizeType SizeType
Definition: otbStreamingHistogramVectorImageFilter.h:74
otb::PersistentFilterStreamingDecorator
This filter link a persistent filter with a StreamingImageVirtualWriter.
Definition: otbPersistentFilterStreamingDecorator.h:47
otb::PersistentHistogramVectorImageFilter::InputImagePointer
TInputImage::Pointer InputImagePointer
Definition: otbStreamingHistogramVectorImageFilter.h:72
otb::PersistentHistogramVectorImageFilter::DFContainerType
itk::Statistics::DenseFrequencyContainer2 DFContainerType
Definition: otbStreamingHistogramVectorImageFilter.h:93
otb::PersistentHistogramVectorImageFilter::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbStreamingHistogramVectorImageFilter.h:61
otb::PersistentHistogramVectorImageFilter::MeasurementVectorType
PixelType MeasurementVectorType
Definition: otbStreamingHistogramVectorImageFilter.h:101
otb::PersistentHistogramVectorImageFilter::ImageType
TInputImage ImageType
Definition: otbStreamingHistogramVectorImageFilter.h:68
otb::StreamingHistogramVectorImageFilter::GetHistogramList
HistogramListType * GetHistogramList()
Definition: otbStreamingHistogramVectorImageFilter.h:261
otb::StreamingHistogramVectorImageFilter::InputImageType
TInputImage InputImageType
Definition: otbStreamingHistogramVectorImageFilter.h:241
otb::PersistentHistogramVectorImageFilter::InternalPixelType
TInputImage::InternalPixelType InternalPixelType
Definition: otbStreamingHistogramVectorImageFilter.h:77
otb::PersistentHistogramVectorImageFilter::HistogramType
itk::Statistics::Histogram< HistogramMeasurementRealType, DFContainerType > HistogramType
Definition: otbStreamingHistogramVectorImageFilter.h:97
otb::PersistentHistogramVectorImageFilter::m_ThreadHistogramList
ArrayHistogramListType m_ThreadHistogramList
Definition: otbStreamingHistogramVectorImageFilter.h:193
otb::StreamingHistogramVectorImageFilter::GetInput
const InputImageType * GetInput()
Definition: otbStreamingHistogramVectorImageFilter.h:255
otb::PersistentHistogramVectorImageFilter::m_SubSamplingRate
unsigned int m_SubSamplingRate
Definition: otbStreamingHistogramVectorImageFilter.h:201
otb::PersistentHistogramVectorImageFilter::ArrayHistogramListType
std::vector< HistogramListPointerType > ArrayHistogramListType
Definition: otbStreamingHistogramVectorImageFilter.h:104
otb::PersistentHistogramVectorImageFilter::HistogramListType
ObjectList< HistogramType > HistogramListType
Definition: otbStreamingHistogramVectorImageFilter.h:102
otb::ObjectList
This class is a generic all-purpose wrapping around an std::vector<itk::SmartPointer<ObjectType> >.
Definition: otbObjectList.h:40
otb::StreamingHistogramVectorImageFilter::Self
StreamingHistogramVectorImageFilter Self
Definition: otbStreamingHistogramVectorImageFilter.h:232
otb::PersistentHistogramVectorImageFilter::PixelType
TInputImage::PixelType PixelType
Definition: otbStreamingHistogramVectorImageFilter.h:76
otb::PersistentHistogramVectorImageFilter
Compute the histogram of a large image using streaming.
Definition: otbStreamingHistogramVectorImageFilter.h:55
otb::PersistentHistogramVectorImageFilter::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbStreamingHistogramVectorImageFilter.h:62
otb::PersistentHistogramVectorImageFilter::m_NoDataValue
InternalPixelType m_NoDataValue
Definition: otbStreamingHistogramVectorImageFilter.h:198