OTB  6.1.0
Orfeo Toolbox
otbISRAUnmixingImageFilter.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 otbISRAUnmixingImageFilter_h
22 #define otbISRAUnmixingImageFilter_h
23 
24 #include "itkNumericTraits.h"
26 #include "vnl/algo/vnl_svd.h"
27 #include <boost/shared_ptr.hpp>
28 
29 namespace otb
30 {
31 
32 namespace Functor {
33 
41 template<class TInput, class TOutput, class TPrecision>
43 {
44 public:
46 
47  typedef TInput InputType;
48  typedef TOutput OutputType;
49  typedef TPrecision PrecisionType;
50 
51  typedef vnl_vector<PrecisionType> VectorType;
52  typedef vnl_matrix<PrecisionType> MatrixType;
53 
55  virtual ~ISRAUnmixingFunctor();
56 
57  unsigned int GetOutputSize() const;
58 
59  bool operator !=(const ISRAUnmixingFunctor& other) const;
60 
61  bool operator ==(const ISRAUnmixingFunctor& other) const;
62 
63  void SetEndmembersMatrix(const MatrixType& U);
64  const MatrixType& GetEndmembersMatrix(void) const;
65 
66  void SetMaxIteration(unsigned int val)
67  {
68  m_MaxIteration = val;
69  }
70 
71  unsigned int GetMaxIteration() const
72  {
73  return m_MaxIteration;
74  }
75 
76  OutputType operator ()(const InputType& in) const;
77 
78 private:
79 
80  static bool IsNonNegative(PrecisionType val)
81  {
82  return val >= 0;
83  }
84 
85  typedef vnl_svd<PrecisionType> SVDType;
86  typedef boost::shared_ptr<SVDType> SVDPointerType;
87 
89  SVDPointerType m_Svd; // SVD of U
90  unsigned int m_OutputSize;
91  unsigned int m_MaxIteration;
92 };
93 }
94 
121 template <class TInputImage, class TOutputImage, class TPrecision>
122 class ITK_EXPORT ISRAUnmixingImageFilter :
123  public otb::UnaryFunctorImageFilter<TInputImage, TOutputImage,
124  Functor::ISRAUnmixingFunctor<typename TInputImage::PixelType,
125  typename TOutputImage::PixelType, TPrecision> >
126 {
127 public:
131  <TInputImage,
132  TOutputImage,
134  typename TInputImage::PixelType,
135  typename TOutputImage::PixelType,
136  TPrecision>
140 
142  typename TInputImage::PixelType,
143  typename TOutputImage::PixelType,
144  TPrecision> FunctorType;
146 
148  itkNewMacro(Self);
149 
152 
154  typedef typename TInputImage::PixelType InputPixelType;
155  typedef typename TOutputImage::PixelType OutputPixelType;
156 
157  void SetEndmembersMatrix(const MatrixType& m);
158  const MatrixType& GetEndmembersMatrix() const;
159 
160  void SetMaxIteration( unsigned int val )
161  {
162  this->GetFunctor().SetMaxIteration(val);
163  this->Modified();
164  }
165 
166  unsigned int GetMaxIteration() const
167  {
168  return this->GetFunctor().GetMaxIteration();
169  }
170 
171 protected:
173 
174  ~ISRAUnmixingImageFilter() ITK_OVERRIDE;
175 
176  void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE;
177 
178 private:
179  ISRAUnmixingImageFilter(const Self &); //purposely not implemented
180  void operator =(const Self&); //purposely not implemented
181 
182 };
183 
184 } // end namespace otb
185 
186 #ifndef OTB_MANUAL_INSTANTIATION
188 #endif
189 
190 #endif
191 
Implements pixel-wise generic operation on one image.
itk::SmartPointer< const Self > ConstPointer
Functor::ISRAUnmixingFunctor< typename TInputImage::PixelType, typename TOutputImage::PixelType, TPrecision > FunctorType
boost::shared_ptr< SVDType > SVDPointerType
bool operator==(const ISRAUnmixingFunctor &other) const
otb::UnaryFunctorImageFilter< TInputImage, TOutputImage, Functor::ISRAUnmixingFunctor< typename TInputImage::PixelType, typename TOutputImage::PixelType, TPrecision > > Superclass
static bool IsNonNegative(PrecisionType val)
OutputType operator()(const InputType &in) const
Performs fully constrained least squares on each pixel of a VectorImage.
bool operator!=(const ISRAUnmixingFunctor &other) const
ISRAUnmixingFunctor< TInput, TOutput, TPrecision > Self
const MatrixType & GetEndmembersMatrix(void) const