OTB  7.1.0
Orfeo Toolbox
otbImportImageFilter.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1999-2011 Insight Software Consortium
3  * Copyright (C) 2005-2019 Centre National d'Etudes Spatiales (CNES)
4  *
5  * This file is part of Orfeo Toolbox
6  *
7  * https://www.orfeo-toolbox.org/
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  */
21 
22 
23 #ifndef otbImportImageFilter_h
24 #define otbImportImageFilter_h
25 
26 #include "itkImageSource.h"
27 
28 namespace otb
29 {
30 
44 template <typename TOutputImageType>
45 class ITK_EXPORT ImportImageFilter : public itk::ImageSource<TOutputImageType>
46 {
47 public:
49  typedef TOutputImageType OutputImageType;
50  typedef typename OutputImageType::Pointer OutputImagePointer;
53 
56  typedef itk::ImageSource<OutputImageType> Superclass;
57  typedef itk::SmartPointer<Self> Pointer;
58  typedef itk::SmartPointer<const Self> ConstPointer;
59 
61  itkNewMacro(Self);
62 
64  itkTypeMacro(ImportImageFilter, itk::ImageSource);
65 
67  typedef itk::Index<OutputImageType::ImageDimension> IndexType;
68 
70  typedef itk::Size<OutputImageType::ImageDimension> SizeType;
71 
74  typedef itk::ImageRegion<OutputImageType::ImageDimension> RegionType;
75 
77  typedef typename OutputImageType::PixelType TPixel;
78 
80  TPixel* GetImportPointer();
81 
89  void SetImportPointer(TPixel* ptr, unsigned long num, bool LetFilterManageMemory);
90 
95  void SetRegion(const RegionType& region)
96  {
97  if (m_Region != region)
98  {
99  m_Region = region;
100  this->Modified();
101  }
102  }
104 
109  const RegionType& GetRegion() const
110  {
111  return m_Region;
112  }
113 
116  itkSetVectorMacro(Spacing, const double, OutputImageType::ImageDimension);
117  itkSetVectorMacro(Spacing, const float, OutputImageType::ImageDimension);
119 
122  itkGetVectorMacro(Spacing, const double, OutputImageType::ImageDimension);
123  void SetSpacing(const SpacingType& spacing);
125 
128  itkSetVectorMacro(Origin, const double, OutputImageType::ImageDimension);
129  itkSetVectorMacro(Origin, const float, OutputImageType::ImageDimension);
130  void SetOrigin(const OriginType& origin);
132 
135  itkGetVectorMacro(Origin, const double, OutputImageType::ImageDimension);
136 
137  typedef itk::Matrix<double, OutputImageType::ImageDimension, OutputImageType::ImageDimension> DirectionType;
138 
141  virtual void SetDirection(const DirectionType direction);
142 
145  itkGetConstReferenceMacro(Direction, DirectionType);
146 
147 protected:
149  ~ImportImageFilter() override;
150  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
151 
154  void GenerateData() override;
155 
159  void GenerateOutputInformation() override;
160 
168  void EnlargeOutputRequestedRegion(itk::DataObject* output) override;
169 
170 private:
171  ImportImageFilter(const ImportImageFilter&) = delete;
172  void operator=(const ImportImageFilter&) = delete;
173 
174  RegionType m_Region;
175  double m_Spacing[OutputImageType::ImageDimension];
176  double m_Origin[OutputImageType::ImageDimension];
177  DirectionType m_Direction;
178 
181  unsigned long m_Size;
182 };
183 
184 } // end namespace otb
185 
186 #ifndef OTB_MANUAL_INSTANTIATION
187 #include "otbImportImageFilter.hxx"
188 #endif
189 
190 #endif
TOutputImageType OutputImageType
itk::Size< OutputImageType::ImageDimension > SizeType
OutputImageType::PointType OriginType
OutputImageType::Pointer OutputImagePointer
itk::ImageRegion< OutputImageType::ImageDimension > RegionType
itk::ImageSource< OutputImageType > Superclass
void SetRegion(const RegionType &region)
itk::Index< OutputImageType::ImageDimension > IndexType
const RegionType & GetRegion() const
itk::Matrix< double, OutputImageType::ImageDimension, OutputImageType::ImageDimension > DirectionType
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
OutputImageType::SpacingType SpacingType
itk::SmartPointer< const Self > ConstPointer
OutputImageType::PixelType TPixel
VectorImageType::SpacingType SpacingType
Definition: mvdTypes.h:175
VectorImageType::PointType PointType
Definition: mvdTypes.h:183
itk::SmartPointer< Self > Pointer
Import data from a standard C array into an Image Type.