OTB  6.1.0
Orfeo Toolbox
otbImageToProfileFilter.txx
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2017 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 otbImageToProfileFilter_txx
22 #define otbImageToProfileFilter_txx
23 
25 
26 namespace otb
27 {
31 template <class TInputImage, class TOutputImage, class TFilter, class TParameter>
34 {
35  m_InitialValue = 0;
36  m_Step = 1;
37  m_ProfileSize = 10;
38  m_OutputIndex = 0;
39  m_Filter = FilterType::New();
40 }
41 
45 template <class TInputImage, class TOutputImage, class TFilter, class TParameter>
46 void
49 {
50  // Retrieving input/output pointers
51  InputImagePointerType inputPtr = this->GetInput();
52  OutputImageListPointerType outputPtr = this->GetOutput();
53  if (outputPtr)
54  {
55  if (outputPtr->Size() != m_ProfileSize)
56  {
57  // in this case, clear the list
58  outputPtr->Clear();
59  for (unsigned int i = 0; i < m_ProfileSize; ++i)
60  {
61  //Create the output image
62  outputPtr->PushBack(OutputImageType::New());
63  }
64  }
65  // For each output image
66  typename OutputImageListType::Iterator outputListIt = outputPtr->Begin();
67  m_Filter->SetInput(inputPtr);
68  m_Filter->UpdateOutputInformation();
69  while (outputListIt != outputPtr->End())
70  {
71  //Set the image information
72  outputListIt.Get()->CopyInformation(m_Filter->GetOutput(m_OutputIndex));
73  outputListIt.Get()->SetLargestPossibleRegion(m_Filter->GetOutput(m_OutputIndex)->GetLargestPossibleRegion());
74  ++outputListIt;
75  }
76  }
77 }
78 
82 template <class TInputImage, class TOutputImage, class TFilter, class TParameter>
83 void
86 {
87  // Retrieving input/output pointers
88  InputImagePointerType inputPtr = this->GetInput();
89  OutputImageListPointerType outputPtr = this->GetOutput();
91 
92  // For each output image
93  typename OutputImageListType::Iterator outputListIt = outputPtr->Begin();
94 
95  m_Filter->SetInput(inputPtr);
96 
97  // Use the filter to generate input requested region
98  while (outputListIt != outputPtr->End())
99  {
100  m_Filter->GetOutput(m_OutputIndex)->SetRequestedRegion(outputListIt.Get()->GetRequestedRegion());
101  m_Filter->PropagateRequestedRegion(outputListIt.Get());
102  ++outputListIt;
103  }
104 }
108 template <class TInputImage, class TOutputImage, class TFilter, class TParameter>
109 void
112 {
113 // Retrieving input/output pointers
114  InputImagePointerType inputPtr = this->GetInput();
115  OutputImageListPointerType outputPtr = this->GetOutput();
116  m_Filter->SetInput(inputPtr);
118 
119  for (unsigned int i = 0; i < m_ProfileSize; ++i)
120  {
121  ParameterType profileParameter = m_InitialValue + static_cast<ParameterType>(i) * m_Step;
122  this->SetProfileParameter(profileParameter);
123  m_Filter->GetOutput(m_OutputIndex)->SetRequestedRegion(outputPtr->GetNthElement(i)->GetRequestedRegion());
124  m_Filter->Update();
125  outputPtr->SetNthElement(i, static_cast<OutputImageType *>(m_Filter->GetOutput(m_OutputIndex)));
126  outputPtr->GetNthElement(i)->DisconnectPipeline();
127  }
128 }
129 
133 template <class TInputImage, class TOutputImage, class TFilter, class TParameter>
134 void
136 ::PrintSelf(std::ostream& os, itk::Indent indent) const
137 {
138  Superclass::PrintSelf(os, indent);
139  os << indent << "Filter: " << m_Filter->GetNameOfClass() << std::endl;
140  os << indent << "OutputIndex: " << m_OutputIndex << std::endl;
141  os << indent << "ProfileSize: " << m_ProfileSize << std::endl;
142  os << indent << "InitialValue: " << m_InitialValue << std::endl;
143  os << indent << "Step: " << m_Step << std::endl;
145 
146 }
147 } // End namespace otb
148 #endif
void GenerateData(void) ITK_OVERRIDE
Superclass::Iterator Iterator
Definition: otbImageList.h:58
void PrintSelf(std::ostream &os, itk::Indent indent) const ITK_OVERRIDE
void GenerateOutputInformation(void) ITK_OVERRIDE
static const char * GetNameOfClass()
void GenerateInputRequestedRegion(void) ITK_OVERRIDE
Superclass::InputImagePointer InputImagePointerType