OTB  6.7.0
Orfeo Toolbox
otbMulti3DMapToDEMFilter.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2019 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 otbMulti3DMapToDEMFilter_h
22 #define otbMulti3DMapToDEMFilter_h
23 
24 #include "itkImageToImageFilter.h"
28 #include "otbVectorImage.h"
29 #include "otbImage.h"
30 #include "itkImageRegionSplitter.h"
31 #include "otbObjectList.h"
32 #include <string>
33 
34 namespace otb
35 {
36 
37 namespace CellFusionMode
38 {
40  MIN = 0,
41  MAX = 1,
42  MEAN = 2,
43  ACC = 3 //return accumulator for debug purpose
44  };
45 }
46 
47 
81 template <class T3DImage = otb::VectorImage<double,2>,
82  class TMaskImage = otb::Image<unsigned char>, class TOutputDEMImage = otb::Image<double> >
83 class ITK_EXPORT Multi3DMapToDEMFilter :
84  public itk::ImageToImageFilter<T3DImage,TOutputDEMImage>
85 {
86 public:
89  typedef itk::ImageToImageFilter<T3DImage,
90  TOutputDEMImage> Superclass;
93 
95  itkNewMacro(Self);
96 
98  itkTypeMacro(Multi3DMapToDEMFilter, ImageToImageFilter);
99 
101  typedef T3DImage InputMapType;
102  typedef TOutputDEMImage OutputImageType;
103  typedef TMaskImage MaskImageType;
105 
106  typedef typename OutputImageType::RegionType RegionType;
107  typedef typename OutputImageType::PixelType DEMPixelType;
112 
114 
115  typedef typename InputMapType::PixelType MapPixelType;
116  typedef typename InputMapType::InternalPixelType InputInternalPixelType;
117  // 3D RS transform
118  // TODO: Allow tuning precision (i.e. double or float)
119  typedef double PrecisionType;
122 
124 
125  // 3D points
127 
128  // 2D Transform
130 
132 
133  typedef std::map
134  <unsigned int,
136 
137  typedef std::map
138  <unsigned int,
140 
141 
142  typedef double ValueType;
144 
147 
149  void SetNumberOf3DMaps(unsigned int nb);
150 
152  unsigned int GetNumberOf3DMaps();
153 
155  void Set3DMapInput(unsigned int index, const T3DImage * hmap);
156 
160  void SetMaskInput(unsigned int index, const TMaskImage * mask);
161 
163  const T3DImage * Get3DMapInput(unsigned int index) const;
164  const TMaskImage * GetMaskInput(unsigned int index) const;
166 
168  const TOutputDEMImage * GetDEMOutput() const;
169  TOutputDEMImage * GetDEMOutput();
171 
173  itkSetMacro(DEMGridStep, double);
174  itkGetConstReferenceMacro(DEMGridStep, double);
176 
178  itkSetMacro(CellFusionMode, int);
179  itkGetConstReferenceMacro(CellFusionMode, int);
181 
183  itkSetMacro(NoDataValue, DEMPixelType);
184  itkGetConstReferenceMacro(NoDataValue, DEMPixelType);
186 
190  void SetOutputParametersFrom3DMap(int index=-1)
191  {
192  if (static_cast<unsigned int>((2 * (index + 1))) > this->GetNumberOfInputs())
193  {
194  itkExceptionMacro(<< "input at position "<<index<<" is unavailable");
195  }
196  m_OutputParametersFrom3DMap=index;
197  }
199 
200 
201  itkSetMacro(OutputOrigin, OriginType);
202  itkGetConstReferenceMacro(OutputOrigin, OriginType);
203 
205  itkSetMacro(OutputStartIndex, IndexType);
206  itkGetConstReferenceMacro(OutputStartIndex, IndexType);
208 
210  itkSetMacro(OutputSize, SizeType);
211  itkGetConstReferenceMacro(OutputSize, SizeType);
213 
215  itkSetMacro(OutputSpacing, SpacingType);
216  itkGetConstReferenceMacro(OutputSpacing, SpacingType);
218 
220  itkSetMacro(ProjectionRef, std::string);
221  itkGetConstReferenceMacro(ProjectionRef, std::string);
223 
224  itkGetConstReferenceMacro(OutputParametersFrom3DMap, int);
225 
226 
228  itkSetMacro(ElevationMin, double);
229  itkGetConstReferenceMacro(ElevationMin, double);
231 
233  itkSetMacro(ElevationMax, double);
234  itkGetConstReferenceMacro(ElevationMax, double);
236 
237 
239  itkSetMacro(Margin, SizeType);
240  itkGetConstReferenceMacro(Margin, SizeType);
242 
243 
244 protected:
247 
249  ~Multi3DMapToDEMFilter() override;
250 
252  void GenerateOutputInformation() override;
253 
255  void GenerateInputRequestedRegion() override;
256 
258  void BeforeThreadedGenerateData() override;
259 
261  void ThreadedGenerateData(const RegionType & outputRegionForThread, itk::ThreadIdType threadId) override;
262 
264  void AfterThreadedGenerateData() override;
265 
271  void VerifyInputInformation() override {}
272 
273 
274 private:
275 
276  void SetOutputParametersFromImage();
277 
278  Multi3DMapToDEMFilter(const Self&) = delete;
279  void operator=(const Self&) = delete;
280 
282  // std::vector<ImageKeywordListType> m_MapKeywordLists;
283 
284 
287 
289  std::vector<RSTransformType::Pointer> m_MapToGroundTransform;
290 
291  std::vector<MeasurementType> m_MapMinVal;
292  std::vector<MeasurementType> m_MapMaxVal;
295 
297  std::vector<typename OutputImageType::Pointer> m_TempDEMRegions;
298 
300  std::vector<typename AccumulatorImageType::Pointer> m_TempDEMAccumulatorRegions;
301 
302 
303  std::vector<unsigned int> m_NumberOfSplit; // number of split for each map
304  // std::vector<int> m_ThreadProcessed; //
307 
310  std::string m_ProjectionRef;
311 
314 
317 
318 
323 
325 
328 
331 
332 };
333 } // end namespace otb
334 
335 #ifndef OTB_MANUAL_INSTANTIATION
337 #endif
338 
339 #endif
itk::Size< Monteverdi_DIMENSION > SizeType
Definition: mvdTypes.h:137
otb::GenericRSTransform RSTransform2DType
Storage and conversion for OSSIM metadata.
itk::ImageToImageFilter< T3DImage, TOutputDEMImage > Superclass
otb::Image< unsigned int > AccumulatorImageType
OutputImageType::RegionType RegionType
SplitterListType::Pointer m_MapSplitterList
OutputImageType::IndexType IndexType
InputMapType::PixelType MapPixelType
OTBOSSIMAdapters_EXPORT char const * NoDataValue
Project N 3D images (long,lat,alti) into a regular DEM in the chosen map projection system...
OutputImageType::PointType OriginType
std::vector< typename AccumulatorImageType::Pointer > m_TempDEMAccumulatorRegions
std::vector< typename OutputImageType::Pointer > m_TempDEMRegions
itk::SmartPointer< const Self > ConstPointer
std::vector< RSTransformType::Pointer > m_MapToGroundTransform
itk::Index< Monteverdi_DIMENSION > IndexType
Definition: mvdTypes.h:133
otb::ObjectList< SplitterType > SplitterListType
This class is a generic all-purpose wrapping around an std::vector<itk::SmartPointer<ObjectType> >...
Definition: otbObjectList.h:40
otb::GenericRSTransform< PrecisionType, 3, 3 > RSTransformType
InputMapType::InternalPixelType InputInternalPixelType
itk::VariableLengthVector< ValueType > MeasurementType
OutputImageType::SpacingType SpacingType
Creation of an "otb" image which contains metadata.
Definition: otbImage.h:89
void SetOutputParametersFrom3DMap(int index=-1)
std::vector< MeasurementType > m_MapMinVal
itk::ImageRegionSplitter< 2 > SplitterType
std::vector< MeasurementType > m_MapMaxVal
RSTransform2DType::Pointer m_GroundTransform
otb::ImageKeywordlist ImageKeywordListType
OutputImageType::PixelType DEMPixelType
unsigned int ThreadIdType
This is the class to handle generic remote sensing transform.
itk::SmartPointer< Self > Pointer
This class is a helper class to estimate the output parameters of an image after projection in a targ...
std::map< unsigned int, itk::ImageRegionConstIterator< InputMapType > > MapIteratorList
OutputImageType::SizeType SizeType
Superclass::PixelType PixelType
Definition: otbImage.h:107
VectorImageType::SpacingType SpacingType
Definition: mvdTypes.h:181
RSTransformType::InputPointType TDPointType
std::vector< unsigned int > m_NumberOfSplit
otb::ImageToGenericRSOutputParameters< OutputImageType > OutputParametersEstimatorType
VectorImageType::PointType PointType
Definition: mvdTypes.h:189
std::map< unsigned int, itk::ImageRegionConstIterator< MaskImageType > > MaskIteratorList
RSTransformType::Pointer m_ReferenceToGroundTransform
AccumulatorImageType::PixelType AccumulatorPixelType