OTB  10.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-2024 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 
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:
365  void operator=(const Self&) = delete;
366 };
367 }
368 
369 #ifndef OTB_MANUAL_INSTANTIATION
371 #endif
372 
373 #endif
Creation of an "otb" image which contains metadata.
Definition: otbImage.h:92
MeanShiftSmoothingImageFilter< TInputImage, TOutputImage, TOutputImage2, TKernelType >::OutputLabelImageType LabelImageType
Accessor to the index of the labeled output image of the Template Filter.
static const unsigned int LabeledOutputIndex
TFilter::OutputImageType LabelImageType
This filter link a persistent filter with a StreamingImageVirtualWriter.
This filter is the base class for all filter persisting data through multiple update....
Perform vectorization in a persistent way.
itk::MultiplyImageFilter< LabelImageType, LabelImageType, LabelImageType > MultiplyImageFilterType
LabeledOutputAccessor< SegmentationFilterType >::LabelImageType LabelImageType
otb::LabelImageToOGRDataSourceFilter< LabelImageType > LabelImageToOGRDataSourceFilterType
itkGetObjectMacro(SegmentationFilter, SegmentationFilterType)
RelabelComponentImageFilter< LabelImageType, LabelImageType > RelabelComponentImageFilterType
PersistentImageToOGRLayerSegmentationFilter(const Self &)=delete
Relabel the components in an image such that consecutive labels are used.
This filter is a framework for large scale segmentation. It is a persistent filter that process the i...
PersistentImageToOGRLayerSegmentationFilter< TImageType, TSegmentationFilter >::OGRLayerType OGRLayerType
PersistentFilterStreamingDecorator< PersistentImageToOGRLayerSegmentationFilter< TImageType, TSegmentationFilter > > Superclass
PersistentImageToOGRLayerSegmentationFilter< TImageType, TSegmentationFilter >::LabelImageType LabelImageType
StreamingImageToOGRLayerSegmentationFilter(const Self &)=delete
PersistentImageToOGRLayerSegmentationFilter< TImageType, TSegmentationFilter >::LabelPixelType LabelPixelType
PersistentImageToOGRLayerSegmentationFilter< TImageType, TSegmentationFilter >::OGRDataSourcePointerType OGRDataSourcePointerType
OTBGdalAdapters_EXPORT UniqueGeometryPtr Simplify(OGRGeometry const &g, double tolerance)
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.