OTB  9.0.0
Orfeo Toolbox
otbImageSampleExtractorFilter.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 otbImageSampleExtractorFilter_h
22 #define otbImageSampleExtractorFilter_h
23 
27 #include "otbImage.h"
28 #include <string>
29 
30 namespace otb
31 {
32 
40 template <class TInputImage>
42 {
43 public:
44 
48  typedef itk::SmartPointer<Self> Pointer;
49  typedef itk::SmartPointer<const Self> ConstPointer;
50 
51  typedef TInputImage InputImageType;
52  typedef typename InputImageType::Pointer InputImagePointer;
53  typedef typename InputImageType::RegionType RegionType;
54  typedef typename InputImageType::PointType PointType;
55  typedef typename InputImageType::IndexType IndexType;
56  typedef typename InputImageType::PixelType PixelType;
57  typedef typename InputImageType::InternalPixelType InternalPixelType;
58 
61 
62  typedef itk::DataObject::DataObjectPointerArraySizeType DataObjectPointerArraySizeType;
63 
65  itkNewMacro(Self);
66 
69 
72  void SetOutputSamples(ogr::DataSource* data);
73 
75  ogr::DataSource* GetOutputSamples();
76 
77  void Synthetize(void) override
78  {
79  }
80 
82  void Reset(void) override;
83 
84  itkSetMacro(SampleFieldPrefix, std::string);
85  itkGetMacro(SampleFieldPrefix, std::string);
86 
88  void SetSampleFieldNames(std::vector<std::string>& names);
89 
91  const std::vector<std::string>& GetSampleFieldNames();
92 
93 protected:
96 
99  {
100  }
101 
102  void GenerateOutputInformation() override;
103 
104  void GenerateInputRequestedRegion() override;
105 
107  void ThreadedGenerateVectorData(const ogr::Layer& layerForThread, itk::ThreadIdType threadid) override;
108 
109 private:
110  PersistentImageSampleExtractorFilter(const Self&) = delete;
111  void operator=(const Self&) = delete;
112 
114  void InitializeFields();
115 
118  std::string m_SampleFieldPrefix;
119 
121  std::vector<std::string> m_SampleFieldNames;
122 };
123 
133 template <class TInputImage>
134 class ITK_EXPORT ImageSampleExtractorFilter : public PersistentFilterStreamingDecorator<PersistentImageSampleExtractorFilter<TInputImage>>
135 {
136 public:
137 
141  typedef itk::SmartPointer<Self> Pointer;
142  typedef itk::SmartPointer<const Self> ConstPointer;
143 
144  typedef TInputImage InputImageType;
146 
148 
150  itkNewMacro(Self);
151 
154 
155  using Superclass::SetInput;
156  virtual void SetInput(const TInputImage* image);
157 
158  const TInputImage* GetInput();
159 
160  void SetSamplePositions(const otb::ogr::DataSource* data);
161  const otb::ogr::DataSource* GetSamplePositions();
162 
163  void SetOutputSamples(OGRDataType::Pointer data);
164  const otb::ogr::DataSource* GetOutputSamples();
165 
166  void SetOutputFieldPrefix(const std::string& key);
167  std::string GetOutputFieldPrefix();
168 
170  void SetOutputFieldNames(std::vector<std::string>& names);
171 
173  const std::vector<std::string>& GetOutputFieldNames();
174 
175  void SetLayerIndex(int index);
176  int GetLayerIndex();
177 
178  void SetClassFieldName(const std::string& name);
179  std::string GetClassFieldName(void);
180 
181 protected:
184  {
185  }
186 
189  {
190  }
191 
192 private:
193  ImageSampleExtractorFilter(const Self&) = delete;
194  void operator=(const Self&) = delete;
195 };
196 
197 } // end of namespace otb
198 
199 #ifndef OTB_MANUAL_INSTANTIATION
201 #endif
202 
203 #endif
otb::PersistentImageSampleExtractorFilter::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbImageSampleExtractorFilter.h:48
otb::PersistentImageSampleExtractorFilter::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbImageSampleExtractorFilter.h:49
otb::PersistentImageSampleExtractorFilter::DataObjectPointerArraySizeType
itk::DataObject::DataObjectPointerArraySizeType DataObjectPointerArraySizeType
Definition: otbImageSampleExtractorFilter.h:62
otb::ImageSampleExtractorFilter::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbImageSampleExtractorFilter.h:141
otbImage.h
otb::PersistentImageSampleExtractorFilter::PixelType
InputImageType::PixelType PixelType
Definition: otbImageSampleExtractorFilter.h:56
otbPersistentFilterStreamingDecorator.h
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::ogr::DataSource
Collection of geometric objects.
Definition: otbOGRDataSourceWrapper.h:83
otb::ImageSampleExtractorFilter::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbImageSampleExtractorFilter.h:142
otbPersistentSamplingFilterBase.h
otb::ImageSampleExtractorFilter::Superclass
PersistentFilterStreamingDecorator< PersistentImageSampleExtractorFilter< TInputImage > > Superclass
Definition: otbImageSampleExtractorFilter.h:140
otb::PersistentImageSampleExtractorFilter::Synthetize
void Synthetize(void) override
Definition: otbImageSampleExtractorFilter.h:77
otb::PersistentSamplingFilterBase
Base class for persistent filter doing sampling tasks.
Definition: otbPersistentSamplingFilterBase.h:42
otb::ImageSampleExtractorFilter::FilterType
Superclass::FilterType FilterType
Definition: otbImageSampleExtractorFilter.h:147
otb::PersistentImageSampleExtractorFilter::Superclass
PersistentSamplingFilterBase< TInputImage > Superclass
Definition: otbImageSampleExtractorFilter.h:47
otb::PersistentImageSampleExtractorFilter::Self
PersistentImageSampleExtractorFilter Self
Definition: otbImageSampleExtractorFilter.h:46
otb::ImageSampleExtractorFilter::ImageSampleExtractorFilter
ImageSampleExtractorFilter()
Definition: otbImageSampleExtractorFilter.h:183
otb::PersistentImageSampleExtractorFilter::InternalPixelType
InputImageType::InternalPixelType InternalPixelType
Definition: otbImageSampleExtractorFilter.h:57
otb::PersistentImageSampleExtractorFilter::RegionType
InputImageType::RegionType RegionType
Definition: otbImageSampleExtractorFilter.h:53
otb::PersistentImageSampleExtractorFilter::InputImageType
TInputImage InputImageType
Definition: otbImageSampleExtractorFilter.h:51
otb::ImageSampleExtractorFilter::OGRDataType
otb::ogr::DataSource OGRDataType
Definition: otbImageSampleExtractorFilter.h:145
otb::PersistentImageSampleExtractorFilter
Persistent filter to extract sample values from an image.
Definition: otbImageSampleExtractorFilter.h:41
otb::PersistentFilterStreamingDecorator
This filter link a persistent filter with a StreamingImageVirtualWriter.
Definition: otbPersistentFilterStreamingDecorator.h:47
otb::PersistentImageSampleExtractorFilter::m_SampleFieldNames
std::vector< std::string > m_SampleFieldNames
Definition: otbImageSampleExtractorFilter.h:121
otb::ogr::DataSource::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbOGRDataSourceWrapper.h:90
otb::ImageSampleExtractorFilter::Self
ImageSampleExtractorFilter Self
Definition: otbImageSampleExtractorFilter.h:139
otb::ImageSampleExtractorFilter::~ImageSampleExtractorFilter
~ImageSampleExtractorFilter() override
Definition: otbImageSampleExtractorFilter.h:188
otb::PersistentImageSampleExtractorFilter::OGRDataPointer
ogr::DataSource::Pointer OGRDataPointer
Definition: otbImageSampleExtractorFilter.h:60
otbImageSampleExtractorFilter.hxx
otb::PersistentImageSampleExtractorFilter::m_SampleFieldPrefix
std::string m_SampleFieldPrefix
Definition: otbImageSampleExtractorFilter.h:118
otb::PersistentImageSampleExtractorFilter::IndexType
InputImageType::IndexType IndexType
Definition: otbImageSampleExtractorFilter.h:55
otb::PersistentImageSampleExtractorFilter::PointType
InputImageType::PointType PointType
Definition: otbImageSampleExtractorFilter.h:54
otb::ImageSampleExtractorFilter
Extract sample values from an image into an OGRDataSource using a persistent filter.
Definition: otbImageSampleExtractorFilter.h:134
otb::PersistentImageSampleExtractorFilter::OGRDataType
ogr::DataSource OGRDataType
Definition: otbImageSampleExtractorFilter.h:59
otb::ogr::Layer
Layer of geometric objects.
Definition: otbOGRLayerWrapper.h:80
otb::PersistentImageSampleExtractorFilter::InputImagePointer
InputImageType::Pointer InputImagePointer
Definition: otbImageSampleExtractorFilter.h:52
otb::ImageSampleExtractorFilter::InputImageType
TInputImage InputImageType
Definition: otbImageSampleExtractorFilter.h:144
otb::PersistentImageSampleExtractorFilter::~PersistentImageSampleExtractorFilter
~PersistentImageSampleExtractorFilter() override
Definition: otbImageSampleExtractorFilter.h:98
otbOGRDataSourceWrapper.h