OTB  9.0.0
Orfeo Toolbox
otbHessianToScalarImageFilter.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 otbHessianToScalarImageFilter_h
22 #define otbHessianToScalarImageFilter_h
23 
24 #include "itkUnaryFunctorImageFilter.h"
25 
26 namespace otb
27 {
28 
35 namespace Functor
36 {
37 
38 template <class TInput, class TOutput>
40 {
41 public:
43  {
44  m_Alpha = 1.0;
45  }
46  virtual ~HessianToScalar()
47  {
48  }
49  inline TOutput operator()(const TInput& Hessian)
50  {
51 
52  TOutput det;
53  TOutput trace;
54  TOutput result;
55 
56  det = static_cast<TOutput>(Hessian(0, 0) * Hessian(1, 1) - Hessian(0, 1) * Hessian(1, 0));
57  trace = static_cast<TOutput>(Hessian(0, 0) + Hessian(1, 1));
58 
59  result = det - (static_cast<TOutput>(m_Alpha) * trace * trace);
60 
61  return result;
62  }
63 
64  void SetAlpha(double Alpha)
65  {
66  m_Alpha = Alpha;
67  }
68  double GetAlpha(void) const
69  {
70  return (m_Alpha);
71  }
72 
73 private:
74  double m_Alpha;
75 };
76 }
77 
78 template <class TInputImage, class TOutputImage>
80  : public itk::UnaryFunctorImageFilter<TInputImage, TOutputImage,
81  Functor::HessianToScalar<typename TInputImage::PixelType, typename TOutputImage::PixelType>>
82 {
83 public:
86  typedef typename itk::UnaryFunctorImageFilter<TInputImage, TOutputImage,
89  typedef itk::SmartPointer<Self> Pointer;
90  typedef itk::SmartPointer<const Self> ConstPointer;
91 
93  itkNewMacro(Self);
94 
95  void SetAlpha(double Alpha)
96  {
97  this->GetFunctor().SetAlpha(Alpha);
98  this->Modified();
99  }
100  double GetAlpha(void) const
101  {
102  return (this->GetFunctor().GetAlpha());
103  }
104 
105 protected:
107  {
108  }
110  {
111  }
112 
113 private:
114  HessianToScalarImageFilter(const Self&) = delete;
115  void operator=(const Self&) = delete;
116 };
117 
118 } // end namespace otb
119 
120 #endif
otb::Functor::HessianToScalar::operator()
TOutput operator()(const TInput &Hessian)
Definition: otbHessianToScalarImageFilter.h:49
otb::HessianToScalarImageFilter::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbHessianToScalarImageFilter.h:90
otb::Functor::HessianToScalar::~HessianToScalar
virtual ~HessianToScalar()
Definition: otbHessianToScalarImageFilter.h:46
otb::Functor::HessianToScalar::GetAlpha
double GetAlpha(void) const
Definition: otbHessianToScalarImageFilter.h:68
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::Functor::HessianToScalar::m_Alpha
double m_Alpha
Definition: otbHessianToScalarImageFilter.h:74
otb::HessianToScalarImageFilter::~HessianToScalarImageFilter
~HessianToScalarImageFilter() override
Definition: otbHessianToScalarImageFilter.h:109
otb::HessianToScalarImageFilter::HessianToScalarImageFilter
HessianToScalarImageFilter()
Definition: otbHessianToScalarImageFilter.h:106
otb::HessianToScalarImageFilter::Self
HessianToScalarImageFilter Self
Definition: otbHessianToScalarImageFilter.h:85
otb::Functor::HessianToScalar::HessianToScalar
HessianToScalar()
Definition: otbHessianToScalarImageFilter.h:42
otb::HessianToScalarImageFilter::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbHessianToScalarImageFilter.h:89
otb::HessianToScalarImageFilter
TODO.
Definition: otbHessianToScalarImageFilter.h:79
otb::HessianToScalarImageFilter::GetAlpha
double GetAlpha(void) const
Definition: otbHessianToScalarImageFilter.h:100
otb::HessianToScalarImageFilter::Superclass
itk::UnaryFunctorImageFilter< TInputImage, TOutputImage, Functor::HessianToScalar< typename TInputImage::PixelType, typename TOutputImage::PixelType > > Superclass
Definition: otbHessianToScalarImageFilter.h:88
otb::Functor::HessianToScalar::SetAlpha
void SetAlpha(double Alpha)
Definition: otbHessianToScalarImageFilter.h:64
otb::Functor::HessianToScalar
Definition: otbHessianToScalarImageFilter.h:39
otb::HessianToScalarImageFilter::SetAlpha
void SetAlpha(double Alpha)
Definition: otbHessianToScalarImageFilter.h:95