OTB  9.0.0
Orfeo Toolbox
otbDEMToImageGenerator.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 otbDEMToImageGenerator_h
22 #define otbDEMToImageGenerator_h
23 
24 #include <stdio.h>
25 #include <string>
26 
27 #include "itkImageSource.h"
28 #include "otbImage.h"
29 #include "otbDEMHandler.h"
30 #include "itkImageRegionIteratorWithIndex.h"
31 #include "otbGenericRSTransform.h"
32 
33 namespace otb
34 {
50 template <class TDEMImage>
51 class ITK_EXPORT DEMToImageGenerator : public itk::ImageSource<TDEMImage>
52 {
53 public:
55  typedef TDEMImage DEMImageType;
56  typedef typename DEMImageType::Pointer DEMImagePointerType;
57  typedef typename DEMImageType::PixelType PixelType;
58 
60  typedef itk::ImageSource<DEMImageType> Superclass;
61  typedef itk::SmartPointer<Self> Pointer;
62  typedef itk::SmartPointer<const Self> ConstPointer;
64 
65  typedef typename Superclass::Pointer OutputImagePointer;
66  typedef typename OutputImageType::SpacingType SpacingType;
67  typedef typename OutputImageType::SizeType SizeType;
68  typedef typename OutputImageType::PointType PointType;
69  typedef typename OutputImageType::IndexType IndexType;
70  typedef typename Superclass::OutputImageRegionType OutputImageRegionType;
71  typedef itk::ImageRegionIteratorWithIndex<DEMImageType> ImageIteratorType;
72 
74 
80 
81 
83  itkNewMacro(Self);
84 
86  itkTypeMacro(DEMToImageGenerator, ImageSource);
87 
89  itkSetMacro(OutputOrigin, PointType);
90  itkGetConstReferenceMacro(OutputOrigin, PointType);
92 
94  itkSetMacro(OutputSize, SizeType);
95  itkGetConstReferenceMacro(OutputSize, SizeType);
97 
99  itkSetMacro(OutputSpacing, SpacingType);
100  itkGetConstReferenceMacro(OutputSpacing, SpacingType);
102 
104  itkSetObjectMacro(Transform, GenericRSTransformType);
105  itkGetConstObjectMacro(Transform, GenericRSTransformType);
107 
110  itkSetMacro(AboveEllipsoid, bool);
111  itkGetMacro(AboveEllipsoid, bool);
112  itkBooleanMacro(AboveEllipsoid);
114 
115  void InstantiateTransform();
116 
122  void SetInputProjectionRef(const std::string& ref)
123  {
124  m_Transform->SetOutputProjectionRef(ref);
125  this->Modified();
126  }
128 
129  std::string GetInputProjectionRef() const
130  {
131  return m_Transform->GetOutputProjectionRef();
132  }
133 
134  void SetOutputProjectionRef(const std::string& ref)
135  {
136  m_Transform->SetInputProjectionRef(ref);
137  this->Modified();
138  }
139 
140  std::string GetOutputProjectionRef() const
141  {
142  return m_Transform->GetInputProjectionRef();
143  }
144 
147  {
148  return m_Transform->GetOutputImageMetadata();
149  }
150 
152  {
153  m_Transform->SetOutputImageMetadata(imd);
154  this->Modified();
155  }
156 
158  {
159  return m_Transform->GetInputImageMetadata();
160  }
162  {
163  m_Transform->SetInputImageMetadata(imd);
164  this->Modified();
165  }
167 
169  template <class TImageType>
170  void SetOutputParametersFromImage(const TImageType* image)
171  {
172  this->SetOutputOrigin(image->GetOrigin());
173  this->SetOutputSpacing(image->GetSignedSpacing());
174  // this->SetOutputStartIndex ( image->GetLargestPossibleRegion().GetIndex() );
175  this->SetOutputSize(image->GetLargestPossibleRegion().GetSize());
176  this->SetOutputProjectionRef(image->GetProjectionRef());
177  this->SetOutputImageMetadata(&(image->GetImageMetadata()));
179 
180  InstantiateTransform();
181  }
182 
183 protected:
186  {
187  }
188 
189  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
190  void BeforeThreadedGenerateData() override;
191  void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) override;
192  void GenerateOutputInformation() override;
193 
194  PointType m_OutputOrigin{0.0};
195  SpacingType m_OutputSpacing{0.0};
196  SizeType m_OutputSize{0,0};
199 
200 private:
201  DEMToImageGenerator(const Self&) = delete;
202  void operator=(const Self&) = delete;
203 
205 };
206 
207 } // namespace otb
208 
209 #ifndef OTB_MANUAL_INSTANTIATION
211 #endif
212 
213 #endif
otb::DEMToImageGenerator::GetOutputProjectionRef
std::string GetOutputProjectionRef() const
Definition: otbDEMToImageGenerator.h:140
otb::GenericRSTransform::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbGenericRSTransform.h:66
otb::DEMToImageGenerator::m_Transform
GenericRSTransformPointerType m_Transform
Definition: otbDEMToImageGenerator.h:204
otb::DEMToImageGenerator::SetOutputParametersFromImage
void SetOutputParametersFromImage(const TImageType *image)
Definition: otbDEMToImageGenerator.h:170
otbImage.h
otb::DEMToImageGenerator::OutputImageRegionType
Superclass::OutputImageRegionType OutputImageRegionType
Definition: otbDEMToImageGenerator.h:70
otb::DEMToImageGenerator::DEMImagePointerType
DEMImageType::Pointer DEMImagePointerType
Definition: otbDEMToImageGenerator.h:56
otbDEMHandler.h
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::DEMHandler
Single access point for DEM data retrieval.
Definition: otbDEMHandler.h:113
otb::DEMToImageGenerator::GenericRSTransformPointerType
GenericRSTransformType::Pointer GenericRSTransformPointerType
Definition: otbDEMToImageGenerator.h:79
otb::DEMToImageGenerator
Class to generate an image from DEM data.
Definition: otbDEMToImageGenerator.h:51
otb::DEMToImageGenerator::DEMImageType
TDEMImage DEMImageType
Definition: otbDEMToImageGenerator.h:55
otb::DEMToImageGenerator::OutputImageType
DEMImageType OutputImageType
Definition: otbDEMToImageGenerator.h:63
otb::DEMToImageGenerator::SetOutputProjectionRef
void SetOutputProjectionRef(const std::string &ref)
Definition: otbDEMToImageGenerator.h:134
otb::DEMToImageGenerator::ImageIteratorType
itk::ImageRegionIteratorWithIndex< DEMImageType > ImageIteratorType
Definition: otbDEMToImageGenerator.h:71
otb::GenericRSTransform
This is the class to handle generic remote sensing transform.
Definition: otbGenericRSTransform.h:57
otb::Transform
Class to overload method passed to virtual pure in ITK V4.
Definition: otbTransform.h:39
otb::DEMToImageGenerator::GetOutputImageMetadata
const ImageMetadata * GetOutputImageMetadata() const
Definition: otbDEMToImageGenerator.h:157
otb::DEMToImageGenerator::GetInputImageMetadata
const ImageMetadata * GetInputImageMetadata() const
Definition: otbDEMToImageGenerator.h:146
otb::DEMToImageGenerator::m_AboveEllipsoid
bool m_AboveEllipsoid
Definition: otbDEMToImageGenerator.h:198
otb::DEMToImageGenerator::IndexType
OutputImageType::IndexType IndexType
Definition: otbDEMToImageGenerator.h:69
otb::DEMToImageGenerator::SetInputImageMetadata
void SetInputImageMetadata(const ImageMetadata *imd)
Definition: otbDEMToImageGenerator.h:151
otb::DEMToImageGenerator::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbDEMToImageGenerator.h:61
otb::DEMToImageGenerator::SizeType
OutputImageType::SizeType SizeType
Definition: otbDEMToImageGenerator.h:67
otb::DEMToImageGenerator::m_DefaultUnknownValue
PixelType m_DefaultUnknownValue
Definition: otbDEMToImageGenerator.h:197
otbGenericRSTransform.h
otb::DEMToImageGenerator::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbDEMToImageGenerator.h:62
otb::DEMToImageGenerator::~DEMToImageGenerator
~DEMToImageGenerator() override
Definition: otbDEMToImageGenerator.h:185
otb::DEMToImageGenerator::GetInputProjectionRef
std::string GetInputProjectionRef() const
Definition: otbDEMToImageGenerator.h:129
otb::DEMToImageGenerator::Superclass
itk::ImageSource< DEMImageType > Superclass
Definition: otbDEMToImageGenerator.h:60
otb::DEMToImageGenerator::GenericRSTransformType
GenericRSTransform GenericRSTransformType
Definition: otbDEMToImageGenerator.h:78
otb::DEMToImageGenerator::PointType
OutputImageType::PointType PointType
Definition: otbDEMToImageGenerator.h:68
otb::DEMToImageGenerator::SetInputProjectionRef
void SetInputProjectionRef(const std::string &ref)
Definition: otbDEMToImageGenerator.h:122
otb::DEMToImageGenerator::PixelType
DEMImageType::PixelType PixelType
Definition: otbDEMToImageGenerator.h:57
otbDEMToImageGenerator.hxx
otb::ImageMetadata
Generic class containing image metadata used in OTB.
Definition: otbImageMetadata.h:270
otb::DEMToImageGenerator::SetOutputImageMetadata
void SetOutputImageMetadata(const ImageMetadata *imd)
Definition: otbDEMToImageGenerator.h:161
otb::DEMToImageGenerator::SpacingType
OutputImageType::SpacingType SpacingType
Definition: otbDEMToImageGenerator.h:66
otb::DEMToImageGenerator::DEMHandlerType
otb::DEMHandler DEMHandlerType
Definition: otbDEMToImageGenerator.h:73
otb::DEMToImageGenerator::Self
DEMToImageGenerator Self
Definition: otbDEMToImageGenerator.h:59
otb::DEMToImageGenerator::OutputImagePointer
Superclass::Pointer OutputImagePointer
Definition: otbDEMToImageGenerator.h:65