OTB  9.0.0
Orfeo Toolbox
otbUnConstrainedLeastSquareImageFilter.hxx
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 otbUnConstrainedLeastSquareImageFilter_hxx
22 #define otbUnConstrainedLeastSquareImageFilter_hxx
23 
25 
26 namespace otb
27 {
28 namespace Functor
29 {
30 
31 template <class TInput, class TOutput, class TPrecision>
33 {
34  return m_OutputSize;
35 }
36 
37 template <class TInput, class TOutput, class TPrecision>
39 {
40  m_Svd.reset(new SVDType(m));
41  m_Inv = m_Svd->inverse();
42  m_OutputSize = m.cols();
43 }
44 
45 template <class TInput, class TOutput, class TPrecision>
47 operator()(const InputType& in) const
48 {
49  VectorType inVector(in.Size());
50  for (unsigned int i = 0; i < in.GetSize(); ++i)
51  {
52  inVector[i] = in[i];
53  }
54 
55  VectorType outVector = m_Inv * inVector;
56 
57  OutputType out(outVector.size());
58  for (unsigned int i = 0; i < out.GetSize(); ++i)
59  {
60  out[i] = outVector[i];
61  }
62 
63  return out;
64 }
65 
66 
67 } // end namespace Functor
68 } // end namespace otb
69 
70 #endif
otb::Functor::UnConstrainedLeastSquareFunctor::SetMatrix
void SetMatrix(const MatrixType &m)
Definition: otbUnConstrainedLeastSquareImageFilter.hxx:38
otb::Functor::UnConstrainedLeastSquareFunctor::OutputSize
vcl_size_t OutputSize(const std::array< vcl_size_t, 1 > &nbBands) const
Definition: otbUnConstrainedLeastSquareImageFilter.hxx:32
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::Functor::UnConstrainedLeastSquareFunctor::operator()
OutputType operator()(const InputType &in) const
Definition: otbUnConstrainedLeastSquareImageFilter.hxx:47
otbUnConstrainedLeastSquareImageFilter.h
otb::Functor::UnConstrainedLeastSquareFunctor::OutputType
TOutput OutputType
Definition: otbUnConstrainedLeastSquareImageFilter.h:48
otb::Functor::UnConstrainedLeastSquareFunctor::MatrixType
vnl_matrix< PrecisionType > MatrixType
Definition: otbUnConstrainedLeastSquareImageFilter.h:52
otb::Functor::UnConstrainedLeastSquareFunctor::InputType
TInput InputType
Definition: otbUnConstrainedLeastSquareImageFilter.h:47
otb::Functor::UnConstrainedLeastSquareFunctor::SVDType
vnl_svd< PrecisionType > SVDType
Definition: otbUnConstrainedLeastSquareImageFilter.h:64
otb::Functor::UnConstrainedLeastSquareFunctor::VectorType
vnl_vector< PrecisionType > VectorType
Definition: otbUnConstrainedLeastSquareImageFilter.h:51