OTB  6.7.0
Orfeo Toolbox
otbSpectralResponse.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 otbSpectralResponse_h
22 #define otbSpectralResponse_h
23 
24 #include "itkDataObject.h"
25 #include <itkObjectFactory.h>
26 #include <vector>
27 #include <utility>
28 #include <limits>
29 
30 #include "otbVectorImage.h"
31 #include "itkImageRegionIterator.h"
32 
34 
35 #include <boost/shared_ptr.hpp>
36 
37 namespace otb
38 {
56 template<class TPrecision = double, class TValuePrecision = double>
58 {
59 public:
65 
67  typedef TPrecision PrecisionType;
68  typedef TValuePrecision ValuePrecisionType;
69 
70  typedef std::pair<TPrecision, TValuePrecision> PairType;
71  //typedef boost::shared_ptr<PairType> PairPointerType;
72  typedef typename std::vector<PairType> VectorPairType;
73 
78 
82 
83  typedef std::pair<TPrecision, TPrecision> IntervalType;
85  itkNewMacro(Self);
86  itkTypeMacro(SpectralResponse, DataObject);
88 
89 
90  itkSetMacro(SensitivityThreshold, TPrecision);
91  itkGetConstMacro(SensitivityThreshold, TPrecision);
92 
93  itkSetMacro(UsePosGuess, bool);
94  itkGetConstMacro(UsePosGuess, bool);
95 
96 
98  virtual bool Clear();
99 
101  virtual unsigned int Size() const;
102 
104  void Load(const std::string & filename, ValuePrecisionType coefNormalization = 1.0);
105 
107  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
108 
111  {
112  return m_Response;
113  }
114 
115  void SetResponse(const VectorPairType& resp)
116  {
117  m_Response = resp;
118  }
119 
124  inline ValuePrecisionType operator()(const PrecisionType & lambda);
125 
126 
130  struct sort_pair
131  {
133  {
134  return a.first < b.first;
135  }
136  };
137 
139  //void DropNullReflectance() {}
140 
143 
145  void SetFromImage(ImagePointerType image);
146 
149 
152  {
153  if (!m_IntervalComputed) this->ComputeInterval();
154  return m_Interval;
155  }
157 
159  void SetPosGuessMin(const PrecisionType & lambda);
160 
161 
162 protected:
165 
167  //SpectralResponse( const std::string & filename );
168 
170  ~SpectralResponse() override
171  {
172  }
173 ;
174 
176  //void PrintSelf(std::ostream& os, itk::Indent indent) const;
177 
180 
184  unsigned long m_PosGuess;
187  void ComputeInterval();
188 
189 private:
190  SpectralResponse(const Self&) = delete;
191  void operator=(const Self&) = delete;
192 
193 };
194 
195 }// end namespace otb
196 
197 
198 #ifndef OTB_MANUAL_INSTANTIATION
199 #include "otbSpectralResponse.hxx"
200 #endif
201 
202 #endif
std::vector< PairType > VectorPairType
otb::FilterFunctionValues FilterFunctionValuesType
Creation of an "otb" vector image which contains metadata.
std::pair< TPrecision, TValuePrecision > PairType
ImagePointerType GetImage(ImagePointerType image) const
virtual unsigned int Size() const
ValuePrecisionType operator()(const PrecisionType &lambda)
void operator=(const Self &)=delete
void SetPosGuessMin(const PrecisionType &lambda)
void SetFromImage(ImagePointerType image)
std::pair< TPrecision, TPrecision > IntervalType
bool operator()(PairType a, PairType b)
itk::DataObject Superclass
void Load(const std::string &filename, ValuePrecisionType coefNormalization=1.0)
void PrintSelf(std::ostream &os, itk::Indent indent) const override
TValuePrecision ValuePrecisionType
void SetResponse(const VectorPairType &resp)
itk::ImageRegionIterator< ImageType > IteratorType
itk::SmartPointer< Self > Pointer
itk::SmartPointer< const Self > ConstPointer
ImageType::Pointer ImagePointerType
This class represents the spectral response of an object (or a satellite band).
This class contains the values of the filter function for the processed spectral band.
otb::VectorImage< TValuePrecision, 2 > ImageType
FilterFunctionValuesPointerType GetFilterFunctionValues(double step=0.0025)
itk::SmartPointer< FilterFunctionValuesType > FilterFunctionValuesPointerType
VectorPairType & GetResponse()