OTB  9.0.0
Orfeo Toolbox
otbMulti3DMapToDEMFilter.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2022 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"
26 #include "itkImageRegionIteratorWithIndex.h"
27 #include "itkImageRegionConstIterator.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 {
41  MIN = 0,
42  MAX = 1,
43  MEAN = 2,
44  ACC = 3 // return accumulator for debug purpose
45 };
46 }
47 
48 
82 template <class T3DImage = otb::VectorImage<double, 2>, class TMaskImage = otb::Image<unsigned char>, class TOutputDEMImage = otb::Image<double>>
83 class ITK_EXPORT Multi3DMapToDEMFilter : public itk::ImageToImageFilter<T3DImage, TOutputDEMImage>
84 {
85 public:
88  typedef itk::ImageToImageFilter<T3DImage, TOutputDEMImage> Superclass;
89  typedef itk::SmartPointer<Self> Pointer;
90  typedef itk::SmartPointer<const Self> ConstPointer;
91 
93  itkNewMacro(Self);
94 
96  itkTypeMacro(Multi3DMapToDEMFilter, ImageToImageFilter);
97 
99  typedef T3DImage InputMapType;
100  typedef TOutputDEMImage OutputImageType;
101  typedef TMaskImage MaskImageType;
103 
104  typedef typename OutputImageType::RegionType RegionType;
105  typedef typename OutputImageType::PixelType DEMPixelType;
106  typedef typename OutputImageType::PointType OriginType;
107  typedef typename OutputImageType::SpacingType SpacingType;
108  typedef typename OutputImageType::SizeType SizeType;
109  typedef typename OutputImageType::IndexType IndexType;
110 
112 
113  typedef typename InputMapType::PixelType MapPixelType;
114  typedef typename InputMapType::InternalPixelType InputInternalPixelType;
115  // 3D RS transform
116  // TODO: Allow tuning precision (i.e. double or float)
117  typedef double PrecisionType;
119 
121 
122  // 3D points
124 
125  // 2D Transform
127 
128  typedef std::map<unsigned int, itk::ImageRegionConstIterator<InputMapType>> MapIteratorList;
129 
130  typedef std::map<unsigned int, itk::ImageRegionConstIterator<MaskImageType>> MaskIteratorList;
131 
132 
133  typedef double ValueType;
134  typedef itk::VariableLengthVector<ValueType> MeasurementType;
135 
136  typedef itk::ImageRegionSplitter<2> SplitterType;
138 
140  void SetNumberOf3DMaps(unsigned int nb);
141 
143  unsigned int GetNumberOf3DMaps();
144 
146  void Set3DMapInput(unsigned int index, const T3DImage* hmap);
147 
151  void SetMaskInput(unsigned int index, const TMaskImage* mask);
152 
154  const T3DImage* Get3DMapInput(unsigned int index) const;
155  const TMaskImage* GetMaskInput(unsigned int index) const;
157 
159  const TOutputDEMImage* GetDEMOutput() const;
160  TOutputDEMImage* GetDEMOutput();
162 
164  itkSetMacro(DEMGridStep, double);
165  itkGetConstReferenceMacro(DEMGridStep, double);
167 
169  itkSetMacro(CellFusionMode, int);
170  itkGetConstReferenceMacro(CellFusionMode, int);
172 
174  itkSetMacro(NoDataValue, DEMPixelType);
175  itkGetConstReferenceMacro(NoDataValue, DEMPixelType);
177 
181  void SetOutputParametersFrom3DMap(int index = -1)
182  {
183  if (static_cast<unsigned int>((2 * (index + 1))) > this->GetNumberOfInputs())
184  {
185  itkExceptionMacro(<< "input at position " << index << " is unavailable");
186  }
187  m_OutputParametersFrom3DMap = index;
188  }
190 
191 
192  itkSetMacro(OutputOrigin, OriginType);
193  itkGetConstReferenceMacro(OutputOrigin, OriginType);
194 
196  itkSetMacro(OutputStartIndex, IndexType);
197  itkGetConstReferenceMacro(OutputStartIndex, IndexType);
199 
201  itkSetMacro(OutputSize, SizeType);
202  itkGetConstReferenceMacro(OutputSize, SizeType);
204 
206  itkSetMacro(OutputSpacing, SpacingType);
207  itkGetConstReferenceMacro(OutputSpacing, SpacingType);
209 
211  itkSetMacro(ProjectionRef, std::string);
212  itkGetConstReferenceMacro(ProjectionRef, std::string);
214 
215  itkGetConstReferenceMacro(OutputParametersFrom3DMap, int);
216 
217 
219  itkSetMacro(ElevationMin, double);
220  itkGetConstReferenceMacro(ElevationMin, double);
222 
224  itkSetMacro(ElevationMax, double);
225  itkGetConstReferenceMacro(ElevationMax, double);
227 
228 
230  itkSetMacro(Margin, SizeType);
231  itkGetConstReferenceMacro(Margin, SizeType);
233 
234 
235 protected:
238 
240  ~Multi3DMapToDEMFilter() override;
241 
243  void GenerateOutputInformation() override;
244 
246  void GenerateInputRequestedRegion() override;
247 
249  void BeforeThreadedGenerateData() override;
250 
252  void ThreadedGenerateData(const RegionType& outputRegionForThread, itk::ThreadIdType threadId) override;
253 
255  void AfterThreadedGenerateData() override;
256 
262  void VerifyInputInformation() override
263  {
264  }
265 
266 
267 private:
268  void SetOutputParametersFromImage();
269 
270  Multi3DMapToDEMFilter(const Self&) = delete;
271  void operator=(const Self&) = delete;
272 
275 
277  std::vector<RSTransformType::Pointer> m_MapToGroundTransform;
278 
279  std::vector<MeasurementType> m_MapMinVal;
280  std::vector<MeasurementType> m_MapMaxVal;
283 
285  std::vector<typename OutputImageType::Pointer> m_TempDEMRegions;
286 
288  std::vector<typename AccumulatorImageType::Pointer> m_TempDEMAccumulatorRegions;
289 
290 
291  std::vector<unsigned int> m_NumberOfSplit; // number of split for each map
292  // std::vector<int> m_ThreadProcessed; //
295 
298  std::string m_ProjectionRef;
299 
302 
305 
306 
307  SizeType m_OutputSize{0,0};
309  SpacingType m_OutputSpacing{0.0};
310  OriginType m_OutputOrigin{0.0};
311 
313 
316 
319 };
320 } // end namespace otb
321 
322 #ifndef OTB_MANUAL_INSTANTIATION
324 #endif
325 
326 #endif
otb::Multi3DMapToDEMFilter::m_ElevationMax
double m_ElevationMax
Definition: otbMulti3DMapToDEMFilter.h:304
otb::GenericRSTransform::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbGenericRSTransform.h:66
otbMulti3DMapToDEMFilter.hxx
otb::Multi3DMapToDEMFilter::PrecisionType
double PrecisionType
Definition: otbMulti3DMapToDEMFilter.h:117
otb::Multi3DMapToDEMFilter::m_TempDEMAccumulatorRegions
std::vector< typename AccumulatorImageType::Pointer > m_TempDEMAccumulatorRegions
Definition: otbMulti3DMapToDEMFilter.h:288
otb::Multi3DMapToDEMFilter::MaskImageType
TMaskImage MaskImageType
Definition: otbMulti3DMapToDEMFilter.h:101
otbVectorImage.h
otb::Multi3DMapToDEMFilter::SplitterListType
otb::ObjectList< SplitterType > SplitterListType
Definition: otbMulti3DMapToDEMFilter.h:137
otb::Multi3DMapToDEMFilter::SizeType
OutputImageType::SizeType SizeType
Definition: otbMulti3DMapToDEMFilter.h:108
otb::CellFusionMode::MIN
@ MIN
Definition: otbMulti3DMapToDEMFilter.h:41
otb::Multi3DMapToDEMFilter::m_MapToGroundTransform
std::vector< RSTransformType::Pointer > m_MapToGroundTransform
Definition: otbMulti3DMapToDEMFilter.h:277
otb::Multi3DMapToDEMFilter::m_NoDataValue
DEMPixelType m_NoDataValue
Definition: otbMulti3DMapToDEMFilter.h:296
otb::Multi3DMapToDEMFilter::m_ReferenceToGroundTransform
RSTransformType::Pointer m_ReferenceToGroundTransform
Definition: otbMulti3DMapToDEMFilter.h:274
otbImage.h
otb::Multi3DMapToDEMFilter::InputInternalPixelType
InputMapType::InternalPixelType InputInternalPixelType
Definition: otbMulti3DMapToDEMFilter.h:114
otb::CellFusionMode::ACC
@ ACC
Definition: otbMulti3DMapToDEMFilter.h:44
otb::Multi3DMapToDEMFilter::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbMulti3DMapToDEMFilter.h:90
otb::CellFusionMode::MEAN
@ MEAN
Definition: otbMulti3DMapToDEMFilter.h:43
otb::Multi3DMapToDEMFilter::OutputParametersEstimatorType
otb::ImageToGenericRSOutputParameters< OutputImageType > OutputParametersEstimatorType
Definition: otbMulti3DMapToDEMFilter.h:120
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::Image
Creation of an "otb" image which contains metadata.
Definition: otbImage.h:89
otbImageToGenericRSOutputParameters.h
otb::Multi3DMapToDEMFilter::m_MapMaxVal
std::vector< MeasurementType > m_MapMaxVal
Definition: otbMulti3DMapToDEMFilter.h:280
otb::ImageToGenericRSOutputParameters
This class is a helper class to estimate the output parameters of an image after projection in a targ...
Definition: otbImageToGenericRSOutputParameters.h:57
otb::Multi3DMapToDEMFilter::SetOutputParametersFrom3DMap
void SetOutputParametersFrom3DMap(int index=-1)
Definition: otbMulti3DMapToDEMFilter.h:181
otb::Multi3DMapToDEMFilter::m_ElevationMin
double m_ElevationMin
Definition: otbMulti3DMapToDEMFilter.h:301
otb::Multi3DMapToDEMFilter::AccumulatorPixelType
AccumulatorImageType::PixelType AccumulatorPixelType
Definition: otbMulti3DMapToDEMFilter.h:111
otb::CellFusionMode::CellFusionMode
CellFusionMode
Definition: otbMulti3DMapToDEMFilter.h:39
otb::Multi3DMapToDEMFilter::MaskIteratorList
std::map< unsigned int, itk::ImageRegionConstIterator< MaskImageType > > MaskIteratorList
Definition: otbMulti3DMapToDEMFilter.h:130
otb::ObjectList::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbObjectList.h:46
otb::Multi3DMapToDEMFilter::Self
Multi3DMapToDEMFilter Self
Definition: otbMulti3DMapToDEMFilter.h:87
otb::Multi3DMapToDEMFilter::m_GroundTransform
RSTransform2DType::Pointer m_GroundTransform
Definition: otbMulti3DMapToDEMFilter.h:318
otb::Multi3DMapToDEMFilter::DEMPixelType
OutputImageType::PixelType DEMPixelType
Definition: otbMulti3DMapToDEMFilter.h:105
otb::Multi3DMapToDEMFilter::VerifyInputInformation
void VerifyInputInformation() override
Definition: otbMulti3DMapToDEMFilter.h:262
otb::Multi3DMapToDEMFilter::OutputImageType
TOutputDEMImage OutputImageType
Definition: otbMulti3DMapToDEMFilter.h:100
otb::Multi3DMapToDEMFilter::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbMulti3DMapToDEMFilter.h:89
otb::Multi3DMapToDEMFilter::RegionType
OutputImageType::RegionType RegionType
Definition: otbMulti3DMapToDEMFilter.h:104
otb::Multi3DMapToDEMFilter::m_OutputParametersFrom3DMap
int m_OutputParametersFrom3DMap
Definition: otbMulti3DMapToDEMFilter.h:314
otb::Multi3DMapToDEMFilter::m_IsGeographic
bool m_IsGeographic
Definition: otbMulti3DMapToDEMFilter.h:315
otb::Multi3DMapToDEMFilter::m_MapSplitterList
SplitterListType::Pointer m_MapSplitterList
Definition: otbMulti3DMapToDEMFilter.h:294
otb::Multi3DMapToDEMFilter
Project N 3D images (long,lat,alti) into a regular DEM in the chosen map projection system.
Definition: otbMulti3DMapToDEMFilter.h:83
otb::Multi3DMapToDEMFilter::TDPointType
RSTransformType::InputPointType TDPointType
Definition: otbMulti3DMapToDEMFilter.h:123
otb::MetaDataKey::NoDataValue
OTBMetadata_EXPORT char const * NoDataValue
otb::Multi3DMapToDEMFilter::m_Margin
SizeType m_Margin
Definition: otbMulti3DMapToDEMFilter.h:312
otb::Multi3DMapToDEMFilter::MapIteratorList
std::map< unsigned int, itk::ImageRegionConstIterator< InputMapType > > MapIteratorList
Definition: otbMulti3DMapToDEMFilter.h:128
otb::GenericRSTransform
This is the class to handle generic remote sensing transform.
Definition: otbGenericRSTransform.h:57
otb::Multi3DMapToDEMFilter::m_OutputStartIndex
IndexType m_OutputStartIndex
Definition: otbMulti3DMapToDEMFilter.h:308
otb::CellFusionMode::MAX
@ MAX
Definition: otbMulti3DMapToDEMFilter.h:42
otbObjectList.h
otb::GenericRSTransform::InputPointType
itk::Point< ScalarType, NInputDimensions > InputPointType
Definition: otbGenericRSTransform.h:72
otb::Multi3DMapToDEMFilter::RSTransform2DType
otb::GenericRSTransform RSTransform2DType
Definition: otbMulti3DMapToDEMFilter.h:126
otb::Multi3DMapToDEMFilter::m_NumberOfSplit
std::vector< unsigned int > m_NumberOfSplit
Definition: otbMulti3DMapToDEMFilter.h:291
otb::Multi3DMapToDEMFilter::m_DEMGridStep
double m_DEMGridStep
Definition: otbMulti3DMapToDEMFilter.h:282
otb::Multi3DMapToDEMFilter::m_CellFusionMode
int m_CellFusionMode
Definition: otbMulti3DMapToDEMFilter.h:297
otb::Multi3DMapToDEMFilter::AccumulatorImageType
otb::Image< unsigned int > AccumulatorImageType
Definition: otbMulti3DMapToDEMFilter.h:102
otb::Multi3DMapToDEMFilter::m_TempDEMRegions
std::vector< typename OutputImageType::Pointer > m_TempDEMRegions
Definition: otbMulti3DMapToDEMFilter.h:285
otb::Multi3DMapToDEMFilter::MeasurementType
itk::VariableLengthVector< ValueType > MeasurementType
Definition: otbMulti3DMapToDEMFilter.h:134
otb::Multi3DMapToDEMFilter::SplitterType
itk::ImageRegionSplitter< 2 > SplitterType
Definition: otbMulti3DMapToDEMFilter.h:136
otb::Multi3DMapToDEMFilter::MapPixelType
InputMapType::PixelType MapPixelType
Definition: otbMulti3DMapToDEMFilter.h:113
otb::Multi3DMapToDEMFilter::RSTransformType
otb::GenericRSTransform< PrecisionType, 3, 3 > RSTransformType
Definition: otbMulti3DMapToDEMFilter.h:118
otb::ObjectList
This class is a generic all-purpose wrapping around an std::vector<itk::SmartPointer<ObjectType> >.
Definition: otbObjectList.h:40
otb::Image::PixelType
Superclass::PixelType PixelType
Definition: otbImage.h:107
otb::Multi3DMapToDEMFilter::m_MapMinVal
std::vector< MeasurementType > m_MapMinVal
Definition: otbMulti3DMapToDEMFilter.h:279
otb::Multi3DMapToDEMFilter::Superclass
itk::ImageToImageFilter< T3DImage, TOutputDEMImage > Superclass
Definition: otbMulti3DMapToDEMFilter.h:88
otb::Multi3DMapToDEMFilter::SpacingType
OutputImageType::SpacingType SpacingType
Definition: otbMulti3DMapToDEMFilter.h:107
otb::Multi3DMapToDEMFilter::IndexType
OutputImageType::IndexType IndexType
Definition: otbMulti3DMapToDEMFilter.h:109
otb::Multi3DMapToDEMFilter::m_ProjectionRef
std::string m_ProjectionRef
Definition: otbMulti3DMapToDEMFilter.h:298
otb::Multi3DMapToDEMFilter::OriginType
OutputImageType::PointType OriginType
Definition: otbMulti3DMapToDEMFilter.h:106
otb::Multi3DMapToDEMFilter::InputMapType
T3DImage InputMapType
Definition: otbMulti3DMapToDEMFilter.h:96
otb::Multi3DMapToDEMFilter::ValueType
double ValueType
Definition: otbMulti3DMapToDEMFilter.h:133