OTB  9.0.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-2022 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;
51  typedef typename OutputImageType::SpacingType SpacingType;
52  typedef typename OutputImageType::PointType OriginType;
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 
175  double m_Spacing[OutputImageType::ImageDimension];
176  double m_Origin[OutputImageType::ImageDimension];
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
otb::ImportImageFilter::Self
ImportImageFilter Self
Definition: otbImportImageFilter.h:55
otb::ImportImageFilter::SpacingType
OutputImageType::SpacingType SpacingType
Definition: otbImportImageFilter.h:51
otb::ImportImageFilter::m_FilterManageMemory
bool m_FilterManageMemory
Definition: otbImportImageFilter.h:180
otb::ImportImageFilter::Superclass
itk::ImageSource< OutputImageType > Superclass
Definition: otbImportImageFilter.h:56
otb::ImportImageFilter::IndexType
itk::Index< OutputImageType::ImageDimension > IndexType
Definition: otbImportImageFilter.h:64
otb::ImportImageFilter::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbImportImageFilter.h:57
otbImportImageFilter.hxx
otb::ImportImageFilter::m_Size
unsigned long m_Size
Definition: otbImportImageFilter.h:181
otb::ImportImageFilter::SizeType
itk::Size< OutputImageType::ImageDimension > SizeType
Definition: otbImportImageFilter.h:70
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::ImportImageFilter::OriginType
OutputImageType::PointType OriginType
Definition: otbImportImageFilter.h:52
otb::ImportImageFilter
Import data from a standard C array into an Image Type.
Definition: otbImportImageFilter.h:45
otb::ImportImageFilter::RegionType
itk::ImageRegion< OutputImageType::ImageDimension > RegionType
Definition: otbImportImageFilter.h:74
otb::ImportImageFilter::TPixel
OutputImageType::PixelType TPixel
Definition: otbImportImageFilter.h:77
otb::ImportImageFilter::OutputImagePointer
OutputImageType::Pointer OutputImagePointer
Definition: otbImportImageFilter.h:50
otb::ImportImageFilter::DirectionType
itk::Matrix< double, OutputImageType::ImageDimension, OutputImageType::ImageDimension > DirectionType
Definition: otbImportImageFilter.h:135
otb::ImportImageFilter::SetRegion
void SetRegion(const RegionType &region)
Definition: otbImportImageFilter.h:95
otb::ImportImageFilter::OutputImageType
TOutputImageType OutputImageType
Definition: otbImportImageFilter.h:49
otb::ImportImageFilter::m_Region
RegionType m_Region
Definition: otbImportImageFilter.h:174
otb::ImportImageFilter::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbImportImageFilter.h:58
otb::ImportImageFilter::m_Direction
DirectionType m_Direction
Definition: otbImportImageFilter.h:177
otb::ImportImageFilter::m_ImportPointer
TPixel * m_ImportPointer
Definition: otbImportImageFilter.h:179
otb::ImportImageFilter::GetRegion
const RegionType & GetRegion() const
Definition: otbImportImageFilter.h:109