OTB  10.0.0
Orfeo Toolbox
otbBinaryImageDensityFunction.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 otbBinaryImageDensityFunction_h
22 #define otbBinaryImageDensityFunction_h
23 
24 #include "itkImageFunction.h"
25 #include "itkNumericTraits.h"
26 
27 namespace otb
28 {
29 
47 template <class TInputImage, class TCoordRep = float>
49  : public itk::ImageFunction<TInputImage, typename itk::NumericTraits<typename TInputImage::PixelType>::RealType, TCoordRep>
50 {
51 public:
52 
55  typedef itk::ImageFunction<TInputImage, typename itk::NumericTraits<typename TInputImage::PixelType>::RealType, TCoordRep> Superclass;
56  typedef itk::SmartPointer<Self> Pointer;
57  typedef itk::SmartPointer<const Self> ConstPointer;
58 
60  itkTypeMacro(BinaryImageDensityFunction, itk::ImageFunction);
61 
63  itkNewMacro(Self);
64 
66  typedef TInputImage InputImageType;
67  typedef typename InputImageType::SizeType RadiusType;
68  typedef typename Superclass::OutputType OutputType;
69  typedef typename Superclass::IndexType IndexType;
70  typedef typename Superclass::ContinuousIndexType ContinuousIndexType;
71  typedef typename Superclass::PointType PointType;
72 
73  itkStaticConstMacro(ImageDimension, unsigned int, InputImageType::ImageDimension);
74 
76  typedef typename itk::NumericTraits<typename InputImageType::PixelType>::RealType RealType;
77 
79  RealType EvaluateAtIndex(const IndexType& index) const override;
80 
82  RealType Evaluate(const PointType& point) const override
83  {
84  IndexType index;
85  this->ConvertPointToNearestIndex(point, index);
86  return this->EvaluateAtIndex(index);
87  }
89  {
90  IndexType index;
91  this->ConvertContinuousIndexToNearestIndex(cindex, index);
92  return this->EvaluateAtIndex(index);
93  }
95 
98  itkSetMacro(NeighborhoodRadius, RadiusType);
99  itkGetConstReferenceMacro(NeighborhoodRadius, RadiusType);
100  void SetNeighborhoodRadius(unsigned int rad)
101  {
102  m_NeighborhoodRadius.Fill(rad);
103  this->Modified();
104  }
106 
107 protected:
110  {
111  }
112  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
113 
114 private:
116  void operator=(const Self&) = delete;
117 
119 };
120 
121 } // end namespace otb
122 
123 #ifndef OTB_MANUAL_INSTANTIATION
125 #endif
126 
127 #endif
Calculate the density pixel of in the neighborhood of a pixel.
BinaryImageDensityFunction(const Self &)=delete
itk::NumericTraits< typename InputImageType::PixelType >::RealType RealType
itk::ImageFunction< TInputImage, typename itk::NumericTraits< typename TInputImage::PixelType >::RealType, TCoordRep > Superclass
Superclass::ContinuousIndexType ContinuousIndexType
void operator=(const Self &)=delete
RealType EvaluateAtContinuousIndex(const ContinuousIndexType &cindex) const override
itk::SmartPointer< const Self > ConstPointer
RealType Evaluate(const PointType &point) const override
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.