OTB  9.0.0
Orfeo Toolbox
otbProlateInterpolateImageFunction.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 otbProlateInterpolateImageFunction_hxx
22 #define otbProlateInterpolateImageFunction_hxx
23 
25 
26 namespace otb
27 {
28 namespace Function
29 {
30 template <class TInput, class TOutput>
31 double ProlateFunction<TInput, TOutput>::ComputeEnergy(double resampleRatio) const
32 {
33  vnl_vector<std::complex<double>> resampledProfile(1024);
34  resampledProfile.fill(0);
35 
36  for (unsigned int i = 0; i < m_Radius + 1; ++i)
37  {
38  unsigned int ival = static_cast<unsigned int>(static_cast<double>(m_OriginalProfile.size() * i) / static_cast<double>(m_Radius + 1));
39  resampledProfile[i] = m_OriginalProfile[ival];
40  }
41  vnl_fft_1d<double> v1d(1024);
42  v1d.fwd_transform(resampledProfile);
43 
44  // Carrful, spectrum is symmetrical
45  unsigned int sampleNb = static_cast<unsigned int>(1024 / (2 * resampleRatio));
46 
47  double energy = 0.;
48  // First part of spectrum
49  for (unsigned int j = 0; j < sampleNb + 1; ++j)
50  {
51  energy += std::abs(resampledProfile[j]) * std::abs(resampledProfile[j]);
52  }
53  // Last part of spectrum
54  for (unsigned int j = 1023; j > 1023 - sampleNb; j--)
55  {
56  energy += std::abs(resampledProfile[j]) * std::abs(resampledProfile[j]);
57  }
58 
59  double totalEnergy = energy;
60  // Middle part
61  for (unsigned int j = sampleNb + 1; j < 1023 - sampleNb + 1; ++j)
62  {
63  totalEnergy += std::abs(resampledProfile[j]) * std::abs(resampledProfile[j]);
64  }
65 
66  return std::sqrt(energy) / std::sqrt(totalEnergy);
67 }
68 
69 } // end namespace Function
70 
72 template <class TInputImage, class TBoundaryCondition, class TCoordRep, class TInputInterpolator, class TOutputInterpolator>
74 {
75  // VectorType m_ResampledProfil(1, 0.);
76  this->SetNormalizeWeight(true);
77 }
79 
81 template <class TInputImage, class TBoundaryCondition, class TCoordRep, class TInputInterpolator, class TOutputInterpolator>
83 {
84 }
85 
86 template <class TInputImage, class TBoundaryCondition, class TCoordRep, class TInputInterpolator, class TOutputInterpolator>
88  itk::Indent indent) const
89 {
90  Superclass::PrintSelf(os, indent);
91 }
92 
93 } // namespace otb
94 
95 #endif
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::ProlateInterpolateImageFunction::PrintSelf
void PrintSelf(std::ostream &os, itk::Indent indent) const override
Definition: otbProlateInterpolateImageFunction.hxx:87
otb::ProlateInterpolateImageFunction::ProlateInterpolateImageFunction
ProlateInterpolateImageFunction()
Definition: otbProlateInterpolateImageFunction.hxx:73
otb::Function::ProlateFunction::ComputeEnergy
double ComputeEnergy(double resampleRatio) const
Definition: otbProlateInterpolateImageFunction.hxx:31
otbProlateInterpolateImageFunction.h
otb::ProlateInterpolateImageFunction::~ProlateInterpolateImageFunction
~ProlateInterpolateImageFunction() override
Definition: otbProlateInterpolateImageFunction.hxx:82