OTB  10.0.0
Orfeo Toolbox
otbSpectralResponse.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2024 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 namespace otb
36 {
54 template <class TPrecision = double, class TValuePrecision = double>
55 class SpectralResponse : public itk::DataObject
56 {
57 public:
60  typedef itk::DataObject Superclass;
61  typedef itk::SmartPointer<Self> Pointer;
62  typedef itk::SmartPointer<const Self> ConstPointer;
63 
65  typedef TPrecision PrecisionType;
66  typedef TValuePrecision ValuePrecisionType;
67 
68  typedef std::pair<TPrecision, TValuePrecision> PairType;
69  // typedef std::shared_ptr<PairType> PairPointerType;
70  typedef typename std::vector<PairType> VectorPairType;
71 
75  typedef itk::ImageRegionIterator<ImageType> IteratorType;
76 
79  typedef itk::SmartPointer<FilterFunctionValuesType> FilterFunctionValuesPointerType;
80 
81  typedef std::pair<TPrecision, TPrecision> IntervalType;
83  itkNewMacro(Self);
84  itkTypeMacro(SpectralResponse, DataObject);
86 
87 
88  itkSetMacro(SensitivityThreshold, TPrecision);
89  itkGetConstMacro(SensitivityThreshold, TPrecision);
90 
91  itkSetMacro(UsePosGuess, bool);
92  itkGetConstMacro(UsePosGuess, bool);
93 
94 
96  virtual bool Clear();
97 
99  virtual unsigned int Size() const;
100 
102  void Load(const std::string& filename, ValuePrecisionType coefNormalization = 1.0);
103 
105  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
106 
109  {
110  return m_Response;
111  }
112 
113  void SetResponse(const VectorPairType& resp)
114  {
115  m_Response = resp;
116  }
117 
122  inline ValuePrecisionType operator()(const PrecisionType& lambda);
123 
124 
128  struct sort_pair
129  {
131  {
132  return a.first < b.first;
133  }
134  };
135 
137  // void DropNullReflectance() {}
138 
141 
143  void SetFromImage(ImagePointerType image);
144 
147 
150  {
151  if (!m_IntervalComputed)
152  this->ComputeInterval();
153  return m_Interval;
154  }
156 
158  void SetPosGuessMin(const PrecisionType& lambda);
159 
160 
161 protected:
164 
166  // SpectralResponse( const std::string & filename );
167 
169  ~SpectralResponse() override{};
170 
172  // void PrintSelf(std::ostream& os, itk::Indent indent) const;
173 
176 
180  unsigned long m_PosGuess;
183  void ComputeInterval();
184 
185 private:
186  SpectralResponse(const Self&) = delete;
187  void operator=(const Self&) = delete;
188 };
189 
190 } // end namespace otb
191 
192 
193 #ifndef OTB_MANUAL_INSTANTIATION
194 #include "otbSpectralResponse.hxx"
195 #endif
196 
197 #endif
This class contains the values of the filter function for the processed spectral band.
This class represents the spectral response of an object (or a satellite band).
itk::ImageRegionIterator< ImageType > IteratorType
VectorPairType & GetResponse()
otb::VectorImage< TValuePrecision, 2 > ImageType
itk::SmartPointer< Self > Pointer
TValuePrecision ValuePrecisionType
itk::SmartPointer< FilterFunctionValuesType > FilterFunctionValuesPointerType
virtual unsigned int Size() const
std::pair< TPrecision, TPrecision > IntervalType
FilterFunctionValuesPointerType GetFilterFunctionValues(double step=0.0025)
void Load(const std::string &filename, ValuePrecisionType coefNormalization=1.0)
ImageType::Pointer ImagePointerType
std::vector< PairType > VectorPairType
void PrintSelf(std::ostream &os, itk::Indent indent) const override
void SetFromImage(ImagePointerType image)
void operator=(const Self &)=delete
ValuePrecisionType operator()(const PrecisionType &lambda)
itk::DataObject Superclass
itk::SmartPointer< const Self > ConstPointer
ImagePointerType GetImage(ImagePointerType image) const
void SetResponse(const VectorPairType &resp)
void SetPosGuessMin(const PrecisionType &lambda)
SpectralResponse(const Self &)=delete
std::pair< TPrecision, TValuePrecision > PairType
otb::FilterFunctionValues FilterFunctionValuesType
Creation of an "otb" vector image which contains metadata.
itk::SmartPointer< Self > Pointer
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
bool operator()(PairType a, PairType b)