OTB  10.0.0
Orfeo Toolbox
otbImageSampleExtractorFilter.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 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:
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:
194  void operator=(const Self&) = delete;
195 };
196 
197 } // end of namespace otb
198 
199 #ifndef OTB_MANUAL_INSTANTIATION
201 #endif
202 
203 #endif
Extract sample values from an image into an OGRDataSource using a persistent filter.
void operator=(const Self &)=delete
itk::SmartPointer< const Self > ConstPointer
ImageSampleExtractorFilter(const Self &)=delete
PersistentFilterStreamingDecorator< PersistentImageSampleExtractorFilter< TInputImage > > Superclass
This filter link a persistent filter with a StreamingImageVirtualWriter.
Persistent filter to extract sample values from an image.
PersistentImageSampleExtractorFilter(const Self &)=delete
InputImageType::InternalPixelType InternalPixelType
PersistentSamplingFilterBase< TInputImage > Superclass
itk::DataObject::DataObjectPointerArraySizeType DataObjectPointerArraySizeType
void operator=(const Self &)=delete
Base class for persistent filter doing sampling tasks.
Collection of geometric objects.
itk::SmartPointer< Self > Pointer
Layer of geometric objects.
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.