OTB  10.0.0
Orfeo Toolbox
otbLocalHistogramImageFunction.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 otbLocalHistogramImageFunction_h
22 #define otbLocalHistogramImageFunction_h
23 
24 #include "itkImageFunction.h"
25 #include "itkHistogram.h"
26 #include "itkNumericTraits.h"
27 
28 namespace otb
29 {
30 
54 template <class TInputImage, class TCoordRep = double>
56  : public itk::ImageFunction<TInputImage, typename itk::Statistics::Histogram<typename TInputImage::PixelType>::Pointer, TCoordRep>
57 {
58 public:
61  typedef itk::ImageFunction<TInputImage, typename itk::Statistics::Histogram<typename TInputImage::PixelType>::Pointer, TCoordRep> Superclass;
62  typedef itk::SmartPointer<Self> Pointer;
63  typedef itk::SmartPointer<const Self> ConstPointer;
64 
66  itkTypeMacro(LocalHistogramImageFunction, ImageFunction);
67 
69  itkNewMacro(Self);
70 
72  typedef TInputImage InputImageType;
73  typedef typename Superclass::IndexType IndexType;
74  typedef typename Superclass::ContinuousIndexType ContinuousIndexType;
75  typedef typename Superclass::PointType PointType;
76 
77  typedef typename Superclass::OutputType OutputType;
78  typedef itk::Statistics::Histogram<typename TInputImage::PixelType> HistogramType;
79  typedef typename HistogramType::Pointer HistogramPointer;
80 
81  typedef TCoordRep CoordRepType;
82 
84  itkStaticConstMacro(ImageDimension, unsigned int, InputImageType::ImageDimension);
85 
87  OutputType EvaluateAtIndex(const IndexType& index) const override;
88 
90  OutputType Evaluate(const PointType& point) const override
91  {
92  IndexType index;
93  this->ConvertPointToNearestIndex(point, index);
94  return this->EvaluateAtIndex(index);
95  }
97  {
98  IndexType index;
99  this->ConvertContinuousIndexToNearestIndex(cindex, index);
100  return this->EvaluateAtIndex(index);
101  }
103 
107  itkSetMacro(NeighborhoodRadius, unsigned int);
108  itkGetConstReferenceMacro(NeighborhoodRadius, unsigned int);
110 
112  itkSetClampMacro(NumberOfHistogramBins, unsigned long, 1, itk::NumericTraits<unsigned long>::max());
113  itkGetConstMacro(NumberOfHistogramBins, unsigned long);
115 
116  itkSetMacro(HistogramMin, double);
117  itkGetConstReferenceMacro(HistogramMin, double);
118 
119  itkSetMacro(HistogramMax, double);
120  itkGetConstReferenceMacro(HistogramMax, double);
121 
122  itkSetMacro(GaussianSmoothing, bool);
123  itkGetConstReferenceMacro(GaussianSmoothing, bool);
124  itkBooleanMacro(GaussianSmoothing);
125 
126 protected:
129  {
130  }
131  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
132 
133 private:
135  void operator=(const Self&) = delete;
136 
137  unsigned int m_NeighborhoodRadius;
138  unsigned long m_NumberOfHistogramBins;
142 };
143 
144 } // namespace otb
145 
146 #ifndef OTB_MANUAL_INSTANTIATION
148 #endif
149 
150 #endif
Calculate a local histogram over a specified circular neighborhood.
LocalHistogramImageFunction(const Self &)=delete
itk::ImageFunction< TInputImage, typename itk::Statistics::Histogram< typename TInputImage::PixelType >::Pointer, TCoordRep > Superclass
void operator=(const Self &)=delete
OutputType Evaluate(const PointType &point) const override
OutputType EvaluateAtContinuousIndex(const ContinuousIndexType &cindex) const override
itk::SmartPointer< const Self > ConstPointer
Superclass::ContinuousIndexType ContinuousIndexType
itk::Statistics::Histogram< typename TInputImage::PixelType > HistogramType
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.