OTB  9.0.0
Orfeo Toolbox
otbAtmosphericEffects.hxx
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 otbAtmosphericEffects_hxx
22 #define otbAtmosphericEffects_hxx
23 
24 #include "otbAtmosphericEffects.h"
26 
27 namespace otb
28 {
29 
30 template <class TSpectralResponse, class TRSR>
32  m_InputSpectralResponse(InputSpectralResponseType::New()),
33  m_CorrectedSpectralResponse(InputSpectralResponseType::New()),
34  m_InputSatRSR(InputRSRType::New()),
35  m_IsSetAtmosphericRadiativeTerms(false)
36 {
37 }
38 
39 /*
40 template <class TSpectralResponse , class TRSR>
41 void
42 AtmosphericEffects<TSpectralResponse , TRSR>
43 ::LoadFilterFunctionAtmosphericCorrectionParameters(double step)
44 {
45  //LMoad the filter function from the RSR
46  for (unsigned int i=0; i<this->m_InputSatRSR->GetNbBands(); ++i)
47  {
48  m_DataAtmosphericCorrectionParameters->SetWavelenghtSpectralBandWithIndex(i, this->m_InputSatRSR->GetRSR()[i]->GetFilterFunctionValues (step));
49  }
50 }
51 */
52 template <class TSpectralResponse, class TRSR>
53 void AtmosphericEffects<TSpectralResponse, TRSR>::Process(/*const unsigned int numBand*/)
54 {
55  /*typedef otb::AtmosphericCorrectionParametersTo6SAtmosphericRadiativeTerms
56  AtmosphericCorrectionParametersTo6SRadiativeTermsType;
57 
58  AtmosphericCorrectionParametersTo6SRadiativeTermsType::Pointer filterAtmosphericCorrectionParametersTo6SRadiativeTerms =
59  AtmosphericCorrectionParametersTo6SRadiativeTermsType::New();
60 
61  //Set filter function to get the RSR Sat!!!//TODO
62  typedef otb::FilterFunctionValues FilterFunctionValuesType;
63  typedef FilterFunctionValuesType::ValuesVectorType ValuesVectorType;
64  ValuesVectorType valuesVector;
65  const double step = 0.0025;
66  for (unsigned int i=0; i < this->m_InputSatRSR->GetNbBands(); ++i)
67  {
68  //Foreach band
69  valuesVector.clear();
70  PairType inter;
71  inter = (this->m_InputSatRSR->GetRSR())[i]->GetInterval();
72  otbGenericMsgDebugMacro(<<"inter " << inter.first << " " << inter.second);
73 
74  PairType pair;
75  pair.first=(inter.first+inter.second)/2.0;
76  pair.second=0.;
77  m_CorrectedSpectralResponse->GetResponse().push_back(pair);
78 
79  for ( double j=inter.first; j <= inter.second; j+=step)
80  {
81  valuesVector.push_back( (*this->m_InputSatRSR->GetRSR()[i])(j) );
82  }
83 
84  FilterFunctionValuesType::Pointer functionValues = FilterFunctionValuesType::New();
85  functionValues->SetFilterFunctionValues(valuesVector);
86  functionValues->SetMinSpectralValue(inter.first);
87  functionValues->SetMaxSpectralValue(inter.second - step);
88 
89  //TODO Is it the efficient method Problem in 6STraits
90  functionValues->SetUserStep( step );
91 
92  m_DataAtmosphericCorrectionParameters->SetWavelengthSpectralBandWithIndex(i, functionValues);
93  }
94 
95  filterAtmosphericCorrectionParametersTo6SRadiativeTerms->SetInput( m_DataAtmosphericCorrectionParameters );
96  filterAtmosphericCorrectionParametersTo6SRadiativeTerms->Update();
97 
98  otbGenericMsgDebugMacro(<<"6S radiative term performed");
99 
100  typedef typename InputSpectralResponseType::ImageType ImageType;
101 
102  typedef SurfaceReflectanceToReflectanceFilter<ImageType, ImageType> SurfaceReflectanceToReflectanceFilterType;
103  typename SurfaceReflectanceToReflectanceFilterType::Pointer filterSRToR = SurfaceReflectanceToReflectanceFilterType::New();
104 
105  filterSRToR->SetAtmosphericRadiativeTerms( filterAtmosphericCorrectionParametersTo6SRadiativeTerms->GetOutput() );
106 
107  typename ImageType::Pointer image = ImageType::New();
108  this->m_InputSpectralResponse->GetImage(image);
109  filterSRToR->SetInput( image );
110  filterSRToR->Update();
111 
112 
113  this->m_CorrectedSpectralResponse->SetFromImage( filterSRToR->GetOutput() ); */
114 
115  /*if (m_IsSetAtmosphericRadiativeTerms)
116  {*/
117  typedef typename InputSpectralResponseType::ImageType ImageType;
118 
119  typedef SurfaceReflectanceToReflectanceFilter<ImageType, ImageType> SurfaceReflectanceToReflectanceFilterType;
120  typename SurfaceReflectanceToReflectanceFilterType::Pointer filterSRToR = SurfaceReflectanceToReflectanceFilterType::New();
121 
122  filterSRToR->SetAtmosphericRadiativeTerms(m_AtmosphericRadiativeTerms);
123 
124  typename ImageType::Pointer image = ImageType::New();
125  this->m_InputSpectralResponse->GetImage(image);
126  filterSRToR->SetInput(image);
127  filterSRToR->Update();
128 
129  this->m_CorrectedSpectralResponse->SetFromImage(filterSRToR->GetOutput());
130  /*}
131  else
132  itkExceptionMacro(<< "Atmospheric radiative terms must be provided before updating the CSR (Corrected Spectral Response)"); */
133 }
134 } // end namespace otb
135 
136 #endif
otb::AtmosphericEffects::AtmosphericEffects
AtmosphericEffects()
Definition: otbAtmosphericEffects.hxx:31
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::SurfaceReflectanceToReflectanceFilter
Calculates the slope, the orientation incidence and exitance radius values for each pixel.
Definition: otbSurfaceReflectanceToReflectanceFilter.h:166
otb::AtmosphericEffects::InputRSRType
TRSR InputRSRType
Definition: otbAtmosphericEffects.h:58
otbAtmosphericEffects.h
otb::AtmosphericEffects::Process
void Process()
Definition: otbAtmosphericEffects.hxx:53
otbSurfaceReflectanceToReflectanceFilter.h
otb::AtmosphericEffects::InputSpectralResponseType
TSpectralResponse InputSpectralResponseType
Definition: otbAtmosphericEffects.h:53