OTB  10.0.0
Orfeo Toolbox
otbMeanShiftSegmentationFilter.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 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
void operator=(const Self &)=delete
ConnectedLabelFunctor(const Self &)=delete
Creation of an "otb" image which contains metadata.
Definition: otbImage.h:92
RegionPruningFilterPointerType m_RegionPruningFilter
LabelImageRegionPruningFilter< OutputLabelImageType, OutputClusteredImageType, OutputLabelImageType, OutputClusteredImageType > RegionPruningFilterType
itk::SmartPointer< const Self > ConstPointer
otbGetObjectMemberConstReferenceMacro(MeanShiftFilter, RangeBandwidth, RealType)
RegionPruningFilterType::Pointer RegionPruningFilterPointerType
LabelImageRegionMergingFilter< InputLabelImageType, MeanShiftFilteredImageType, OutputLabelImageType, OutputClusteredImageType > RegionMergingFilterType
otbGetObjectMemberConstReferenceMacro(MeanShiftFilter, Threshold, RealType)
MeanShiftFilterType::LabelType InputLabelPixelType
otbSetObjectMemberMacro(MeanShiftFilter, MaxIterationNumber, unsigned int)
otbGetObjectMemberConstReferenceMacro(MeanShiftFilter, SpatialBandwidth, RealType)
otbSetObjectMemberMacro(RegionPruningFilter, MinRegionSize, RealType)
otbSetObjectMemberMacro(MeanShiftFilter, Threshold, RealType)
MeanShiftSmoothingImageFilter< InputSpectralImageType, MeanShiftFilteredImageType, KernelType > MeanShiftFilterType
Functor::ConnectedLabelFunctor< InputLabelPixelType > LabelFunctorType
RelabelComponentFilterPointerType m_RelabelFilter
itk::ConnectedComponentFunctorImageFilter< InputLabelImageType, InputLabelImageType, LabelFunctorType > RelabelComponentFilterType
MeanShiftFilterType::Pointer MeanShiftFilterPointerType
otbSetObjectMemberMacro(MeanShiftFilter, RangeBandwidth, RealType)
MeanShiftFilterType::OutputLabelImageType InputLabelImageType
RegionMergingFilterPointerType m_RegionMergingFilter
otbSetObjectMemberMacro(MeanShiftFilter, SpatialBandwidth, RealType)
itk::ImageToImageFilter< TInputImage, TOutputLabelImage > Superclass
otbGetObjectMemberMacro(RegionPruningFilter, MinRegionSize, RealType)
otbGetObjectMemberConstReferenceMacro(MeanShiftFilter, MaxIterationNumber, unsigned int)
RelabelComponentFilterType::Pointer RelabelComponentFilterPointerType
RegionMergingFilterType::Pointer RegionMergingFilterPointerType
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.