OTB  9.0.0
Orfeo Toolbox
otbSqrtSpectralAngleFunctor.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 otbSqrtSpectralAngleFunctor_h
22 #define otbSqrtSpectralAngleFunctor_h
23 
25 #include "itkMacro.h"
26 
27 namespace otb
28 {
29 
30 namespace Functor
31 {
32 
44 template <class TInput, class TOutputValue>
46 {
47 public:
49  {
50  m_ReferencePixel.SetSize(4);
51  m_ReferencePixel.Fill(1);
52  }
53 
54  virtual ~SqrtSpectralAngleFunctor() = default;
55 
56  // Binary operator
57  inline TOutputValue operator()(TInput const & inPix) const
58  {
59  return std::sqrt(SpectralAngleDetails::ComputeSpectralAngle<TInput, TInput, TOutputValue>(inPix, inPix.GetNorm(), m_ReferencePixel, m_RefNorm));
60  }
61 
62  void SetReferencePixel(TInput const & ref)
63  {
64  m_ReferencePixel = ref;
65  m_RefNorm = ref.GetNorm();
66  }
67 
68  TInput GetReferencePixel() const
69  {
70  return m_ReferencePixel;
71  }
72 
73 private :
75  double m_RefNorm;
76 };
77 
78 } // end namespace Functor
79 } // end namespace otb
80 
81 #ifndef OTB_MANUAL_INSTANTIATION
82 #endif
83 
84 #endif
otb::Functor::SqrtSpectralAngleFunctor::m_ReferencePixel
TInput m_ReferencePixel
Definition: otbSqrtSpectralAngleFunctor.h:74
otb::Functor::SqrtSpectralAngleFunctor::SetReferencePixel
void SetReferencePixel(TInput const &ref)
Definition: otbSqrtSpectralAngleFunctor.h:62
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::Functor::SqrtSpectralAngleFunctor::~SqrtSpectralAngleFunctor
virtual ~SqrtSpectralAngleFunctor()=default
otb::Functor::SqrtSpectralAngleFunctor::m_RefNorm
double m_RefNorm
Definition: otbSqrtSpectralAngleFunctor.h:75
otb::Functor::SqrtSpectralAngleFunctor::SqrtSpectralAngleFunctor
SqrtSpectralAngleFunctor()
Definition: otbSqrtSpectralAngleFunctor.h:48
otb::Functor::SqrtSpectralAngleFunctor::operator()
TOutputValue operator()(TInput const &inPix) const
Definition: otbSqrtSpectralAngleFunctor.h:57
otb::Functor::SqrtSpectralAngleFunctor::GetReferencePixel
TInput GetReferencePixel() const
Definition: otbSqrtSpectralAngleFunctor.h:68
otbSpectralAngleFunctor.h
otb::Functor::SqrtSpectralAngleFunctor
This functor computes the square root of a spectral angle according to a reference pixel.
Definition: otbSqrtSpectralAngleFunctor.h:45