OTB  6.7.0
Orfeo Toolbox
otbMeanShiftSegmentationFilter.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2019 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"
31 #include <string>
32 
33 
34 namespace otb {
35 
36 
37 namespace Functor
38 {
39 
40 template<class TInput>
41 class ITK_EXPORT ConnectedLabelFunctor
42 {
43 
44 public:
45 
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  }
64 
66  {
67  }
68 
69 private:
70 
71  ConnectedLabelFunctor(const Self &) = delete;
72  void operator =(const Self &) = delete;
73 
74 };
75 
76 } // end of Functor namespace
77 
78 
90 template <class TInputImage, class TOutputLabelImage, class TOutputClusteredImage = TInputImage, class TKernel = Meanshift::KernelUniform>
91 class ITK_EXPORT MeanShiftSegmentationFilter : public itk::ImageToImageFilter<TInputImage, TOutputLabelImage>
92 {
93 public:
97 
100 
102  typedef TInputImage InputSpectralImageType;
103  typedef TOutputLabelImage OutputLabelImageType;
104  typedef TOutputClusteredImage OutputClusteredImageType;
105  typedef TKernel KernelType;
106  typedef double RealType;
107 
109  itkNewMacro(Self);
110 
112  itkTypeMacro(MeanShiftSegmentationFilter, ImageToImageFilter);
113 
115  itkStaticConstMacro(ImageDimension, unsigned int, TInputImage::ImageDimension);
116 
117  // Mean shift filter
121  // Region merging filter
130 
131 
133 
136 
137 
141  otbSetObjectMemberMacro(MeanShiftFilter,SpatialBandwidth,RealType);
142  otbGetObjectMemberConstReferenceMacro(MeanShiftFilter,SpatialBandwidth,RealType);
144 
148  otbSetObjectMemberMacro(MeanShiftFilter,RangeBandwidth,RealType);
149  otbGetObjectMemberConstReferenceMacro(MeanShiftFilter,RangeBandwidth,RealType);
151 
153  otbSetObjectMemberMacro(MeanShiftFilter,MaxIterationNumber,unsigned int);
154  otbGetObjectMemberConstReferenceMacro(MeanShiftFilter,MaxIterationNumber,unsigned int);
156 
158  otbSetObjectMemberMacro(MeanShiftFilter,Threshold,RealType);
159  otbGetObjectMemberConstReferenceMacro(MeanShiftFilter,Threshold,RealType);
161 
165  otbSetObjectMemberMacro(RegionPruningFilter,MinRegionSize,RealType);
166  otbGetObjectMemberMacro(RegionPruningFilter,MinRegionSize,RealType);
168 
169 
171  const OutputLabelImageType * GetLabelOutput() const;
172 
174  OutputLabelImageType * GetLabelOutput();
175 
177  const OutputClusteredImageType * GetClusteredOutput() const;
178 
180  OutputClusteredImageType * GetClusteredOutput();
181 
182 protected:
184 
185  ~MeanShiftSegmentationFilter() override;
186 
187 // virtual void GenerateOutputInformation(void);
188 
189  void GenerateData() override;
190 
191 private:
192 
197 };
198 
199 
200 } // end namespace otb
201 
202 #ifndef OTB_MANUAL_INSTANTIATION
204 #endif
205 
206 #endif
RegionMergingFilterPointerType m_RegionMergingFilter
MeanShiftFilterType::OutputLabelImageType InputLabelImageType
LabelImageRegionMergingFilter< InputLabelImageType, MeanShiftFilteredImageType, OutputLabelImageType, OutputClusteredImageType > RegionMergingFilterType
MeanShiftSmoothingImageFilter< InputSpectralImageType, MeanShiftFilteredImageType, KernelType > MeanShiftFilterType
#define otbGetObjectMemberMacro(object, name, type)
Definition: otbMacro.h:90
RegionPruningFilterType::Pointer RegionPruningFilterPointerType
Functor::ConnectedLabelFunctor< InputLabelPixelType > LabelFunctorType
itk::ImageToImageFilter< TInputImage, TOutputLabelImage > Superclass
LabelImageRegionPruningFilter< OutputLabelImageType, OutputClusteredImageType, OutputLabelImageType, OutputClusteredImageType > RegionPruningFilterType
RegionMergingFilterType::Pointer RegionMergingFilterPointerType
MeanShiftFilterType::Pointer MeanShiftFilterPointerType
RelabelComponentFilterType::Pointer RelabelComponentFilterPointerType
#define otbGetObjectMemberConstReferenceMacro(object, name, type)
Definition: otbMacro.h:113
RegionPruningFilterPointerType m_RegionPruningFilter
Creation of an "otb" image which contains metadata.
Definition: otbImage.h:89
RelabelComponentFilterPointerType m_RelabelFilter
#define otbSetObjectMemberMacro(object, name, type)
Definition: otbMacro.h:80
itk::SmartPointer< const Self > ConstPointer
itk::ConnectedComponentFunctorImageFilter< InputLabelImageType, InputLabelImageType, LabelFunctorType > RelabelComponentFilterType
MeanShiftFilterType::LabelType InputLabelPixelType