OTB  9.0.0
Orfeo Toolbox
otbLocalHistogramImageFunction.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 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:
134  LocalHistogramImageFunction(const Self&) = delete;
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
otb::LocalHistogramImageFunction::OutputType
Superclass::OutputType OutputType
Definition: otbLocalHistogramImageFunction.h:77
otbLocalHistogramImageFunction.hxx
otb::LocalHistogramImageFunction::IndexType
Superclass::IndexType IndexType
Definition: otbLocalHistogramImageFunction.h:73
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::LocalHistogramImageFunction::m_HistogramMin
double m_HistogramMin
Definition: otbLocalHistogramImageFunction.h:139
otb::LocalHistogramImageFunction::ContinuousIndexType
Superclass::ContinuousIndexType ContinuousIndexType
Definition: otbLocalHistogramImageFunction.h:74
otb::LocalHistogramImageFunction::InputImageType
TInputImage InputImageType
Definition: otbLocalHistogramImageFunction.h:69
otb::LocalHistogramImageFunction::m_HistogramMax
double m_HistogramMax
Definition: otbLocalHistogramImageFunction.h:140
otb::LocalHistogramImageFunction::PointType
Superclass::PointType PointType
Definition: otbLocalHistogramImageFunction.h:75
otb::LocalHistogramImageFunction::HistogramType
itk::Statistics::Histogram< typename TInputImage::PixelType > HistogramType
Definition: otbLocalHistogramImageFunction.h:78
otb::LocalHistogramImageFunction::m_NumberOfHistogramBins
unsigned long m_NumberOfHistogramBins
Definition: otbLocalHistogramImageFunction.h:138
otb::LocalHistogramImageFunction::m_NeighborhoodRadius
unsigned int m_NeighborhoodRadius
Definition: otbLocalHistogramImageFunction.h:137
otb::LocalHistogramImageFunction::EvaluateAtContinuousIndex
OutputType EvaluateAtContinuousIndex(const ContinuousIndexType &cindex) const override
Definition: otbLocalHistogramImageFunction.h:96
otb::LocalHistogramImageFunction::m_GaussianSmoothing
bool m_GaussianSmoothing
Definition: otbLocalHistogramImageFunction.h:141
otb::LocalHistogramImageFunction::CoordRepType
TCoordRep CoordRepType
Definition: otbLocalHistogramImageFunction.h:81
otb::LocalHistogramImageFunction
Calculate a local histogram over a specified circular neighborhood.
Definition: otbLocalHistogramImageFunction.h:55
otb::LocalHistogramImageFunction::Self
LocalHistogramImageFunction Self
Definition: otbLocalHistogramImageFunction.h:60
otb::LocalHistogramImageFunction::Evaluate
OutputType Evaluate(const PointType &point) const override
Definition: otbLocalHistogramImageFunction.h:90
otb::LocalHistogramImageFunction::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbLocalHistogramImageFunction.h:62
otb::LocalHistogramImageFunction::~LocalHistogramImageFunction
~LocalHistogramImageFunction() override
Definition: otbLocalHistogramImageFunction.h:128
otb::LocalHistogramImageFunction::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbLocalHistogramImageFunction.h:63
otb::LocalHistogramImageFunction::HistogramPointer
HistogramType::Pointer HistogramPointer
Definition: otbLocalHistogramImageFunction.h:79
otb::LocalHistogramImageFunction::Superclass
itk::ImageFunction< TInputImage, typename itk::Statistics::Histogram< typename TInputImage::PixelType >::Pointer, TCoordRep > Superclass
Definition: otbLocalHistogramImageFunction.h:61