OTB  9.0.0
Orfeo Toolbox
otbLog10ThresholdedImageFilter.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 otbLog10ThresholdedImageFilter_h
22 #define otbLog10ThresholdedImageFilter_h
23 
24 #include "itkUnaryFunctorImageFilter.h"
25 #include "vnl/vnl_math.h"
26 
27 namespace otb
28 {
34 namespace Functor
35 {
36 template <class TInput, class TOutput>
38 {
39 public:
41  {
42  m_ThresholdValue = 0.001; // -> -30dB
43  }
45  {
46  }
47 
48  bool operator!=(const Log10Thresholded&) const
49  {
50  return false;
51  }
52  bool operator==(const Log10Thresholded& other) const
53  {
54  return !(*this != other);
55  }
56  inline TOutput operator()(const TInput& A) const
57  {
58  if ((static_cast<double>(A) >= m_ThresholdValue) && (A == A))
59  {
60  return static_cast<TOutput>(10.0 * std::log10(static_cast<double>(A)));
61  }
62  else // If (A != A) then A is a NaN
63  {
64  return static_cast<TOutput>(10.0 * std::log10(m_ThresholdValue));
65  }
66  }
67 
69  void SetThresholdValue(const double value)
70  {
71  if (value > 0.0)
72  {
73  m_ThresholdValue = value;
74  }
75  }
77 
78 private:
80 };
81 } // End namespace Functor
82 
83 template <class TInputImage, class TOutputImage>
85  : public itk::UnaryFunctorImageFilter<TInputImage, TOutputImage,
86  Functor::Log10Thresholded<typename TInputImage::PixelType, typename TOutputImage::PixelType>>
87 {
88 public:
92  typedef itk::UnaryFunctorImageFilter<TInputImage, TOutputImage, FunctorType> Superclass;
93  typedef itk::SmartPointer<Self> Pointer;
94  typedef itk::SmartPointer<const Self> ConstPointer;
95 
97  itkNewMacro(Self);
98 
100  itkTypeMacro(Log10ThresholdedImageFilter, itk::UnaryFunctorImageFilter);
101 
102  void SetThresholdedValue(double val)
103  {
104  this->GetFunctor().SetThresholdValue(val);
105  }
106 
107 protected:
109  {
110  }
112  {
113  }
114 
115 private:
116  Log10ThresholdedImageFilter(const Self&) = delete;
117  void operator=(const Self&) = delete;
118 };
119 
120 } // end namespace otb
121 
122 #endif
otb::Log10ThresholdedImageFilter
Computes the 10 * std::log10(x) pixel-wise with a threshold for the lowest values.
Definition: otbLog10ThresholdedImageFilter.h:84
otb::Functor::Log10Thresholded::m_ThresholdValue
double m_ThresholdValue
Definition: otbLog10ThresholdedImageFilter.h:79
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::Log10ThresholdedImageFilter::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbLog10ThresholdedImageFilter.h:94
otb::Functor::Log10Thresholded::~Log10Thresholded
~Log10Thresholded()
Definition: otbLog10ThresholdedImageFilter.h:44
otb::Functor::Log10Thresholded::SetThresholdValue
void SetThresholdValue(const double value)
Definition: otbLog10ThresholdedImageFilter.h:69
otb::Log10ThresholdedImageFilter::Log10ThresholdedImageFilter
Log10ThresholdedImageFilter()
Definition: otbLog10ThresholdedImageFilter.h:108
otb::Log10ThresholdedImageFilter::SetThresholdedValue
void SetThresholdedValue(double val)
Definition: otbLog10ThresholdedImageFilter.h:102
otb::Log10ThresholdedImageFilter::~Log10ThresholdedImageFilter
~Log10ThresholdedImageFilter() override
Definition: otbLog10ThresholdedImageFilter.h:111
otb::Log10ThresholdedImageFilter::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbLog10ThresholdedImageFilter.h:93
otb::Functor::Log10Thresholded
Definition: otbLog10ThresholdedImageFilter.h:37
otb::Functor::Log10Thresholded::operator==
bool operator==(const Log10Thresholded &other) const
Definition: otbLog10ThresholdedImageFilter.h:52
otb::Log10ThresholdedImageFilter::Superclass
itk::UnaryFunctorImageFilter< TInputImage, TOutputImage, FunctorType > Superclass
Definition: otbLog10ThresholdedImageFilter.h:92
otb::Functor::Log10Thresholded::Log10Thresholded
Log10Thresholded()
Definition: otbLog10ThresholdedImageFilter.h:40
otb::Functor::Log10Thresholded::operator()
TOutput operator()(const TInput &A) const
Definition: otbLog10ThresholdedImageFilter.h:56
otb::Log10ThresholdedImageFilter::FunctorType
Functor::Log10Thresholded< typename TInputImage::PixelType, typename TOutputImage::PixelType > FunctorType
Definition: otbLog10ThresholdedImageFilter.h:91
otb::Log10ThresholdedImageFilter::Self
Log10ThresholdedImageFilter Self
Definition: otbLog10ThresholdedImageFilter.h:90
otb::Functor::Log10Thresholded::operator!=
bool operator!=(const Log10Thresholded &) const
Definition: otbLog10ThresholdedImageFilter.h:48