OTB  6.7.0
Orfeo Toolbox
otbLocalHistogramImageFunction.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2019 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 >
55 class ITK_EXPORT LocalHistogramImageFunction :
56  public itk::ImageFunction< TInputImage,
57  typename itk::Statistics::Histogram<typename TInputImage::PixelType>::Pointer,
58  TCoordRep >
59 {
60 public:
63  typedef itk::ImageFunction< TInputImage,
65  TCoordRep > Superclass;
68 
70  itkTypeMacro(LocalHistogramImageFunction, ImageFunction);
71 
73  itkNewMacro(Self);
74 
76  typedef TInputImage InputImageType;
77  typedef typename Superclass::IndexType IndexType;
78  typedef typename Superclass::ContinuousIndexType ContinuousIndexType;
79  typedef typename Superclass::PointType PointType;
80 
84 
85  typedef TCoordRep CoordRepType;
86 
88  itkStaticConstMacro(ImageDimension, unsigned int,
89  InputImageType::ImageDimension);
90 
92  OutputType EvaluateAtIndex(const IndexType& index) const override;
93 
95  OutputType Evaluate(const PointType& point) const override
96  {
97  IndexType index;
98  this->ConvertPointToNearestIndex(point, index);
99  return this->EvaluateAtIndex(index);
100  }
102  const ContinuousIndexType& cindex) const override
103  {
104  IndexType index;
105  this->ConvertContinuousIndexToNearestIndex(cindex, index);
106  return this->EvaluateAtIndex(index);
107  }
109 
113  itkSetMacro( NeighborhoodRadius, unsigned int );
114  itkGetConstReferenceMacro( NeighborhoodRadius, unsigned int );
116 
118  itkSetClampMacro( NumberOfHistogramBins, unsigned long, 1, itk::NumericTraits<unsigned long>::max() );
119  itkGetConstMacro( NumberOfHistogramBins, unsigned long );
121 
122  itkSetMacro( HistogramMin, double );
123  itkGetConstReferenceMacro( HistogramMin, double );
124 
125  itkSetMacro( HistogramMax, double );
126  itkGetConstReferenceMacro( HistogramMax, double );
127 
128  itkSetMacro(GaussianSmoothing, bool);
129  itkGetConstReferenceMacro(GaussianSmoothing, bool);
130  itkBooleanMacro(GaussianSmoothing);
131 
132 protected:
135  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
136 
137 private:
138  LocalHistogramImageFunction(const Self &) = delete;
139  void operator =(const Self&) = delete;
140 
141  unsigned int m_NeighborhoodRadius;
142  unsigned long m_NumberOfHistogramBins;
146 };
147 
148 } // namespace otb
149 
150 #ifndef OTB_MANUAL_INSTANTIATION
152 #endif
153 
154 #endif
155 
OutputType EvaluateAtContinuousIndex(const ContinuousIndexType &cindex) const override
Calculate a local histogram over a specified circular neighborhood.
itk::SmartPointer< const Self > ConstPointer
itk::Statistics::Histogram< typename TInputImage::PixelType > HistogramType
OutputType Evaluate(const PointType &point) const override
itk::Index< Monteverdi_DIMENSION > IndexType
Definition: mvdTypes.h:133
itk::ImageFunction< TInputImage, typename itk::Statistics::Histogram< typename TInputImage::PixelType >::Pointer, TCoordRep > Superclass
Superclass::ContinuousIndexType ContinuousIndexType
VectorImageType::PointType PointType
Definition: mvdTypes.h:189