OTB  9.0.0
Orfeo Toolbox
otbCLHistogramEqualizationFilter.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 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:
161  CLHistogramEqualizationFilter(const Self&) = delete;
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
otb::ComputeGainLutFilter::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbComputeGainLutFilter.h:53
otb::CLHistogramEqualizationFilter::SetNoData
void SetNoData(InputPixelType n)
Definition: otbCLHistogramEqualizationFilter.h:129
otb::CLHistogramEqualizationFilter::InputPixelType
InputImageType::PixelType InputPixelType
Definition: otbCLHistogramEqualizationFilter.h:73
otbVectorImage.h
otb::CLHistogramEqualizationFilter::SetMax
void SetMax(InputPixelType max)
Definition: otbCLHistogramEqualizationFilter.h:93
otb::CLHistogramEqualizationFilter::m_ApplyGainFilter
ApplyGainFilter::Pointer m_ApplyGainFilter
Definition: otbCLHistogramEqualizationFilter.h:166
otb::CLHistogramEqualizationFilter::SetNbBin
void SetNbBin(unsigned long bin)
Definition: otbCLHistogramEqualizationFilter.h:103
otbImage.h
otb::ApplyGainFilter::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbApplyGainFilter.h:52
otb::CLHistogramEqualizationFilter::m_StreamingImageFilter
StreamingImageFilter::Pointer m_StreamingImageFilter
Definition: otbCLHistogramEqualizationFilter.h:167
otbInPlacePassFilter.h
otb::CLHistogramEqualizationFilter::LutType
otb::VectorImage< double, 2 > LutType
Definition: otbCLHistogramEqualizationFilter.h:61
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::CLHistogramEqualizationFilter::~CLHistogramEqualizationFilter
~CLHistogramEqualizationFilter() override
Definition: otbCLHistogramEqualizationFilter.h:148
otb::ComputeHistoFilter::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbComputeHistoFilter.h:53
otb::ComputeHistoFilter
Compute local histogram with several parameters.
Definition: otbComputeHistoFilter.h:43
otb::CLHistogramEqualizationFilter::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbCLHistogramEqualizationFilter.h:57
otb::CLHistogramEqualizationFilter::StreamingImageFilter
itk::StreamingImageFilter< LutType, LutType > StreamingImageFilter
Definition: otbCLHistogramEqualizationFilter.h:63
otb::CLHistogramEqualizationFilter::GainLutFilter
otb::ComputeGainLutFilter< HistogramType, LutType > GainLutFilter
Definition: otbCLHistogramEqualizationFilter.h:69
otbCLHistogramEqualizationFilter.hxx
otb::CLHistogramEqualizationFilter::OutputImageRegionType
OutputImageType::RegionType OutputImageRegionType
Definition: otbCLHistogramEqualizationFilter.h:74
otbComputeHistoFilter.h
otb::CLHistogramEqualizationFilter::m_NoData
InputPixelType m_NoData
Definition: otbCLHistogramEqualizationFilter.h:169
otbApplyGainFilter.h
otb::CLHistogramEqualizationFilter::SetMin
void SetMin(InputPixelType min)
Definition: otbCLHistogramEqualizationFilter.h:83
otb::CLHistogramEqualizationFilter::m_HistoFilter
HistoFilter::Pointer m_HistoFilter
Definition: otbCLHistogramEqualizationFilter.h:164
otb::CLHistogramEqualizationFilter::Superclass
itk::ImageToImageFilter< InputImageType, OutputImageType > Superclass
Definition: otbCLHistogramEqualizationFilter.h:56
otb::CLHistogramEqualizationFilter
Implement CLAHE algorithm.
Definition: otbCLHistogramEqualizationFilter.h:47
otb::CLHistogramEqualizationFilter::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbCLHistogramEqualizationFilter.h:58
otb::CLHistogramEqualizationFilter::InputImageType
TInputImage InputImageType
Definition: otbCLHistogramEqualizationFilter.h:52
otb::CLHistogramEqualizationFilter::OutputImageType
TOutputImage OutputImageType
Definition: otbCLHistogramEqualizationFilter.h:53
otb::ApplyGainFilter
Apply gain on the input image with a bilineare interpolation.
Definition: otbApplyGainFilter.h:42
otb::CLHistogramEqualizationFilter::SetNoDataFlag
void SetNoDataFlag(bool flag)
Definition: otbCLHistogramEqualizationFilter.h:139
otb::CLHistogramEqualizationFilter::SetThreshold
void SetThreshold(double t)
Definition: otbCLHistogramEqualizationFilter.h:121
otb::InPlacePassFilter::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbInPlacePassFilter.h:54
otb::ComputeGainLutFilter
Compute the gain for each pixel value from a histogram.
Definition: otbComputeGainLutFilter.h:43
otb::CLHistogramEqualizationFilter::m_BufferFilter
BufferFilter::Pointer m_BufferFilter
Definition: otbCLHistogramEqualizationFilter.h:168
otb::CLHistogramEqualizationFilter::SetThumbSize
void SetThumbSize(typename InputImageType::SizeType size)
Definition: otbCLHistogramEqualizationFilter.h:111
otb::CLHistogramEqualizationFilter::m_NoDataFlag
bool m_NoDataFlag
Definition: otbCLHistogramEqualizationFilter.h:173
otb::CLHistogramEqualizationFilter::m_GainLutFilter
GainLutFilter::Pointer m_GainLutFilter
Definition: otbCLHistogramEqualizationFilter.h:165
otb::CLHistogramEqualizationFilter::HistoFilter
otb::ComputeHistoFilter< InputImageType, HistogramType > HistoFilter
Definition: otbCLHistogramEqualizationFilter.h:67
otb::CLHistogramEqualizationFilter::ApplyGainFilter
otb::ApplyGainFilter< InputImageType, LutType, OutputImageType > ApplyGainFilter
Definition: otbCLHistogramEqualizationFilter.h:71
otb::CLHistogramEqualizationFilter::m_NbBin
unsigned long m_NbBin
Definition: otbCLHistogramEqualizationFilter.h:170
otb::CLHistogramEqualizationFilter::HistogramType
otb::VectorImage< unsigned int, 2 > HistogramType
Definition: otbCLHistogramEqualizationFilter.h:60
otb::CLHistogramEqualizationFilter::Self
CLHistogramEqualizationFilter Self
Definition: otbCLHistogramEqualizationFilter.h:55
otbComputeGainLutFilter.h
otb::InPlacePassFilter
This filter has the only purpose to recall regions.
Definition: otbInPlacePassFilter.h:46
otb::CLHistogramEqualizationFilter::BufferFilter
otb::InPlacePassFilter< InputImageType > BufferFilter
Definition: otbCLHistogramEqualizationFilter.h:65
otb::CLHistogramEqualizationFilter::m_Threshold
double m_Threshold
Definition: otbCLHistogramEqualizationFilter.h:172
otb::VectorImage
Creation of an "otb" vector image which contains metadata.
Definition: otbVectorImage.h:45