OTB  6.7.0
Orfeo Toolbox
otbDotProductImageFilter.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2019 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
virtual ~DotProductFunctor()=default
OutputType operator()(const InputType &in)
A generic functor filter templated by its functor.
Computes the dot product against a specific vector.