OTB  5.0.0
Orfeo Toolbox
otbISRAUnmixingImageFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ORFEO Toolbox
4  Language: C++
5  Date: $Date$
6  Version: $Revision$
7 
8 
9  Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
10  See OTBCopyright.txt for details.
11 
12 
13  This software is distributed WITHOUT ANY WARRANTY; without even
14  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  PURPOSE. See the above copyright notices for more information.
16 
17 =========================================================================*/
18 #ifndef __otbISRAUnmixingImageFilter_h
19 #define __otbISRAUnmixingImageFilter_h
20 
21 #include "itkNumericTraits.h"
23 #include "vnl/algo/vnl_svd.h"
24 #include <boost/shared_ptr.hpp>
25 
26 namespace otb
27 {
28 
29 namespace Functor {
30 
38 template<class TInput, class TOutput, class TPrecision>
40 {
41 public:
43 
44  typedef TInput InputType;
45  typedef TOutput OutputType;
46  typedef TPrecision PrecisionType;
47 
48  typedef vnl_vector<PrecisionType> VectorType;
49  typedef vnl_matrix<PrecisionType> MatrixType;
50 
52  virtual ~ISRAUnmixingFunctor();
53 
54  unsigned int GetOutputSize() const;
55 
56  bool operator !=(const ISRAUnmixingFunctor& other) const;
57 
58  bool operator ==(const ISRAUnmixingFunctor& other) const;
59 
60  void SetEndmembersMatrix(const MatrixType& U);
61  const MatrixType& GetEndmembersMatrix(void) const;
62 
63  void SetMaxIteration(unsigned int val)
64  {
65  m_MaxIteration = val;
66  }
67 
68  unsigned int GetMaxIteration() const
69  {
70  return m_MaxIteration;
71  }
72 
73  OutputType operator ()(const InputType& in) const;
74 
75 private:
76 
77  static bool IsNonNegative(PrecisionType val)
78  {
79  return val >= 0;
80  }
81 
82  typedef vnl_svd<PrecisionType> SVDType;
83  typedef boost::shared_ptr<SVDType> SVDPointerType;
84 
86  SVDPointerType m_Svd; // SVD of U
87  unsigned int m_OutputSize;
88  unsigned int m_MaxIteration;
89 };
90 }
91 
118 template <class TInputImage, class TOutputImage, class TPrecision>
119 class ITK_EXPORT ISRAUnmixingImageFilter :
120  public otb::UnaryFunctorImageFilter<TInputImage, TOutputImage,
121  Functor::ISRAUnmixingFunctor<typename TInputImage::PixelType,
122  typename TOutputImage::PixelType, TPrecision> >
123 {
124 public:
128  <TInputImage,
129  TOutputImage,
131  typename TInputImage::PixelType,
132  typename TOutputImage::PixelType,
133  TPrecision>
137 
139  typename TInputImage::PixelType,
140  typename TOutputImage::PixelType,
141  TPrecision> FunctorType;
143 
145  itkNewMacro(Self);
146 
149 
151  typedef typename TInputImage::PixelType InputPixelType;
152  typedef typename TOutputImage::PixelType OutputPixelType;
153 
154  void SetEndmembersMatrix(const MatrixType& m);
155  const MatrixType& GetEndmembersMatrix() const;
156 
157  void SetMaxIteration( unsigned int val )
158  {
159  this->GetFunctor().SetMaxIteration(val);
160  this->Modified();
161  }
162 
163  unsigned int GetMaxIteration() const
164  {
165  return this->GetFunctor().GetMaxIteration();
166  }
167 
168 protected:
170 
171  virtual ~ISRAUnmixingImageFilter();
172 
173  void PrintSelf(std::ostream& os, itk::Indent indent) const;
174 
175 private:
176  ISRAUnmixingImageFilter(const Self &); //purposely not implemented
177  void operator =(const Self&); //purposely not implemented
178 
179 };
180 
181 } // end namespace otb
182 
183 #ifndef OTB_MANUAL_INSTANTIATION
185 #endif
186 
187 #endif
188 
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