OTB  9.0.0
Orfeo Toolbox
otbSpectralResponse.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2022 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
otb::SpectralResponse::m_UsePosGuess
bool m_UsePosGuess
Definition: otbSpectralResponse.h:182
otb::SpectralResponse::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbSpectralResponse.h:61
otb::SpectralResponse::PairType
std::pair< TPrecision, TValuePrecision > PairType
Definition: otbSpectralResponse.h:68
otbSpectralResponse.hxx
otbVectorImage.h
otb::SpectralResponse::SetFromImage
void SetFromImage(ImagePointerType image)
Definition: otbSpectralResponse.hxx:227
otb::SpectralResponse::Size
virtual unsigned int Size() const
Definition: otbSpectralResponse.hxx:87
otb::SpectralResponse::PrintSelf
void PrintSelf(std::ostream &os, itk::Indent indent) const override
Definition: otbSpectralResponse.hxx:297
otb::SpectralResponse::FilterFunctionValuesPointerType
itk::SmartPointer< FilterFunctionValuesType > FilterFunctionValuesPointerType
Definition: otbSpectralResponse.h:79
otb::SpectralResponse::ValuePrecisionType
TValuePrecision ValuePrecisionType
Definition: otbSpectralResponse.h:66
otb::VectorImage::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbVectorImage.h:53
otb::SpectralResponse::GetFilterFunctionValues
FilterFunctionValuesPointerType GetFilterFunctionValues(double step=0.0025)
Definition: otbSpectralResponse.hxx:243
otb::SpectralResponse::GetImage
ImagePointerType GetImage(ImagePointerType image) const
Definition: otbSpectralResponse.hxx:186
otb::SpectralResponse::ImagePointerType
ImageType::Pointer ImagePointerType
Definition: otbSpectralResponse.h:74
otb::SpectralResponse::GetResponse
VectorPairType & GetResponse()
Definition: otbSpectralResponse.h:108
otb::SpectralResponse::PrecisionType
TPrecision PrecisionType
Definition: otbSpectralResponse.h:65
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::SpectralResponse::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbSpectralResponse.h:62
otb::SpectralResponse::Self
SpectralResponse Self
Definition: otbSpectralResponse.h:59
otb::FilterFunctionValues
This class contains the values of the filter function for the processed spectral band.
Definition: otbFilterFunctionValues.h:44
otb::SpectralResponse::sort_pair::operator()
bool operator()(PairType a, PairType b)
Definition: otbSpectralResponse.h:130
otb::SpectralResponse::Load
void Load(const std::string &filename, ValuePrecisionType coefNormalization=1.0)
Definition: otbSpectralResponse.hxx:44
otb::SpectralResponse::SpectralResponse
SpectralResponse()
Definition: otbSpectralResponse.hxx:35
otb::SpectralResponse::Clear
virtual bool Clear()
Definition: otbSpectralResponse.hxx:79
otb::SpectralResponse::~SpectralResponse
~SpectralResponse() override
Definition: otbSpectralResponse.h:169
otb::SpectralResponse::ImageType
otb::VectorImage< TValuePrecision, 2 > ImageType
Definition: otbSpectralResponse.h:73
otb::SpectralResponse::m_Interval
IntervalType m_Interval
Definition: otbSpectralResponse.h:179
otb::SpectralResponse::m_SensitivityThreshold
TPrecision m_SensitivityThreshold
Definition: otbSpectralResponse.h:178
otb::SpectralResponse::m_Response
VectorPairType m_Response
Definition: otbSpectralResponse.h:169
otb::SpectralResponse::operator()
ValuePrecisionType operator()(const PrecisionType &lambda)
Definition: otbSpectralResponse.hxx:123
otb::SpectralResponse::m_PosGuess
unsigned long m_PosGuess
Definition: otbSpectralResponse.h:180
otb::SpectralResponse::Superclass
itk::DataObject Superclass
Definition: otbSpectralResponse.h:60
otb::SpectralResponse::VectorPairType
std::vector< PairType > VectorPairType
Definition: otbSpectralResponse.h:70
otb::SpectralResponse::FilterFunctionValuesType
otb::FilterFunctionValues FilterFunctionValuesType
Definition: otbSpectralResponse.h:78
otb::SpectralResponse::ComputeInterval
void ComputeInterval()
Definition: otbSpectralResponse.hxx:264
otb::SpectralResponse::IteratorType
itk::ImageRegionIterator< ImageType > IteratorType
Definition: otbSpectralResponse.h:75
otb::SpectralResponse::GetInterval
IntervalType GetInterval()
Definition: otbSpectralResponse.h:149
otb::SpectralResponse
This class represents the spectral response of an object (or a satellite band).
Definition: otbSpectralResponse.h:55
otbAtmosphericCorrectionParameters.h
otb::SpectralResponse::operator=
void operator=(const Self &)=delete
otb::SpectralResponse::SetPosGuessMin
void SetPosGuessMin(const PrecisionType &lambda)
Definition: otbSpectralResponse.hxx:94
otb::SpectralResponse::sort_pair
Definition: otbSpectralResponse.h:128
otb::SpectralResponse::IntervalType
std::pair< TPrecision, TPrecision > IntervalType
Definition: otbSpectralResponse.h:81
otb::SpectralResponse::SetResponse
void SetResponse(const VectorPairType &resp)
Definition: otbSpectralResponse.h:113
otb::VectorImage
Creation of an "otb" vector image which contains metadata.
Definition: otbVectorImage.h:45
otb::SpectralResponse::m_IntervalComputed
bool m_IntervalComputed
Definition: otbSpectralResponse.h:181