OTB  10.0.0
Orfeo Toolbox
otbCLHistogramEqualizationFilter.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2024 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 otbCLHistogramEqualizationFilter_h
22 #define otbCLHistogramEqualizationFilter_h
23 
24 #include "itkImageToImageFilter.h"
25 #include "otbImage.h"
26 #include "otbVectorImage.h"
27 #include "otbComputeHistoFilter.h"
29 #include "otbApplyGainFilter.h"
30 #include "itkStreamingImageFilter.h"
31 #include "otbInPlacePassFilter.h"
32 
33 namespace otb
34 {
35 
46 template <class TInputImage, class TOutputImage>
47 class ITK_EXPORT CLHistogramEqualizationFilter : public itk::ImageToImageFilter<TInputImage, TOutputImage>
48 {
49 public:
52  typedef TInputImage InputImageType;
53  typedef TOutputImage OutputImageType;
54 
56  typedef itk::ImageToImageFilter<InputImageType, OutputImageType> Superclass;
57  typedef itk::SmartPointer<Self> Pointer;
58  typedef itk::SmartPointer<const Self> ConstPointer;
59 
62 
63  typedef itk::StreamingImageFilter<LutType, LutType> StreamingImageFilter;
64 
66 
68 
70 
72 
73  typedef typename InputImageType::PixelType InputPixelType;
74  typedef typename OutputImageType::RegionType OutputImageRegionType;
76  itkNewMacro(Self);
77 
79  itkTypeMacro(CLHistogramEqualizationFilter, ImageToImageFilter);
80 
81  itkGetMacro(Min, InputPixelType);
82  // itkSetMacro(Min, InputPixelType);
84  {
85  m_HistoFilter->SetMin(min);
86  m_GainLutFilter->SetMin(min);
87  m_ApplyGainFilter->SetMin(min);
88  m_Min = min;
89  };
90 
91  itkGetMacro(Max, InputPixelType);
92  // itkSetMacro(Max, InputPixelType);
94  {
95  m_HistoFilter->SetMax(max);
96  m_GainLutFilter->SetMax(max);
97  m_ApplyGainFilter->SetMax(max);
98  m_Max = max;
99  };
100 
101  itkGetMacro(NbBin, unsigned long);
102  // itkSetMacro(NbBin, unsigned long);
103  void SetNbBin(unsigned long bin)
104  {
105  m_HistoFilter->SetNbBin(bin);
106  m_NbBin = bin;
107  };
108 
109  itkGetMacro(ThumbSize, typename InputImageType::SizeType);
110  // itkSetMacro(ThumbSize, typename InputImageType::SizeType);
111  void SetThumbSize(typename InputImageType::SizeType size)
112  {
113  m_HistoFilter->SetThumbSize(size);
114  m_ApplyGainFilter->SetThumbSize(size);
115  m_GainLutFilter->SetNbPixel(size[0] * size[1]);
116  m_ThumbSize = size;
117  };
118 
119  itkGetMacro(Threshold, double);
120  // itkSetMacro(Threshold, double);
121  void SetThreshold(double t)
122  {
123  m_HistoFilter->SetThreshold(t);
124  m_Threshold = t;
125  };
126 
127  itkGetMacro(NoData, InputPixelType);
128  // itkSetMacro(NoData, InputPixelType);
130  {
131  m_HistoFilter->SetNoData(n);
132  m_ApplyGainFilter->SetNoData(n);
133  m_NoData = n;
134  }
135 
136 
137  itkGetMacro(NoDataFlag, bool);
138  // itkSetMacro(NoDataFlag, bool);
139  void SetNoDataFlag(bool flag)
140  {
141  m_HistoFilter->SetNoDataFlag(flag);
142  m_ApplyGainFilter->SetNoDataFlag(flag);
143  m_NoDataFlag = flag;
144  }
145 
146 protected:
149  {
150  }
151 
152  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
153 
154  void UpdateOutputInformation() override;
155 
156  void PropagateRequestedRegion(itk::DataObject* output) override;
157 
158  void GenerateData() override;
159 
160 private:
162  void operator=(const Self&) = delete;
163 
167  typename StreamingImageFilter::Pointer m_StreamingImageFilter;
169  InputPixelType m_Min, m_Max, m_NoData;
170  unsigned long m_NbBin;
171  typename InputImageType::SizeType m_ThumbSize{0,0};
172  double m_Threshold;
174 };
175 
176 } // End namespace otb
177 
178 #ifndef OTB_MANUAL_INSTANTIATION
180 #endif
181 
182 
183 #endif
Apply gain on the input image with a bilineare interpolation.
itk::SmartPointer< Self > Pointer
otb::InPlacePassFilter< InputImageType > BufferFilter
CLHistogramEqualizationFilter(const Self &)=delete
otb::VectorImage< unsigned int, 2 > HistogramType
itk::StreamingImageFilter< LutType, LutType > StreamingImageFilter
otb::ComputeGainLutFilter< HistogramType, LutType > GainLutFilter
itk::ImageToImageFilter< InputImageType, OutputImageType > Superclass
void operator=(const Self &)=delete
otb::ApplyGainFilter< InputImageType, LutType, OutputImageType > ApplyGainFilter
otb::ComputeHistoFilter< InputImageType, HistogramType > HistoFilter
StreamingImageFilter::Pointer m_StreamingImageFilter
void SetThumbSize(typename InputImageType::SizeType size)
Compute the gain for each pixel value from a histogram.
itk::SmartPointer< Self > Pointer
Compute local histogram with several parameters.
itk::SmartPointer< Self > Pointer
This filter has the only purpose to recall regions.
itk::SmartPointer< Self > Pointer
Creation of an "otb" vector image which contains metadata.
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.