OTB  5.0.0
Orfeo Toolbox
otbImageToProfileFilter.txx
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ORFEO Toolbox
4  Language: C++
5  Date: $Date$
6  Version: $Revision$
7 
8 
9  Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
10  See OTBCopyright.txt for details.
11 
12 
13  This software is distributed WITHOUT ANY WARRANTY; without even
14  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  PURPOSE. See the above copyright notices for more information.
16 
17 =========================================================================*/
18 #ifndef __otbImageToProfileFilter_txx
19 #define __otbImageToProfileFilter_txx
20 
22 
23 namespace otb
24 {
28 template <class TInputImage, class TOutputImage, class TFilter, class TParameter>
31 {
32  m_InitialValue = 0;
33  m_Step = 1;
34  m_ProfileSize = 10;
35  m_OutputIndex = 0;
36  m_Filter = FilterType::New();
37 }
38 
42 template <class TInputImage, class TOutputImage, class TFilter, class TParameter>
43 void
46 {
47  // Retrieving input/output pointers
48  InputImagePointerType inputPtr = this->GetInput();
49  OutputImageListPointerType outputPtr = this->GetOutput();
50  if (outputPtr)
51  {
52  if (outputPtr->Size() != m_ProfileSize)
53  {
54  // in this case, clear the list
55  outputPtr->Clear();
56  for (unsigned int i = 0; i < m_ProfileSize; ++i)
57  {
58  //Create the output image
59  outputPtr->PushBack(OutputImageType::New());
60  }
61  }
62  // For each output image
63  typename OutputImageListType::Iterator outputListIt = outputPtr->Begin();
64  m_Filter->SetInput(inputPtr);
65  m_Filter->UpdateOutputInformation();
66  while (outputListIt != outputPtr->End())
67  {
68  //Set the image information
69  outputListIt.Get()->CopyInformation(m_Filter->GetOutput(m_OutputIndex));
70  outputListIt.Get()->SetLargestPossibleRegion(m_Filter->GetOutput(m_OutputIndex)->GetLargestPossibleRegion());
71  ++outputListIt;
72  }
73  }
74 }
75 
79 template <class TInputImage, class TOutputImage, class TFilter, class TParameter>
80 void
83 {
84  // Retrieving input/output pointers
85  InputImagePointerType inputPtr = this->GetInput();
86  OutputImageListPointerType outputPtr = this->GetOutput();
88 
89  // For each output image
90  typename OutputImageListType::Iterator outputListIt = outputPtr->Begin();
91 
92  m_Filter->SetInput(inputPtr);
93 
94  // Use the filter to generate input requested region
95  while (outputListIt != outputPtr->End())
96  {
97  m_Filter->GetOutput(m_OutputIndex)->SetRequestedRegion(outputListIt.Get()->GetRequestedRegion());
98  m_Filter->PropagateRequestedRegion(outputListIt.Get());
99  ++outputListIt;
100  }
101 }
105 template <class TInputImage, class TOutputImage, class TFilter, class TParameter>
106 void
109 {
110 // Retrieving input/output pointers
111  InputImagePointerType inputPtr = this->GetInput();
112  OutputImageListPointerType outputPtr = this->GetOutput();
113  m_Filter->SetInput(inputPtr);
115 
116  for (unsigned int i = 0; i < m_ProfileSize; ++i)
117  {
118  ParameterType profileParameter = m_InitialValue + static_cast<ParameterType>(i) * m_Step;
119  this->SetProfileParameter(profileParameter);
120  m_Filter->GetOutput(m_OutputIndex)->SetRequestedRegion(outputPtr->GetNthElement(i)->GetRequestedRegion());
121  m_Filter->Update();
122  outputPtr->SetNthElement(i, static_cast<OutputImageType *>(m_Filter->GetOutput(m_OutputIndex)));
123  outputPtr->GetNthElement(i)->DisconnectPipeline();
124  }
125 }
126 
130 template <class TInputImage, class TOutputImage, class TFilter, class TParameter>
131 void
133 ::PrintSelf(std::ostream& os, itk::Indent indent) const
134 {
135  Superclass::PrintSelf(os, indent);
136  os << indent << "Filter: " << m_Filter->GetNameOfClass() << std::endl;
137  os << indent << "OutputIndex: " << m_OutputIndex << std::endl;
138  os << indent << "ProfileSize: " << m_ProfileSize << std::endl;
139  os << indent << "InitialValue: " << m_InitialValue << std::endl;
140  os << indent << "Step: " << m_Step << std::endl;
142 
143 }
144 } // End namespace otb
145 #endif
virtual void GenerateInputRequestedRegion(void)
Superclass::Iterator Iterator
Definition: otbImageList.h:55
virtual void GenerateOutputInformation(void)
static const char * GetNameOfClass()
virtual void PrintSelf(std::ostream &os, itk::Indent indent) const
Superclass::InputImagePointer InputImagePointerType