OTB  6.7.0
Orfeo Toolbox
otbNCLSUnmixingImageFilter.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 otbNCLSUnmixingImageFilter_h
22 #define otbNCLSUnmixingImageFilter_h
23 
24 #include "itkMacro.h"
25 #include "itkNumericTraits.h"
26 #include "otbFunctorImageFilter.h"
27 #include "vnl/algo/vnl_svd.h"
28 #include <boost/shared_ptr.hpp>
29 
30 namespace otb
31 {
32 
33 namespace Functor {
34 
43 template<class TInput, class TOutput, class TPrecision>
45 {
46 public:
48 
49  typedef TInput InputType;
50  typedef TOutput OutputType;
51  typedef TPrecision PrecisionType;
52 
53  typedef vnl_vector<PrecisionType> VectorType;
54  typedef vnl_matrix<PrecisionType> MatrixType;
55 
57  virtual ~NCLSUnmixingFunctor() = default;
58 
59  size_t OutputSize(const std::array<size_t, 1>& nbBands) const;
60 
61  void SetEndmembersMatrix(const MatrixType& U);
62  const MatrixType& GetEndmembersMatrix(void) const;
63 
64  void SetMaxIteration(unsigned int val)
65  {
66  m_MaxIteration = val;
67  }
68 
69  unsigned int GetMaxIteration() const
70  {
71  return m_MaxIteration;
72  }
73 
74  OutputType operator ()(const InputType& in) const;
75 
76 private:
77 
78  static bool IsNonNegative(PrecisionType val)
79  {
80  return val >= 0;
81  }
82 
83  typedef vnl_svd<PrecisionType> SVDType;
84  typedef boost::shared_ptr<SVDType> SVDPointerType;
85 
89  SVDPointerType m_Svd; // SVD of U
90  unsigned int m_OutputSize;
91  unsigned int m_MaxIteration;
92 };
93 }
94 
121 template <typename TInputImage, typename TOutputImage, typename TPrecision>
123 
124 } // end namespace otb
125 
126 #ifndef OTB_MANUAL_INSTANTIATION
128 #endif
129 
130 #endif
131 
virtual ~NCLSUnmixingFunctor()=default
const MatrixType & GetEndmembersMatrix(void) const
vcl_size_t OutputSize(const std::array< vcl_size_t, 1 > &nbBands) const
static bool IsNonNegative(PrecisionType val)
OutputType operator()(const InputType &in) const
Performs fully constrained least squares on a pixel.
boost::shared_ptr< SVDType > SVDPointerType
A generic functor filter templated by its functor.
NCLSUnmixingFunctor< TInput, TOutput, TPrecision > Self