OTB  7.2.0
Orfeo Toolbox
otbPerBandVectorImageFilter.hxx
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2020 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 otbPerBandVectorImageFilter_hxx
22 #define otbPerBandVectorImageFilter_hxx
23 
25 
26 namespace otb
27 {
31 template <class TInputImage, class TOutputImage, class TFilter>
33 {
34  m_Filter = FilterType::New();
35  m_OutputIndex = 0;
36 }
38 
39 template <class TInputImage, class TOutputImage, class TFilter>
41 {
42  if (this->GetInput())
43  {
44  // Create a false monoband image
45  typename InputImageType::Pointer dummyInputImage = InputImageType::New();
46  dummyInputImage->CopyInformation(this->GetInput());
47  dummyInputImage->SetNumberOfComponentsPerPixel(1);
48  m_Filter->SetInput(dummyInputImage);
49  m_Filter->UpdateOutputInformation();
50  this->GetOutput()->CopyInformation(m_Filter->GetOutput(m_OutputIndex));
51  this->GetOutput()->SetNumberOfComponentsPerPixel(this->GetInput()->GetNumberOfComponentsPerPixel());
52  }
53 }
54 
55 template <class TInputImage, class TOutputImage, class TFilter>
57 {
58  InputVectorImageType* inputPtr = const_cast<InputVectorImageType*>(this->GetInput());
59  typename InputImageType::Pointer dummyInputImage = InputImageType::New();
60  dummyInputImage->CopyInformation(this->GetInput());
61  dummyInputImage->SetNumberOfComponentsPerPixel(1);
62  m_Filter->SetInput(dummyInputImage);
63  m_Filter->GetOutput(m_OutputIndex)->SetRequestedRegion(this->GetOutput()->GetRequestedRegion());
64  m_Filter->PropagateRequestedRegion(this->GetOutput());
65  inputPtr->SetRequestedRegion(m_Filter->GetInput()->GetRequestedRegion());
66 }
70 template <class TInputImage, class TOutputImage, class TFilter>
72 {
73  InputVectorImageType* inputPtr = const_cast<InputVectorImageType*>(this->GetInput());
74  OutputVectorImagePointerType outputPtr = this->GetOutput();
75  DecompositionFilterPointerType decomposer = DecompositionFilterType::New();
76  ProcessingFilterPointerType processor = ProcessingFilterType::New();
77  RecompositionFilterPointerType recomposer = RecompositionFilterType::New();
79 
80  inputPtr->UpdateOutputData();
81 
82  decomposer->SetInput(this->GetInput());
83  processor->SetInput(decomposer->GetOutput());
84  processor->SetFilter(m_Filter);
85  processor->SetOutputIndex(m_OutputIndex);
86  recomposer->SetInput(processor->GetOutput());
87  recomposer->GetOutput()->SetRequestedRegion(this->GetOutput()->GetRequestedRegion());
88 
89  recomposer->GraftOutput(this->GetOutput());
90  recomposer->Update();
91  this->GraftOutput(recomposer->GetOutput());
92 }
void GenerateData(void) override
void GenerateOutputInformation(void) override
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
void GenerateInputRequestedRegion(void) override