Orfeo Toolbox  4.0
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 }
41 template <class TInputImage, class TOutputImage, class TFilter, class TParameter>
42 void
45 {
46  // Retrieving input/output pointers
47  InputImagePointerType inputPtr = this->GetInput();
48  OutputImageListPointerType outputPtr = this->GetOutput();
49  if (outputPtr)
50  {
51  if (outputPtr->Size() != m_ProfileSize)
52  {
53  // in this case, clear the list
54  outputPtr->Clear();
55  for (unsigned int i = 0; i < m_ProfileSize; ++i)
56  {
57  //Create the output image
58  outputPtr->PushBack(OutputImageType::New());
59  }
60  }
61  // For each output image
62  typename OutputImageListType::Iterator outputListIt = outputPtr->Begin();
63  m_Filter->SetInput(inputPtr);
64  m_Filter->UpdateOutputInformation();
65  while (outputListIt != outputPtr->End())
66  {
67  //Set the image information
68  outputListIt.Get()->CopyInformation(m_Filter->GetOutput(m_OutputIndex));
69  outputListIt.Get()->SetLargestPossibleRegion(m_Filter->GetOutput(m_OutputIndex)->GetLargestPossibleRegion());
70  ++outputListIt;
71  }
72  }
73 }
77 template <class TInputImage, class TOutputImage, class TFilter, class TParameter>
78 void
81 {
82  // Retrieving input/output pointers
83  InputImagePointerType inputPtr = this->GetInput();
84  OutputImageListPointerType outputPtr = this->GetOutput();
85 
86  // For each output image
87  typename OutputImageListType::Iterator outputListIt = outputPtr->Begin();
88 
89  m_Filter->SetInput(inputPtr);
90 
91  // Use the filter to generate input requested region
92  while (outputListIt != outputPtr->End())
93  {
94  m_Filter->GetOutput(m_OutputIndex)->SetRequestedRegion(outputListIt.Get()->GetRequestedRegion());
95  m_Filter->PropagateRequestedRegion(outputListIt.Get());
96  ++outputListIt;
97  }
98 }
102 template <class TInputImage, class TOutputImage, class TFilter, class TParameter>
103 void
106 {
107 // Retrieving input/output pointers
108  InputImagePointerType inputPtr = this->GetInput();
109  OutputImageListPointerType outputPtr = this->GetOutput();
110  m_Filter->SetInput(inputPtr);
111 
112  for (unsigned int i = 0; i < m_ProfileSize; ++i)
113  {
114  ParameterType profileParameter = m_InitialValue + static_cast<ParameterType>(i) * m_Step;
115  this->SetProfileParameter(profileParameter);
116  m_Filter->GetOutput(m_OutputIndex)->SetRequestedRegion(outputPtr->GetNthElement(i)->GetRequestedRegion());
117  m_Filter->Update();
118  outputPtr->SetNthElement(i, static_cast<OutputImageType *>(m_Filter->GetOutput(m_OutputIndex)));
119  outputPtr->GetNthElement(i)->DisconnectPipeline();
120  }
121 }
122 
126 template <class TInputImage, class TOutputImage, class TFilter, class TParameter>
127 void
129 ::PrintSelf(std::ostream& os, itk::Indent indent) const
130 {
131  Superclass::PrintSelf(os, indent);
132  os << indent << "Filter: " << m_Filter->GetNameOfClass() << std::endl;
133  os << indent << "OutputIndex: " << m_OutputIndex << std::endl;
134  os << indent << "ProfileSize: " << m_ProfileSize << std::endl;
135  os << indent << "InitialValue: " << m_InitialValue << std::endl;
136  os << indent << "Step: " << m_Step << std::endl;
137 
138 }
139 } // End namespace otb
140 #endif

Generated at Sat Mar 8 2014 16:02:21 for Orfeo Toolbox with doxygen 1.8.3.1