OTB  10.0.0
Orfeo Toolbox
otbWatershedSegmentationFilter.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 otbWatershedSegmentationFilter_h
22 #define otbWatershedSegmentationFilter_h
23 
24 #include "otbMacro.h"
25 #include "itkUnaryFunctorImageFilter.h"
26 #include "itkCastImageFilter.h"
27 #include "itkWatershedImageFilter.h"
28 
29 namespace otb
30 {
31 
48 template <class TInputImage, class TOutputLabelImage>
49 class WatershedSegmentationFilter : public itk::ImageToImageFilter<TInputImage, TOutputLabelImage>
50 {
51 public:
54  typedef itk::ImageToImageFilter<TInputImage, TOutputLabelImage> Superclass;
55  typedef itk::SmartPointer<Self> Pointer;
56  typedef itk::SmartPointer<const Self> ConstPointer;
57 
59  typedef TInputImage InputImageType;
60  typedef TOutputLabelImage OutputLabelImageType;
61 
62  typedef itk::WatershedImageFilter<TInputImage> WatershedFilterType;
63  typedef typename WatershedFilterType::OutputImageType InternalOutputImageType;
64 
65  typedef itk::CastImageFilter<InternalOutputImageType, OutputLabelImageType> CastImageFilterType;
66 
68  itkNewMacro(Self);
69 
71  itkTypeMacro(WatershedSegmentationFilter, ImageToImageFilter);
72 
74  itkStaticConstMacro(ImageDimension, unsigned int, TInputImage::ImageDimension);
75 
76  otbSetObjectMemberMacro(WatershedFilter, Level, float);
77  otbGetObjectMemberMacro(WatershedFilter, Level, float);
78 
79  otbSetObjectMemberMacro(WatershedFilter, Threshold, float);
80  otbGetObjectMemberMacro(WatershedFilter, Threshold, float);
81 
82 
83 protected:
85 
87 
88  void GenerateData() override;
89 
90 private:
91  typename CastImageFilterType::Pointer m_CastFilter;
92  typename WatershedFilterType::Pointer m_WatershedFilter;
93 };
94 
95 
96 } // end namespace otb
97 
98 #ifndef OTB_MANUAL_INSTANTIATION
100 #endif
101 
102 #endif
Watershed composite filter allowing to set output type.
otbSetObjectMemberMacro(WatershedFilter, Threshold, float)
itk::ImageToImageFilter< TInputImage, TOutputLabelImage > Superclass
WatershedFilterType::OutputImageType InternalOutputImageType
itk::CastImageFilter< InternalOutputImageType, OutputLabelImageType > CastImageFilterType
otbGetObjectMemberMacro(WatershedFilter, Level, float)
itk::WatershedImageFilter< TInputImage > WatershedFilterType
otbSetObjectMemberMacro(WatershedFilter, Level, float)
itk::SmartPointer< const Self > ConstPointer
WatershedFilterType::Pointer m_WatershedFilter
otbGetObjectMemberMacro(WatershedFilter, Threshold, float)
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.