OTB  10.0.0
Orfeo Toolbox
otbComputeGainLutFilter.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 otbComputeGainLutFilter_h
22 #define otbComputeGainLutFilter_h
23 
24 #include "itkImageToImageFilter.h"
25 #include "otbImage.h"
26 
27 namespace otb
28 {
29 
42 template <class TInputImage, class TOutputImage>
43 class ITK_EXPORT ComputeGainLutFilter : 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::PixelType HistoType;
57  typedef typename OutputImageType::PixelType LutType;
58  typedef typename OutputImageType::InternalPixelType OutputPixelType;
59  typedef typename OutputImageType::RegionType OutputImageRegionType;
60 
62  itkNewMacro(Self);
63 
65  itkTypeMacro(ComputeGainLutFilter, ImageToImageFilter);
66 
68  itkSetMacro(NbPixel, unsigned long);
69  itkGetMacro(NbPixel, unsigned long);
71 
73  itkSetMacro(Min, double);
74  itkGetMacro(Min, double);
76 
78  itkSetMacro(Max, double);
79  itkGetMacro(Max, double);
81 
82 protected:
85  {
86  }
87  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
88 
89  void BeforeThreadedGenerateData() override;
90 
91  void DynamicThreadedGenerateData(const OutputImageRegionType& outputRegionForThread) override;
92 
93 private:
94  ComputeGainLutFilter(const Self&) = delete;
95  void operator=(const Self&) = delete;
96 
98  OutputPixelType PostProcess(unsigned int countMapValue, unsigned int countValue);
99 
102  void Equalized(const HistoType& inputHisto, HistoType& targetHisto, LutType& lut);
103 
105  void CreateTarget(const HistoType& inputHisto, HistoType& targetHisto);
106  // TODO Give the opportunity to choose the histogram target
107 
109  bool IsValid(const HistoType& inputHisto);
110 
111  double m_Min;
112  double m_Max;
113  double m_Step;
114  unsigned int m_NbBin;
115  unsigned long m_NbPixel;
116 };
117 
118 // End namespace otb
119 }
120 
121 #ifndef OTB_MANUAL_INSTANTIATION
123 #endif
124 
125 #endif
Compute the gain for each pixel value from a histogram.
ComputeGainLutFilter(const Self &)=delete
void operator=(const Self &)=delete
itk::SmartPointer< Self > Pointer
OutputImageType::RegionType OutputImageRegionType
OutputImageType::PixelType LutType
itk::SmartPointer< const Self > ConstPointer
itk::ImageToImageFilter< InputImageType, OutputImageType > Superclass
InputImageType::PixelType HistoType
OutputImageType::InternalPixelType OutputPixelType
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.