OTB  10.0.0
Orfeo Toolbox
otbDEMToImageGenerator.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2024 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 DynamicThreadedGenerateData(const OutputImageRegionType& outputRegionForThread) 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
Single access point for DEM data retrieval.
Class to generate an image from DEM data.
OutputImageType::SizeType SizeType
void SetOutputParametersFromImage(const TImageType *image)
Superclass::OutputImageRegionType OutputImageRegionType
itk::SmartPointer< Self > Pointer
itk::SmartPointer< const Self > ConstPointer
std::string GetInputProjectionRef() const
GenericRSTransformPointerType m_Transform
DEMToImageGenerator(const Self &)=delete
GenericRSTransform GenericRSTransformType
OutputImageType::IndexType IndexType
void SetOutputImageMetadata(const ImageMetadata *imd)
void SetInputProjectionRef(const std::string &ref)
DEMImageType::PixelType PixelType
void operator=(const Self &)=delete
const ImageMetadata * GetInputImageMetadata() const
void SetInputImageMetadata(const ImageMetadata *imd)
OutputImageType::SpacingType SpacingType
const ImageMetadata * GetOutputImageMetadata() const
OutputImageType::PointType PointType
void SetOutputProjectionRef(const std::string &ref)
itk::ImageSource< DEMImageType > Superclass
GenericRSTransformType::Pointer GenericRSTransformPointerType
Superclass::Pointer OutputImagePointer
itk::ImageRegionIteratorWithIndex< DEMImageType > ImageIteratorType
DEMImageType::Pointer DEMImagePointerType
std::string GetOutputProjectionRef() const
This is the class to handle generic remote sensing transform.
itk::SmartPointer< Self > Pointer
Generic class containing image metadata used in OTB.
Class to overload method passed to virtual pure in ITK V4.
Definition: otbTransform.h:42
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.