OTB  9.0.0
Orfeo Toolbox
otbDotProductImageFilter.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 otbDotProductImageFilter_h
22 #define otbDotProductImageFilter_h
23 
24 #include "itkMacro.h"
25 #include "otbFunctorImageFilter.h"
26 
27 namespace otb
28 {
29 
30 namespace Functor
31 {
32 
39 template <class TInput, class TOutput>
41 {
42 public:
43  typedef TInput InputType;
44  typedef TOutput OutputType;
45 
46  DotProductFunctor() = default;
47  virtual ~DotProductFunctor() = default;
48 
50  {
51  return m_Vector;
52  }
53 
54  void SetVector(const InputType& m)
55  {
56  m_Vector = m;
57  }
58 
60  {
61  assert(in.Size() == m_Vector.Size());
62  OutputType result = 0;
63  for (unsigned int i = 0; i < in.Size(); ++i)
64  {
65  result += in[i] * m_Vector[i];
66  }
67  return result;
68  }
69 
70 private:
72 };
73 } // namespace Functor
74 
89 template <typename TInputImage, typename TOutputImage>
91 
92 } // namespace otb
93 #endif
otbFunctorImageFilter.h
otb::Functor::DotProductFunctor::OutputType
TOutput OutputType
Definition: otbDotProductImageFilter.h:44
otb::Functor::DotProductFunctor::DotProductFunctor
DotProductFunctor()=default
otb::FunctorImageFilter
A generic functor filter templated by its functor.
Definition: otbFunctorImageFilter.h:322
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::Functor::DotProductFunctor::operator()
OutputType operator()(const InputType &in)
Definition: otbDotProductImageFilter.h:59
otb::Functor::DotProductFunctor::m_Vector
InputType m_Vector
Definition: otbDotProductImageFilter.h:71
otb::Functor::DotProductFunctor::~DotProductFunctor
virtual ~DotProductFunctor()=default
otb::Functor::DotProductFunctor::GetVector
const InputType & GetVector()
Definition: otbDotProductImageFilter.h:49
otb::Functor::DotProductFunctor::InputType
TInput InputType
Definition: otbDotProductImageFilter.h:43
otb::Functor::DotProductFunctor
Computes the dot product against a specific vector.
Definition: otbDotProductImageFilter.h:40
otb::Functor::DotProductFunctor::SetVector
void SetVector(const InputType &m)
Definition: otbDotProductImageFilter.h:54