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