OTB  9.0.0
Orfeo Toolbox
otbBinaryImageDensityFunction.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 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:
115  BinaryImageDensityFunction(const Self&) = delete;
116  void operator=(const Self&) = delete;
117 
119 };
120 
121 } // end namespace otb
122 
123 #ifndef OTB_MANUAL_INSTANTIATION
125 #endif
126 
127 #endif
otb::BinaryImageDensityFunction::RadiusType
InputImageType::SizeType RadiusType
Definition: otbBinaryImageDensityFunction.h:67
otb::BinaryImageDensityFunction::Superclass
itk::ImageFunction< TInputImage, typename itk::NumericTraits< typename TInputImage::PixelType >::RealType, TCoordRep > Superclass
Definition: otbBinaryImageDensityFunction.h:55
otbBinaryImageDensityFunction.hxx
otb::BinaryImageDensityFunction::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbBinaryImageDensityFunction.h:56
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::BinaryImageDensityFunction::~BinaryImageDensityFunction
~BinaryImageDensityFunction() override
Definition: otbBinaryImageDensityFunction.h:109
otb::BinaryImageDensityFunction
Calculate the density pixel of in the neighborhood of a pixel.
Definition: otbBinaryImageDensityFunction.h:48
otb::BinaryImageDensityFunction::InputImageType
TInputImage InputImageType
Definition: otbBinaryImageDensityFunction.h:63
otb::BinaryImageDensityFunction::Evaluate
RealType Evaluate(const PointType &point) const override
Definition: otbBinaryImageDensityFunction.h:82
otb::BinaryImageDensityFunction::PointType
Superclass::PointType PointType
Definition: otbBinaryImageDensityFunction.h:71
otb::BinaryImageDensityFunction::EvaluateAtContinuousIndex
RealType EvaluateAtContinuousIndex(const ContinuousIndexType &cindex) const override
Definition: otbBinaryImageDensityFunction.h:88
otb::BinaryImageDensityFunction::SetNeighborhoodRadius
void SetNeighborhoodRadius(unsigned int rad)
Definition: otbBinaryImageDensityFunction.h:100
otb::BinaryImageDensityFunction::OutputType
Superclass::OutputType OutputType
Definition: otbBinaryImageDensityFunction.h:68
otb::BinaryImageDensityFunction::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbBinaryImageDensityFunction.h:57
otb::BinaryImageDensityFunction::Self
BinaryImageDensityFunction Self
Definition: otbBinaryImageDensityFunction.h:54
otb::BinaryImageDensityFunction::RealType
itk::NumericTraits< typename InputImageType::PixelType >::RealType RealType
Definition: otbBinaryImageDensityFunction.h:76
otb::BinaryImageDensityFunction::IndexType
Superclass::IndexType IndexType
Definition: otbBinaryImageDensityFunction.h:69
otb::BinaryImageDensityFunction::ContinuousIndexType
Superclass::ContinuousIndexType ContinuousIndexType
Definition: otbBinaryImageDensityFunction.h:70
otb::BinaryImageDensityFunction::m_NeighborhoodRadius
RadiusType m_NeighborhoodRadius
Definition: otbBinaryImageDensityFunction.h:118