OTB  9.0.0
Orfeo Toolbox
otbComputeHistoFilter.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2022 Centre National d'Etudes Spatiales (CNES)
3  *
4  * This file is part of Orfeo Toolbox
5  *
6  * https://www.orfeo-toolbox.org/
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20 
21 #ifndef otbComputeHistoFilter_h
22 #define otbComputeHistoFilter_h
23 
24 #include "itkImageToImageFilter.h"
25 #include "otbImage.h"
26 #include "itkImageRegionIterator.h"
27 
28 namespace otb
29 {
30 
42 template <class TInputImage, class TOutputImage>
43 class ITK_EXPORT ComputeHistoFilter : public itk::ImageToImageFilter<TInputImage, TOutputImage>
44 {
45 public:
48  typedef TInputImage InputImageType;
49  typedef TOutputImage OutputImageType;
50 
52  typedef itk::ImageToImageFilter<InputImageType, OutputImageType> Superclass;
53  typedef itk::SmartPointer<Self> Pointer;
54  typedef itk::SmartPointer<const Self> ConstPointer;
55 
56  typedef typename InputImageType::InternalPixelType InputPixelType;
57  typedef typename InputImageType::IndexType IndexType;
58  typedef typename InputImageType::SizeType SizeType;
59  typedef typename OutputImageType::RegionType OutputImageRegionType;
60 
62  itkNewMacro(Self);
63 
65  itkTypeMacro(ComputeHistoFilter, ImageToImageFilter);
66 
68  itkSetMacro(NbBin, unsigned int);
69  itkGetMacro(NbBin, unsigned int);
71 
73  itkSetMacro(Min, InputPixelType);
74  itkGetMacro(Min, InputPixelType);
76 
78  itkSetMacro(Max, InputPixelType);
79  itkGetMacro(Max, InputPixelType);
81 
83  itkSetMacro(NoData, InputPixelType);
84  itkGetMacro(NoData, InputPixelType);
86 
88  itkBooleanMacro(NoDataFlag);
89  itkGetMacro(NoDataFlag, bool);
90  itkSetMacro(NoDataFlag, bool);
92 
94  itkSetMacro(ThumbSize, SizeType);
95  itkGetMacro(ThumbSize, SizeType);
97 
99  itkSetMacro(Threshold, float);
100  itkGetMacro(Threshold, float);
102 
103  typename OutputImageType::Pointer GetHistoOutput();
104 
105  virtual itk::ProcessObject::DataObjectPointer MakeOutput(itk::ProcessObject::DataObjectPointerArraySizeType idx) override;
106 
107  virtual itk::ProcessObject::DataObjectPointer MakeOutput(const itk::ProcessObject::DataObjectIdentifierType&) override;
108 
109 
110 protected:
113  {
114  }
115  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
116 
117  void GenerateInputRequestedRegion() override;
118 
119  void GenerateOutputInformation() override;
120 
121  // Call BeforeThreadedGenerateData after getting the number of thread
122  void GenerateData() override;
123 
124 
125  void BeforeThreadedGenerateData() override;
126 
127  virtual void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) override;
128 
129  void AfterThreadedGenerateData() override;
130 
131  void GenerateOutputRequestedRegion(itk::DataObject* output) override;
132 
133 private:
134  ComputeHistoFilter(const Self&) = delete;
135  void operator=(const Self&) = delete;
136 
137  void SetRequestedRegion(itk::ImageBase<2>* image);
138 
139  void ApplyThreshold(typename itk::ImageRegionIterator<OutputImageType> oit, unsigned int total);
140 
141  std::vector<typename OutputImageType::PixelType> m_HistoThread;
145  SizeType m_ThumbSize{0,0};
147  double m_Step;
148  float m_Threshold;
149  unsigned int m_NbBin;
150  unsigned int m_ValidThreads;
151 };
152 
153 } // End namespace otb
154 
155 #ifndef OTB_MANUAL_INSTANTIATION
156 #include "otbComputeHistoFilter.hxx"
157 #endif
158 
159 #endif
otb::ComputeHistoFilter::m_Max
InputPixelType m_Max
Definition: otbComputeHistoFilter.h:143
otb::ComputeHistoFilter::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbComputeHistoFilter.h:54
otb::ComputeHistoFilter::m_NoDataFlag
bool m_NoDataFlag
Definition: otbComputeHistoFilter.h:146
otb::ComputeHistoFilter::InputPixelType
InputImageType::InternalPixelType InputPixelType
Definition: otbComputeHistoFilter.h:56
otbImage.h
otb::ComputeHistoFilter::m_ValidThreads
unsigned int m_ValidThreads
Definition: otbComputeHistoFilter.h:150
otb::ComputeHistoFilter::InputImageType
TInputImage InputImageType
Definition: otbComputeHistoFilter.h:48
otb::ComputeHistoFilter::m_Threshold
float m_Threshold
Definition: otbComputeHistoFilter.h:148
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::ComputeHistoFilter::m_NoData
InputPixelType m_NoData
Definition: otbComputeHistoFilter.h:144
otbComputeHistoFilter.hxx
otb::ComputeHistoFilter::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbComputeHistoFilter.h:53
otb::ComputeHistoFilter
Compute local histogram with several parameters.
Definition: otbComputeHistoFilter.h:43
otb::ComputeHistoFilter::m_NbBin
unsigned int m_NbBin
Definition: otbComputeHistoFilter.h:149
otb::ComputeHistoFilter::SizeType
InputImageType::SizeType SizeType
Definition: otbComputeHistoFilter.h:58
otb::ComputeHistoFilter::OutputImageRegionType
OutputImageType::RegionType OutputImageRegionType
Definition: otbComputeHistoFilter.h:59
otb::ComputeHistoFilter::m_Step
double m_Step
Definition: otbComputeHistoFilter.h:147
otb::ComputeHistoFilter::Self
ComputeHistoFilter Self
Definition: otbComputeHistoFilter.h:51
otb::ComputeHistoFilter::~ComputeHistoFilter
~ComputeHistoFilter() override
Definition: otbComputeHistoFilter.h:112
otb::ComputeHistoFilter::Superclass
itk::ImageToImageFilter< InputImageType, OutputImageType > Superclass
Definition: otbComputeHistoFilter.h:52
otb::ComputeHistoFilter::OutputImageType
TOutputImage OutputImageType
Definition: otbComputeHistoFilter.h:49
otb::ComputeHistoFilter::m_HistoThread
std::vector< typename OutputImageType::PixelType > m_HistoThread
Definition: otbComputeHistoFilter.h:141
otb::ComputeHistoFilter::m_Min
InputPixelType m_Min
Definition: otbComputeHistoFilter.h:142
otb::ComputeHistoFilter::IndexType
InputImageType::IndexType IndexType
Definition: otbComputeHistoFilter.h:57