OTB  9.0.0
Orfeo Toolbox
otbStreamingImageToOGRLayerSegmentationFilter.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 #ifndef otbStreamingImageToOGRLayerSegmentationFilter_h
23 #define otbStreamingImageToOGRLayerSegmentationFilter_h
24 
25 #include "itkExtractImageFilter.h"
26 
30 #include "itkMultiplyImageFilter.h"
32 
34 #include <string>
35 
36 namespace otb
37 {
38 
45 template <class TInputImage, class TOutputImage, class TOutputImage2, class TKernelType>
46 class LabeledOutputAccessor<MeanShiftSmoothingImageFilter<TInputImage, TOutputImage, TOutputImage2, TKernelType>>
47 {
48 public:
50  itkStaticConstMacro(LabeledOutputIndex, unsigned int, 0);
51 };
53 
60 template <class TImageType, class TSegmentationFilter>
62 {
63 public:
67  typedef itk::SmartPointer<Self> Pointer;
68  typedef itk::SmartPointer<const Self> ConstPointer;
69 
72 
73  typedef TSegmentationFilter SegmentationFilterType;
75  typedef typename LabelImageType::PixelType LabelPixelType;
76 
81 
83  typedef itk::MultiplyImageFilter<LabelImageType, LabelImageType, LabelImageType> MultiplyImageFilterType;
84 
86  itkNewMacro(Self);
87 
90 
92  itkGetObjectMacro(SegmentationFilter, SegmentationFilterType);
93 
94  itkSetStringMacro(FieldName);
95  itkGetStringMacro(FieldName);
96 
98  void SetStartLabel(const LabelPixelType& label)
99  {
100  m_StartLabel = label;
101  m_TileMaxLabel = label;
102  }
103 
105  itkGetMacro(StartLabel, LabelPixelType);
106 
110  itkSetMacro(Use8Connected, bool);
111 
115  itkGetMacro(Use8Connected, bool);
116 
118  itkSetMacro(FilterSmallObject, bool);
119 
121  itkGetMacro(FilterSmallObject, bool);
122 
124  itkSetMacro(MinimumObjectSize, unsigned int);
125 
127  itkGetMacro(MinimumObjectSize, unsigned int);
128 
130  itkSetMacro(Simplify, bool);
131  itkGetMacro(Simplify, bool);
133 
137  itkSetMacro(SimplificationTolerance, double);
138 
142  itkGetMacro(SimplificationTolerance, double);
143 
148  virtual void SetInputMask(const LabelImageType* mask);
149  virtual const LabelImageType* GetInputMask(void);
151 
152 protected:
154 
156 
157 
158 private:
160  void operator=(const Self&) = delete;
161 
163 
164 
167  typename SegmentationFilterType::Pointer m_SegmentationFilter;
168 
169  std::string m_FieldName;
170 
171  unsigned int m_TileNumber;
174  unsigned int m_MinimumObjectSize;
177 };
178 
202 template <class TImageType, class TSegmentationFilter>
204  : public PersistentFilterStreamingDecorator<PersistentImageToOGRLayerSegmentationFilter<TImageType, TSegmentationFilter>>
205 {
206 
207 public:
211  typedef itk::SmartPointer<Self> Pointer;
212  typedef itk::SmartPointer<const Self> ConstPointer;
213 
215  itkNewMacro(Self);
216 
219 
220  typedef TSegmentationFilter SegmentationFilterType;
221  typedef TImageType InputImageType;
226 
227  typedef typename InputImageType::SizeType SizeType;
228 
230  using Superclass::SetInput;
232  {
233  this->GetFilter()->SetInput(input);
234  }
236  {
237  return this->GetFilter()->GetInput();
238  }
239 
245  {
246  this->GetFilter()->SetInputMask(mask);
247  }
249  {
250  return this->GetFilter()->GetInputMask();
251  }
252 
254  void SetOGRLayer(const OGRLayerType& ogrLayer)
255  {
256  this->GetFilter()->SetOGRLayer(ogrLayer);
257  }
258 
259  void SetFieldName(const std::string& fieldName)
260  {
261  this->GetFilter()->SetFieldName(fieldName);
262  }
263 
264  const std::string& GetFieldName() const
265  {
266  return this->GetFilter()->GetFieldName();
267  }
268 
269 
271  {
272  return this->GetFilter()->GetSegmentationFilter();
273  }
274 
276  void SetStartLabel(const LabelPixelType& label)
277  {
278  this->GetFilter()->SetStartLabel(label);
279  }
280 
283  {
284  return this->GetFilter()->GetStartLabel();
285  }
286 
289  {
290  return this->GetFilter()->GetStreamSize();
291  }
292 
293  void Initialize()
294  {
295  this->GetFilter()->Initialize();
296  }
300  void SetUse8Connected(bool flag)
301  {
302  this->GetFilter()->SetUse8Connected(flag);
303  }
304 
306  {
307  return this->GetFilter()->GetUse8Connected();
308  }
310  void SetFilterSmallObject(bool flag)
311  {
312  this->GetFilter()->SetFilterSmallObject(flag);
313  }
314 
316  {
317  return this->GetFilter()->GetFilterSmallObject();
318  }
320  void SetMinimumObjectSize(const unsigned int& size)
321  {
322  this->GetFilter()->SetMinimumObjectSize(size);
323  }
324 
325  unsigned int GetMinimumObjectSize()
326  {
327  return this->GetFilter()->GetMinimumObjectSize();
328  }
330  void SetSimplify(bool flag)
331  {
332  this->GetFilter()->SetSimplify(flag);
333  }
334 
335  bool GetSimplify()
336  {
337  return this->GetFilter()->GetSimplify();
338  }
342  void SetSimplificationTolerance(const double& tol)
343  {
344  this->GetFilter()->SetSimplificationTolerance(tol);
345  }
346 
348  {
349  return this->GetFilter()->GetSimplificationTolerance();
350  }
351 
352 protected:
355  {
356  }
357 
360  {
361  }
362 
363 private:
364  StreamingImageToOGRLayerSegmentationFilter(const Self&) = delete;
365  void operator=(const Self&) = delete;
366 };
367 }
368 
369 #ifndef OTB_MANUAL_INSTANTIATION
371 #endif
372 
373 #endif
otb::StreamingImageToOGRLayerSegmentationFilter::GetStartLabel
const LabelPixelType & GetStartLabel()
Definition: otbStreamingImageToOGRLayerSegmentationFilter.h:282
otb::StreamingImageToOGRLayerSegmentationFilter::GetStreamSize
SizeType GetStreamSize()
Definition: otbStreamingImageToOGRLayerSegmentationFilter.h:288
otb::PersistentImageToOGRLayerSegmentationFilter::SetInputMask
virtual void SetInputMask(const LabelImageType *mask)
Definition: otbStreamingImageToOGRLayerSegmentationFilter.hxx:61
otb::PersistentImageToOGRLayerSegmentationFilter::RelabelComponentImageFilterType
RelabelComponentImageFilter< LabelImageType, LabelImageType > RelabelComponentImageFilterType
Definition: otbStreamingImageToOGRLayerSegmentationFilter.h:82
otbLabeledOutputAccessor.h
otb::PersistentImageToOGRLayerSegmentationFilter::ProcessTile
OGRDataSourcePointerType ProcessTile() override
Definition: otbStreamingImageToOGRLayerSegmentationFilter.hxx:76
otb::PersistentImageToOGRLayerSegmentationFilter::GetInputMask
virtual const LabelImageType * GetInputMask(void)
Definition: otbStreamingImageToOGRLayerSegmentationFilter.hxx:68
otb::PersistentImageToOGRLayerSegmentationFilter::m_MinimumObjectSize
unsigned int m_MinimumObjectSize
Definition: otbStreamingImageToOGRLayerSegmentationFilter.h:174
otb::StreamingImageToOGRLayerSegmentationFilter::GetSimplificationTolerance
double GetSimplificationTolerance()
Definition: otbStreamingImageToOGRLayerSegmentationFilter.h:347
otb::StreamingImageToOGRLayerSegmentationFilter::GetFilterSmallObject
bool GetFilterSmallObject()
Definition: otbStreamingImageToOGRLayerSegmentationFilter.h:315
otb::StreamingImageToOGRLayerSegmentationFilter::SizeType
InputImageType::SizeType SizeType
Definition: otbStreamingImageToOGRLayerSegmentationFilter.h:227
otb::StreamingImageToOGRLayerSegmentationFilter::Self
StreamingImageToOGRLayerSegmentationFilter Self
Definition: otbStreamingImageToOGRLayerSegmentationFilter.h:209
otb::StreamingImageToOGRLayerSegmentationFilter::InputImageType
TImageType InputImageType
Definition: otbStreamingImageToOGRLayerSegmentationFilter.h:221
otb::StreamingImageToOGRLayerSegmentationFilter::SegmentationFilterType
TSegmentationFilter SegmentationFilterType
Definition: otbStreamingImageToOGRLayerSegmentationFilter.h:218
otb::PersistentImageToOGRLayerSegmentationFilter::Superclass
PersistentImageToOGRLayerFilter< TImageType > Superclass
Definition: otbStreamingImageToOGRLayerSegmentationFilter.h:66
otb::PersistentImageToOGRLayerFilter::OGRDataSourcePointerType
OGRDataSourceType::Pointer OGRDataSourcePointerType
Definition: otbPersistentImageToOGRLayerFilter.h:72
otb::PersistentImageToOGRLayerSegmentationFilter::~PersistentImageToOGRLayerSegmentationFilter
~PersistentImageToOGRLayerSegmentationFilter() override
Definition: otbStreamingImageToOGRLayerSegmentationFilter.hxx:56
otb::StreamingImageToOGRLayerSegmentationFilter::SetMinimumObjectSize
void SetMinimumObjectSize(const unsigned int &size)
Definition: otbStreamingImageToOGRLayerSegmentationFilter.h:320
otbPersistentFilterStreamingDecorator.h
otb::StreamingImageToOGRLayerSegmentationFilter::Superclass
PersistentFilterStreamingDecorator< PersistentImageToOGRLayerSegmentationFilter< TImageType, TSegmentationFilter > > Superclass
Definition: otbStreamingImageToOGRLayerSegmentationFilter.h:210
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::Image
Creation of an "otb" image which contains metadata.
Definition: otbImage.h:89
otb::ogr::DataSource
Collection of geometric objects.
Definition: otbOGRDataSourceWrapper.h:83
otb::PersistentImageToOGRLayerSegmentationFilter::m_FilterSmallObject
bool m_FilterSmallObject
Definition: otbStreamingImageToOGRLayerSegmentationFilter.h:173
otb::PersistentImageToOGRLayerSegmentationFilter::LabelImageType
LabeledOutputAccessor< SegmentationFilterType >::LabelImageType LabelImageType
Definition: otbStreamingImageToOGRLayerSegmentationFilter.h:74
otb::StreamingImageToOGRLayerSegmentationFilter::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbStreamingImageToOGRLayerSegmentationFilter.h:211
otb::LabeledOutputAccessor
Accessor to the index of the labeled output image of the Template Filter.
Definition: otbLabeledOutputAccessor.h:37
otb::PersistentImageToOGRLayerSegmentationFilter::m_StartLabel
LabelPixelType m_StartLabel
Definition: otbStreamingImageToOGRLayerSegmentationFilter.h:166
otb::PersistentImageToOGRLayerSegmentationFilter::OGRLayerType
Superclass::OGRLayerType OGRLayerType
Definition: otbStreamingImageToOGRLayerSegmentationFilter.h:80
otb::PersistentImageToOGRLayerSegmentationFilter::LabelImageToOGRDataSourceFilterType
otb::LabelImageToOGRDataSourceFilter< LabelImageType > LabelImageToOGRDataSourceFilterType
Definition: otbStreamingImageToOGRLayerSegmentationFilter.h:77
otbPersistentImageToOGRLayerFilter.h
otb::StreamingImageToOGRLayerSegmentationFilter::GetUse8Connected
bool GetUse8Connected()
Definition: otbStreamingImageToOGRLayerSegmentationFilter.h:305
otb::StreamingImageToOGRLayerSegmentationFilter::OGRDataSourcePointerType
PersistentImageToOGRLayerSegmentationFilter< TImageType, TSegmentationFilter >::OGRDataSourcePointerType OGRDataSourcePointerType
Definition: otbStreamingImageToOGRLayerSegmentationFilter.h:224
otb::PersistentImageToOGRLayerSegmentationFilter::m_TileMaxLabel
int m_TileMaxLabel
Definition: otbStreamingImageToOGRLayerSegmentationFilter.h:165
otb::StreamingImageToOGRLayerSegmentationFilter::LabelPixelType
PersistentImageToOGRLayerSegmentationFilter< TImageType, TSegmentationFilter >::LabelPixelType LabelPixelType
Definition: otbStreamingImageToOGRLayerSegmentationFilter.h:222
otb::PersistentImageToOGRLayerSegmentationFilter::itkGetObjectMacro
itkGetObjectMacro(SegmentationFilter, SegmentationFilterType)
otb::StreamingImageToOGRLayerSegmentationFilter::SetStartLabel
void SetStartLabel(const LabelPixelType &label)
Definition: otbStreamingImageToOGRLayerSegmentationFilter.h:276
otb::PersistentImageToOGRLayerFilter::InputImageType
TImage InputImageType
Definition: otbPersistentImageToOGRLayerFilter.h:61
otb::StreamingImageToOGRLayerSegmentationFilter::SetInputMask
void SetInputMask(LabelImageType *mask)
Definition: otbStreamingImageToOGRLayerSegmentationFilter.h:244
otb::PersistentImageToOGRLayerSegmentationFilter::SegmentationFilterType
TSegmentationFilter SegmentationFilterType
Definition: otbStreamingImageToOGRLayerSegmentationFilter.h:73
otb::StreamingImageToOGRLayerSegmentationFilter::SetFilterSmallObject
void SetFilterSmallObject(bool flag)
Definition: otbStreamingImageToOGRLayerSegmentationFilter.h:310
otb::ogr::Simplify
OTBGdalAdapters_EXPORT UniqueGeometryPtr Simplify(OGRGeometry const &g, double tolerance)
otb::PersistentImageToOGRLayerSegmentationFilter::m_SegmentationFilter
SegmentationFilterType::Pointer m_SegmentationFilter
Definition: otbStreamingImageToOGRLayerSegmentationFilter.h:167
otb::PersistentImageToOGRLayerSegmentationFilter::LabelPixelType
LabelImageType::PixelType LabelPixelType
Definition: otbStreamingImageToOGRLayerSegmentationFilter.h:75
otb::PersistentImageToOGRLayerSegmentationFilter::m_FieldName
std::string m_FieldName
Definition: otbStreamingImageToOGRLayerSegmentationFilter.h:169
otb::StreamingImageToOGRLayerSegmentationFilter::OGRLayerType
PersistentImageToOGRLayerSegmentationFilter< TImageType, TSegmentationFilter >::OGRLayerType OGRLayerType
Definition: otbStreamingImageToOGRLayerSegmentationFilter.h:225
otb::PersistentImageToOGRLayerSegmentationFilter::InputImagePointerType
Superclass::InputImagePointer InputImagePointerType
Definition: otbStreamingImageToOGRLayerSegmentationFilter.h:71
otb::StreamingImageToOGRLayerSegmentationFilter::SetInput
void SetInput(InputImageType *input)
Definition: otbStreamingImageToOGRLayerSegmentationFilter.h:231
otb::StreamingImageToOGRLayerSegmentationFilter::GetSegmentationFilter
SegmentationFilterType * GetSegmentationFilter()
Definition: otbStreamingImageToOGRLayerSegmentationFilter.h:270
otb::PersistentImageToOGRLayerSegmentationFilter::Self
PersistentImageToOGRLayerSegmentationFilter Self
Definition: otbStreamingImageToOGRLayerSegmentationFilter.h:65
otb::PersistentImageToOGRLayerSegmentationFilter::m_TileNumber
unsigned int m_TileNumber
Definition: otbStreamingImageToOGRLayerSegmentationFilter.h:171
otb::StreamingImageToOGRLayerSegmentationFilter::SetSimplify
void SetSimplify(bool flag)
Definition: otbStreamingImageToOGRLayerSegmentationFilter.h:330
otb::StreamingImageToOGRLayerSegmentationFilter::StreamingImageToOGRLayerSegmentationFilter
StreamingImageToOGRLayerSegmentationFilter()
Definition: otbStreamingImageToOGRLayerSegmentationFilter.h:354
otb::PersistentImageToOGRLayerSegmentationFilter::MultiplyImageFilterType
itk::MultiplyImageFilter< LabelImageType, LabelImageType, LabelImageType > MultiplyImageFilterType
Definition: otbStreamingImageToOGRLayerSegmentationFilter.h:83
otb::PersistentImageToOGRLayerSegmentationFilter::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbStreamingImageToOGRLayerSegmentationFilter.h:68
otb::PersistentFilterStreamingDecorator
This filter link a persistent filter with a StreamingImageVirtualWriter.
Definition: otbPersistentFilterStreamingDecorator.h:47
otb::PersistentImageToOGRLayerSegmentationFilter::m_Simplify
bool m_Simplify
Definition: otbStreamingImageToOGRLayerSegmentationFilter.h:175
otb::StreamingImageToOGRLayerSegmentationFilter::GetInputMask
const LabelImageType * GetInputMask()
Definition: otbStreamingImageToOGRLayerSegmentationFilter.h:248
otb::StreamingImageToOGRLayerSegmentationFilter::LabelImageType
PersistentImageToOGRLayerSegmentationFilter< TImageType, TSegmentationFilter >::LabelImageType LabelImageType
Definition: otbStreamingImageToOGRLayerSegmentationFilter.h:223
otb::PersistentImageToOGRLayerSegmentationFilter::OGRDataSourcePointerType
Superclass::OGRDataSourcePointerType OGRDataSourcePointerType
Definition: otbStreamingImageToOGRLayerSegmentationFilter.h:79
otbRelabelComponentImageFilter.h
otb::LabeledOutputAccessor::LabeledOutputIndex
static const unsigned int LabeledOutputIndex
Definition: otbLabeledOutputAccessor.h:41
otb::StreamingImageToOGRLayerSegmentationFilter::~StreamingImageToOGRLayerSegmentationFilter
~StreamingImageToOGRLayerSegmentationFilter() override
Definition: otbStreamingImageToOGRLayerSegmentationFilter.h:359
otb::PersistentImageToOGRLayerSegmentationFilter::OGRDataSourceType
Superclass::OGRDataSourceType OGRDataSourceType
Definition: otbStreamingImageToOGRLayerSegmentationFilter.h:78
otb::PersistentImageToOGRLayerSegmentationFilter
Definition: otbStreamingImageToOGRLayerSegmentationFilter.h:61
otb::PersistentImageToOGRLayerSegmentationFilter::PersistentImageToOGRLayerSegmentationFilter
PersistentImageToOGRLayerSegmentationFilter()
Definition: otbStreamingImageToOGRLayerSegmentationFilter.hxx:38
otb::StreamingImageToOGRLayerSegmentationFilter::SetFieldName
void SetFieldName(const std::string &fieldName)
Definition: otbStreamingImageToOGRLayerSegmentationFilter.h:259
otb::PersistentImageToOGRLayerSegmentationFilter::InputImageType
Superclass::InputImageType InputImageType
Definition: otbStreamingImageToOGRLayerSegmentationFilter.h:70
otb::StreamingImageToOGRLayerSegmentationFilter::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbStreamingImageToOGRLayerSegmentationFilter.h:212
otb::PersistentImageToOGRLayerSegmentationFilter::operator=
void operator=(const Self &)=delete
otb::StreamingImageToOGRLayerSegmentationFilter::GetSimplify
bool GetSimplify()
Definition: otbStreamingImageToOGRLayerSegmentationFilter.h:335
otb::LabeledOutputAccessor< MeanShiftSmoothingImageFilter< TInputImage, TOutputImage, TOutputImage2, TKernelType > >::LabelImageType
MeanShiftSmoothingImageFilter< TInputImage, TOutputImage, TOutputImage2, TKernelType >::OutputLabelImageType LabelImageType
Definition: otbStreamingImageToOGRLayerSegmentationFilter.h:49
otb::PersistentImageToOGRLayerSegmentationFilter::m_SimplificationTolerance
double m_SimplificationTolerance
Definition: otbStreamingImageToOGRLayerSegmentationFilter.h:176
otb::PersistentImageToOGRLayerSegmentationFilter::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbStreamingImageToOGRLayerSegmentationFilter.h:67
otb::MeanShiftSmoothingImageFilter
Definition: otbMeanShiftSmoothingImageFilter.h:467
otb::StreamingImageToOGRLayerSegmentationFilter::SetUse8Connected
void SetUse8Connected(bool flag)
Definition: otbStreamingImageToOGRLayerSegmentationFilter.h:300
otb::StreamingImageToOGRLayerSegmentationFilter::SetSimplificationTolerance
void SetSimplificationTolerance(const double &tol)
Definition: otbStreamingImageToOGRLayerSegmentationFilter.h:342
otb::ogr::Layer
Layer of geometric objects.
Definition: otbOGRLayerWrapper.h:80
otb::StreamingImageToOGRLayerSegmentationFilter::GetFieldName
const std::string & GetFieldName() const
Definition: otbStreamingImageToOGRLayerSegmentationFilter.h:264
otb::StreamingImageToOGRLayerSegmentationFilter::GetInput
const InputImageType * GetInput()
Definition: otbStreamingImageToOGRLayerSegmentationFilter.h:235
otbMeanShiftSmoothingImageFilter.h
otb::PersistentImageToOGRLayerFilter
Perform vectorization in a persistent way.
Definition: otbPersistentImageToOGRLayerFilter.h:51
otb::LabeledOutputAccessor::LabelImageType
TFilter::OutputImageType LabelImageType
Definition: otbLabeledOutputAccessor.h:40
otb::LabelImageToOGRDataSourceFilter
Definition: otbLabelImageToOGRDataSourceFilter.h:48
otb::PersistentImageToOGRLayerSegmentationFilter::m_Use8Connected
bool m_Use8Connected
Definition: otbStreamingImageToOGRLayerSegmentationFilter.h:172
otb::StreamingImageToOGRLayerSegmentationFilter
This filter is a framework for large scale segmentation. It is a persistent filter that process the i...
Definition: otbStreamingImageToOGRLayerSegmentationFilter.h:203
otb::StreamingImageToOGRLayerSegmentationFilter::SetOGRLayer
void SetOGRLayer(const OGRLayerType &ogrLayer)
Definition: otbStreamingImageToOGRLayerSegmentationFilter.h:254
otbStreamingImageToOGRLayerSegmentationFilter.hxx
otb::StreamingImageToOGRLayerSegmentationFilter::Initialize
void Initialize()
Definition: otbStreamingImageToOGRLayerSegmentationFilter.h:293
otb::PersistentImageToOGRLayerSegmentationFilter::SetStartLabel
void SetStartLabel(const LabelPixelType &label)
Definition: otbStreamingImageToOGRLayerSegmentationFilter.h:98
otb::RelabelComponentImageFilter
Relabel the components in an image such that consecutive labels are used.
Definition: otbRelabelComponentImageFilter.h:80
otb::StreamingImageToOGRLayerSegmentationFilter::GetMinimumObjectSize
unsigned int GetMinimumObjectSize()
Definition: otbStreamingImageToOGRLayerSegmentationFilter.h:325
otb::PersistentImageToOGRLayerFilter< TImageType >::InputImagePointer
InputImageType::Pointer InputImagePointer
Definition: otbPersistentImageToOGRLayerFilter.h:64