Orfeo Toolbox  3.16
otbVectorImageTo3DScalarImageFilter.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 __otbVectorImageTo3DScalarImageFilter_txx
19 #define __otbVectorImageTo3DScalarImageFilter_txx
20 
24 
25 namespace otb
26 {
30 template <class TInputImage, class TOutputImage>
33 {}
35 template <class TInputImage, class TOutputImage>
36 void
39 {
40 
41  const InputImageType* inputPtr = this->GetInput();
42  OutputImageType* outputPtr = this->GetOutput();
43 
44  InputImageRegionType inputLargestRegion = this->GetInput()->GetLargestPossibleRegion();
47  for (unsigned int i = 0; i < InputImageType::ImageDimension; ++i)
48  {
49  size[i] = inputLargestRegion.GetSize()[i];
50  index[i] = inputLargestRegion.GetIndex()[i];
51  }
52  size[OutputImageType::ImageDimension - 1] = inputPtr->GetNumberOfComponentsPerPixel();
53  index[OutputImageType::ImageDimension - 1] = 0;
54 
55  OutputImageRegionType outputRegion;
56  outputRegion.SetSize(size);
57  outputRegion.SetIndex(index);
58  outputPtr->SetLargestPossibleRegion(outputRegion);
59 }
61 template <class TInputImage, class TOutputImage>
62 void
65 {
66  InputImageType* inputPtr = const_cast<InputImageType *>(this->GetInput());
67  OutputImageType* outputPtr = this->GetOutput();
68 
69  OutputImageRegionType requestedRegion = outputPtr->GetRequestedRegion();
70  InputImageRegionType inputRequestedRegion;
71  InputImageSizeType size;
72  InputImageIndexType index;
73 
74  for (unsigned int i = 0; i < InputImageType::ImageDimension; ++i)
75  {
76  size[i] = requestedRegion.GetSize()[i];
77  index[i] = requestedRegion.GetIndex()[i];
78  }
79  inputRequestedRegion.SetSize(size);
80  inputRequestedRegion.SetIndex(index);
81  inputPtr->SetRequestedRegion(inputRequestedRegion);
82 }
83 template <class TInputImage, class TOutputImage>
84 void
86 ::ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread,
87  int threadId)
88 {
89  const InputImageType* inputPtr = this->GetInput();
90  OutputImageType* outputPtr = this->GetOutput();
91 
92  typedef itk::ImageRegionConstIterator<InputImageType> InputIteratorType;
93  typedef itk::ImageSliceIteratorWithIndex<OutputImageType> OutputIteratorType;
94 
95  InputImageRegionType inputRegion;
96  InputImageSizeType size;
97  InputImageIndexType index;
98 
99  for (unsigned int i = 0; i < InputImageType::ImageDimension; ++i)
100  {
101  size[i] = outputRegionForThread.GetSize()[i];
102  index[i] = outputRegionForThread.GetIndex()[i];
103  }
104  inputRegion.SetSize(size);
105  inputRegion.SetIndex(index);
106 
107  InputIteratorType inIt(inputPtr, inputRegion);
108 
109  OutputIteratorType outIt(outputPtr, outputRegionForThread);
110  outIt.SetFirstDirection(0);
111  outIt.SetSecondDirection(1);
112 
113  outIt.GoToBegin();
114  inIt.GoToBegin();
115 
116  while (!outIt.IsAtEnd())
117  {
118  outIt.Set(static_cast<OutputPixelType>(inIt.Get()[outIt.GetIndex()[InputImageType::ImageDimension]]));
119  ++inIt;
120  if (inIt.IsAtEnd())
121  {
122  inIt.GoToBegin();
123  }
124  ++outIt;
125  if (outIt.IsAtEndOfLine())
126  {
127  outIt.NextLine();
128  }
129  if (outIt.IsAtEndOfSlice())
130  {
131  outIt.NextSlice();
132  }
133  }
134 }
138 template <class TInputImage, class TOutputImage>
139 void
141 ::PrintSelf(std::ostream& os, itk::Indent indent) const
142 {
143  Superclass::PrintSelf(os, indent);
144 }
145 } // End namespace otb
146 #endif

Generated at Sun Jun 16 2013 00:57:33 for Orfeo Toolbox with doxygen 1.8.3.1