OTB  6.7.0
Orfeo Toolbox
otbNCLSUnmixingImageFilter.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2017 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"
27 #include "vnl/algo/vnl_svd.h"
28 #include <boost/shared_ptr.hpp>
29 
30 namespace otb
31 {
32 
33 namespace Functor {
34 
42 template<class TInput, class TOutput, class TPrecision>
44 {
45 public:
47 
48  typedef TInput InputType;
49  typedef TOutput OutputType;
50  typedef TPrecision PrecisionType;
51 
52  typedef vnl_vector<PrecisionType> VectorType;
53  typedef vnl_matrix<PrecisionType> MatrixType;
54 
56  virtual ~NCLSUnmixingFunctor();
57 
58  unsigned int GetOutputSize() const;
59 
60  bool operator !=(const NCLSUnmixingFunctor& other) const;
61 
62  bool operator ==(const NCLSUnmixingFunctor& other) const;
63 
64  void SetEndmembersMatrix(const MatrixType& U);
65  const MatrixType& GetEndmembersMatrix(void) const;
66 
67  void SetMaxIteration(unsigned int val)
68  {
69  m_MaxIteration = val;
70  }
71 
72  unsigned int GetMaxIteration() const
73  {
74  return m_MaxIteration;
75  }
76 
77  OutputType operator ()(const InputType& in) const;
78 
79 private:
80 
81  static bool IsNonNegative(PrecisionType val)
82  {
83  return val >= 0;
84  }
85 
86  typedef vnl_svd<PrecisionType> SVDType;
87  typedef boost::shared_ptr<SVDType> SVDPointerType;
88 
92  SVDPointerType m_Svd; // SVD of U
93  unsigned int m_OutputSize;
94  unsigned int m_MaxIteration;
95 };
96 }
97 
124 template <class TInputImage, class TOutputImage, class TPrecision>
125 class ITK_EXPORT NCLSUnmixingImageFilter :
126  public otb::UnaryFunctorImageFilter<TInputImage, TOutputImage,
127  Functor::NCLSUnmixingFunctor<typename TInputImage::PixelType,
128  typename TOutputImage::PixelType, TPrecision> >
129 {
130 public:
134  <TInputImage,
135  TOutputImage,
137  typename TInputImage::PixelType,
138  typename TOutputImage::PixelType,
139  TPrecision>
143 
145  typename TInputImage::PixelType,
146  typename TOutputImage::PixelType,
147  TPrecision> FunctorType;
149 
151  itkNewMacro(Self);
152 
155 
157  typedef typename TInputImage::PixelType InputPixelType;
158  typedef typename TOutputImage::PixelType OutputPixelType;
159 
160  void SetEndmembersMatrix(const MatrixType& m);
161  const MatrixType& GetEndmembersMatrix() const;
162 
163  void SetMaxIteration( unsigned int val )
164  {
165  this->GetFunctor().SetMaxIteration(val);
166  this->Modified();
167  }
168 
169  unsigned int GetMaxIteration() const
170  {
171  return this->GetFunctor().GetMaxIteration();
172  }
173 
174 protected:
176 
177  ~NCLSUnmixingImageFilter() override;
178 
179  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
180 
181 private:
182  NCLSUnmixingImageFilter(const Self &) = delete;
183  void operator =(const Self&) = delete;
184 
185 };
186 
187 } // end namespace otb
188 
189 #ifndef OTB_MANUAL_INSTANTIATION
191 #endif
192 
193 #endif
194 
Implements pixel-wise generic operation on one image.
const MatrixType & GetEndmembersMatrix(void) const
bool operator==(const NCLSUnmixingFunctor &other) const
static bool IsNonNegative(PrecisionType val)
bool operator!=(const NCLSUnmixingFunctor &other) const
Performs fully constrained least squares on each pixel of a VectorImage.
OutputType operator()(const InputType &in) const
Functor::NCLSUnmixingFunctor< typename TInputImage::PixelType, typename TOutputImage::PixelType, TPrecision > FunctorType
boost::shared_ptr< SVDType > SVDPointerType
NCLSUnmixingFunctor< TInput, TOutput, TPrecision > Self
otb::UnaryFunctorImageFilter< TInputImage, TOutputImage, Functor::NCLSUnmixingFunctor< typename TInputImage::PixelType, typename TOutputImage::PixelType, TPrecision > > Superclass
itk::SmartPointer< const Self > ConstPointer