OTB  9.0.0
Orfeo Toolbox
otbMeanShiftSegmentationFilter.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 otbMeanShiftSegmentationFilter_h
22 #define otbMeanShiftSegmentationFilter_h
23 
24 #include "itkMacro.h"
25 #include "otbMacro.h"
29 #include "itkRelabelComponentImageFilter.h"
30 #include "itkConnectedComponentFunctorImageFilter.h"
31 #include <string>
32 
33 
34 namespace otb
35 {
36 
37 
38 namespace Functor
39 {
40 
41 template <class TInput>
42 class ITK_EXPORT ConnectedLabelFunctor
43 {
44 
45 public:
47 
48  std::string GetNameOfClass()
49  {
50  return "ConnectedLabelFunctor";
51  }
52 
53  inline bool operator()(TInput& p1, TInput& p2)
54  {
55  // return static_cast<bool> (0);
56  return static_cast<bool>(p1 == p2);
57  }
58 
59 
61  {
62  }
63 
65  {
66  }
67 
68 private:
69  ConnectedLabelFunctor(const Self&) = delete;
70  void operator=(const Self&) = delete;
71 };
72 
73 } // end of Functor namespace
74 
75 
87 template <class TInputImage, class TOutputLabelImage, class TOutputClusteredImage = TInputImage, class TKernel = Meanshift::KernelUniform>
88 class ITK_EXPORT MeanShiftSegmentationFilter : public itk::ImageToImageFilter<TInputImage, TOutputLabelImage>
89 {
90 public:
93  typedef itk::ImageToImageFilter<TInputImage, TOutputLabelImage> Superclass;
94 
95  typedef itk::SmartPointer<Self> Pointer;
96  typedef itk::SmartPointer<const Self> ConstPointer;
97 
99  typedef TInputImage InputSpectralImageType;
100  typedef TOutputLabelImage OutputLabelImageType;
101  typedef TOutputClusteredImage OutputClusteredImageType;
102  typedef TKernel KernelType;
103  typedef double RealType;
104 
106  itkNewMacro(Self);
107 
109  itkTypeMacro(MeanShiftSegmentationFilter, ImageToImageFilter);
110 
112  itkStaticConstMacro(ImageDimension, unsigned int, TInputImage::ImageDimension);
113 
114  // Mean shift filter
118  // Region merging filter
126 
127 
129 
130  typedef itk::ConnectedComponentFunctorImageFilter<InputLabelImageType, InputLabelImageType, LabelFunctorType> RelabelComponentFilterType;
131  typedef typename RelabelComponentFilterType::Pointer RelabelComponentFilterPointerType;
132 
133 
137  otbSetObjectMemberMacro(MeanShiftFilter, SpatialBandwidth, RealType);
138  otbGetObjectMemberConstReferenceMacro(MeanShiftFilter, SpatialBandwidth, RealType);
140 
144  otbSetObjectMemberMacro(MeanShiftFilter, RangeBandwidth, RealType);
145  otbGetObjectMemberConstReferenceMacro(MeanShiftFilter, RangeBandwidth, RealType);
147 
149  otbSetObjectMemberMacro(MeanShiftFilter, MaxIterationNumber, unsigned int);
150  otbGetObjectMemberConstReferenceMacro(MeanShiftFilter, MaxIterationNumber, unsigned int);
152 
154  otbSetObjectMemberMacro(MeanShiftFilter, Threshold, RealType);
155  otbGetObjectMemberConstReferenceMacro(MeanShiftFilter, Threshold, RealType);
157 
161  otbSetObjectMemberMacro(RegionPruningFilter, MinRegionSize, RealType);
162  otbGetObjectMemberMacro(RegionPruningFilter, MinRegionSize, RealType);
164 
165 
167  const OutputLabelImageType* GetLabelOutput() const;
168 
170  OutputLabelImageType* GetLabelOutput();
171 
173  const OutputClusteredImageType* GetClusteredOutput() const;
174 
176  OutputClusteredImageType* GetClusteredOutput();
177 
178 protected:
180 
181  ~MeanShiftSegmentationFilter() override;
182 
183  // virtual void GenerateOutputInformation(void);
184 
185  void GenerateData() override;
186 
187 private:
192 };
193 
194 
195 } // end namespace otb
196 
197 #ifndef OTB_MANUAL_INSTANTIATION
199 #endif
200 
201 #endif
otb::MeanShiftSegmentationFilter::RegionMergingFilterPointerType
RegionMergingFilterType::Pointer RegionMergingFilterPointerType
Definition: otbMeanShiftSegmentationFilter.h:123
otb::LabelImageRegionPruningFilter::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbLabelImageRegionPruningFilter.h:52
otb::LabelImageRegionMergingFilter::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbLabelImageRegionMergingFilter.h:51
otb::MeanShiftSegmentationFilter::MeanShiftFilteredImageType
OutputClusteredImageType MeanShiftFilteredImageType
Definition: otbMeanShiftSegmentationFilter.h:115
otb::Functor::ConnectedLabelFunctor::~ConnectedLabelFunctor
~ConnectedLabelFunctor()
Definition: otbMeanShiftSegmentationFilter.h:64
otb::MeanShiftSegmentationFilter::m_RelabelFilter
RelabelComponentFilterPointerType m_RelabelFilter
Definition: otbMeanShiftSegmentationFilter.h:191
otb::MeanShiftSegmentationFilter::KernelType
TKernel KernelType
Definition: otbMeanShiftSegmentationFilter.h:102
otb::MeanShiftSegmentationFilter::m_RegionPruningFilter
RegionPruningFilterPointerType m_RegionPruningFilter
Definition: otbMeanShiftSegmentationFilter.h:190
otb::MeanShiftSegmentationFilter::Self
MeanShiftSegmentationFilter Self
Definition: otbMeanShiftSegmentationFilter.h:92
otb::MeanShiftSegmentationFilter::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbMeanShiftSegmentationFilter.h:96
otb::MeanShiftSegmentationFilter::RegionPruningFilterType
LabelImageRegionPruningFilter< OutputLabelImageType, OutputClusteredImageType, OutputLabelImageType, OutputClusteredImageType > RegionPruningFilterType
Definition: otbMeanShiftSegmentationFilter.h:124
otb::MeanShiftSegmentationFilter::RelabelComponentFilterType
itk::ConnectedComponentFunctorImageFilter< InputLabelImageType, InputLabelImageType, LabelFunctorType > RelabelComponentFilterType
Definition: otbMeanShiftSegmentationFilter.h:130
otbMeanShiftSegmentationFilter.hxx
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::MeanShiftSegmentationFilter::RealType
double RealType
Definition: otbMeanShiftSegmentationFilter.h:103
otbMacro.h
otb::MeanShiftSegmentationFilter
Definition: otbMeanShiftSegmentationFilter.h:88
otb::MeanShiftSegmentationFilter::m_RegionMergingFilter
RegionMergingFilterPointerType m_RegionMergingFilter
Definition: otbMeanShiftSegmentationFilter.h:189
otb::MeanShiftSegmentationFilter::InputSpectralImageType
TInputImage InputSpectralImageType
Definition: otbMeanShiftSegmentationFilter.h:99
otb::MeanShiftSegmentationFilter::InputLabelPixelType
MeanShiftFilterType::LabelType InputLabelPixelType
Definition: otbMeanShiftSegmentationFilter.h:120
otbLabelImageRegionMergingFilter.h
otb::MeanShiftSegmentationFilter::RegionPruningFilterPointerType
RegionPruningFilterType::Pointer RegionPruningFilterPointerType
Definition: otbMeanShiftSegmentationFilter.h:125
otb::LabelImageRegionPruningFilter
Definition: otbLabelImageRegionPruningFilter.h:46
otbLabelImageRegionPruningFilter.h
otb::MeanShiftSegmentationFilter::m_MeanShiftFilter
MeanShiftFilterPointerType m_MeanShiftFilter
Definition: otbMeanShiftSegmentationFilter.h:188
otb::MeanShiftSegmentationFilter::InputLabelImageType
MeanShiftFilterType::OutputLabelImageType InputLabelImageType
Definition: otbMeanShiftSegmentationFilter.h:119
otb::MeanShiftSegmentationFilter::RegionMergingFilterType
LabelImageRegionMergingFilter< InputLabelImageType, MeanShiftFilteredImageType, OutputLabelImageType, OutputClusteredImageType > RegionMergingFilterType
Definition: otbMeanShiftSegmentationFilter.h:122
otb::MeanShiftSegmentationFilter::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbMeanShiftSegmentationFilter.h:95
otbGetObjectMemberConstReferenceMacro
#define otbGetObjectMemberConstReferenceMacro(object, name, type)
Definition: otbMacro.h:112
otb::MeanShiftSegmentationFilter::MeanShiftFilterType
MeanShiftSmoothingImageFilter< InputSpectralImageType, MeanShiftFilteredImageType, KernelType > MeanShiftFilterType
Definition: otbMeanShiftSegmentationFilter.h:116
otb::MeanShiftSegmentationFilter::OutputLabelImageType
TOutputLabelImage OutputLabelImageType
Definition: otbMeanShiftSegmentationFilter.h:100
otb::MeanShiftSegmentationFilter::LabelFunctorType
Functor::ConnectedLabelFunctor< InputLabelPixelType > LabelFunctorType
Definition: otbMeanShiftSegmentationFilter.h:128
otb::Functor::ConnectedLabelFunctor::GetNameOfClass
std::string GetNameOfClass()
Definition: otbMeanShiftSegmentationFilter.h:48
otb::MeanShiftSmoothingImageFilter
Definition: otbMeanShiftSmoothingImageFilter.h:467
otb::Functor::ConnectedLabelFunctor::operator()
bool operator()(TInput &p1, TInput &p2)
Definition: otbMeanShiftSegmentationFilter.h:53
otb::Functor::ConnectedLabelFunctor::Self
ConnectedLabelFunctor Self
Definition: otbMeanShiftSegmentationFilter.h:46
otb::MeanShiftSmoothingImageFilter::LabelType
unsigned long LabelType
Definition: otbMeanShiftSmoothingImageFilter.h:503
otbMeanShiftSmoothingImageFilter.h
otb::MeanShiftSegmentationFilter::Superclass
itk::ImageToImageFilter< TInputImage, TOutputLabelImage > Superclass
Definition: otbMeanShiftSegmentationFilter.h:93
otbGetObjectMemberMacro
#define otbGetObjectMemberMacro(object, name, type)
Definition: otbMacro.h:89
otbSetObjectMemberMacro
#define otbSetObjectMemberMacro(object, name, type)
Definition: otbMacro.h:79
otb::LabelImageRegionMergingFilter
Definition: otbLabelImageRegionMergingFilter.h:45
otb::Functor::ConnectedLabelFunctor::ConnectedLabelFunctor
ConnectedLabelFunctor()
Definition: otbMeanShiftSegmentationFilter.h:60
otb::MeanShiftSegmentationFilter::MeanShiftFilterPointerType
MeanShiftFilterType::Pointer MeanShiftFilterPointerType
Definition: otbMeanShiftSegmentationFilter.h:117
otb::MeanShiftSmoothingImageFilter::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbMeanShiftSmoothingImageFilter.h:473
otb::Functor::ConnectedLabelFunctor
Definition: otbMeanShiftSegmentationFilter.h:42
otb::MeanShiftSegmentationFilter::OutputClusteredImageType
TOutputClusteredImage OutputClusteredImageType
Definition: otbMeanShiftSegmentationFilter.h:101
otb::MeanShiftSegmentationFilter::RelabelComponentFilterPointerType
RelabelComponentFilterType::Pointer RelabelComponentFilterPointerType
Definition: otbMeanShiftSegmentationFilter.h:131