OTB  9.0.0
Orfeo Toolbox
otbProfileToProfileDerivativeFilter.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 otbProfileToProfileDerivativeFilter_hxx
22 #define otbProfileToProfileDerivativeFilter_hxx
23 
25 
26 namespace otb
27 {
31 template <class TInputImageList, class TOutputImageList>
33 {
34  m_SubtractFilter = SubtractFilterType::New();
35  m_AbsFilter = AbsFilterType::New();
36 }
37 
40 template <class TInputImageList, class TOutputImageList>
42 {
43  // Retrieving input/output pointers
44  InputImageListPointerType inputPtr = this->GetInput();
45  OutputImageListPointerType outputPtr = this->GetOutput();
46  if (outputPtr)
47  {
48  if (outputPtr->Size() != inputPtr->Size() - 1)
49  {
50  // in this case, clear the list
51  outputPtr->Clear();
52  typename InputImageListType::ConstIterator inputListIt = inputPtr->Begin();
53  ++inputListIt;
54  while (inputListIt != inputPtr->End())
55  {
56  outputPtr->PushBack(OutputImageType::New());
57  ++inputListIt;
58  }
59  }
61 
62  // For each input image
63  typename InputImageListType::ConstIterator inputListIt = inputPtr->Begin();
64  typename OutputImageListType::Iterator outputListIt = outputPtr->Begin();
65  ++inputListIt;
66  while (inputListIt != inputPtr->End() && outputListIt != outputPtr->End())
67  {
68  // Create the output image and set its information
69  outputListIt.Get()->CopyInformation(inputListIt.Get());
70  outputListIt.Get()->SetLargestPossibleRegion(inputListIt.Get()->GetLargestPossibleRegion());
71  ++inputListIt;
72  ++outputListIt;
73  }
74  }
75 }
77 template <class TInputImageList, class TOutputImageList>
79 {
80  // Retrieving input/output pointers
81  InputImageListPointerType inputPtr = this->GetInput();
82  OutputImageListPointerType outputPtr = this->GetOutput();
84 
85  // For each input image and corresponding output image
86  typename InputImageListType::ConstIterator inputListIt = inputPtr->Begin();
87  typename OutputImageListType::Iterator outputListIt = outputPtr->Begin();
88 
89  // Use the filter to generate input requested region
90  while (inputListIt != inputPtr->End() && outputListIt != outputPtr->End())
91  {
92  inputListIt.Get()->SetRequestedRegion(outputListIt.Get()->GetRequestedRegion());
93  ++inputListIt;
94  ++outputListIt;
95  }
96 }
98 template <class TInputImageList, class TOutputImageList>
100 {
101  m_AbsFilter->SetInput(m_SubtractFilter->GetOutput());
102 
103  // Retrieving input/output pointers
104  InputImageListPointerType inputPtr = this->GetInput();
105  OutputImageListPointerType outputPtr = this->GetOutput();
106 
107  // For each input image and corresponding output image
108  typename InputImageListType::ConstIterator inputListIt = inputPtr->Begin();
109  typename OutputImageListType::Iterator outputListIt = outputPtr->Begin();
110  unsigned int counter = 0;
111 
112  InputImagePointerType lastImage = inputListIt.Get();
113  ++inputListIt;
114 
115  while (inputListIt != inputPtr->End() && outputListIt != outputPtr->End())
116  {
117  m_SubtractFilter->SetInput1(inputListIt.Get());
118  m_SubtractFilter->SetInput2(lastImage);
119  m_AbsFilter->GetOutput()->SetRequestedRegion(outputListIt.Get()->GetRequestedRegion());
120  m_AbsFilter->Update();
121  outputPtr->SetNthElement(counter, static_cast<OutputImageType*>(m_AbsFilter->GetOutput()));
122  outputListIt.Get()->DisconnectPipeline();
123  lastImage = inputListIt.Get();
124  ++inputListIt;
125  ++outputListIt;
126  ++counter;
127  }
128 }
otbProfileToProfileDerivativeFilter.h
otb::ProfileToProfileDerivativeFilter::GenerateData
void GenerateData(void) override
otb::ProfileToProfileDerivativeFilter::GenerateInputRequestedRegion
void GenerateInputRequestedRegion(void) override
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::ProfileToProfileDerivativeFilter::ProfileToProfileDerivativeFilter
ProfileToProfileDerivativeFilter()
otb::ProfileToProfileDerivativeFilter::GenerateOutputInformation
void GenerateOutputInformation(void) override