OTB  6.7.0
Orfeo Toolbox
otbProfileToProfileDerivativeFilter.hxx
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2019 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>
34 {
35  m_SubtractFilter = SubtractFilterType::New();
36  m_AbsFilter = AbsFilterType::New();
37 }
38 
41 template <class TInputImageList, class TOutputImageList>
42 void
45 {
46  // Retrieving input/output pointers
47  InputImageListPointerType inputPtr = this->GetInput();
48  OutputImageListPointerType outputPtr = this->GetOutput();
49  if (outputPtr)
50  {
51  if (outputPtr->Size() != inputPtr->Size() - 1)
52  {
53  // in this case, clear the list
54  outputPtr->Clear();
55  typename InputImageListType::ConstIterator inputListIt = inputPtr->Begin();
56  ++inputListIt;
57  while (inputListIt != inputPtr->End())
58  {
59  outputPtr->PushBack(OutputImageType::New());
60  ++inputListIt;
61  }
62  }
64 
65  // For each input image
66  typename InputImageListType::ConstIterator inputListIt = inputPtr->Begin();
67  typename OutputImageListType::Iterator outputListIt = outputPtr->Begin();
68  ++inputListIt;
69  while (inputListIt != inputPtr->End() && outputListIt != outputPtr->End())
70  {
71  // Create the output image and set its information
72  outputListIt.Get()->CopyInformation(inputListIt.Get());
73  outputListIt.Get()->SetLargestPossibleRegion(inputListIt.Get()->GetLargestPossibleRegion());
74  ++inputListIt;
75  ++outputListIt;
76  }
77  }
78 }
80 template <class TInputImageList, class TOutputImageList>
81 void
84 {
85  // Retrieving input/output pointers
86  InputImageListPointerType inputPtr = this->GetInput();
87  OutputImageListPointerType outputPtr = this->GetOutput();
89 
90  // For each input image and corresponding output image
91  typename InputImageListType::ConstIterator inputListIt = inputPtr->Begin();
92  typename OutputImageListType::Iterator outputListIt = outputPtr->Begin();
93 
94  // Use the filter to generate input requested region
95  while (inputListIt != inputPtr->End() && outputListIt != outputPtr->End())
96  {
97  inputListIt.Get()->SetRequestedRegion(outputListIt.Get()->GetRequestedRegion());
98  ++inputListIt;
99  ++outputListIt;
100  }
101 }
103 template <class TInputImageList, class TOutputImageList>
104 void
107 {
108  m_AbsFilter->SetInput(m_SubtractFilter->GetOutput());
109 
110  // Retrieving input/output pointers
111  InputImageListPointerType inputPtr = this->GetInput();
112  OutputImageListPointerType outputPtr = this->GetOutput();
113 
114  // For each input image and corresponding output image
115  typename InputImageListType::ConstIterator inputListIt = inputPtr->Begin();
116  typename OutputImageListType::Iterator outputListIt = outputPtr->Begin();
117  unsigned int counter = 0;
118 
119  InputImagePointerType lastImage = inputListIt.Get();
120  ++inputListIt;
121 
122  while (inputListIt != inputPtr->End() && outputListIt != outputPtr->End())
123  {
124  m_SubtractFilter->SetInput1(inputListIt.Get());
125  m_SubtractFilter->SetInput2(lastImage);
126  m_AbsFilter->GetOutput()->SetRequestedRegion(outputListIt.Get()->GetRequestedRegion());
127  m_AbsFilter->Update();
128  outputPtr->SetNthElement(counter, static_cast<OutputImageType *>(m_AbsFilter->GetOutput()));
129  outputListIt.Get()->DisconnectPipeline();
130  lastImage = inputListIt.Get();
131  ++inputListIt;
132  ++outputListIt;
133  ++counter;
134  }
135 }
void GenerateOutputInformation(void) override
void GenerateInputRequestedRegion(void) override